Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[full-ci] feat: introduce contrast colors in swatches #8563

Merged
merged 13 commits into from
Mar 22, 2023

Conversation

kulmann
Copy link
Member

@kulmann kulmann commented Mar 7, 2023

Description

This PR introduces a contrast token for all our swatches (i.e. our color variations in the design system). Their purpose is to define a high contrast color in relation to the default token of the swatches. This way the contrast token can e.g. be used as text color if the default token represents a background color.

The contrast tokens are mainly used in three components of the design system:

  • OcModal
  • OcButton
  • OcIcon
    The main difference in those components now is that they don't use a generic text color anymore, but instead use the contrast color of the active variation. This brings us the flexibility of having light and dark swatches in parallel. Previously this was not possible because one single text color was used for all swatches/variations. Having a light brand color and a dark danger color was conflicting. One of the two always had bad readability for text.

One additional goal was to completely get rid of the inverse swatch. Because, come on, inverse to what exactly?! I'm not there, yet, there are still 4 usages of the inverse swatch in the code. Might push that to a followup.

Motivation and Context

More flexibility in theming.

How Has This Been Tested?

Well, it's about colors. Manually.
Mainly there are two areas of interest:

  • check that the existing owncloud default theme looks the same as before with this PR.
  • try out your own custom theme with a light brand color. E.g. the json at the end of this PR description.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Example theme.json with light brand color

In order to test this, create a new theme folder in packages/web-runtime/themes, insert the following content in a theme.json file. Add logos as needed in an assets folder. Build web and set the theme path in the docker-compose.yaml file.

{
	"common": {
		"name": "Custom",
		"slogan": "Custom - Your custom cloud",
		"logo": "themes/custom/assets/logo.svg"
	},
	"ios": {},
	"web": {
		"default": {
			"general": {
				"name": "Custom",
				"slogan": "Custom - Your custom cloud"
			},
			"logo": {
				"topbar": "themes/custom/assets/logo.svg",
				"favicon": "themes/custom/assets/favicon.ico",
				"login": "themes/custom/assets/logo.svg"
			},
			"loginPage": {
				"autoRedirect": true,
				"backgroundImg": "themes/custom/assets/loginBackground.svg"
			},
			"designTokens": {
				"colorPalette": {
					"background-accentuate": "rgba(255, 255, 5, 0.1)",
					"background-default": "#ffffff",
					"background-highlight": "#edf3fa",
					"background-muted": "#f8f8f8",
					"background-secondary": "#ffffff",
					"background-hover": "rgb(236, 236, 236)",
					"border": "#ecebee",
					"input-bg": "#f0f4f8",
					"input-border": "#ceddee",
					"input-text-default": "#041e42",
					"input-text-muted": "#4c5f79",
					"swatch-brand-default": "rgb(238, 238, 238)",
					"swatch-brand-hover": "#223959",
          "swatch-brand-muted": "#223959",
          "swatch-brand-contrast": "rgb(39, 77, 127)",
					"swatch-danger-default": "#e00000",
					"swatch-danger-hover": "#e96464",
					"swatch-danger-muted": "#b50000",
					"swatch-inverse-default": "#ffffff",
					"swatch-inverse-hover": "#ffffff",
					"swatch-inverse-muted": "#bfbfbf",
					"swatch-passive-default": "#4c5f79",
					"swatch-passive-hover": "#97a2b1",
					"swatch-passive-muted": "#283e5d",
					"swatch-primary-default": "#4a76ac",
					"swatch-primary-hover": "#80a7d7",
					"swatch-primary-muted": "#2c588e",
					"swatch-primary-gradient": "#4e85c8",
					"swatch-success-default": "#4f822f",
					"swatch-success-hover": "#93e054",
					"swatch-success-muted": "#53960a",
					"swatch-warning-default": "#c6501b",
					"swatch-warning-hover": "#fda94b",
					"swatch-warning-muted": "#b35100",
					"text-default": "#041e42",
					"text-inverse": "#ffffff",
					"text-muted": "#4c5f79",
					"icon-folder": "#4d7eaf",
					"icon-archive": "#fbbe54",
					"icon-image": "#ee6b3b",
					"icon-spreadsheet": "#15c286",
					"icon-document": "#3b44a6",
					"icon-video": "#045459",
					"icon-audio": "#700460",
					"icon-presentation": "#ee6b3b",
					"icon-pdf": "#ec0d47"
				}
			}
		}
	}
}

@update-docs
Copy link

update-docs bot commented Mar 7, 2023

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@kulmann kulmann force-pushed the enhancement-background-theming branch from 926e6c6 to d707d89 Compare March 7, 2023 22:20
Copy link
Contributor

@JammingBen JammingBen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icon of the current view mode is displayed in a white color now, which is a bit harder to see than the dark color before.

Now:
image

Before:
image

LGTM otherwise 🚀

Comment on lines -233 to -239
&-input input {
border: 1px solid var(--oc-color-swatch-inverse-muted);
}
&-checkbox input {
border: 2px solid var(--oc-color-swatch-inverse-muted);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, the filter checkboxes are hidden in dark mode:

image

In light mode, the normal background color as well as the drop background color are white. TBH, I don't know why these colours differ in dark mode and why drops have this (ugly 😅 ) light background.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icon of the current view mode is displayed in a white color now, which is a bit harder to see than the dark color before.

Stupid / naive me, thinking the tokens referencing values of other tokens would be respected at runtime. That's not the case. Only at build time. So the theme actually does need to set color vars for the contrast swatch tokens. Grmpf, that's not what I wanted to achieve. But probably the way to go for now if we don't want to rebuild the tokens at runtime when switching / loading themes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, the filter checkboxes are hidden in dark mode:
In light mode, the normal background color as well as the drop background color are white. TBH, I don't know why these colours differ in dark mode and why drops have this (ugly 😅 ) light background.

Can be solved by setting an input-border color value in dark mode which is not the same as the secondary background color. :trollface: Did that in this PR. Checkbox needs some more fine tuning. Some of it is done in a PR from @hurradieweltgehtunter

@lookacat
Copy link
Contributor

lookacat commented Mar 8, 2023

When I pull this PR and don't change the themes.json manually some icons are just black, if I use the example theme.json it looks alright so far. Shouldn't we change the themes.json for master?
captures_chrome-capture-2023-2-8

@kulmann
Copy link
Member Author

kulmann commented Mar 8, 2023

@lookacat did you run pnpm build:tokens or pnpm build (which also generates the tokens)? Or only pnpm vite (which doesn't build the tokens)

@kulmann kulmann force-pushed the enhancement-background-theming branch from d707d89 to f5c575f Compare March 14, 2023 21:46
@JammingBen
Copy link
Contributor

Now the share indicators have a black icon in dark mode (as well as the checkboxes, though you already mentioned that those need more fine tuning anyway) 😅

image

@kulmann kulmann force-pushed the enhancement-background-theming branch 2 times, most recently from e8e0c9b to 5e833b8 Compare March 21, 2023 13:53
@kulmann kulmann requested a review from JammingBen March 21, 2023 15:24
Copy link
Contributor

@JammingBen JammingBen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

<oc-button
:id="`files-role-${roleOption.label.toLowerCase()}`"
:id="`files-role-${roleOption.key}`"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, that change causes the tests to fail because they look for the id including the role name. So either we switch to data-test-id for this, or revert it. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, thank you! I took the third option / a variation of the first option: I changed the id prop again to use roleOption.name because that is a lower-case html safe attribute already. With labels you never know for sure, since they're meant for the human eye. That's why I wanted to remove it from the template for the id in the first place.

@kulmann kulmann changed the title feat: introduce contrast colors in swatches [full-ci] feat: introduce contrast colors in swatches Mar 22, 2023
@kulmann kulmann force-pushed the enhancement-background-theming branch 2 times, most recently from b37a138 to 63228b5 Compare March 22, 2023 21:25
@ownclouders
Copy link
Contributor

@kulmann kulmann force-pushed the enhancement-background-theming branch from 63228b5 to 5aa0cb3 Compare March 22, 2023 22:06
@sonarcloud
Copy link

sonarcloud bot commented Mar 22, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

50.0% 50.0% Coverage
0.0% 0.0% Duplication

@kulmann kulmann merged commit c792eb0 into master Mar 22, 2023
@delete-merged-branch delete-merged-branch bot deleted the enhancement-background-theming branch March 22, 2023 23:01
@micbar micbar mentioned this pull request May 3, 2023
89 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants