@readme/markdown 6.87.1 → 6.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -23
- package/components/Anchor.jsx +15 -26
- package/components/Callout/index.tsx +41 -0
- package/components/Callout/style.scss +11 -39
- package/components/CardsGrid/index.tsx +18 -0
- package/components/CardsGrid/style.scss +12 -0
- package/components/Code/index.tsx +75 -0
- package/components/Code/style.scss +54 -47
- package/components/CodeTabs/index.tsx +38 -0
- package/components/CodeTabs/style.scss +22 -30
- package/components/Embed/index.tsx +98 -0
- package/components/Embed/style.scss +59 -69
- package/components/Glossary/index.tsx +37 -0
- package/components/{GlossaryItem → Glossary}/style.scss +16 -18
- package/components/HTMLBlock/index.tsx +38 -0
- package/components/Heading/index.tsx +31 -0
- package/components/Heading/style.scss +9 -15
- package/components/Image/index.tsx +113 -0
- package/components/Image/style.scss +62 -64
- package/components/Table/index.tsx +20 -0
- package/components/Table/style.scss +17 -23
- package/components/TableOfContents/{index.jsx → index.tsx} +3 -8
- package/components/{index.js → index.ts} +2 -2
- package/dist/components/Callout/index.d.ts +9 -0
- package/dist/components/CardsGrid/index.d.ts +7 -0
- package/dist/components/Code/index.d.ts +11 -0
- package/dist/components/CodeTabs/index.d.ts +3 -0
- package/dist/components/Embed/index.d.ts +15 -0
- package/dist/components/Glossary/index.d.ts +10 -0
- package/dist/components/HTMLBlock/index.d.ts +7 -0
- package/dist/components/Heading/index.d.ts +8 -0
- package/dist/components/Image/index.d.ts +16 -0
- package/dist/components/Table/index.d.ts +7 -0
- package/dist/components/TableOfContents/index.d.ts +3 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/contexts/GlossaryTerms.d.ts +7 -0
- package/dist/contexts/index.d.ts +5 -0
- package/dist/enums.d.ts +14 -0
- package/dist/errors/mdx-syntax-error.d.ts +5 -0
- package/dist/example/App.d.ts +4 -0
- package/dist/example/Doc.d.ts +3 -0
- package/dist/example/Form.d.ts +3 -0
- package/dist/example/Header.d.ts +3 -0
- package/dist/example/RenderError.d.ts +23 -0
- package/dist/example/Root.d.ts +3 -0
- package/dist/example/docs.d.ts +2 -0
- package/dist/example/index.d.ts +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/lib/ast-processor.d.ts +12 -0
- package/dist/lib/compile.d.ts +8 -0
- package/dist/lib/hast.d.ts +3 -0
- package/dist/lib/index.d.ts +9 -0
- package/dist/lib/mdast.d.ts +2 -0
- package/dist/lib/mdx.d.ts +4 -0
- package/dist/lib/owlmoji.d.ts +4 -0
- package/dist/lib/plain.d.ts +6 -0
- package/dist/lib/run.d.ts +24 -0
- package/dist/main.css +2 -17
- package/dist/main.js +70676 -29848
- package/dist/main.node.js +90238 -50277
- package/dist/processor/compile/callout.d.ts +3 -0
- package/dist/processor/compile/code-tabs.d.ts +3 -0
- package/dist/processor/compile/compatibility.d.ts +53 -0
- package/dist/processor/compile/embed.d.ts +3 -0
- package/dist/processor/compile/gemoji.d.ts +3 -0
- package/dist/processor/compile/html-block.d.ts +3 -0
- package/dist/processor/compile/image.d.ts +3 -0
- package/dist/processor/compile/index.d.ts +2 -0
- package/dist/processor/compile/table.d.ts +0 -0
- package/dist/processor/compile/variable.d.ts +3 -0
- package/dist/processor/plugin/toc.d.ts +9 -0
- package/dist/processor/transform/callouts.d.ts +2 -0
- package/dist/processor/transform/code-tabs.d.ts +3 -0
- package/dist/processor/transform/div.d.ts +3 -0
- package/dist/processor/transform/embeds.d.ts +3 -0
- package/dist/processor/transform/gemoji+.d.ts +3 -0
- package/dist/processor/transform/images.d.ts +3 -0
- package/dist/processor/transform/index.d.ts +9 -0
- package/dist/processor/transform/inject-components.d.ts +7 -0
- package/dist/processor/transform/readme-components.d.ts +7 -0
- package/dist/processor/transform/readme-to-mdx.d.ts +3 -0
- package/dist/processor/transform/tables-to-jsx.d.ts +3 -0
- package/dist/processor/transform/variables.d.ts +5 -0
- package/dist/processor/utils.d.ts +77 -0
- package/package.json +93 -99
- package/styles/components.scss +1 -1
- package/components/Callout/index.jsx +0 -42
- package/components/Code/index.jsx +0 -103
- package/components/CodeTabs/index.jsx +0 -60
- package/components/Embed/index.jsx +0 -88
- package/components/GlossaryItem/index.jsx +0 -44
- package/components/HTMLBlock/index.jsx +0 -68
- package/components/Heading/index.jsx +0 -56
- package/components/Image/index.jsx +0 -107
- package/components/Style.jsx +0 -30
- package/components/Table/index.jsx +0 -19
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { uppercase } from '@readme/syntax-highlighter';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const CodeTabs = props => {
|
|
5
|
+
const { children, theme } = props;
|
|
6
|
+
|
|
7
|
+
function handleClick({ target }, index: number) {
|
|
8
|
+
const $wrap = target.parentElement.parentElement;
|
|
9
|
+
const $open = [].slice.call($wrap.querySelectorAll('.CodeTabs_active'));
|
|
10
|
+
$open.forEach((el: Element) => el.classList.remove('CodeTabs_active'));
|
|
11
|
+
$wrap.classList.remove('CodeTabs_initial');
|
|
12
|
+
|
|
13
|
+
const codeblocks = $wrap.querySelectorAll('pre');
|
|
14
|
+
codeblocks[index].classList.add('CodeTabs_active');
|
|
15
|
+
|
|
16
|
+
target.classList.add('CodeTabs_active');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div className={`CodeTabs CodeTabs_initial theme-${theme}`}>
|
|
21
|
+
<div className="CodeTabs-toolbar">
|
|
22
|
+
{(Array.isArray(children) ? children : [children]).map((pre, i) => {
|
|
23
|
+
const { meta, lang } = pre.props.children.props;
|
|
24
|
+
|
|
25
|
+
/* istanbul ignore next */
|
|
26
|
+
return (
|
|
27
|
+
<button key={i} onClick={e => handleClick(e, i)} type="button">
|
|
28
|
+
{meta || `${!lang ? 'Text' : uppercase(lang)}`}
|
|
29
|
+
</button>
|
|
30
|
+
);
|
|
31
|
+
})}
|
|
32
|
+
</div>
|
|
33
|
+
<div className="CodeTabs-inner">{children}</div>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default CodeTabs;
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
/* stylelint-disable no-descending-specificity */
|
|
2
|
-
/* stylelint-disable declaration-property-value-disallowed-list */
|
|
3
1
|
@import '~codemirror/lib/codemirror.css';
|
|
4
2
|
@import '~codemirror/theme/neo.css';
|
|
5
3
|
|
|
6
|
-
@mixin
|
|
7
|
-
$bgc-pre: #
|
|
8
|
-
$bgc-pre-dark: #
|
|
4
|
+
@mixin CodeTabs {
|
|
5
|
+
$bgc-pre: #F6F8FA;
|
|
6
|
+
$bgc-pre-dark: #242E34;
|
|
9
7
|
$bgc-bar: darken(desaturate($bgc-pre, 17.46), 4.31);
|
|
10
8
|
$bgc-bar-dark: lighten(desaturate($bgc-pre-dark, 17.46), 4.31);
|
|
11
9
|
$radius: var(--md-code-radius, var(--markdown-radius, 3px));
|
|
12
10
|
|
|
13
|
-
border-radius: $radius !important;
|
|
14
11
|
color: #333;
|
|
15
12
|
color: var(--md-code-text, #333);
|
|
13
|
+
border-radius: $radius !important;
|
|
16
14
|
overflow: hidden;
|
|
17
15
|
|
|
18
16
|
&.theme-dark {
|
|
19
17
|
color: white;
|
|
20
18
|
color: var(--md-code-text, white);
|
|
21
|
-
|
|
22
19
|
.CodeTabs-toolbar {
|
|
23
20
|
background: $bgc-bar-dark;
|
|
24
21
|
background: var(--md-code-tabs, $bgc-bar-dark);
|
|
@@ -31,28 +28,27 @@
|
|
|
31
28
|
display: flex;
|
|
32
29
|
flex-flow: row nowrap;
|
|
33
30
|
overflow: hidden;
|
|
34
|
-
-webkit-overflow-scrolling: touch;
|
|
35
|
-
-ms-overflow-style: none;
|
|
36
31
|
overflow-x: auto;
|
|
37
|
-
|
|
32
|
+
-ms-overflow-style: none;
|
|
33
|
+
-webkit-overflow-scrolling: touch;
|
|
38
34
|
&::-webkit-scrollbar {
|
|
39
35
|
display: none;
|
|
40
36
|
}
|
|
41
|
-
|
|
42
37
|
button {
|
|
38
|
+
white-space: nowrap;
|
|
39
|
+
transition: .123s ease;
|
|
40
|
+
-webkit-appearance: none;
|
|
43
41
|
appearance: none;
|
|
44
|
-
background: transparent;
|
|
45
|
-
border: none;
|
|
46
|
-
color: inherit;
|
|
47
|
-
cursor: pointer;
|
|
48
42
|
display: inline-block;
|
|
49
|
-
font: inherit;
|
|
50
|
-
font-size: 0.75em;
|
|
51
43
|
line-height: 2;
|
|
44
|
+
padding: .5em 1em;
|
|
45
|
+
border: none;
|
|
46
|
+
background: transparent;
|
|
52
47
|
outline: none;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
color: inherit;
|
|
49
|
+
font: inherit;
|
|
50
|
+
font-size: .75em;
|
|
51
|
+
cursor: pointer;
|
|
56
52
|
}
|
|
57
53
|
}
|
|
58
54
|
|
|
@@ -73,20 +69,16 @@
|
|
|
73
69
|
color: var(--md-code-text, white);
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
&-toolbar button:not(.CodeTabs_active):hover
|
|
77
|
-
|
|
78
|
-
&-toolbar button:not(.CodeTabs_active):focus {
|
|
79
|
-
background: rgba(0, 0, 0, 0.075);
|
|
72
|
+
&-toolbar button:not(.CodeTabs_active):hover {
|
|
73
|
+
background: rgba(0, 0, 0, .075);
|
|
80
74
|
}
|
|
81
75
|
|
|
82
76
|
pre {
|
|
83
|
-
background: var(--md-code-background, $bgc-pre);
|
|
84
77
|
border-radius: 0 0 $radius $radius !important;
|
|
78
|
+
background: $bgc-pre;
|
|
79
|
+
background: var(--md-code-background, $bgc-pre);
|
|
85
80
|
margin-bottom: 0;
|
|
86
|
-
|
|
87
|
-
&:not(.CodeTabs_active) {
|
|
88
|
-
display: none;
|
|
89
|
-
}
|
|
81
|
+
&:not(.CodeTabs_active) { display: none }
|
|
90
82
|
}
|
|
91
83
|
|
|
92
84
|
&.theme-dark pre {
|
|
@@ -100,5 +92,5 @@
|
|
|
100
92
|
}
|
|
101
93
|
|
|
102
94
|
.CodeTabs {
|
|
103
|
-
@include
|
|
95
|
+
@include CodeTabs;
|
|
104
96
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface FaviconProps {
|
|
4
|
+
src: string;
|
|
5
|
+
alt?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const Favicon = ({ src, alt = 'favicon', ...attr }: FaviconProps) => (
|
|
9
|
+
<img {...attr} alt={alt} height="14" src={src} width="14" />
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
interface EmbedProps {
|
|
13
|
+
lazy?: boolean;
|
|
14
|
+
url: string;
|
|
15
|
+
title: string;
|
|
16
|
+
providerName?: string;
|
|
17
|
+
providerUrl?: string;
|
|
18
|
+
html?: string;
|
|
19
|
+
iframe?: boolean;
|
|
20
|
+
image?: string;
|
|
21
|
+
favicon?: string;
|
|
22
|
+
typeOfEmbed?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const Embed = ({
|
|
26
|
+
lazy = true,
|
|
27
|
+
url,
|
|
28
|
+
html,
|
|
29
|
+
providerName,
|
|
30
|
+
providerUrl,
|
|
31
|
+
title,
|
|
32
|
+
iframe,
|
|
33
|
+
image,
|
|
34
|
+
favicon,
|
|
35
|
+
...attrs
|
|
36
|
+
}: EmbedProps) => {
|
|
37
|
+
if (typeof iframe !== 'boolean') iframe = iframe === 'true';
|
|
38
|
+
|
|
39
|
+
if (html) {
|
|
40
|
+
try {
|
|
41
|
+
if (html !== decodeURIComponent(html)) {
|
|
42
|
+
html = decodeURIComponent(html);
|
|
43
|
+
} else if (html === 'false') {
|
|
44
|
+
html = undefined;
|
|
45
|
+
}
|
|
46
|
+
} catch (e) {
|
|
47
|
+
// html wasn't HTML apparently
|
|
48
|
+
html = undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (iframe) {
|
|
53
|
+
return <iframe {...attrs} src={url} style={{ border: 'none', display: 'flex', margin: 'auto' }} />;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!providerUrl && url)
|
|
57
|
+
providerUrl = new URL(url).hostname
|
|
58
|
+
.split(/(?:www)?\./)
|
|
59
|
+
.filter(i => i)
|
|
60
|
+
.join('.');
|
|
61
|
+
|
|
62
|
+
if (!providerName) providerName = providerUrl;
|
|
63
|
+
|
|
64
|
+
const classes = ['embed', image ? 'embed_hasImg' : ''];
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div className={classes.join(' ')}>
|
|
68
|
+
{html ? (
|
|
69
|
+
<div className="embed-media" dangerouslySetInnerHTML={{ __html: html }} />
|
|
70
|
+
) : (
|
|
71
|
+
<a className="embed-link" href={url} rel="noopener noreferrer" target="_blank">
|
|
72
|
+
{!image || <img alt={title} className="embed-img" loading={lazy ? 'lazy' : undefined} src={image} />}
|
|
73
|
+
{title && title !== '@embed' ? (
|
|
74
|
+
<div className="embed-body">
|
|
75
|
+
{!favicon || <Favicon alt={providerName} src={favicon} />}
|
|
76
|
+
{providerUrl && (
|
|
77
|
+
<small className="embed-provider">
|
|
78
|
+
{providerUrl.search(/^@{1}/) < 0 ? (
|
|
79
|
+
providerName
|
|
80
|
+
) : (
|
|
81
|
+
<code style={{ fontFamily: 'var(--md-code-font, monospace)' }}>{url}</code>
|
|
82
|
+
)}
|
|
83
|
+
</small>
|
|
84
|
+
)}
|
|
85
|
+
<div className="embed-title">{title}</div>
|
|
86
|
+
</div>
|
|
87
|
+
) : (
|
|
88
|
+
<div className="embed-body">
|
|
89
|
+
<b>View</b>: <span className="embed-body-url">{url}</span>
|
|
90
|
+
</div>
|
|
91
|
+
)}
|
|
92
|
+
</a>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default Embed;
|
|
@@ -1,40 +1,33 @@
|
|
|
1
1
|
.markdown-body .embed {
|
|
2
|
-
$
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
box-shadow: inset 0 0 0 1px rgba(black, 0.1);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@at-root .markdown-body > #{$embed}_hasImg:nth-of-type(odd) {
|
|
18
|
-
margin-right: 30px;
|
|
19
|
-
padding-right: 0;
|
|
20
|
-
#{$embed}-link {
|
|
21
|
-
flex-direction: row-reverse;
|
|
2
|
+
$B: '.embed';
|
|
3
|
+
& {
|
|
4
|
+
padding: 15px;
|
|
5
|
+
color: var(--md-code-text, inherit);
|
|
6
|
+
border-radius: var(--md-code-radius, var(--markdown-radius, 3px));
|
|
7
|
+
border-radius: 3px;
|
|
8
|
+
background: transparent;
|
|
9
|
+
box-shadow: inset 0 0 0 1px rgba(black, .15);
|
|
10
|
+
transition: .3s ease;
|
|
11
|
+
&:hover {
|
|
12
|
+
background: var(--md-code-background, #f6f8fa);
|
|
13
|
+
box-shadow: inset 0 0 0 1px rgba(black, .1);
|
|
22
14
|
}
|
|
23
|
-
#{$
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
@at-root .markdown-body > #{$B}_hasImg:nth-of-type(odd) {
|
|
16
|
+
margin-right: 30px;
|
|
17
|
+
padding-right: 0;
|
|
18
|
+
#{$B}-link { flex-direction: row-reverse }
|
|
19
|
+
#{$B}-img {
|
|
20
|
+
margin-left: .88em;
|
|
21
|
+
margin-right: -30px;
|
|
22
|
+
box-shadow: -.3em .3em .9em -.3em rgba(black, .15);
|
|
23
|
+
}
|
|
27
24
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
padding-left: 0;
|
|
33
|
-
#{$embed}-img {
|
|
34
|
-
margin-left: -30px;
|
|
25
|
+
@at-root .markdown-body > #{$B}_hasImg:nth-of-type(even) {
|
|
26
|
+
margin-left: 30px;
|
|
27
|
+
padding-left: 0;
|
|
28
|
+
#{$B}-img { margin-left: -30px }
|
|
35
29
|
}
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
&:empty {
|
|
39
32
|
display: none;
|
|
40
33
|
}
|
|
@@ -42,87 +35,84 @@
|
|
|
42
35
|
&-media {
|
|
43
36
|
display: flex;
|
|
44
37
|
justify-content: center;
|
|
45
|
-
|
|
46
|
-
> :only-child {
|
|
47
|
-
border-radius: 0 !important;
|
|
38
|
+
>:only-child {
|
|
48
39
|
flex: 1;
|
|
49
40
|
margin: -15px;
|
|
41
|
+
border-radius: 0 !important;
|
|
50
42
|
}
|
|
51
43
|
}
|
|
52
44
|
|
|
53
45
|
&-link {
|
|
46
|
+
display: flex;
|
|
54
47
|
align-items: center;
|
|
55
48
|
color: var(--markdown-text, #333);
|
|
56
|
-
display: flex;
|
|
57
49
|
text-decoration: none !important;
|
|
58
50
|
}
|
|
59
51
|
|
|
60
52
|
&-body {
|
|
61
53
|
flex: 1;
|
|
62
54
|
line-height: 1.3;
|
|
63
|
-
&,
|
|
64
|
-
#{$embed}-title {
|
|
55
|
+
&, #{$B}-title {
|
|
65
56
|
font-size: 1.15em;
|
|
66
57
|
overflow: hidden;
|
|
67
|
-
text-overflow: ellipsis;
|
|
68
58
|
white-space: nowrap;
|
|
59
|
+
text-overflow: ellipsis;
|
|
69
60
|
}
|
|
70
|
-
#{$
|
|
61
|
+
#{$B}-provider {
|
|
71
62
|
display: block;
|
|
72
|
-
opacity: 0.88;
|
|
73
63
|
text-decoration-color: transparent !important;
|
|
64
|
+
opacity: .88;
|
|
74
65
|
}
|
|
75
|
-
|
|
76
66
|
&-url {
|
|
77
|
-
opacity:
|
|
67
|
+
opacity: .75;
|
|
78
68
|
}
|
|
79
69
|
}
|
|
80
70
|
|
|
81
71
|
&-provider {
|
|
82
72
|
font-size: 0.8em;
|
|
83
73
|
line-height: 1.6;
|
|
84
|
-
transition: 0.2 ease;
|
|
85
|
-
|
|
86
|
-
code {
|
|
87
|
-
opacity: 0.8;
|
|
88
|
-
}
|
|
89
74
|
|
|
90
75
|
code:only-child {
|
|
91
|
-
background: transparent;
|
|
92
76
|
display: block;
|
|
93
|
-
|
|
94
|
-
|
|
77
|
+
width: 100%;
|
|
78
|
+
font-size: 1.15em;
|
|
95
79
|
overflow: hidden;
|
|
96
|
-
padding: 0;
|
|
97
|
-
text-overflow: ellipsis;
|
|
98
80
|
white-space: nowrap;
|
|
99
|
-
|
|
81
|
+
text-overflow: ellipsis;
|
|
82
|
+
background: transparent;
|
|
83
|
+
margin: 0;
|
|
84
|
+
padding: 0;
|
|
85
|
+
font-size: inherit !important;
|
|
100
86
|
}
|
|
101
|
-
|
|
87
|
+
transition: .2 ease;
|
|
88
|
+
code {
|
|
89
|
+
opacity: 0.8;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
102
92
|
|
|
103
93
|
&-img {
|
|
104
|
-
|
|
105
|
-
border: 1px solid rgba(black, 0.15);
|
|
106
|
-
border-radius: 3px;
|
|
107
|
-
box-shadow: 0.3em 0.3em 0.9em -0.3em rgba(black, 0.15);
|
|
108
|
-
margin: 0 0.88em 0 0;
|
|
94
|
+
width: 5em;
|
|
109
95
|
max-width: 5em;
|
|
96
|
+
margin: 0 .88em 0 0;
|
|
110
97
|
padding: 4px;
|
|
98
|
+
background: white;
|
|
99
|
+
border: 1px solid rgba(black, .15);
|
|
100
|
+
border-radius: 3px;
|
|
111
101
|
transition: inherit;
|
|
112
|
-
|
|
102
|
+
box-shadow: .3em .3em .9em -.3em rgba(black, .15);
|
|
113
103
|
}
|
|
114
|
-
&:not(:hover) #{$
|
|
115
|
-
box-shadow: 0
|
|
104
|
+
&:not(:hover) #{$B}-img {
|
|
105
|
+
box-shadow: 0 .25em 1em -.5em rgba(black, .133);
|
|
116
106
|
}
|
|
117
|
-
&:hover #{$
|
|
118
|
-
border: 1px solid rgba(black,
|
|
107
|
+
&:hover #{$B}-img {
|
|
108
|
+
border: 1px solid rgba(black, .2);
|
|
119
109
|
}
|
|
120
110
|
|
|
121
111
|
&-favicon {
|
|
112
|
+
width: 12px !important;
|
|
122
113
|
height: 12px !important;
|
|
123
|
-
margin-bottom: 12px;
|
|
124
|
-
margin-right: 6px;
|
|
125
114
|
margin-top: 4px;
|
|
126
|
-
|
|
115
|
+
margin-right: 6px;
|
|
116
|
+
margin-bottom: 12px;
|
|
127
117
|
}
|
|
128
|
-
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import Tooltip from '@tippyjs/react';
|
|
3
|
+
import GlossaryContext from '../../contexts/GlossaryTerms';
|
|
4
|
+
import type { GlossaryTerm } from '../../contexts/GlossaryTerms';
|
|
5
|
+
|
|
6
|
+
interface Props extends React.PropsWithChildren {
|
|
7
|
+
term?: string;
|
|
8
|
+
terms: GlossaryTerm[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Glossary = ({ children, term: termProp, terms }: Props) => {
|
|
12
|
+
const term = (Array.isArray(children) ? children[0] : children) || termProp;
|
|
13
|
+
const foundTerm = terms.find(i => term.toLowerCase() === i?.term?.toLowerCase());
|
|
14
|
+
|
|
15
|
+
if (!foundTerm) return <span>{term}</span>;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Tooltip
|
|
19
|
+
content={
|
|
20
|
+
<div className="GlossaryItem-tooltip-content">
|
|
21
|
+
<strong className="GlossaryItem-term">{foundTerm.term}</strong> - {foundTerm.definition}
|
|
22
|
+
</div>
|
|
23
|
+
}
|
|
24
|
+
offset={[-5, 5]}
|
|
25
|
+
placement="bottom-start"
|
|
26
|
+
>
|
|
27
|
+
<span className="GlossaryItem-trigger">{term}</span>
|
|
28
|
+
</Tooltip>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const GlossaryWithContext = props => {
|
|
33
|
+
const terms = useContext(GlossaryContext);
|
|
34
|
+
return terms ? <Glossary {...props} terms={terms} /> : <span>{props.term}</span>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { Glossary, GlossaryWithContext as default, GlossaryContext };
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
/* stylelint-disable declaration-property-value-disallowed-list */
|
|
2
|
-
/* stylelint-disable custom-property-pattern */
|
|
3
|
-
/* stylelint-disable order/order */
|
|
4
1
|
.GlossaryItem {
|
|
5
2
|
&-trigger {
|
|
6
|
-
border-bottom: 1px
|
|
3
|
+
border-bottom: 1px solid #737c83;
|
|
4
|
+
border-style: dotted;
|
|
5
|
+
border-top: none;
|
|
7
6
|
border-left: none;
|
|
8
7
|
border-right: none;
|
|
9
|
-
border-top: none;
|
|
10
8
|
cursor: pointer;
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
&-tooltip-content {
|
|
14
|
-
--
|
|
15
|
-
--
|
|
16
|
-
--
|
|
12
|
+
--Glossary-bg: var(--color-bg-page, var(--white));
|
|
13
|
+
--Glossary-color: var(--color-text-default, var(--gray20));
|
|
14
|
+
--Glossary-shadow: var(
|
|
17
15
|
--box-shadow-menu-light,
|
|
18
16
|
0 5px 10px rgba(0, 0, 0, 0.05),
|
|
19
17
|
0 2px 6px rgba(0, 0, 0, 0.025),
|
|
@@ -22,9 +20,9 @@
|
|
|
22
20
|
|
|
23
21
|
/* what the dark-mode mixin does in the readme project */
|
|
24
22
|
[data-color-mode='dark'] & {
|
|
25
|
-
--
|
|
26
|
-
--
|
|
27
|
-
--
|
|
23
|
+
--Glossary-bg: var(--gray15);
|
|
24
|
+
--Glossary-color: var(--color-text-default, var(--white));
|
|
25
|
+
--Glossary-shadow: var(
|
|
28
26
|
--box-shadow-menu-dark,
|
|
29
27
|
0 1px 3px rgba(0, 0, 0, 0.025),
|
|
30
28
|
0 2px 6px rgba(0, 0, 0, 0.025),
|
|
@@ -33,10 +31,10 @@
|
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
@media (prefers-color-scheme: dark) {
|
|
36
|
-
[data-color-mode='
|
|
37
|
-
--
|
|
38
|
-
--
|
|
39
|
-
--
|
|
34
|
+
[data-color-mode='auto'] & {
|
|
35
|
+
--Glossary-bg: var(--Tooltip-bg, var(--gray0));
|
|
36
|
+
--Glossary-color: var(--color-text-default, var(--white));
|
|
37
|
+
--Glossary-shadow: var(
|
|
40
38
|
--box-shadow-menu-dark,
|
|
41
39
|
0 1px 3px rgba(0, 0, 0, 0.025),
|
|
42
40
|
0 2px 6px rgba(0, 0, 0, 0.025),
|
|
@@ -45,11 +43,11 @@
|
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
background-color: var(--
|
|
46
|
+
background-color: var(--Glossary-bg);
|
|
49
47
|
border: 1px solid #{var(--color-border-default, rgba(black, 0.1))};
|
|
50
48
|
border-radius: var(--border-radius);
|
|
51
|
-
box-shadow: var(--
|
|
52
|
-
color: var(--
|
|
49
|
+
box-shadow: var(--Glossary-shadow);
|
|
50
|
+
color: var(--Glossary-color);
|
|
53
51
|
font-size: 15px;
|
|
54
52
|
font-weight: 400;
|
|
55
53
|
line-height: 1.5;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
3
|
+
|
|
4
|
+
const MATCH_SCRIPT_TAGS = /<script\b[^>]*>([\s\S]*?)<\/script *>\n?/gim;
|
|
5
|
+
|
|
6
|
+
const extractScripts = (html: string = ''): [string, () => void] => {
|
|
7
|
+
const scripts: string[] = [];
|
|
8
|
+
let match: RegExpExecArray | null;
|
|
9
|
+
while ((match = MATCH_SCRIPT_TAGS.exec(html)) !== null) {
|
|
10
|
+
scripts.push(match[1]);
|
|
11
|
+
}
|
|
12
|
+
const cleaned = html.replace(MATCH_SCRIPT_TAGS, '');
|
|
13
|
+
return [cleaned, () => scripts.map(js => window.eval(js))];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const HTMLBlock = ({ children = '', runScripts, safeMode = false }) => {
|
|
17
|
+
let html = children;
|
|
18
|
+
runScripts = typeof runScripts !== 'boolean' ? (runScripts === 'true' ? true : false) : runScripts;
|
|
19
|
+
|
|
20
|
+
if (typeof html !== 'string') html = renderToStaticMarkup(html);
|
|
21
|
+
const [cleanedHtml, exec] = extractScripts(html);
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (typeof window !== 'undefined' && typeof runScripts === 'boolean' && runScripts) exec();
|
|
25
|
+
}, [runScripts, exec]);
|
|
26
|
+
|
|
27
|
+
if (safeMode) {
|
|
28
|
+
return (
|
|
29
|
+
<pre className="html-unsafe">
|
|
30
|
+
<code>{html}</code>
|
|
31
|
+
</pre>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return <div className="rdmd-html" dangerouslySetInnerHTML={{ __html: cleanedHtml }} />;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default HTMLBlock;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export type Depth = 1 | 2 | 3 | 4 | 5 | 6;
|
|
4
|
+
|
|
5
|
+
interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLHeadingElement>> {
|
|
6
|
+
tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
7
|
+
depth: Depth;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const Heading = ({ tag: Tag = 'h3', depth = 3, id, children, ...attrs }: Props) => {
|
|
11
|
+
if (!children) return '';
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Tag {...attrs} className={`heading heading-${depth} header-scroll`}>
|
|
15
|
+
<div key={`heading-anchor-${id}`} className="heading-anchor anchor waypoint" id={id} />
|
|
16
|
+
<div key={`heading-text-${id}`} className="heading-text">
|
|
17
|
+
{children}
|
|
18
|
+
</div>
|
|
19
|
+
<a
|
|
20
|
+
key={`heading-anchor-icon-${id}`}
|
|
21
|
+
aria-label={`Skip link to ${children}`}
|
|
22
|
+
className="heading-anchor-icon fa fa-anchor"
|
|
23
|
+
href={`#${id}`}
|
|
24
|
+
/>
|
|
25
|
+
</Tag>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const CreateHeading = (depth: Depth) => (props: Props) => <Heading {...props} depth={depth} tag={`h${depth}`} />;
|
|
30
|
+
|
|
31
|
+
export default CreateHeading;
|
|
@@ -1,43 +1,37 @@
|
|
|
1
1
|
.heading.heading {
|
|
2
|
-
align-items: center;
|
|
3
2
|
display: flex;
|
|
4
3
|
justify-content: flex-start;
|
|
4
|
+
align-items: center;
|
|
5
5
|
position: relative;
|
|
6
|
-
|
|
7
6
|
.heading-text {
|
|
8
7
|
flex: 1 100%;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
.heading-anchor-deprecated {
|
|
12
10
|
position: absolute;
|
|
13
11
|
top: 0;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
.heading-anchor {
|
|
17
14
|
top: -1rem !important;
|
|
18
15
|
}
|
|
19
|
-
|
|
20
16
|
.heading-anchor,
|
|
21
17
|
.heading-anchor-icon {
|
|
22
|
-
|
|
18
|
+
position: absolute !important;
|
|
23
19
|
display: inline !important;
|
|
24
|
-
font-size: 0.8rem !important;
|
|
25
|
-
margin-right: -0.8rem;
|
|
26
20
|
order: -1;
|
|
27
|
-
padding: 0.8rem 0.2rem 0.8rem 0 !important;
|
|
28
|
-
position: absolute !important;
|
|
29
21
|
right: 100%;
|
|
30
|
-
text-decoration: none;
|
|
31
22
|
top: unset !important;
|
|
23
|
+
margin-right: -.8rem;
|
|
24
|
+
padding: .8rem .2rem .8rem 0 !important;
|
|
25
|
+
font-size: .8rem !important;
|
|
26
|
+
text-decoration: none;
|
|
27
|
+
color: inherit;
|
|
32
28
|
transform: translateX(-100%);
|
|
33
|
-
transition:
|
|
34
|
-
|
|
29
|
+
transition: .2s ease;
|
|
35
30
|
&:hover {
|
|
36
31
|
opacity: 1;
|
|
37
32
|
}
|
|
38
33
|
}
|
|
39
|
-
|
|
40
34
|
&:not(:hover) .heading-anchor-icon {
|
|
41
35
|
opacity: 0;
|
|
42
36
|
}
|
|
43
|
-
}
|
|
37
|
+
}
|