Skip to content

Commit 056c6da

Browse files
feat(theme): containers: add the success custom block
This adds a custom block with the `success` keyword, which is a green container. The colours for this container already exist in vars.css (--vp-c-success*), which, before this commit, is completely unused outside of generating a diff. For example, this can be used for messages such as: ``` ::: success You have completed the walkthrough! ::: ```
1 parent 78c4d3d commit 056c6da

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

Diff for: docs/en/guide/markdown.md

+9
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ This is a warning.
149149
This is a dangerous warning.
150150
:::
151151

152+
::: success
153+
This is a success notice.
154+
:::
155+
152156
::: details
153157
This is a details block.
154158
:::
@@ -172,6 +176,10 @@ This is a warning.
172176
This is a dangerous warning.
173177
:::
174178

179+
::: success
180+
This is a success notice.
181+
:::
182+
175183
::: details
176184
This is a details block.
177185
:::
@@ -218,6 +226,7 @@ export default defineConfig({
218226
warningLabel: '警告',
219227
dangerLabel: '危险',
220228
infoLabel: '信息',
229+
successLabel: '成功',
221230
detailsLabel: '详细信息'
222231
}
223232
}

Diff for: src/client/theme-default/styles/components/custom-block.css

+20
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,26 @@
166166
background-color: var(--vp-custom-block-details-code-bg);
167167
}
168168

169+
.custom-block.success {
170+
border-color: var(--vp-custom-block-success-border);
171+
color: var(--vp-custom-block-success-text);
172+
background-color: var(--vp-custom-block-success-bg);
173+
}
174+
175+
.custom-block.success a,
176+
.custom-block.success code {
177+
color: var(--vp-c-brand-1);
178+
}
179+
180+
.custom-block.success a:hover,
181+
.custom-block.success a:hover > code {
182+
color: var(--vp-c-brand-2);
183+
}
184+
185+
.custom-block.success code {
186+
background-color: var(--vp-custom-block-success-code-bg);
187+
}
188+
169189
.custom-block-title {
170190
font-weight: 600;
171191
}

Diff for: src/client/theme-default/styles/vars.css

+5
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,11 @@
446446
--vp-custom-block-caution-bg: var(--vp-c-caution-soft);
447447
--vp-custom-block-caution-code-bg: var(--vp-c-caution-soft);
448448

449+
--vp-custom-block-success-border: transparent;
450+
--vp-custom-block-success-text: var(--vp-c-text-1);
451+
--vp-custom-block-success-bg: var(--vp-c-success-soft);
452+
--vp-custom-block-success-code-bg: var(--vp-c-success-soft);
453+
449454
--vp-custom-block-details-border: var(--vp-custom-block-info-border);
450455
--vp-custom-block-details-text: var(--vp-custom-block-info-text);
451456
--vp-custom-block-details-bg: var(--vp-custom-block-info-bg);

Diff for: src/node/markdown/plugins/containers.ts

+8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ export const containerPlugin = (
3232
md
3333
)
3434
)
35+
.use(
36+
...createContainer(
37+
'success',
38+
containerOptions?.successLabel || 'SUCCESS',
39+
md
40+
)
41+
)
3542
.use(
3643
...createContainer(
3744
'details',
@@ -138,4 +145,5 @@ export interface ContainerOptions {
138145
detailsLabel?: string
139146
importantLabel?: string
140147
cautionLabel?: string
148+
successLabel?: string
141149
}

0 commit comments

Comments
 (0)