Skip to content

Commit 1104591

Browse files
retyuiSimek
andauthored
feat: Add a custom important admonition type, other small tweaks (#5064)
* feat: Extends default admonitions with a custom `important` by default info was used: https://github.com/facebook/docusaurus/blob/094248992c5b5e99c8dc8ab3f77d564192736a29/packages/docusaurus-theme-classic/src/theme/Admonition/Types.tsx#L30 * fix props overwrite, naming tweak * convert to TSX, shade tweak, use new admonition in one more fragment * improve Tip admonition heading color in light mode --------- Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com>
1 parent 1ca33a5 commit 1104591

8 files changed

Lines changed: 51 additions & 7 deletions

File tree

docs/_experimental-channel-api-warning.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:::tip[Experimental Feature 🧪]
1+
:::important[Experimental Feature 🧪]
22

33
**This API is currently only available in React Native’s Experimental channels.**
44

website/docusaurus.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export type EditUrlButton = {
3030
};
3131

3232
const commonDocsOptions: PluginContentDocs.Options = {
33+
admonitions: {keywords: ['important'], extendDefaults: true},
3334
breadcrumbs: false,
3435
showLastUpdateAuthor: false,
3536
showLastUpdateTime: true,

website/src/css/customTheme.scss

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,13 +664,20 @@ html[data-theme="dark"] article .badge {
664664
--ifm-alert-background-color-highlight: rgba(225, 227, 230, 0.7);
665665
}
666666

667+
.alert--important {
668+
--ifm-alert-background-color: #8250df2a;
669+
--ifm-alert-background-color-highlight: #e0cfff;
670+
--ifm-alert-foreground-color: #281846;
671+
--ifm-alert-border-color: #e0cfff;
672+
}
673+
667674
html[data-theme="dark"] {
668675
span[class^="admonitionIcon"] svg {
669-
fill: hsl(from var(--ifm-alert-border-color) h calc(s + 10) calc(l + 10));
676+
fill: hsl(from var(--ifm-alert-border-color) h calc(s - 10) calc(l + 10));
670677
}
671678

672679
div[class^="admonitionHeading"] {
673-
color: hsl(from var(--ifm-alert-border-color) h calc(s + 10) calc(l + 10));
680+
color: hsl(from var(--ifm-alert-border-color) h calc(s - 10) calc(l + 10));
674681
}
675682

676683
.alert--secondary {
@@ -679,6 +686,25 @@ html[data-theme="dark"] {
679686
);
680687
--ifm-alert-background-color-highlight: rgba(225, 227, 230, 0.15);
681688
}
689+
.alert--important {
690+
--ifm-alert-background-color-highlight: #442f6b;
691+
--ifm-alert-foreground-color: #c0b1dc;
692+
--ifm-alert-border-color: #8250df;
693+
}
694+
}
695+
696+
html[data-theme="light"] {
697+
.alert--success {
698+
span[class^="admonitionIcon"] svg {
699+
fill: hsl(from var(--ifm-alert-border-color) h calc(s + 20) calc(l - 10));
700+
}
701+
702+
div[class^="admonitionHeading"] {
703+
color: hsl(
704+
from var(--ifm-alert-border-color) h calc(s + 20) calc(l - 10)
705+
);
706+
}
707+
}
682708
}
683709

684710
/* Home page */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import clsx from 'clsx';
3+
import DefaultAdmonitionTypes from '@theme-original/Admonition/Types';
4+
import type {Props} from '@theme/Admonition';
5+
6+
const {info: Info} = DefaultAdmonitionTypes;
7+
8+
function ImportantAdmonition({className, ...rest}: Props) {
9+
return <Info className={clsx(className, 'alert--important')} {...rest} />;
10+
}
11+
12+
const AdmonitionTypes = {
13+
...DefaultAdmonitionTypes,
14+
important: ImportantAdmonition,
15+
};
16+
17+
export default AdmonitionTypes;

website/versioned_docs/version-0.82/_experimental-channel-api-warning.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:::tip[Experimental Feature 🧪]
1+
:::important[Experimental Feature 🧪]
22

33
**This API is currently only available in React Native’s Experimental channels.**
44

website/versioned_docs/version-0.83/_experimental-channel-api-warning.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:::tip[Experimental Feature 🧪]
1+
:::important[Experimental Feature 🧪]
22

33
**This API is currently only available in React Native’s Experimental channels.**
44

website/versioned_docs/version-0.84/_experimental-channel-api-warning.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:::tip[Experimental Feature 🧪]
1+
:::important[Experimental Feature 🧪]
22

33
**This API is currently only available in React Native’s Experimental channels.**
44

website/versioned_docs/version-0.85/_experimental-channel-api-warning.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:::tip[Experimental Feature 🧪]
1+
:::important[Experimental Feature 🧪]
22

33
**This API is currently only available in React Native’s Experimental channels.**
44

0 commit comments

Comments
 (0)