Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(theme): containers: add the success custom block #4228

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/en/guide/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ This is a warning.
This is a dangerous warning.
:::

::: success
This is a success notice.
:::

::: details
This is a details block.
:::
Expand All @@ -172,6 +176,10 @@ This is a warning.
This is a dangerous warning.
:::

::: success
This is a success notice.
:::

::: details
This is a details block.
:::
Expand Down Expand Up @@ -218,6 +226,7 @@ export default defineConfig({
warningLabel: '警告',
dangerLabel: '危险',
infoLabel: '信息',
successLabel: '成功',
detailsLabel: '详细信息'
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/client/theme-default/styles/components/custom-block.css
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,26 @@
background-color: var(--vp-custom-block-details-code-bg);
}

.custom-block.success {
border-color: var(--vp-custom-block-success-border);
color: var(--vp-custom-block-success-text);
background-color: var(--vp-custom-block-success-bg);
}

.custom-block.success a,
.custom-block.success code {
color: var(--vp-c-brand-1);
}

.custom-block.success a:hover,
.custom-block.success a:hover > code {
color: var(--vp-c-brand-2);
}

.custom-block.success code {
background-color: var(--vp-custom-block-success-code-bg);
}

.custom-block-title {
font-weight: 600;
}
Expand Down
5 changes: 5 additions & 0 deletions src/client/theme-default/styles/vars.css
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@
--vp-custom-block-caution-bg: var(--vp-c-caution-soft);
--vp-custom-block-caution-code-bg: var(--vp-c-caution-soft);

--vp-custom-block-success-border: transparent;
--vp-custom-block-success-text: var(--vp-c-text-1);
--vp-custom-block-success-bg: var(--vp-c-success-soft);
--vp-custom-block-success-code-bg: var(--vp-c-success-soft);

--vp-custom-block-details-border: var(--vp-custom-block-info-border);
--vp-custom-block-details-text: var(--vp-custom-block-info-text);
--vp-custom-block-details-bg: var(--vp-custom-block-info-bg);
Expand Down
8 changes: 8 additions & 0 deletions src/node/markdown/plugins/containers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export const containerPlugin = (
md
)
)
.use(
...createContainer(
'success',
containerOptions?.successLabel || 'SUCCESS',
md
)
)
.use(
...createContainer(
'details',
Expand Down Expand Up @@ -138,4 +145,5 @@ export interface ContainerOptions {
detailsLabel?: string
importantLabel?: string
cautionLabel?: string
successLabel?: string
}