Skip to content

Commit 39d5c05

Browse files
committed
rework theme mechanism so toggle buttons are styled right away, add docs for lucide icons
1 parent 8c54e95 commit 39d5c05

20 files changed

+174
-154
lines changed

gulp.d/tasks/build-preview-pages.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ const yaml = require('js-yaml')
1414

1515
const ASCIIDOC_ATTRIBUTES = { experimental: '', icons: 'font', sectanchors: '', 'source-highlighter': 'highlight.js' }
1616

17+
const algoliaTestKeys = {
18+
algoliaAppId: 'R2IYF7ETH7',
19+
algoliaIndexName: 'docsearch',
20+
algoliaApiKey: '599cec31baffa4868cae4e79f180729b',
21+
}
22+
1723
module.exports = (src, previewSrc, previewDest, sink = () => map()) => (done) =>
1824
Promise.all([
1925
loadSampleUiModel(previewSrc),
@@ -37,7 +43,7 @@ module.exports = (src, previewSrc, previewDest, sink = () => map()) => (done) =>
3743
for (const component of baseUiModel.site.components) {
3844
for (const version of component.versions || []) version.asciidoc = asciidoc
3945
}
40-
baseUiModel = { ...baseUiModel, env: process.env }
46+
baseUiModel = { ...baseUiModel, env: process.env, site: { ...baseUiModel.site, keys: algoliaTestKeys } }
4147
delete baseUiModel.asciidoc
4248
return [baseUiModel, layouts]
4349
})

gulp.d/tasks/build.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ module.exports = (src, dest, preview) => () => {
4242
}),
4343
postcssUrl([
4444
{
45-
filter: (asset) => new RegExp('.+[.](?:ttf|woff2?)$').test(asset.url),
45+
filter: (asset) => new RegExp('.+[.](?:ttf|woff2?)(?:\\?[^\\s]*)?$').test(asset.url),
4646
url: (asset) => {
47-
const relpath = asset.pathname.substr(1)
48-
const abspath = require.resolve(relpath)
49-
const basename = ospath.basename(abspath)
47+
const basename = ospath.basename(asset.absolutePath)
5048
const destpath = ospath.join(dest, 'font', basename)
51-
if (!fs.pathExistsSync(destpath)) fs.copySync(abspath, destpath)
49+
if (!fs.pathExistsSync(destpath)) fs.copySync(asset.absolutePath, destpath)
5250
return path.join('..', 'font', basename)
5351
},
5452
},

preview-src/asciidoc/images.adoc

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Click the Astra Vector icon image:../img/astra-vector-light.svg[title="Astra Vec
112112

113113
[NOTE]
114114
======
115-
You can define icons from https://fonts.google.com/icons?icon.set=Material+Icons&icon.style=Outlined[Material Icons,window=_blank] or an svg file using the customized `icon` macro or the `material-icons` role.
115+
You can define icons from https://fonts.google.com/icons?icon.set=Material+Icons&icon.style=Outlined[Material Icons,window=_blank] and https://lucide.dev/icons/[Lucide Icons,window=_blank]. You can also apply an svg file using the customized `icon` macro.
116116
117117
Method 1: Inline icon macro with an svg file::
118118
The customized inline icon macro accepts a file path as it's target source. The file must be an svg file.
@@ -127,6 +127,8 @@ icon:ROOT:ui/icons/vector.svg[]
127127
Method 2: Inline icon macro with a material-icons target::
128128
The customized inline icon macro supports material icon names as it's target source prefixed with `material-icons:`. Ensure the name is lower case with underscores instead of spaces.
129129
+
130+
This macro does not yet support Lucide icons.
131+
+
130132
This method supports light and dark mode automatically.
131133
+
132134
[source]
@@ -151,12 +153,31 @@ thumb_up
151153
----
152154
Inline material icons [.material-icons]#thumb_up#
153155
----
154-
======
156+
+
157+
[.material-icons]#thumb_up# [.material-icons]#rocket_launch#
155158
156-
[.material-icons]
157-
add_reaction
159+
Method 4: Lucide icons with HTML passthrough::
160+
Use block or inline HTML passthrough to create an icon element `<i class="icon-{icon-name}"></i>`.
161+
+
162+
This method supports light and dark mode automatically.
163+
+
164+
.Block passthrough
165+
[source]
166+
----
167+
++++
168+
<i class="icon-boom-box"></i>
169+
++++
170+
----
171+
+
172+
.Inline passthrough
173+
[source]
174+
----
175+
Inline lucide icons +++<i class="icon-boom-box"></i>+++
176+
----
177+
+
178+
+++<i class="icon-boom-box"></i>+++ +++<i class="icon-atom"></i>+++ +++<i class="icon-moon"></i>+++
179+
======
158180

159-
Inline material icons [.material-icons]#thumb_up# [.material-icons]#support# [.material-icons]#code# [.material-icons]#rocket_launch# [.material-icons.text-2xl]#rocket_launch# [.material-icons.text-3xl]#rocket_launch#
160181

161182
== Video
162183

src/css/asciidoc/admonition-block.css

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@
5959
}
6060

6161
.doc .admonitionblock.note .icon::before {
62-
color: var(--ds-success-500);
62+
color: var(--ds-success-soft-color);
6363
content: "\e88e";
6464
}
6565

6666
.doc .admonitionblock.tip .icon::before {
67-
color: var(--ds-success-500);
67+
color: var(--ds-success-soft-color);
6868
content: "\e0f0";
6969
}
7070

@@ -79,7 +79,7 @@
7979
}
8080

8181
.doc .admonitionblock.caution .icon::before {
82-
color: var(--ds-warning-500);
82+
color: var(--ds-warning-soft-color);
8383
content: "\e88e";
8484
}
8585

@@ -96,16 +96,12 @@
9696
}
9797

9898
.doc .admonitionblock.warning .icon::before {
99-
color: var(--ds-failure-500);
99+
color: var(--ds-failure-soft-color);
100100
content: "\f083";
101101
}
102102

103103
.doc .admonitionblock.important .icon::before {
104-
color: var(--ds-failure-500);
104+
color: var(--ds-failure-soft-color);
105105
content: "\e160";
106106
}
107-
108-
html[data-theme="dark"] .doc .admonitionblock .icon::before {
109-
color: var(--ds-primary-text);
110-
}
111107
}

src/css/asciidoc/doc.css

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -430,39 +430,17 @@
430430
border-radius: var(--ds-space-1);
431431
transform: translate(-0.25rem, -50%);
432432
}
433-
434-
.doc .admonitionblock.caution .icon {
435-
background-color: var(--ds-primary-main);
436-
color: var(--ds-text-inverse);
437-
}
438-
439-
.doc .admonitionblock.important .icon {
440-
background-color: var(--ds-failure-man);
441-
color: var(--ds-text-inverse);
442-
}
443-
444-
.doc .admonitionblock.note .icon {
445-
background-color: var(--ds-cyan-main);
446-
color: var(--ds-text-inverse);
447-
}
448-
449-
.doc .admonitionblock.tip .icon {
450-
background-color: var(--ds-success-main);
451-
color: var(--ds-text-inverse);
452-
}
453-
454-
.doc .admonitionblock.warning .icon {
455-
background-color: var(--ds-warning-main);
456-
color: var(--ds-text-inverse);
457-
}
458-
433+
459434
.doc .admonitionblock .icon i {
460435
display: inline-flex;
461436
align-items: center;
462437
height: 100%;
463438
}
464439

465440
.doc .admonitionblock .icon i::after {
441+
font-size: 1rem;
442+
font-weight: 600;
443+
font-family: "Roboto Flex", sans-serif;
466444
content: attr(title);
467445
}
468446

src/css/docsearch.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ html[data-theme="dark"] .DocSearch .DocSearch-Modal {
1515
.DocSearch .DocSearch-Commands-Key,
1616
.DocSearch .DocSearch-Button-Key {
1717
border-radius: 4px;
18-
color: var(--ds-text-tertiary);
18+
color: var(--ds-text-secondary);
1919
}
2020

2121
.DocSearch .DocSearch-LoadingIndicator svg,
@@ -128,7 +128,7 @@ html[data-theme="dark"] .DocSearch .DocSearch-Modal {
128128
--docsearch-hit-shadow: none;
129129

130130
/* key */
131-
--docsearch-key-gradient: var(--ds-background-level1);
131+
--docsearch-key-gradient: var(--ds-background-level2);
132132
--docsearch-key-shadow: none;
133133

134134
/* footer */
@@ -149,7 +149,7 @@ html[data-theme="dark"] .DocSearch {
149149
--docsearch-hit-color: var(--ds-text-primary);
150150
--docsearch-hit-shadow: none;
151151
--docsearch-hit-background: var(--ds-background-body);
152-
--docsearch-key-gradient: var(--ds-background-level1);
152+
--docsearch-key-gradient: var(--ds-background-level2);
153153
--docsearch-key-shadow: none;
154154
--docsearch-footer-background: var(--ds-background-body);
155155
--docsearch-footer-shadow: none;

src/css/site.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@import "vars/dark.css";
44
@import "color.css";
55
@import "base.css";
6+
@import "theme-toggle.css";
67
@import "utilities.css";
78
@import "typography.css";
89
@import "components/btn.css";

src/css/theme-toggle.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
html[data-theme="light"]:not([data-theme-system="true"]) {
2+
& #theme-toggle .thumb {
3+
transform: translateX(0);
4+
background-color: theme(colors.amber.300);
5+
}
6+
& #theme-toggle .toggle-button.light:hover {
7+
background-color: transparent;
8+
}
9+
}
10+
11+
html[data-theme="dark"]:not([data-theme-system="true"]) {
12+
& #theme-toggle .thumb {
13+
transform: translateX(1.6125rem);
14+
background-color: theme(colors.purple.500);
15+
}
16+
& #theme-toggle .toggle-button.dark:hover {
17+
background-color: transparent;
18+
}
19+
}
20+
21+
html[data-theme-system="true"] {
22+
& #theme-toggle .thumb {
23+
transform: translateX(3.25rem);
24+
background-color: var(--ds-neutral-solid-bg);
25+
}
26+
& #theme-toggle .toggle-button.system {
27+
color: var(--ds-neutral-solid-color);
28+
&:hover {
29+
background-color: transparent;
30+
}
31+
}
32+
}
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
11
@import "lucide-static/font/lucide.css";
2-
3-
@font-face {
4-
font-family: "lucide";
5-
font-style: normal;
6-
font-weight: 400;
7-
src: url(~lucide-static/font/lucide.woff2) format("woff2");
8-
}

src/css/utilities.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,20 @@
77
-ms-overflow-style: none; /* IE and Edge */
88
scrollbar-width: none; /* Firefox */
99
}
10+
11+
@keyframes fadeInOut {
12+
0% {
13+
opacity: 0.3;
14+
}
15+
50% {
16+
opacity: 1;
17+
}
18+
100% {
19+
opacity: 0.3;
20+
}
21+
}
22+
23+
.animate-fade-in-out {
24+
animation: fadeInOut 3s infinite;
25+
}
1026
}

0 commit comments

Comments
 (0)