Skip to content

Commit eecddaf

Browse files
authored
feat: support hint colors for progress shortcode (#967)
1 parent 93979d4 commit eecddaf

File tree

6 files changed

+42
-5
lines changed

6 files changed

+42
-5
lines changed

exampleSite/content/en/shortcodes/progress.md

+10
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,15 @@ A progress bar shows how far a process has progressed.
2424
<!-- prettier-ignore-start -->
2525
<!-- spellchecker-disable -->
2626
{{< progress title=Eating value=65 icon=gdoc_heart >}}
27+
28+
{{< progress title="Type: note" value=10 icon=gdoc_heart type=note >}}
29+
30+
{{< progress title="Type: tip" value=70 icon=gdoc_heart type=tip >}}
31+
32+
{{< progress title="Type: important" value=30 icon=gdoc_heart type=important >}}
33+
34+
{{< progress title="Type: caution" value=90 icon=gdoc_heart type=caution >}}
35+
36+
{{< progress title="Type: warning" value=80 icon=gdoc_heart type=warning >}}
2737
<!-- spellchecker-enable -->
2838
<!-- prettier-ignore-end -->

exampleSite/data/properties/shortcode-progress.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
---
22
properties:
3+
- name: type
4+
type: string
5+
description: Color type of the progress bar. Supported values are `main|note|tip|important|caution|warning`.
6+
required: false
7+
defaultValue: main
38
- name: value
49
type: integer
510
description: Progress value.

layouts/shortcodes/hint.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
{{ $type := default "note" (.Get "type") }}
2-
{{ $icon := .Get "icon" }}
3-
{{ $title := default ($type | title) (.Get "title") }}
1+
{{- $type := default "note" (.Get "type") }}
2+
{{- $icon := .Get "icon" }}
3+
{{- $title := default ($type | title) (.Get "title") }}
44

55

66
<blockquote class="gdoc-hint {{ $type | lower }}">

layouts/shortcodes/progress.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{- $value := default 0 (.Get "value") -}}
2+
{{- $type := default "main" (.Get "type") }}
23
{{- $title := .Get "title" -}}
34
{{- $icon := .Get "icon" -}}
45

@@ -15,7 +16,7 @@
1516
</div>
1617
<div class="gdoc-progress__wrap">
1718
<div
18-
class="gdoc-progress__bar"
19+
class="gdoc-progress__bar {{ $type | lower }}"
1920
data-percent="{{ $value }}"
2021
style="width: {{ $value }}%;"
2122
></div>

src/sass/_color_mode.scss

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@
9595
filter: saturate(2.5) brightness(0.85);
9696
}
9797

98+
.gdoc-progress__bar {
99+
filter: saturate(0.85) brightness(0.85);
100+
}
101+
98102
.gdoc-hint,
99103
.admonitionblock {
100104
a {

src/sass/_shortcodes.scss

+18-1
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,23 @@
281281
transparent
282282
);
283283
background-size: 2.5em 2.5em;
284-
background-color: defaults.$main-color !important;
284+
background-color: defaults.$main-color;
285+
286+
@each $name, $color in defaults.$hint-colors {
287+
&.#{$name} {
288+
background-image: linear-gradient(
289+
-45deg,
290+
#{color.scale($color, $lightness: -20%)} 25%,
291+
transparent 25%,
292+
transparent 50%,
293+
#{color.scale($color, $lightness: -20%)} 50%,
294+
#{color.scale($color, $lightness: -20%)} 75%,
295+
transparent 75%,
296+
transparent
297+
);
298+
299+
background-color: $color;
300+
}
301+
}
285302
}
286303
}

0 commit comments

Comments
 (0)