Skip to content

Commit 64f3d0e

Browse files
authored
feat: add progress bar shortcode (#594)
1 parent 07bfc6c commit 64f3d0e

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: Progress
3+
---
4+
5+
A progress bar shows how far a process has progressed.
6+
7+
## Attributes
8+
9+
| Name | Description | default |
10+
| ---------------- | -------------------------------------------------------------------------- | --------- |
11+
| value | progress value | 0 |
12+
| icon (optional) | icon to use, need to be an icon from an [SVG sprite](/features/icon-sets/) | undefined |
13+
| title (optional) | progress title | undefined |
14+
15+
## Usage
16+
17+
<!-- prettier-ignore-start -->
18+
```tpl
19+
{{</* progress title=Eating value=65 icon=gdoc_heart */>}}
20+
```
21+
<!-- prettier-ignore-end -->
22+
23+
## Example
24+
25+
<!-- prettier-ignore-start -->
26+
<!-- spellchecker-disable -->
27+
{{< progress title=Eating value=65 icon=gdoc_heart >}}
28+
<!-- spellchecker-enable -->
29+
<!-- prettier-ignore-end -->

layouts/shortcodes/progress.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- $value := default 0 (.Get "value") -}}
2+
{{- $title := .Get "title" -}}
3+
{{- $icon := .Get "icon" -}}
4+
5+
6+
<div class="gdoc-progress">
7+
<div class="gdoc-progress__label flex justify-between">
8+
<div class="gdoc-progress__label--name flex align-center">
9+
{{ with $icon -}}
10+
<svg class="gdoc-icon {{ . }}"><use xlink:href="#{{ . }}"></use></svg>
11+
{{- end }}
12+
{{ with $title }}<span>{{ . }}</span>{{ end }}
13+
</div>
14+
<div>{{ $value }}%</div>
15+
</div>
16+
<div class="gdoc-progress__wrap">
17+
<div
18+
class="gdoc-progress__bar"
19+
data-percent="{{ $value }}"
20+
style="width: {{ $value }}%;"
21+
></div>
22+
</div>
23+
</div>

src/sass/_shortcodes.scss

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,39 @@
238238
font-size: $font-size-14;
239239
}
240240
}
241+
242+
// {{% progress %}}
243+
.gdoc-progress {
244+
margin-bottom: $padding-16;
245+
246+
&__label {
247+
padding: $padding-4 0;
248+
249+
&--name {
250+
font-weight: bold;
251+
}
252+
}
253+
254+
&__wrap {
255+
background-color: var(--accent-color-lite);
256+
border-radius: 1em;
257+
box-shadow: inset 0 0 0 $border-1 var(--accent-color);
258+
}
259+
260+
&__bar {
261+
height: 1em;
262+
border-radius: 1em;
263+
background-image: linear-gradient(
264+
-45deg,
265+
rgba(255, 255, 255, 0.125) 25%,
266+
transparent 25%,
267+
transparent 50%,
268+
rgba(255, 255, 255, 0.125) 50%,
269+
rgba(255, 255, 255, 0.125) 75%,
270+
transparent 75%,
271+
transparent
272+
);
273+
background-size: 2.5em 2.5em;
274+
background-color: $main-color !important;
275+
}
276+
}

0 commit comments

Comments
 (0)