Skip to content

Commit

Permalink
refactor(icon-button): consume colors from schema properly (#997)
Browse files Browse the repository at this point in the history
Co-authored-by: Simeon Simeonoff <[email protected]>
  • Loading branch information
SisIvanova and simeonoff authored Dec 1, 2023
1 parent e62fa49 commit 7a03578
Show file tree
Hide file tree
Showing 10 changed files with 216 additions and 295 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"globby": "^14.0.0",
"husky": "^8.0.3",
"ig-typedoc-theme": "^5.0.1",
"igniteui-theming": "^3.3.2",
"igniteui-theming": "^4.0.0",
"keep-a-changelog": "^2.5.2",
"lint-staged": "^15.1.0",
"lit-analyzer": "^2.0.1",
Expand Down
8 changes: 4 additions & 4 deletions src/components/button/themes/button/dark/_themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@

// Material Themes
$material-flat: digest-schema(map.get($dark-button, 'flat'));
$material-contained: digest-schema(map.get($dark-button, 'raised'));
$material-contained: digest-schema(map.get($dark-button, 'contained'));
$material-outlined: digest-schema(map.get($dark-button, 'outlined'));
$material-fab: digest-schema(map.get($dark-button, 'fab'));

// Bootstrap Themes
$bootstrap-flat: digest-schema(map.get($dark-bootstrap-button, 'flat'));
$bootstrap-contained: digest-schema(map.get($dark-bootstrap-button, 'raised'));
$bootstrap-contained: digest-schema(map.get($dark-bootstrap-button, 'contained'));
$bootstrap-outlined: digest-schema(map.get($dark-bootstrap-button, 'outlined'));
$bootstrap-fab: digest-schema(map.get($dark-bootstrap-button, 'fab'));

// Fluent Themes
$fluent-flat: digest-schema(map.get($dark-fluent-button, 'flat'));
$fluent-contained: digest-schema(map.get($dark-fluent-button, 'raised'));
$fluent-contained: digest-schema(map.get($dark-fluent-button, 'contained'));
$fluent-outlined: digest-schema(map.get($dark-fluent-button, 'outlined'));
$fluent-fab: digest-schema(map.get($dark-fluent-button, 'fab'));

// Indigo Themes
$indigo-flat: digest-schema(map.get($dark-indigo-button, 'flat'));
$indigo-contained: digest-schema(map.get($dark-indigo-button, 'raised'));
$indigo-contained: digest-schema(map.get($dark-indigo-button, 'contained'));
$indigo-outlined: digest-schema(map.get($dark-indigo-button, 'outlined'));
$indigo-fab: digest-schema(map.get($dark-indigo-button, 'fab'));
8 changes: 4 additions & 4 deletions src/components/button/themes/button/light/_themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@

// Material Themes
$material-flat: digest-schema($material-flat-button);
$material-contained: digest-schema($material-raised-button);
$material-contained: digest-schema($material-contained-button);
$material-outlined: digest-schema($material-outlined-button);
$material-fab: digest-schema($material-fab-button);

// Fluent Themes
$fluent-flat: digest-schema($fluent-flat-button);
$fluent-contained: digest-schema($fluent-raised-button);
$fluent-contained: digest-schema($fluent-contained-button);
$fluent-outlined: digest-schema($fluent-outlined-button);
$fluent-fab: digest-schema($fluent-fab-button);

// Bootstrap Themes
$bootstrap-flat: digest-schema($bootstrap-flat-button);
$bootstrap-contained: digest-schema($bootstrap-raised-button);
$bootstrap-contained: digest-schema($bootstrap-contained-button);
$bootstrap-outlined: digest-schema($bootstrap-outlined-button);
$bootstrap-fab: digest-schema($bootstrap-fab-button);

// Indigo Themes
$indigo-flat: digest-schema($indigo-flat-button);
$indigo-contained: digest-schema($indigo-raised-button);
$indigo-contained: digest-schema($indigo-contained-button);
$indigo-outlined: digest-schema($indigo-outlined-button);
$indigo-fab: digest-schema($indigo-fab-button);
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ $contained-theme: $bootstrap-contained;
$outlined-theme: $bootstrap-outlined;

[part='base'] {
border-radius: var-get($flat-theme, 'border-radius');
width: var-get($flat-theme, 'size');
height: var-get($flat-theme, 'size');
transition: box-shadow .15s ease-out, color .15s ease-out, background .15s ease-out;
color: var-get($flat-theme, 'foreground');
padding: pad(7.5px, 9px, 12px);

igc-icon {
color: var-get($flat-theme, 'foreground');
}
}

:host([variant='flat']) {
Expand All @@ -24,21 +16,10 @@ $outlined-theme: $bootstrap-outlined;
--component-size: var(--ig-size, #{var-get($flat-theme, 'default-size')});

[part='base'] {
&:hover {
color: var-get($flat-theme, 'hover-foreground');
}

&:focus,
&:active {
color: var-get($flat-theme, 'focus-foreground');
background: var-get($flat-theme, 'focus-background');
box-shadow: none;
}
}

::slotted(igc-ripple) {
border-radius: var-get($flat-theme, 'border-radius');
}
}

:host([variant='contained']) {
Expand All @@ -47,27 +28,15 @@ $outlined-theme: $bootstrap-outlined;
--component-size: var(--ig-size, #{var-get($contained-theme, 'default-size')});

[part='base'] {
color: var-get($contained-theme, 'foreground');
background: var-get($contained-theme, 'background');

&:hover {
background: var-get($contained-theme, 'focus-background');
}

&:focus,
&:active {
background: var-get($contained-theme, 'focus-background');
&:focus-within {
box-shadow: 0 0 0 rem(4px) var-get($contained-theme, 'focus-border-color');
}

igc-icon {
color: var-get($contained-theme, 'foreground');
&:active {
box-shadow: 0 0 0 rem(4px) var-get($contained-theme, 'focus-border-color');
}
}

::slotted(igc-ripple) {
border-radius: var-get($contained-theme, 'border-radius');
}
}

:host([variant='outlined']) {
Expand All @@ -76,70 +45,30 @@ $outlined-theme: $bootstrap-outlined;
--component-size: var(--ig-size, #{var-get($outlined-theme, 'default-size')});

[part='base'] {
box-shadow: 0 0 0 rem(1px) var-get($outlined-theme, 'border-color');

&:hover {
color: var-get($outlined-theme, 'hover-foreground');
background: var-get($outlined-theme, 'focus-background');

&:hover {
igc-icon {
color: var-get($outlined-theme, 'hover-foreground');
}
}

&:focus,
&:active {
color: var-get($outlined-theme, 'focus-foreground');
background: var-get($outlined-theme, 'focus-background');
&:focus-within {
box-shadow: 0 0 0 rem(4px) var-get($outlined-theme, 'focus-border-color');

igc-icon {
color: var-get($outlined-theme, 'focus-foreground');
}
}
}

igc-icon {
color: var-get($outlined-theme, 'foreground');
}

::slotted(igc-ripple) {
border-radius: var-get($outlined-theme, 'border-radius');
}
}

:host([disabled]),
:host(:disabled) {
[part='base'] {
color: var-get($flat-theme, 'disabled-foreground');
background: var-get($flat-theme, 'disabled-background');
}

igc-icon {
color: var-get($flat-theme, 'disabled-foreground');
}
}

:host([disabled][variant='contained']),
:host(:disabled[variant='contained']) {
[part='base'] {
background: var-get($contained-theme, 'disabled-background');
color: var-get($contained-theme, 'disabled-foreground');
}

igc-icon {
color: var-get($contained-theme, 'disabled-foreground');
&:active {
box-shadow: 0 0 0 rem(4px) var-get($outlined-theme, 'focus-border-color');
}
}
}

:host([disabled][variant='outlined']),
:host(:disabled[variant='outlined']) {
[part='base'] {
color: var-get($outlined-theme, 'disabled-foreground');
box-shadow: 0 0 0 rem(1px) var-get($outlined-theme, 'disabled-border-color');
}

igc-icon {
color: var-get($outlined-theme, 'disabled-foreground');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
@use 'styles/utilities' as *;
@use '../light/themes' as *;

$flat-theme: $material-flat;
$contained-theme: $material-contained;
$outlined-theme: $material-outlined;

[part='base'] {
border-radius: var-get($flat-theme, 'border-radius');
width: var-get($flat-theme, 'size');
height: var-get($flat-theme, 'size');
}

:host([variant='flat']) {
@include css-vars-from-theme($flat-theme, 'ig-icon-button');

--component-size: var(--ig-size, #{var-get($flat-theme, 'default-size')});

[part='base'] {
color: var-get($flat-theme, 'foreground');
background: var-get($flat-theme, 'background');

&:hover {
background: var-get($flat-theme, 'hover-background');
color: var-get($flat-theme, 'hover-foreground');
}

&:focus,
&:focus-within {
background: var-get($flat-theme, 'focus-background');
color: var-get($flat-theme, 'focus-foreground');
}

&:active {
background: var-get($flat-theme, 'active-background');
color: var-get($flat-theme, 'active-foreground');
}
}

igc-icon {
color: var-get($flat-theme, 'foreground');
}

::slotted(igc-ripple) {
border-radius: var-get($flat-theme, 'border-radius');
}
}

:host([variant='contained']) {
@include css-vars-from-theme($contained-theme, 'ig-icon-button');

--component-size: var(--ig-size, #{var-get($contained-theme, 'default-size')});

[part='base'] {
background: var-get($contained-theme, 'background');
color: var-get($contained-theme, 'foreground');

&:hover {
background: var-get($contained-theme, 'hover-background');
color: var-get($contained-theme, 'hover-foreground');
}

&:focus,
&:focus-within {
background: var-get($contained-theme, 'focus-background');
color: var-get($contained-theme, 'focus-foreground');
}

&:active {
background: var-get($contained-theme, 'active-background');
color: var-get($contained-theme, 'active-foreground');
}
}

igc-icon {
color: var-get($contained-theme, 'foreground');
}

::slotted(igc-ripple) {
border-radius: var-get($contained-theme, 'border-radius');
}
}

:host([variant='outlined']) {
@include css-vars-from-theme($outlined-theme, 'ig-icon-button');

--component-size: var(--ig-size, #{var-get($outlined-theme, 'default-size')});

[part='base'] {
color: var-get($outlined-theme, 'foreground');
background: var-get($outlined-theme, 'background');
box-shadow: 0 0 0 rem(1px) var-get($outlined-theme, 'border-color');

&:hover {
background: var-get($outlined-theme, 'hover-background');
color: var-get($outlined-theme, 'hover-foreground');
}

&:focus,
&:focus-within {
background: var-get($outlined-theme, 'focus-background');
color: var-get($outlined-theme, 'focus-foreground');
}

&:active {
background: var-get($outlined-theme, 'active-background');
color: var-get($outlined-theme, 'active-foreground');
}
}

igc-icon {
color: var-get($outlined-theme, 'foreground');
}

::slotted(igc-ripple) {
border-radius: var-get($outlined-theme, 'border-radius');
}
}

:host([disabled]),
:host(:disabled) {
[part='base'] {
background: var-get($flat-theme, 'disabled-background');
color: var-get($flat-theme, 'disabled-foreground');
}

igc-icon {
color: var-get($flat-theme, 'disabled-foreground');
}
}

:host([disabled][variant='contained']),
:host(:disabled[variant='contained']) {
[part='base'] {
background: var-get($contained-theme, 'disabled-background');
color: var-get($contained-theme, 'disabled-foreground');
}

igc-icon {
color: var-get($contained-theme, 'disabled-foreground');
}
}

:host([disabled][variant='outlined']),
:host(:disabled[variant='outlined']) {
[part='base'] {
background: var-get($outlined-theme, 'disabled-background');
color: var-get($outlined-theme, 'disabled-foreground');
}

igc-icon {
color: var-get($outlined-theme, 'disabled-foreground');
}
}
Loading

0 comments on commit 7a03578

Please sign in to comment.