Skip to content

Commit

Permalink
Allow to remove the background and select a custom colour
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Nov 29, 2022
1 parent a884f31 commit cedae7c
Show file tree
Hide file tree
Showing 25 changed files with 585 additions and 246 deletions.
5 changes: 5 additions & 0 deletions apps/theming/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
'url' => '/background/{type}',
'verb' => 'POST',
],
[
'name' => 'userTheme#deleteBackground',
'url' => '/background/custom',
'verb' => 'DELETE',
],
],
'ocs' => [
[
Expand Down
148 changes: 148 additions & 0 deletions apps/theming/css/settings-admin.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

168 changes: 168 additions & 0 deletions apps/theming/css/settings-admin.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#theming {
input {
width: 230px;
}

input:focus,
input:active {
padding-right: 30px;
}

.fileupload {
display: none;
}

div > label {
position: relative;
}

.theme-undo {
position: absolute;
top: -7px; // input padding
right: 4px; // input right margin + border
cursor: pointer;
opacity: .3;
padding: 7px;
vertical-align: top;
display: inline-block;
visibility: hidden;
height: 32px; // height of input
width: 32px; // height of input
}
form.uploadButton {
width: 411px;
display: flex;
align-items: center;
}
form .theme-undo,
.theme-remove-bg {
cursor: pointer;
opacity: .3;
padding: 7px;
vertical-align: top;
display: inline-block;
float: right;
position: relative;
top: 4px;
right: 0px;
visibility: visible;
height: 32px;
width: 32px;
// right align
margin-left: auto;
}
form .theme-undo:not([style*="display:"]) ~ .theme-remove-bg {
// Only align the undo button if both are shown
margin-left: 0;
}

input[type='text']:hover + .theme-undo,
input[type='text'] + .theme-undo:hover,
input[type='text']:focus + .theme-undo,
input[type='text']:active + .theme-undo,
input[type='url']:hover + .theme-undo,
input[type='url'] + .theme-undo:hover,
input[type='url']:focus + .theme-undo,
input[type='url']:active + .theme-undo{
visibility: visible;
}

label span {
display: inline-block;
min-width: 175px;
max-width: 175px;
white-space: wrap;
padding: 8px 0px;
vertical-align: top;
}

.icon-upload,
.uploadButton .icon-loading-small {
padding: 8px 20px;
width: 20px;
margin: 2px 0px;
min-height: 32px;
display: inline-block;
}

#theming_settings_status {
height: 26px;
margin: 10px;
}

#theming_settings_loading {
display: inline-block;
vertical-align: middle;
margin-right: 10px;
}

#theming_settings_msg {
vertical-align: middle;
border-radius: 3px;
}

#theming-preview {
width: 230px;
height: 140px;
background-size: cover;
background-position: center center;
text-align: center;
margin-left: 178px;
margin-top: 10px;
margin-bottom: 20px;
cursor: pointer;
background-color: var(--color-primary-default);
background-image: var(--image-background-default, var(--image-background-plain, linear-gradient(40deg, #0082c9 0%, #30b6ff 100%)));

#theming-preview-logo {
cursor: pointer;
width: 20%;
height: 20%;
margin-top: 20px;
display: inline-block;
background-position: center;
background-repeat: no-repeat;
background-size: contain;
background-image: var(--image-logo, url('../../../core/img/logo/logo.svg'));
}
}

.theming-hints {
margin-top: 20px;
}

.image-preview {
display: inline-block;
width: 80px;
height: 36px;
background-position: center;
background-repeat: no-repeat;
background-size: contain;
}

#theming-preview-logoheader {
// Only using --image-logoheader to show the custom value only
background-image: var(--image-logoheader);
}

#theming-preview-favicon {
background-image: var(--image-favicon);
}

#user-theming {
margin-top: 44px;
display: flex;
& > div {
max-width: 400px;
margin-bottom: 44px;
}
}
}

/* transition effects for theming value changes */
#header {
transition: background-color 500ms linear;
svg, img {
transition: 500ms filter linear;
}
}
10 changes: 3 additions & 7 deletions apps/theming/lib/Command/UpdateConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ class UpdateConfig extends Command {
'name', 'url', 'imprintUrl', 'privacyUrl', 'slogan', 'color', 'disable-user-theming'
];

public const SUPPORTED_IMAGE_KEYS = [
'background', 'logo', 'favicon', 'logoheader'
];

private $themingDefaults;
private $imageManager;
private $config;
Expand Down Expand Up @@ -87,14 +83,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$value = $this->config->getAppValue('theming', $key, '');
$output->writeln('- ' . $key . ': ' . $value . '');
}
foreach (self::SUPPORTED_IMAGE_KEYS as $key) {
foreach (ImageManager::SUPPORTED_IMAGE_KEYS as $key) {
$value = $this->config->getAppValue('theming', $key . 'Mime', '');
$output->writeln('- ' . $key . ': ' . $value . '');
}
return 0;
}

if (!in_array($key, self::SUPPORTED_KEYS, true) && !in_array($key, self::SUPPORTED_IMAGE_KEYS, true)) {
if (!in_array($key, self::SUPPORTED_KEYS, true) && !in_array($key, ImageManager::SUPPORTED_IMAGE_KEYS, true)) {
$output->writeln('<error>Invalid config key provided</error>');
return 1;
}
Expand All @@ -115,7 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

if (in_array($key, self::SUPPORTED_IMAGE_KEYS, true)) {
if (in_array($key, ImageManager::SUPPORTED_IMAGE_KEYS, true)) {
if (strpos($value, '/') !== 0) {
$output->writeln('<error>The image file needs to be provided as an absolute path: ' . $value . '.</error>');
return 1;
Expand Down
Loading

0 comments on commit cedae7c

Please sign in to comment.