Skip to content

Commit db6c58a

Browse files
authored
Fix admonition style (#286)
1 parent c1f313b commit db6c58a

File tree

9 files changed

+424
-28
lines changed

9 files changed

+424
-28
lines changed

content/meta/docs.mdx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: Writing Codewars Docs
3+
---
4+
5+
The Codewars Docs is built with [Docusaurus][docusaurus], and the docs are written in Markdown.
6+
Each page has "Edit this page" link that allows you to contribute on GitHub.
7+
8+
Plain Markdown is great for writing, but sometimes we need extra features to make the docs more helpful.
9+
Docusaurus provides some [Markdown extensions][markdown-features], and has support for [MDX][mdx] to extend Markdown with React components.
10+
11+
This page summarizes the features we use, and is also used to test the styling. See [Docusaurus docs][docusaurus-docs] for more details.
12+
13+
## Admonitions
14+
15+
Use the following syntax to add admonitions:
16+
17+
```markdown
18+
:::type title?
19+
20+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
21+
22+
:::
23+
```
24+
25+
`type` is required. `title` is optional and defaults to uppercased `type`.
26+
27+
### Types
28+
29+
:::note
30+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.
31+
:::
32+
33+
:::tip
34+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.
35+
:::
36+
37+
:::info
38+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.
39+
:::
40+
41+
:::warning
42+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.
43+
:::
44+
45+
:::caution
46+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.
47+
:::
48+
49+
[docusaurus]: https://docusaurus.io/
50+
[docusaurus-docs]: https://docusaurus.io/docs
51+
[mdx]: https://mdxjs.com/
52+
[markdown-features]: https://docusaurus.io/docs/markdown-features

docusaurus.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module.exports = {
6262
sidebarPath: require.resolve("./sidebars.js"),
6363
editUrl: "https://github.com/codewars/docs/edit/master/",
6464
},
65+
blog: false,
6566
theme: {
6667
customCss: require.resolve("./src/css/custom.css"),
6768
},

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
]
3737
},
3838
"devDependencies": {
39-
"prettier": "^2.2.1"
39+
"autoprefixer": "^10.2.5",
40+
"postcss": "^8.2.10",
41+
"postcss-nested": "^5.0.5",
42+
"postcss-preset-env": "^6.7.0",
43+
"prettier": "^2.2.1",
44+
"tailwindcss": "^2.1.1"
4045
}
4146
}

sidebars.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,5 +482,10 @@ module.exports = {
482482
],
483483
},
484484
"glossary",
485+
{
486+
type: "category",
487+
label: "Meta",
488+
items: ["meta/docs"],
489+
},
485490
],
486491
};

sitePlugin.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
const path = require("path");
22

3-
// Make `@components/` resolve to `src/components`.
43
module.exports = () => {
54
return {
65
name: "site-plugin",
6+
7+
// Make `@components/` resolve to `src/components`.
78
configureWebpack: (_config, _isServer) => ({
89
resolve: {
910
alias: {
1011
"@components": path.resolve(__dirname, "src/components/"),
1112
},
1213
},
1314
}),
15+
16+
// Append new PostCSS plugins.
17+
configurePostCss: (postcssOptions) => {
18+
postcssOptions.plugins.push(
19+
require("tailwindcss"),
20+
require("postcss-nested"),
21+
require("postcss-preset-env")({
22+
autoprefixer: {
23+
flexbox: "no-2009",
24+
},
25+
stage: 4,
26+
})
27+
);
28+
return postcssOptions;
29+
},
1430
};
1531
};

src/components/Anchored.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react";
22

33
const Anchored = ({ id, children }) => {
44
return (
5-
<div id={`.${id}`} class="anchored">
5+
<div id={`.${id}`} class="anchored inline relative">
66
<a class="anchor-link" href={`#.${id}`} aria-hidden="true"></a>
77
{children}
88
</div>

src/css/custom.css

Lines changed: 83 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* bundles Infima by default. Infima is a CSS framework designed to
55
* work well for content-centric websites.
66
*/
7+
@tailwind base;
8+
@tailwind components;
9+
@tailwind utilities;
710

811
:root {
912
--ifm-color-primary: #b1361e;
@@ -47,10 +50,6 @@ html[data-theme="dark"] .header-github-link:before {
4750
no-repeat;
4851
}
4952

50-
.anchored {
51-
display: inline;
52-
position: relative;
53-
}
5453
.anchored:target {
5554
background-color: var(--cw-anchored-target-bg);
5655
}
@@ -59,13 +58,85 @@ html[data-theme="dark"] .header-github-link:before {
5958
}
6059
.anchored > .anchor-link::before {
6160
content: "*";
62-
/* -ml-2 pr-2 absolute inset-y-0 opacity-0 float-left text-primary */
63-
margin-left: -0.5rem;
64-
padding-right: 0.5rem;
61+
@apply -ml-2 pr-2 absolute inset-y-0 opacity-0 float-left;
6562
color: var(--ifm-color-primary);
66-
position: absolute;
67-
top: 0;
68-
bottom: 0;
69-
opacity: 0;
70-
float: left;
63+
}
64+
65+
/* Remove .alert styles from Docusaurus */
66+
.admonition.alert {
67+
border-radius: 0;
68+
border-width: 0;
69+
}
70+
71+
.admonition {
72+
@apply mb-4 py-4 pr-8 pl-4;
73+
74+
& .admonition-heading h5 {
75+
@apply flex items-center m-0 mb-2 uppercase text-lg;
76+
}
77+
78+
& .admonition-icon {
79+
@apply inline-block align-middle mr-1 mt-1.5;
80+
81+
& svg {
82+
@apply inline-block w-5 h-5;
83+
@apply fill-current stroke-current;
84+
}
85+
}
86+
}
87+
88+
.admonition.admonition-note {
89+
@apply bg-note bg-opacity-10 border-solid border-l-8 border-note;
90+
91+
& .admonition-heading {
92+
@apply text-note;
93+
}
94+
& .admonition-content {
95+
@apply text-note-content;
96+
}
97+
}
98+
99+
.admonition.admonition-tip {
100+
@apply bg-tip bg-opacity-10 border-solid border-l-8 border-tip;
101+
102+
& .admonition-heading {
103+
@apply text-tip;
104+
}
105+
& .admonition-content {
106+
@apply text-tip-content;
107+
}
108+
}
109+
110+
.admonition.admonition-info {
111+
@apply bg-info bg-opacity-10 border-solid border-l-8 border-info;
112+
113+
& .admonition-heading {
114+
@apply text-info;
115+
}
116+
& .admonition-content {
117+
@apply text-info-content;
118+
}
119+
}
120+
121+
.admonition.admonition-warning {
122+
@apply bg-warning bg-opacity-10 border-solid border-l-8 border-warning;
123+
124+
& .admonition-heading {
125+
@apply text-warning;
126+
}
127+
& .admonition-content {
128+
@apply text-warning-content;
129+
}
130+
}
131+
132+
.admonition.admonition-caution,
133+
.admonition.admonition-danger {
134+
@apply bg-caution bg-opacity-10 border-solid border-l-8 border-caution;
135+
136+
& .admonition-heading {
137+
@apply text-caution;
138+
}
139+
& .admonition-content {
140+
@apply text-caution-content;
141+
}
71142
}

tailwind.config.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const colors = require("tailwindcss/colors");
2+
const plugin = require("tailwindcss/plugin");
3+
4+
module.exports = {
5+
mode: "jit",
6+
purge: ["./src/**/*.{js,jsx,ts,tsx}", "./content/**/*.mdx"],
7+
corePlugins: {
8+
preflight: false,
9+
},
10+
// Using custom dark variant `html[data-theme="dark"]` to match Docusaurus.
11+
darkMode: false,
12+
theme: {
13+
extend: {
14+
colors: {
15+
brand: "#b1361e",
16+
// Admonitions colors
17+
note: colors.coolGray[600],
18+
"note-content": colors.coolGray[500],
19+
tip: colors.emerald[600],
20+
"tip-content": colors.emerald[600],
21+
info: colors.lightBlue[500],
22+
"info-content": colors.lightBlue[700],
23+
warning: colors.orange[500],
24+
"warning-content": colors.orange[700],
25+
caution: colors.red[600],
26+
"caution-content": colors.red[500],
27+
},
28+
},
29+
},
30+
variants: {
31+
extend: {
32+
backgroundColor: ["dark"],
33+
textColor: ["dark"],
34+
display: ["dark"],
35+
},
36+
},
37+
plugins: [
38+
plugin(({ addVariant, e }) => {
39+
addVariant("dark", ({ modifySelectors, separator }) => {
40+
modifySelectors(({ className }) => {
41+
return `html[data-theme="dark"] .${e(
42+
`dark${separator}${className}`
43+
)}`;
44+
});
45+
});
46+
}),
47+
],
48+
};

0 commit comments

Comments
 (0)