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

Abstraction of style values into private css variables #2364

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 packages/itwinui-css/src/breadcrumbs/breadcrumbs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

.iui-breadcrumbs {
--_iui-breadcrumbs-height: var(--iui-component-height);
--_iui-breadcrumbs-content-color-default: var(--iui-color-text-accent);

@include mixins.iui-reset;
display: flex;
Expand Down Expand Up @@ -56,7 +57,7 @@
&:where(button, :any-link) {
@include base.iui-button;
@include borderless.iui-button-borderless;
color: var(--iui-color-text-accent);
color: var(--_iui-breadcrumbs-content-color-default);

&[aria-current] {
color: var(--iui-color-text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
--_iui-expandable-block-header-focus-offset: -2px;
--_iui-expandable-block-header-focus-thickness: 2px;

--_iui-expandable-block-header-caption-color-hover: var(--iui-color-text-hover);

&[data-iui-expanded='true'] {
--_iui-expandable-block-header-bottom-border-radius: 0;
--_iui-expandable-block-expander-icon-transform: rotate(90deg);
Expand Down Expand Up @@ -80,14 +82,14 @@

&:where(:hover) {
--_iui-expandable-block-expander-icon-fill: var(--iui-color-icon-hover);
--_iui-expandable-block-header-caption-color: var(--iui-color-text-hover);
--_iui-expandable-block-header-caption-color: var(--_iui-expandable-block-header-caption-color-hover);
--_iui-expandable-block-header-label-color: var(--iui-color-text-hover);

background-color: var(--_iui-expandable-block-header-background-color-hover);

@media (forced-colors: active) {
--_iui-expandable-block-expander-icon-fill: Highlight;
--_iui-expandable-block-header-caption-color: Highlight;
--_iui-expandable-block-header-caption-color-hover: Highlight;
--_iui-expandable-block-header-label-color: Highlight;
border-color: Highlight;
}
Expand Down
4 changes: 3 additions & 1 deletion packages/itwinui-css/src/menu/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ $iui-active-outline: 1px solid var(--iui-color-border-accent);
}

:is(.iui-list-item, .iui-menu-item-skeleton) {
--_iui-list-item-background-hover: var(--iui-color-background-hover);

display: flex;
align-items: center;
gap: var(--iui-size-xs);
Expand All @@ -54,7 +56,7 @@ $iui-active-outline: 1px solid var(--iui-color-border-accent);
&:where([data-iui-actionable='true']:hover),
&:where(:has(.iui-link-action):hover) {
cursor: pointer;
background-color: var(--iui-color-background-hover);
background-color: var(--_iui-list-item-background-hover);
}

&:where(.iui-large, [data-iui-size='large']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
@use 'sass:string';
@use '../mixins';

:is(.iui-progress-indicator-radial, .iui-progress-indicator-linear) {
--_iui-progress-indicator-color-default-progress: var(--iui-color-border-accent);
}

.iui-progress-indicator-radial {
--_iui-progress-indicator-radial-size: #{map.get(mixins.$iui-icon-sizes, xl)};
vertical-align: middle;
Expand Down Expand Up @@ -34,7 +38,7 @@
&::after {
mask-composite: subtract;
mask-clip: border-box, content-box;
background-color: var(--iui-color-border-accent);
background-color: var(--_iui-progress-indicator-color-default-progress);
}

&::before,
Expand Down Expand Up @@ -144,7 +148,7 @@
content: '';
block-size: var(--iui-size-2xs);
$percentage: var(--iui-progress-percentage, 100%);
$fill: var(--_iui-progress-indicator-track-fill, var(--iui-color-border-accent));
$fill: var(--_iui-progress-indicator-track-fill, var(--_iui-progress-indicator-color-default-progress));

background-color: var(--iui-color-border);
background-image: linear-gradient(90deg, $fill 0% 100%);
Expand Down
32 changes: 24 additions & 8 deletions packages/itwinui-css/src/tabs/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ $borderless-horizontal-tab-min-height: calc(
);

@mixin iui-tabs-wrapper {
--_iui-tab-color-stripe-blue: var(--iui-color-border-accent);
--_iui-tab-color-stripe-green: var(--iui-color-border-positive);
--_iui-tab-color-stripe: var(--_iui-tab-color-stripe-blue);

--_iui-tab-color-default: var(--iui-color-text);
--_iui-tab-color-selected: var(--iui-color-text-accent);
--_iui-tab-color-disabled: var(--iui-color-text-disabled);
--_iui-tab-color-green-selected: var(--iui-color-text-positive);
--_iui-tab-color: var(--_iui-tab-color-default);

display: grid;
position: relative;
}
Expand All @@ -44,13 +54,17 @@ $borderless-horizontal-tab-min-height: calc(
min-block-size: calc(var(--iui-size-m) * 2.5);
block-size: 100%;
cursor: pointer;
color: var(--iui-color-text);
color: var(--_iui-tab-color);
transition: background-color var(--iui-duration-1) ease-out;
text-align: start;
scroll-margin: var(--iui-size-m);

&::after {
background-color: var(--_iui-tab-color-stripe);
}

&[aria-selected='true'] {
color: var(--iui-color-text-accent);
--_iui-tab-color: var(--_iui-tab-color-selected);

.iui-tab-icon svg {
fill: currentColor;
Expand All @@ -63,7 +77,7 @@ $borderless-horizontal-tab-min-height: calc(

&:is([disabled], :disabled, [aria-disabled='true'], [data-iui-disabled='true']) {
cursor: not-allowed;
color: var(--iui-color-text-disabled);
--_iui-tab-color: var(--_iui-tab-color-disabled);

.iui-tab-description {
color: inherit;
Expand Down Expand Up @@ -105,7 +119,7 @@ $borderless-horizontal-tab-min-height: calc(
}

&[aria-selected='true'] {
color: var(--iui-color-text-positive);
--_iui-tab-color: var(--_iui-tab-color-green-selected);

.iui-tab-icon svg {
fill: currentColor;
Expand Down Expand Up @@ -235,7 +249,8 @@ $borderless-horizontal-tab-min-height: calc(
.iui-tab::after {
content: '';
position: absolute;
background-color: var(--iui-color-border-accent);

--_iui-tab-color-stripe: var(--_iui-tab-color-stripe-blue);
}

[aria-selected='true']::after {
Expand All @@ -247,19 +262,20 @@ $borderless-horizontal-tab-min-height: calc(
}

&.iui-green .iui-tab::after {
background-color: var(--iui-color-border-positive);
--_iui-tab-color-stripe: var(--_iui-tab-color-stripe-green);
}
}

@mixin iui-tab-animated {
&::after {
position: absolute;
content: ' ';
background-color: var(--iui-color-border-accent);

background-color: var(--_iui-tab-color-stripe);
}

&.iui-green::after {
background-color: var(--iui-color-border-positive);
--_iui-tab-color-stripe: var(--_iui-tab-color-stripe-green);
}

.iui-horizontal &::after {
Expand Down
2 changes: 1 addition & 1 deletion packages/itwinui-css/src/tabs/default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
}

&.iui-green .iui-tab::after {
background-color: var(--iui-color-border-positive);
--_iui-tab-color-stripe: var(--_iui-tab-color-stripe-green);
}

~ .iui-tabs-content {
Expand Down
Loading