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

Commit

Permalink
feat(highlight): Switched theming to custom properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomheller committed Dec 2, 2020
1 parent 40db4dd commit 7b6f8f2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 32 deletions.
8 changes: 4 additions & 4 deletions apps/dev/src/highlight/highlight-demo.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dt-highlight term=">"
>&lt;&gt;&quot;&amp;&mdash;&nbsp;&apos;&cent;&pound;&yen;&euro;&copy;&reg;&forall;&empty;&exist;&nabla;&isin;&notin;&ni;&prod;&sum;</dt-highlight
>
<dt-highlight term=">">
&lt;&gt;&quot;&amp;&mdash;&nbsp;&apos;&cent;&pound;&yen;&euro;&copy;&reg;&forall;&empty;&exist;&nabla;&isin;&notin;&ni;&prod;&sum;
</dt-highlight>
<hr />

<p dt-highlight term="s">
Expand Down Expand Up @@ -90,7 +90,7 @@

<dt-highlight term="Jane">We welcome {{ name }} to this event.</dt-highlight>

<div dtTheme=":dark" class="dark">
<div dtTheme=":dark" class="dt-example-dark">
<p dt-highlight term="s">
Some
<b>text where</b>
Expand Down
1 change: 1 addition & 0 deletions apps/dev/src/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ body {
.dt-example-dark {
background-color: #2d2d2d;
padding: 16px;
color: #fff;
}
11 changes: 2 additions & 9 deletions libs/barista-components/highlight/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("//tools/bazel_rules:index.bzl", "jest", "ng_module_view_engine", "stylelint")

Expand Down Expand Up @@ -42,17 +42,10 @@ ng_module_view_engine(
],
)

sass_library(
name = "theme",
srcs = glob(
["src/**/_*.scss"],
),
)

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

stylelint(
Expand Down
12 changes: 0 additions & 12 deletions libs/barista-components/highlight/src/_highlight-theme.scss

This file was deleted.

13 changes: 6 additions & 7 deletions libs/barista-components/highlight/src/highlight.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
@import '../../core/src/style/variables';
@import 'highlight-theme';

:host {
// width and height have to be at least 1px for it to work properly
min-height: 1px;
min-width: 1px;
display: inline-block;
--dt-highlight-color: #{$turquoise-100};
}

:host-context(.dt-theme-dark) {
--dt-highlight-color: #{$gray-700};
}

.dt-highlight-source {
display: none;
}

::ng-deep .dt-highlight-mark {
background-color: $turquoise-100;
background-color: var(--dt-highlight-color);
text-decoration: underline;
color: currentColor;

Expand All @@ -33,8 +37,3 @@
content: ' [highlight end] ';
}
}

// Apply the highlight theme to all theme definitions
@include dt-apply-theme() {
@include dt-theme-highlight($dt-current-theme);
}

0 comments on commit 7b6f8f2

Please sign in to comment.