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

refactor(ui-library): change theming approach #991

Merged
merged 28 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5b11cb5
feat(ui-library): introduce theme token iterators for css
faselbaum Apr 12, 2024
b44bd34
feat(all): add vscode extension for template literal syntax highlighting
faselbaum Apr 12, 2024
1e1964d
refactor(ui-library): adapt shared css (foundation)
faselbaum Apr 12, 2024
d528d31
refactor(ui-library): adapt button-group
faselbaum Apr 12, 2024
ea8d9cf
refactor(ui-library): adapt button-icon
faselbaum Apr 12, 2024
4821d74
refactor(ui-library): adapt button-text
faselbaum Apr 12, 2024
e26a557
refactor(ui-library): adapt checkbox
faselbaum Apr 12, 2024
049253b
refactor(ui-library): adapt counter
faselbaum Apr 12, 2024
49c2870
refactor(ui-library): adapt divider
faselbaum Apr 12, 2024
30295e1
refactor(ui-library): adapt form-caption
faselbaum Apr 12, 2024
9fa73a0
refactor(ui-library): adapt form-caption-group
faselbaum Apr 12, 2024
c9250b0
refactor(ui-library): adapt form-label
faselbaum Apr 12, 2024
85d66eb
refactor(ui-library): adapt form-label-inline
faselbaum Apr 12, 2024
7c232fe
refactor(ui-library): adapt icon
faselbaum Apr 12, 2024
04d9150
refactor(ui-library): adapt input-field-number
faselbaum Apr 12, 2024
221e580
refactor(ui-library): adapt input-field-text
faselbaum Apr 12, 2024
482e668
refactor(ui-library): adapt loader
faselbaum Apr 12, 2024
5b13b8a
refactor(ui-library): adapt radio
faselbaum Apr 12, 2024
87d7f33
refactor(ui-library): adapt radio-group
faselbaum Apr 12, 2024
c575205
refactor(ui-library): adapt select
faselbaum Apr 12, 2024
b6095fd
refactor(ui-library): adapt range-legend-slider
faselbaum Apr 12, 2024
6bfa56f
refactor(ui-library): adapt range-slider
faselbaum Apr 12, 2024
2d277ca
refactor(ui-library): adapt range-legend-min-max-slider
faselbaum Apr 12, 2024
af7ba8b
refactor(ui-library): adapt range-min-max-slider
faselbaum Apr 12, 2024
6951a0f
refactor(ui-library): adapt tab-bar
faselbaum Apr 12, 2024
7418e58
refactor(ui-library): adapt textarea
faselbaum Apr 12, 2024
b0341d9
refactor(ui-library): adapt toggle-switch
faselbaum Apr 12, 2024
bdaef69
refactor(ui-library): adapt tooltip
faselbaum Apr 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"runem.lit-plugin"
"runem.lit-plugin",
"bierner.comment-tagged-templates"
]
}
86 changes: 45 additions & 41 deletions packages/ui-library/src/components/button-group/index.css.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
import { componentTokens } from "../../foundation/_tokens-generated/__component-tokens.Light.generated.mjs";
import { typeSafeNestedCss } from "../../utils/nested-typesafe-css-literals";

const { ButtonGroup } = componentTokens.cmp;

export const styleCustom = typeSafeNestedCss`
.blr-button-group {
display: flex;

&.left {
justify-content: flex-start;
}

&.center {
justify-content: center;
}

&.right {
justify-content: flex-end;
}

&.xs {
gap: ${ButtonGroup.Container.ItemSpacing.XS};
}

&.sm {
gap: ${ButtonGroup.Container.ItemSpacing.SM};
}

&.md {
gap: ${ButtonGroup.Container.ItemSpacing.MD};
}

&.lg {
gap: ${ButtonGroup.Container.ItemSpacing.LG};
}

&.xl {
gap: ${ButtonGroup.Container.ItemSpacing.XL};
}
}
import { ComponentThemeIterator } from "../../foundation/_tokens-generated/index.pseudo.generated";
import { typeSafeNestedCss } from "../../utils/css-in-ts/nested-typesafe-css-literals";

export const staticStyles = typeSafeNestedCss/* css */ `
${ComponentThemeIterator((theme, cmp, typeSafeCss) => {
const { ButtonGroup } = cmp;

return typeSafeCss/* css */ `
.blr-button-group.${theme} {
display: flex;

&.left {
justify-content: flex-start;
}

&.center {
justify-content: center;
}

&.right {
justify-content: flex-end;
}

&.xs {
gap: ${ButtonGroup.Container.ItemSpacing.XS};
}

&.sm {
gap: ${ButtonGroup.Container.ItemSpacing.SM};
}

&.md {
gap: ${ButtonGroup.Container.ItemSpacing.MD};
}

&.lg {
gap: ${ButtonGroup.Container.ItemSpacing.LG};
}

&.xl {
gap: ${ButtonGroup.Container.ItemSpacing.XL};
}
}
`;
})}
`;
7 changes: 5 additions & 2 deletions packages/ui-library/src/components/button-group/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import { html } from 'lit';
import { property } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { styleCustom } from './index.css';
import { staticStyles } from './index.css';
import { ButtonGroupAlignmentType, ButtonGroupSizesType } from '../../globals/types';

import { TAG_NAME } from './renderFunction';
import { LitElementCustom } from '../../utils/lit-element-custom';
import { ThemeType } from '../../foundation/_tokens-generated/index.themes';

export class BlrButtonGroup extends LitElementCustom {
static styles = [styleCustom];
static styles = [staticStyles];

@property() sizeVariant: ButtonGroupSizesType = 'md';
@property() alignment: ButtonGroupAlignmentType = 'center';
@property() theme: ThemeType = 'Light';

protected render() {
const classes = classMap({
'blr-button-group': true,
[this.alignment]: this.alignment,
[this.sizeVariant]: this.sizeVariant,
[this.theme]: this.theme,
});

return html`
Expand Down
164 changes: 93 additions & 71 deletions packages/ui-library/src/components/button-icon/index.css.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { componentTokens } from "../../foundation/_tokens-generated/__component-tokens.Light.generated.mjs";
import { semanticTokens } from "../../foundation/_tokens-generated/__semantic-tokens.Light.generated.mjs";
import { typeSafeNestedCss } from "../../utils/nested-typesafe-css-literals";
import { typeSafeNestedCss } from "../../utils/css-in-ts/nested-typesafe-css-literals";
import { ComponentThemeIterator, SemanticThemeIterator } from "../../foundation/_tokens-generated/index.pseudo.generated";

const { ButtonIcon } = componentTokens.cmp;
const { global, buttons } = semanticTokens.sem;

export const styleCustom = typeSafeNestedCss`
export const styleCustom = typeSafeNestedCss/* css */ `
.focus-layer {
position: absolute;
inset: 0;
outline-color: ${global.focusring.border.color};
outline-style: ${global.focusring.border.style};
outline-width: ${global.focusring.border.width};
}

.blr-button-icon {
Expand All @@ -21,80 +14,109 @@ export const styleCustom = typeSafeNestedCss`
display: inline-flex;
cursor: pointer;
position: relative;
}

&.xs {
padding: ${ButtonIcon.Container.Padding.XS};
border-radius: ${ButtonIcon.Container.BorderRadius.XS};
.loading {
&.blr-button-icon:hover, &.blr-button-icon:focus {
cursor: auto;
text-decoration: none;
}

& > .focus-layer {
border-radius: ${ButtonIcon.Container.BorderRadius.XS};
}
& > .icon {
visibility: hidden;
}
}

&.sm {
padding: ${ButtonIcon.Container.Padding.SM};
border-radius: ${ButtonIcon.Container.BorderRadius.SM};
${ComponentThemeIterator((theme, cmp, typeSafeCss) => {
const { ButtonIcon } = cmp;

& > .focus-layer {
border-radius: ${ButtonIcon.Container.BorderRadius.SM};
}
}
return typeSafeCss/*css*/ `
.blr-button-icon.${theme} {
&.xs {
padding: ${ButtonIcon.Container.Padding.XS};
border-radius: ${ButtonIcon.Container.BorderRadius.XS};

&.md {
padding: ${ButtonIcon.Container.Padding.MD};
border-radius: ${ButtonIcon.Container.BorderRadius.MD};
& > .focus-layer {
border-radius: ${ButtonIcon.Container.BorderRadius.XS};
}
}

& > .focus-layer {
border-radius: ${ButtonIcon.Container.BorderRadius.MD};
}
}
&.sm {
padding: ${ButtonIcon.Container.Padding.SM};
border-radius: ${ButtonIcon.Container.BorderRadius.SM};

&.lg {
padding: ${ButtonIcon.Container.Padding.LG};
border-radius: ${ButtonIcon.Container.BorderRadius.LG};
& > .focus-layer {
border-radius: ${ButtonIcon.Container.BorderRadius.SM};
}
}

& > .focus-layer {
border-radius: ${ButtonIcon.Container.BorderRadius.LG};
}
}
&.md {
padding: ${ButtonIcon.Container.Padding.MD};
border-radius: ${ButtonIcon.Container.BorderRadius.MD};

&.xl {
padding: ${ButtonIcon.Container.Padding.XL};
border-radius: ${ButtonIcon.Container.BorderRadius.XL};
& > .focus-layer {
border-radius: ${ButtonIcon.Container.BorderRadius.MD};
}
}

& > .focus-layer {
border-radius: ${ButtonIcon.Container.BorderRadius.XL};
}
}
}

.loading {
&.lg {
padding: ${ButtonIcon.Container.Padding.LG};
border-radius: ${ButtonIcon.Container.BorderRadius.LG};

&.blr-button-icon:hover, &.blr-button-icon:focus{
cursor: auto;
text-decoration: none;
&.cta{
background-color: ${buttons.container.bgcolor.cta.loading}
}
&.primary{
background-color: ${buttons.container.bgcolor.primary.loading}
}
&.secondary{
background-color: ${buttons.container.bgcolor.secondary.loading}
}
&.silent{
background-color: ${buttons.container.bgcolor.silent.loading}
}
&.destructive{
background-color: ${buttons.container.bgcolor.destructive.loading}
& > .focus-layer {
border-radius: ${ButtonIcon.Container.BorderRadius.LG};
}
}

&.xl {
padding: ${ButtonIcon.Container.Padding.XL};
border-radius: ${ButtonIcon.Container.BorderRadius.XL};

& > .focus-layer {
border-radius: ${ButtonIcon.Container.BorderRadius.XL};
}
}
}
&.encourage{
background-color: ${buttons.container.bgcolor.encourage.loading}
`;
})}

${SemanticThemeIterator((theme, sem, typeSafeCss) => {
const { global, buttons } = sem;

return typeSafeCss/*css*/ `
.focus-layer.${theme} {
outline-color: ${global.focusring.border.color};
outline-style: ${global.focusring.border.style};
outline-width: ${global.focusring.border.width};
}
}

& > .icon {
visibility: hidden;
}
}
.loading.${theme} {
&.blr-button-icon:hover, &.blr-button-icon:focus {
&.cta {
background-color: ${buttons.container.bgcolor.cta.loading}
}

&.primary {
background-color: ${buttons.container.bgcolor.primary.loading}
}

&.secondary {
background-color: ${buttons.container.bgcolor.secondary.loading}
}

&.silent {
background-color: ${buttons.container.bgcolor.silent.loading}
}

&.destructive {
background-color: ${buttons.container.bgcolor.destructive.loading}
}

&.encourage {
background-color: ${buttons.container.bgcolor.encourage.loading}
}
}
}
`;
})}
`;
20 changes: 9 additions & 11 deletions packages/ui-library/src/components/button-icon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SizelessIconType } from '@boiler/icons';
import { styleCustom } from './index.css';
import { TAG_NAME } from './renderFunction';
import { ThemeType } from '../../foundation/_tokens-generated/index.themes';
import { actionLight, actionDark } from '../../foundation/semantic-tokens/action.css';
import { staticActionStyles } from '../../foundation/semantic-tokens/action.css';
import { ActionVariantType, ActionSizesType, FormSizesType, SizesType } from '../../globals/types';
import { calculateIconName } from '../../utils/calculate-icon-name';
import { determineLoaderVariant } from '../../utils/determine-loader-variant';
Expand Down Expand Up @@ -35,7 +35,7 @@ export type BlrButtonIconEventHandlers = {
* @fires blrClick Button was clicked
*/
export class BlrButtonIcon extends LitElementCustom {
static styles = [styleCustom];
static styles = [styleCustom, staticActionStyles];

@property() arialabel!: string;
@property() icon?: SizelessIconType;
Expand Down Expand Up @@ -71,13 +71,14 @@ export class BlrButtonIcon extends LitElementCustom {

protected render() {
if (this.sizeVariant) {
const dynamicStyles = this.theme === 'Light' ? [actionLight] : [actionDark];

const classes = classMap({
'blr-semantic-action': true,
'blr-button-icon': true,
[this.variant]: this.variant,
[this.sizeVariant]: this.sizeVariant,
disabled: this.disabled,
loading: this.loading || false,
'disabled': this.disabled,
'loading': this.loading || false,
[this.theme]: this.theme,
});

const iconClasses = classMap({
Expand All @@ -103,12 +104,9 @@ export class BlrButtonIcon extends LitElementCustom {
]).toLowerCase() as SizesType;

return html`
<style>
${dynamicStyles}
</style>
<span
aria-label=${this.arialabel || nothing}
class="blr-semantic-action blr-button-icon ${classes}"
class="${classes}"
aria-disabled=${this.disabled ? 'true' : nothing}
@click=${this.handleClick}
id=${this.buttonIconId || nothing}
Expand All @@ -122,7 +120,7 @@ export class BlrButtonIcon extends LitElementCustom {
}
}}
>
${this.focused && !this.loading ? html`<span class="focus-layer"></span>` : nothing}
${this.focused && !this.loading ? html`<span class="focus-layer ${this.theme}"></span>` : nothing}
${this.loading
? BlrLoaderRenderFunction({
sizeVariant: loaderSizeVariant,
Expand Down
Loading
Loading