Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
refactor(expandable-section): Switch to custom properties for theming.
Browse files Browse the repository at this point in the history
  • Loading branch information
nimrod13 authored and lukasholzer committed Oct 13, 2020
1 parent 1a39593 commit e7c3555
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 67 deletions.
6 changes: 0 additions & 6 deletions libs/barista-components/expandable-section/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,9 @@ stylelint(
srcs = glob(["**/*.scss"]),
)

sass_library(
name = "theme",
srcs = ["src/_expandable-section-theme.scss"],
)

sass_binary(
name = "styles",
src = "src/expandable-section.scss",
deps = [":theme"],
)

jest(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,61 @@
@import '../../style/font-mixins';
@import '../../core/src/style/variables';
@import '../../core/src/style/interactive-common';
@import '../../core/src/theming/theming';
@import './expandable-section-theme';

:host {
box-sizing: border-box;
--dt-expandable-section-arrow-default-color: var(--dt-accent-default-color);
--dt-expandable-section-arrow-hover-color: var(--dt-accent-hover-color);
--dt-expandable-section-disabled-color: #{$gray-300};
--dt-expandable-section-header-line-default-color: #{$gray-500};
}

:host-context(.dt-theme-dark) {
--dt-expandable-section-header-dark-default-color: #{$gray-200};
--dt-expandable-section-header-dark-hover-color: #{$white};
--dt-expandable-section-header-line-dark-default-color: #{$gray-400};
--dt-expandable-section-header-line-dark-hover-color: #{$gray-200};
--dt-expandable-section-disabled-dark-color: #{$gray-500};

&:not(.dt-expandable-section-disabled) {
.dt-expandable-section-header-trigger:focus {
@include dt-focus-style(true);
}
}

.dt-expandable-section-header,
.dt-expandable-section-header-trigger {
color: var(--dt-expandable-section-header-dark-default-color);

~ .dt-expandable-section-header-line {
border-bottom-color: var(
--dt-expandable-section-header-line-dark-default-color
);
}
}

.dt-expandable-section-header-trigger:hover {
color: var(--dt-expandable-section-header-dark-hover-color);

~ .dt-expandable-section-header-line {
border-bottom-color: var(
--dt-expandable-section-header-line-dark-hover-color
);
}
}

&.dt-expandable-section-disabled .dt-expandable-section-header,
&.dt-expandable-section-disabled .dt-expandable-section-header-trigger {
color: var(--dt-expandable-section-disabled-dark-color);

.dt-expandable-section-arrow ::ng-deep svg {
fill: var(--dt-expandable-section-disabled-dark-color);
}

~ .dt-expandable-section-header-line {
border-bottom-color: var(--dt-expandable-section-disabled-dark-color);
}
}
}

.dt-expandable-section-header {
Expand All @@ -20,7 +70,7 @@
height: 16px;
margin-left: -2px;
margin-top: -2px;
fill: $turquoise-600;
fill: var(--dt-expandable-section-arrow-default-color);
vertical-align: middle;
transition: 0.125s;
transform: rotate(-90deg);
Expand All @@ -39,7 +89,8 @@

.dt-expandable-section-header-line {
flex-grow: 1;
border-bottom: 1px solid $gray-500;
border-bottom: 1px solid
var(--dt-expandable-section-header-line-default-color);
}

.dt-expandable-section-header-trigger {
Expand All @@ -59,11 +110,11 @@
color: $gray-900;

.dt-expandable-section-arrow ::ng-deep svg {
fill: $turquoise-700;
fill: var(--dt-expandable-section-arrow-hover-color);
}

~ .dt-expandable-section-header-line {
border-bottom-color: $gray-700;
border-bottom-color: var(--dt-neutral-hover-color);
}
}

Expand All @@ -72,15 +123,15 @@

.dt-expandable-section-header,
.dt-expandable-section-header-trigger {
color: $gray-300;
color: var(--dt-expandable-section-disabled-color);

.dt-expandable-section-arrow ::ng-deep svg {
fill: $gray-300;
fill: var(--dt-expandable-section-disabled-color);
}
}

.dt-expandable-section-header-line {
border-bottom: 1px solid $gray-300;
border-bottom: 1px solid var(--dt-expandable-section-disabled-color);
}
}

Expand All @@ -94,8 +145,3 @@
margin-left: 20px;
margin-top: 12px;
}

// Apply the expandable section theme
@include dt-apply-theme() {
@include dt-theme-expandable-section($dt-current-theme);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
<div class="dt-example-dark" dtTheme=":dark">
<dt-expandable-section>
<dt-expandable-section-header>
My header text
</dt-expandable-section-header>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet.
</dt-expandable-section>
<div class="dt-example-variant">
<dt-expandable-section>
<dt-expandable-section-header>
My header text
</dt-expandable-section-header>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet.
</dt-expandable-section>
</div>
<div class="dt-example-variant">
<h4>Disabled Expandable Section</h4>
<dt-expandable-section disabled>
<dt-expandable-section-header>
My header text
</dt-expandable-section-header>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet.
</dt-expandable-section>
</div>
</div>

0 comments on commit e7c3555

Please sign in to comment.