@zendeskgarden/react-typography 9.0.0-next.17 → 9.0.0-next.19
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/dist/esm/elements/CodeBlock.js +39 -17
- package/dist/esm/styled/StyledBlockquote.js +1 -1
- package/dist/esm/styled/StyledCode.js +1 -1
- package/dist/esm/styled/StyledCodeBlock.js +15 -6
- package/dist/esm/styled/StyledCodeBlockContainer.js +1 -1
- package/dist/esm/styled/StyledCodeBlockLine.js +58 -32
- package/dist/esm/styled/StyledCodeBlockToken.js +159 -20
- package/dist/esm/styled/StyledEllipsis.js +1 -1
- package/dist/esm/styled/StyledFont.js +1 -1
- package/dist/esm/styled/StyledIcon.js +1 -1
- package/dist/esm/styled/StyledList.js +2 -2
- package/dist/esm/styled/StyledListItem.js +2 -2
- package/dist/esm/styled/StyledParagraph.js +1 -1
- package/dist/esm/types/index.js +1 -1
- package/dist/index.cjs.js +279 -85
- package/dist/typings/styled/StyledCodeBlock.d.ts +1 -4
- package/dist/typings/styled/StyledCodeBlockLine.d.ts +0 -5
- package/dist/typings/styled/StyledCodeBlockToken.d.ts +1 -4
- package/dist/typings/types/index.d.ts +1 -1
- package/package.json +5 -4
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
|
-
import React, { useRef, useMemo } from 'react';
|
|
8
|
-
import
|
|
7
|
+
import React, { useRef, useMemo, useState, useCallback, useEffect } from 'react';
|
|
8
|
+
import { Prism, Highlight } from 'prism-react-renderer';
|
|
9
9
|
import { useScrollRegion } from '@zendeskgarden/container-scrollregion';
|
|
10
|
+
import { useWindow, ThemeProvider } from '@zendeskgarden/react-theming';
|
|
10
11
|
import { LANGUAGES } from '../types/index.js';
|
|
11
12
|
import '../styled/StyledBlockquote.js';
|
|
12
13
|
import '../styled/StyledCode.js';
|
|
@@ -28,8 +29,8 @@ const CodeBlock = React.forwardRef((_ref, ref) => {
|
|
|
28
29
|
highlightLines,
|
|
29
30
|
isLight,
|
|
30
31
|
isNumbered,
|
|
31
|
-
language,
|
|
32
|
-
size,
|
|
32
|
+
language = 'tsx',
|
|
33
|
+
size = 'medium',
|
|
33
34
|
...other
|
|
34
35
|
} = _ref;
|
|
35
36
|
const containerRef = useRef(null);
|
|
@@ -39,6 +40,25 @@ const CodeBlock = React.forwardRef((_ref, ref) => {
|
|
|
39
40
|
containerRef,
|
|
40
41
|
dependency
|
|
41
42
|
});
|
|
43
|
+
const [isPrismImported, setIsPrismImported] = useState(false);
|
|
44
|
+
const win = useWindow();
|
|
45
|
+
const importPrism = useCallback(async () => {
|
|
46
|
+
if (win && !isPrismImported) {
|
|
47
|
+
win.Prism = Prism;
|
|
48
|
+
try {
|
|
49
|
+
await import('prismjs/components/prism-bash');
|
|
50
|
+
await import('prismjs/components/prism-diff');
|
|
51
|
+
await import('prismjs/components/prism-json');
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error(error);
|
|
54
|
+
} finally {
|
|
55
|
+
setIsPrismImported(true);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, [win, isPrismImported]);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
importPrism();
|
|
61
|
+
}, [importPrism]);
|
|
42
62
|
const getDiff = line => {
|
|
43
63
|
let retVal;
|
|
44
64
|
if (language === 'diff') {
|
|
@@ -57,11 +77,10 @@ const CodeBlock = React.forwardRef((_ref, ref) => {
|
|
|
57
77
|
}
|
|
58
78
|
return retVal;
|
|
59
79
|
};
|
|
60
|
-
return React.createElement(StyledCodeBlockContainer, Object.assign({}, containerProps, {
|
|
80
|
+
return isPrismImported && React.createElement(StyledCodeBlockContainer, Object.assign({}, containerProps, {
|
|
61
81
|
ref: containerRef,
|
|
62
82
|
tabIndex: containerTabIndex
|
|
63
83
|
}), React.createElement(Highlight, {
|
|
64
|
-
Prism: Prism,
|
|
65
84
|
code: code ? code.trim() : '',
|
|
66
85
|
language: LANGUAGES.includes(language) ? language : 'tsx'
|
|
67
86
|
}, _ref2 => {
|
|
@@ -71,32 +90,35 @@ const CodeBlock = React.forwardRef((_ref, ref) => {
|
|
|
71
90
|
getLineProps,
|
|
72
91
|
getTokenProps
|
|
73
92
|
} = _ref2;
|
|
74
|
-
return React.createElement(
|
|
93
|
+
return React.createElement(ThemeProvider, {
|
|
94
|
+
theme: parentTheme => ({
|
|
95
|
+
...parentTheme,
|
|
96
|
+
colors: {
|
|
97
|
+
...parentTheme.colors,
|
|
98
|
+
base: isLight ? 'light' : 'dark'
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
}, React.createElement(StyledCodeBlock, Object.assign({
|
|
75
102
|
className: className,
|
|
76
|
-
ref: ref
|
|
77
|
-
isLight: isLight
|
|
103
|
+
ref: ref
|
|
78
104
|
}, other), tokens.map((line, index) => React.createElement(StyledCodeBlockLine, Object.assign({}, getLineProps({
|
|
79
105
|
line
|
|
80
106
|
}), {
|
|
81
107
|
key: index,
|
|
82
108
|
language: language,
|
|
83
109
|
isHighlighted: highlightLines && highlightLines.includes(index + 1),
|
|
84
|
-
isLight: isLight,
|
|
85
110
|
isNumbered: isNumbered,
|
|
86
111
|
diff: getDiff(line),
|
|
87
|
-
size: size
|
|
112
|
+
size: size,
|
|
113
|
+
style: undefined
|
|
88
114
|
}), line.map((token, tokenKey) => React.createElement(StyledCodeBlockToken, Object.assign({}, getTokenProps({
|
|
89
115
|
token
|
|
90
116
|
}), {
|
|
91
117
|
key: tokenKey,
|
|
92
|
-
|
|
93
|
-
}), token.empty ? '\n' : token.content)))));
|
|
118
|
+
style: undefined
|
|
119
|
+
}), token.empty ? '\n' : token.content))))));
|
|
94
120
|
}));
|
|
95
121
|
});
|
|
96
122
|
CodeBlock.displayName = 'CodeBlock';
|
|
97
|
-
CodeBlock.defaultProps = {
|
|
98
|
-
language: 'tsx',
|
|
99
|
-
size: 'medium'
|
|
100
|
-
};
|
|
101
123
|
|
|
102
124
|
export { CodeBlock };
|
|
@@ -11,7 +11,7 @@ import { THEME_SIZES } from './StyledFont.js';
|
|
|
11
11
|
const COMPONENT_ID = 'typography.blockquote';
|
|
12
12
|
const StyledBlockquote = styled.blockquote.attrs({
|
|
13
13
|
'data-garden-id': COMPONENT_ID,
|
|
14
|
-
'data-garden-version': '9.0.0-next.
|
|
14
|
+
'data-garden-version': '9.0.0-next.19'
|
|
15
15
|
}).withConfig({
|
|
16
16
|
displayName: "StyledBlockquote",
|
|
17
17
|
componentId: "sc-1tt3ye0-0"
|
|
@@ -50,7 +50,7 @@ const colorStyles = _ref => {
|
|
|
50
50
|
};
|
|
51
51
|
const StyledCode = styled(StyledFont).attrs({
|
|
52
52
|
'data-garden-id': COMPONENT_ID,
|
|
53
|
-
'data-garden-version': '9.0.0-next.
|
|
53
|
+
'data-garden-version': '9.0.0-next.19',
|
|
54
54
|
as: 'code',
|
|
55
55
|
isMonospace: true
|
|
56
56
|
}).withConfig({
|
|
@@ -5,21 +5,30 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import styled, { css } from 'styled-components';
|
|
8
|
-
import { retrieveComponentStyles, DEFAULT_THEME,
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
|
|
9
9
|
|
|
10
10
|
const COMPONENT_ID = 'typography.codeblock';
|
|
11
|
-
const colorStyles =
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const colorStyles = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
theme
|
|
14
|
+
} = _ref;
|
|
15
|
+
const backgroundColor = getColor({
|
|
16
|
+
theme,
|
|
17
|
+
variable: theme.colors.base === 'light' ? 'background.subtle' : 'background.default'
|
|
18
|
+
});
|
|
19
|
+
const foregroundColor = getColor({
|
|
20
|
+
theme,
|
|
21
|
+
variable: 'foreground.default'
|
|
22
|
+
});
|
|
14
23
|
return css(["background-color:", ";color:", ";"], backgroundColor, foregroundColor);
|
|
15
24
|
};
|
|
16
25
|
const StyledCodeBlock = styled.pre.attrs({
|
|
17
26
|
'data-garden-id': COMPONENT_ID,
|
|
18
|
-
'data-garden-version': '9.0.0-next.
|
|
27
|
+
'data-garden-version': '9.0.0-next.19'
|
|
19
28
|
}).withConfig({
|
|
20
29
|
displayName: "StyledCodeBlock",
|
|
21
30
|
componentId: "sc-5wky57-0"
|
|
22
|
-
})(["display:table;margin:0;padding:", "px;box-sizing:border-box;width:100%;direction:ltr;white-space:pre;counter-reset:linenumber;", ";", ";"], props => props.theme.space.base * 3,
|
|
31
|
+
})(["display:table;margin:0;padding:", "px;box-sizing:border-box;width:100%;direction:ltr;white-space:pre;counter-reset:linenumber;", ";", ";"], props => props.theme.space.base * 3, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
23
32
|
StyledCodeBlock.defaultProps = {
|
|
24
33
|
theme: DEFAULT_THEME
|
|
25
34
|
};
|
|
@@ -10,7 +10,7 @@ import { focusStyles, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgar
|
|
|
10
10
|
const COMPONENT_ID = 'typography.codeblock_container';
|
|
11
11
|
const StyledCodeBlockContainer = styled.div.attrs({
|
|
12
12
|
'data-garden-id': COMPONENT_ID,
|
|
13
|
-
'data-garden-version': '9.0.0-next.
|
|
13
|
+
'data-garden-version': '9.0.0-next.19'
|
|
14
14
|
}).withConfig({
|
|
15
15
|
displayName: "StyledCodeBlockContainer",
|
|
16
16
|
componentId: "sc-14zgbfw-0"
|
|
@@ -5,46 +5,72 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import styled, { css } from 'styled-components';
|
|
8
|
-
import { retrieveComponentStyles, DEFAULT_THEME,
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
|
|
9
9
|
import { StyledFont, THEME_SIZES } from './StyledFont.js';
|
|
10
10
|
|
|
11
11
|
const COMPONENT_ID = 'typography.codeblock_code';
|
|
12
|
-
const colorStyles =
|
|
12
|
+
const colorStyles = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
theme,
|
|
15
|
+
diff,
|
|
16
|
+
isHighlighted
|
|
17
|
+
} = _ref;
|
|
13
18
|
let backgroundColor;
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
backgroundColor =
|
|
19
|
+
if (diff) {
|
|
20
|
+
const hues = {
|
|
21
|
+
hunk: 'royal',
|
|
22
|
+
add: 'lime',
|
|
23
|
+
delete: 'crimson',
|
|
24
|
+
change: 'lemon'
|
|
25
|
+
};
|
|
26
|
+
backgroundColor = getColor({
|
|
27
|
+
theme,
|
|
28
|
+
hue: hues[diff],
|
|
29
|
+
dark: {
|
|
30
|
+
shade: 600
|
|
31
|
+
},
|
|
32
|
+
light: {
|
|
33
|
+
shade: 400
|
|
34
|
+
},
|
|
35
|
+
transparency: theme.opacity[300]
|
|
36
|
+
});
|
|
37
|
+
} else if (isHighlighted) {
|
|
38
|
+
backgroundColor = getColor({
|
|
39
|
+
theme,
|
|
40
|
+
dark: {
|
|
41
|
+
hue: 'white'
|
|
42
|
+
},
|
|
43
|
+
light: {
|
|
44
|
+
hue: 'neutralHue',
|
|
45
|
+
shade: 700
|
|
46
|
+
},
|
|
47
|
+
transparency: theme.opacity[100]
|
|
48
|
+
});
|
|
34
49
|
}
|
|
35
50
|
return css(["background-color:", ";"], backgroundColor);
|
|
36
51
|
};
|
|
37
|
-
const lineNumberStyles =
|
|
38
|
-
|
|
52
|
+
const lineNumberStyles = _ref2 => {
|
|
53
|
+
let {
|
|
54
|
+
theme,
|
|
55
|
+
language,
|
|
56
|
+
size
|
|
57
|
+
} = _ref2;
|
|
58
|
+
const color = getColor({
|
|
59
|
+
theme,
|
|
60
|
+
variable: 'foreground.subtle',
|
|
61
|
+
light: {
|
|
62
|
+
offset: -100
|
|
63
|
+
}
|
|
64
|
+
});
|
|
39
65
|
let padding;
|
|
40
|
-
if (
|
|
66
|
+
if (language && language === 'diff') {
|
|
41
67
|
padding = 0;
|
|
42
|
-
} else if (
|
|
43
|
-
padding =
|
|
44
|
-
} else if (
|
|
45
|
-
padding =
|
|
68
|
+
} else if (size === 'small') {
|
|
69
|
+
padding = theme.space.base * 4;
|
|
70
|
+
} else if (size === 'large') {
|
|
71
|
+
padding = theme.space.base * 7;
|
|
46
72
|
} else {
|
|
47
|
-
padding =
|
|
73
|
+
padding = theme.space.base * 6;
|
|
48
74
|
}
|
|
49
75
|
return `
|
|
50
76
|
&::before {
|
|
@@ -60,13 +86,13 @@ const lineNumberStyles = props => {
|
|
|
60
86
|
};
|
|
61
87
|
const StyledCodeBlockLine = styled(StyledFont).attrs({
|
|
62
88
|
'data-garden-id': COMPONENT_ID,
|
|
63
|
-
'data-garden-version': '9.0.0-next.
|
|
89
|
+
'data-garden-version': '9.0.0-next.19',
|
|
64
90
|
as: 'code',
|
|
65
91
|
isMonospace: true
|
|
66
92
|
}).withConfig({
|
|
67
93
|
displayName: "StyledCodeBlockLine",
|
|
68
94
|
componentId: "sc-1goay17-0"
|
|
69
|
-
})(["display:table-row;height:", ";direction:ltr;", ";", ";&::after{display:inline-block;width:", "px;content:'';}", ";"], props => props.theme.lineHeights[THEME_SIZES[props.size]],
|
|
95
|
+
})(["display:table-row;height:", ";direction:ltr;", ";", ";&::after{display:inline-block;width:", "px;content:'';}", ";"], props => props.theme.lineHeights[THEME_SIZES[props.size]], colorStyles, props => props.isNumbered && lineNumberStyles(props), props => props.theme.space.base * 3, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
70
96
|
StyledCodeBlockLine.defaultProps = {
|
|
71
97
|
theme: DEFAULT_THEME
|
|
72
98
|
};
|
|
@@ -5,38 +5,177 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import styled, { css } from 'styled-components';
|
|
8
|
-
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
|
|
9
9
|
import { StyledCodeBlock } from './StyledCodeBlock.js';
|
|
10
10
|
|
|
11
11
|
const COMPONENT_ID = 'typography.codeblock_token';
|
|
12
|
-
const colorStyles =
|
|
13
|
-
|
|
12
|
+
const colorStyles = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
theme
|
|
15
|
+
} = _ref;
|
|
14
16
|
const colors = {
|
|
15
|
-
boolean:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
boolean: getColor({
|
|
18
|
+
theme,
|
|
19
|
+
dark: {
|
|
20
|
+
hue: 'azure',
|
|
21
|
+
shade: 600
|
|
22
|
+
},
|
|
23
|
+
light: {
|
|
24
|
+
hue: 'royal',
|
|
25
|
+
shade: 700
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
builtin: getColor({
|
|
29
|
+
theme,
|
|
30
|
+
hue: 'teal',
|
|
31
|
+
dark: {
|
|
32
|
+
shade: 600
|
|
33
|
+
},
|
|
34
|
+
light: {
|
|
35
|
+
shade: 700
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
comment: getColor({
|
|
39
|
+
theme,
|
|
40
|
+
dark: {
|
|
41
|
+
hue: 'mint',
|
|
42
|
+
shade: 600
|
|
43
|
+
},
|
|
44
|
+
light: {
|
|
45
|
+
hue: 'lime',
|
|
46
|
+
shade: 700
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
constant: getColor({
|
|
50
|
+
theme,
|
|
51
|
+
dark: {
|
|
52
|
+
hue: 'blue',
|
|
53
|
+
shade: 600
|
|
54
|
+
},
|
|
55
|
+
light: {
|
|
56
|
+
hue: 'azure',
|
|
57
|
+
shade: 700
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
coord: getColor({
|
|
61
|
+
theme,
|
|
62
|
+
hue: 'blue',
|
|
63
|
+
dark: {
|
|
64
|
+
shade: 200
|
|
65
|
+
},
|
|
66
|
+
light: {
|
|
67
|
+
shade: 800
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
deleted: getColor({
|
|
71
|
+
theme,
|
|
72
|
+
hue: 'red',
|
|
73
|
+
dark: {
|
|
74
|
+
shade: 200
|
|
75
|
+
},
|
|
76
|
+
light: {
|
|
77
|
+
shade: 800
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
diff: getColor({
|
|
81
|
+
theme,
|
|
82
|
+
hue: 'yellow',
|
|
83
|
+
dark: {
|
|
84
|
+
shade: 200
|
|
85
|
+
},
|
|
86
|
+
light: {
|
|
87
|
+
shade: 800
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
function: getColor({
|
|
91
|
+
theme,
|
|
92
|
+
dark: {
|
|
93
|
+
hue: 'yellow',
|
|
94
|
+
shade: 300
|
|
95
|
+
},
|
|
96
|
+
light: {
|
|
97
|
+
hue: 'orange',
|
|
98
|
+
shade: 700
|
|
99
|
+
}
|
|
100
|
+
}),
|
|
101
|
+
inserted: getColor({
|
|
102
|
+
theme,
|
|
103
|
+
hue: 'green',
|
|
104
|
+
dark: {
|
|
105
|
+
shade: 200
|
|
106
|
+
},
|
|
107
|
+
light: {
|
|
108
|
+
shade: 800
|
|
109
|
+
}
|
|
110
|
+
}),
|
|
111
|
+
keyword: getColor({
|
|
112
|
+
theme,
|
|
113
|
+
hue: 'fuschia',
|
|
114
|
+
dark: {
|
|
115
|
+
shade: 600
|
|
116
|
+
},
|
|
117
|
+
light: {
|
|
118
|
+
shade: 700
|
|
119
|
+
}
|
|
120
|
+
}),
|
|
121
|
+
name: getColor({
|
|
122
|
+
theme,
|
|
123
|
+
dark: {
|
|
124
|
+
hue: 'blue',
|
|
125
|
+
shade: 400
|
|
126
|
+
},
|
|
127
|
+
light: {
|
|
128
|
+
hue: 'crimson',
|
|
129
|
+
shade: 700
|
|
130
|
+
}
|
|
131
|
+
}),
|
|
132
|
+
number: getColor({
|
|
133
|
+
theme,
|
|
134
|
+
hue: 'green',
|
|
135
|
+
dark: {
|
|
136
|
+
shade: 400
|
|
137
|
+
},
|
|
138
|
+
light: {
|
|
139
|
+
shade: 700
|
|
140
|
+
}
|
|
141
|
+
}),
|
|
142
|
+
punctuation: getColor({
|
|
143
|
+
theme,
|
|
144
|
+
dark: {
|
|
145
|
+
hue: 'grey',
|
|
146
|
+
shade: 700
|
|
147
|
+
},
|
|
148
|
+
light: {
|
|
149
|
+
hue: 'red',
|
|
150
|
+
shade: 900
|
|
151
|
+
}
|
|
152
|
+
}),
|
|
153
|
+
regex: getColor({
|
|
154
|
+
theme,
|
|
155
|
+
hue: 'red',
|
|
156
|
+
shade: 600
|
|
157
|
+
}),
|
|
158
|
+
value: getColor({
|
|
159
|
+
theme,
|
|
160
|
+
dark: {
|
|
161
|
+
hue: 'crimson',
|
|
162
|
+
shade: 600
|
|
163
|
+
},
|
|
164
|
+
light: {
|
|
165
|
+
hue: 'red',
|
|
166
|
+
shade: 800
|
|
167
|
+
}
|
|
168
|
+
})
|
|
30
169
|
};
|
|
31
170
|
return css(["&.builtin,&.class-name,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script){color:", ";}&.doctype,&.prolog,&.tag.punctuation:not(.attr-value):not(.script):not(.spread){color:", ";}&.attribute.value,&.attr-value,&.atrule,&.cdata,&.string,&.url.content{color:", ";}&.constant,&.interpolation-punctuation{color:", ";}&.attr-name,&.attr-value.spread,&.environment,&.interpolation,&.parameter,&.property,&.property-access,&.variable{color:", ";}&.parameter.punctuation,&.attr-name + .attr-value.punctuation{color:inherit;}&.regex{color:", ";}&.boolean,&.bold:not(.diff),&.entity,&.important,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script):not(.class-name){color:", ";}&.number,&.unit{color:", ";}&.assign-left,&.function,&.selector:not(.attribute){color:", ";}&.atrule.rule,&.keyword{color:", ";}&.blockquote,&.comment,&.shebang{color:", ";}", ".language-css &&.plain{color:", ";}", ".language-diff &&.coord{color:", ";}", ".language-diff &&.deleted{color:", ";}", ".language-diff &&.diff{color:", ";}", ".language-diff &&.inserted{color:", ";}"], colors.builtin, colors.punctuation, colors.value, colors.constant, colors.name, colors.regex, colors.boolean, colors.number, colors.function, colors.keyword, colors.comment, StyledCodeBlock, colors.value, StyledCodeBlock, colors.coord, StyledCodeBlock, colors.deleted, StyledCodeBlock, colors.diff, StyledCodeBlock, colors.inserted);
|
|
32
171
|
};
|
|
33
172
|
const StyledCodeBlockToken = styled.span.attrs({
|
|
34
173
|
'data-garden-id': COMPONENT_ID,
|
|
35
|
-
'data-garden-version': '9.0.0-next.
|
|
174
|
+
'data-garden-version': '9.0.0-next.19'
|
|
36
175
|
}).withConfig({
|
|
37
176
|
displayName: "StyledCodeBlockToken",
|
|
38
177
|
componentId: "sc-1hkshdq-0"
|
|
39
|
-
})(["display:inline-block;&.bold:not(.diff){font-weight:", ";}&.coord{padding-left:0.75em;}&.italic{font-style:italic;}&.prefix{width:2em;text-align:center;}", ";", ";"], props => props.theme.fontWeights.semibold,
|
|
178
|
+
})(["display:inline-block;&.bold:not(.diff){font-weight:", ";}&.coord{padding-left:0.75em;}&.italic{font-style:italic;}&.prefix{width:2em;text-align:center;}", ";", ";"], props => props.theme.fontWeights.semibold, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
40
179
|
StyledCodeBlockToken.defaultProps = {
|
|
41
180
|
theme: DEFAULT_THEME
|
|
42
181
|
};
|
|
@@ -10,7 +10,7 @@ import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-the
|
|
|
10
10
|
const COMPONENT_ID = 'typography.ellipsis';
|
|
11
11
|
const StyledEllipsis = styled.div.attrs({
|
|
12
12
|
'data-garden-id': COMPONENT_ID,
|
|
13
|
-
'data-garden-version': '9.0.0-next.
|
|
13
|
+
'data-garden-version': '9.0.0-next.19'
|
|
14
14
|
}).withConfig({
|
|
15
15
|
displayName: "StyledEllipsis",
|
|
16
16
|
componentId: "sc-1u4uqmy-0"
|
|
@@ -63,7 +63,7 @@ const fontStyles = _ref => {
|
|
|
63
63
|
};
|
|
64
64
|
const StyledFont = styled.div.attrs({
|
|
65
65
|
'data-garden-id': COMPONENT_ID,
|
|
66
|
-
'data-garden-version': '9.0.0-next.
|
|
66
|
+
'data-garden-version': '9.0.0-next.19'
|
|
67
67
|
}).withConfig({
|
|
68
68
|
displayName: "StyledFont",
|
|
69
69
|
componentId: "sc-1iildbo-0"
|
|
@@ -15,7 +15,7 @@ const sizeStyles = props => {
|
|
|
15
15
|
};
|
|
16
16
|
const StyledIcon = styled(StyledBaseIcon).attrs({
|
|
17
17
|
'data-garden-id': COMPONENT_ID,
|
|
18
|
-
'data-garden-version': '9.0.0-next.
|
|
18
|
+
'data-garden-version': '9.0.0-next.19'
|
|
19
19
|
}).withConfig({
|
|
20
20
|
displayName: "StyledIcon",
|
|
21
21
|
componentId: "sc-10rfb5b-0"
|
|
@@ -14,7 +14,7 @@ const listStyles = props => {
|
|
|
14
14
|
const ORDERED_ID = 'typography.ordered_list';
|
|
15
15
|
const StyledOrderedList = styled.ol.attrs({
|
|
16
16
|
'data-garden-id': ORDERED_ID,
|
|
17
|
-
'data-garden-version': '9.0.0-next.
|
|
17
|
+
'data-garden-version': '9.0.0-next.19'
|
|
18
18
|
}).withConfig({
|
|
19
19
|
displayName: "StyledList__StyledOrderedList",
|
|
20
20
|
componentId: "sc-jdbsfi-0"
|
|
@@ -25,7 +25,7 @@ StyledOrderedList.defaultProps = {
|
|
|
25
25
|
const UNORDERED_ID = 'typography.unordered_list';
|
|
26
26
|
const StyledUnorderedList = styled.ul.attrs({
|
|
27
27
|
'data-garden-id': UNORDERED_ID,
|
|
28
|
-
'data-garden-version': '9.0.0-next.
|
|
28
|
+
'data-garden-version': '9.0.0-next.19'
|
|
29
29
|
}).withConfig({
|
|
30
30
|
displayName: "StyledList__StyledUnorderedList",
|
|
31
31
|
componentId: "sc-jdbsfi-1"
|
|
@@ -21,7 +21,7 @@ const listItemStyles = props => {
|
|
|
21
21
|
const ORDERED_ID = 'typography.ordered_list_item';
|
|
22
22
|
const StyledOrderedListItem = styled(StyledFont).attrs({
|
|
23
23
|
'data-garden-id': ORDERED_ID,
|
|
24
|
-
'data-garden-version': '9.0.0-next.
|
|
24
|
+
'data-garden-version': '9.0.0-next.19',
|
|
25
25
|
as: 'li'
|
|
26
26
|
}).withConfig({
|
|
27
27
|
displayName: "StyledListItem__StyledOrderedListItem",
|
|
@@ -34,7 +34,7 @@ StyledOrderedListItem.defaultProps = {
|
|
|
34
34
|
const UNORDERED_ID = 'typography.unordered_list_item';
|
|
35
35
|
const StyledUnorderedListItem = styled(StyledFont).attrs({
|
|
36
36
|
'data-garden-id': UNORDERED_ID,
|
|
37
|
-
'data-garden-version': '9.0.0-next.
|
|
37
|
+
'data-garden-version': '9.0.0-next.19',
|
|
38
38
|
as: 'li'
|
|
39
39
|
}).withConfig({
|
|
40
40
|
displayName: "StyledListItem__StyledUnorderedListItem",
|
|
@@ -11,7 +11,7 @@ import { THEME_SIZES } from './StyledFont.js';
|
|
|
11
11
|
const COMPONENT_ID = 'typography.paragraph';
|
|
12
12
|
const StyledParagraph = styled.p.attrs({
|
|
13
13
|
'data-garden-id': COMPONENT_ID,
|
|
14
|
-
'data-garden-version': '9.0.0-next.
|
|
14
|
+
'data-garden-version': '9.0.0-next.19'
|
|
15
15
|
}).withConfig({
|
|
16
16
|
displayName: "StyledParagraph",
|
|
17
17
|
componentId: "sc-zkuftz-0"
|
package/dist/esm/types/index.js
CHANGED
|
@@ -9,6 +9,6 @@ const SIZE = ['small', 'medium', 'large'];
|
|
|
9
9
|
const INHERIT_SIZE = ['inherit', ...SIZE];
|
|
10
10
|
const TYPE_ORDERED_LIST = ['decimal', 'decimal-leading-zero', 'lower-alpha', 'lower-roman', 'upper-alpha', 'upper-roman'];
|
|
11
11
|
const TYPE_UNORDERED_LIST = ['circle', 'disc', 'square'];
|
|
12
|
-
const LANGUAGES = ['
|
|
12
|
+
const LANGUAGES = ['bash', 'css', 'diff', 'graphql', 'javascript', 'json', 'jsx', 'markdown', 'markup', 'python', 'typescript', 'tsx', 'yaml'];
|
|
13
13
|
|
|
14
14
|
export { HUE, INHERIT_SIZE, LANGUAGES, SIZE, TYPE_ORDERED_LIST, TYPE_UNORDERED_LIST };
|
package/dist/index.cjs.js
CHANGED
|
@@ -11,7 +11,7 @@ var PropTypes = require('prop-types');
|
|
|
11
11
|
var styled = require('styled-components');
|
|
12
12
|
var reactTheming = require('@zendeskgarden/react-theming');
|
|
13
13
|
var polished = require('polished');
|
|
14
|
-
var
|
|
14
|
+
var prismReactRenderer = require('prism-react-renderer');
|
|
15
15
|
var containerScrollregion = require('@zendeskgarden/container-scrollregion');
|
|
16
16
|
|
|
17
17
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -19,14 +19,13 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
19
19
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
20
20
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
21
21
|
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
22
|
-
var Highlight__default = /*#__PURE__*/_interopDefault(Highlight);
|
|
23
22
|
|
|
24
23
|
const HUE = ['grey', 'red', 'green', 'yellow'];
|
|
25
24
|
const SIZE = ['small', 'medium', 'large'];
|
|
26
25
|
const INHERIT_SIZE = ['inherit', ...SIZE];
|
|
27
26
|
const TYPE_ORDERED_LIST = ['decimal', 'decimal-leading-zero', 'lower-alpha', 'lower-roman', 'upper-alpha', 'upper-roman'];
|
|
28
27
|
const TYPE_UNORDERED_LIST = ['circle', 'disc', 'square'];
|
|
29
|
-
const LANGUAGES = ['
|
|
28
|
+
const LANGUAGES = ['bash', 'css', 'diff', 'graphql', 'javascript', 'json', 'jsx', 'markdown', 'markup', 'python', 'typescript', 'tsx', 'yaml'];
|
|
30
29
|
|
|
31
30
|
const COMPONENT_ID$9 = 'typography.font';
|
|
32
31
|
[...SIZE, 'extralarge', '2xlarge', '3xlarge'];
|
|
@@ -82,7 +81,7 @@ const fontStyles = _ref => {
|
|
|
82
81
|
};
|
|
83
82
|
const StyledFont = styled__default.default.div.attrs({
|
|
84
83
|
'data-garden-id': COMPONENT_ID$9,
|
|
85
|
-
'data-garden-version': '9.0.0-next.
|
|
84
|
+
'data-garden-version': '9.0.0-next.19'
|
|
86
85
|
}).withConfig({
|
|
87
86
|
displayName: "StyledFont",
|
|
88
87
|
componentId: "sc-1iildbo-0"
|
|
@@ -95,7 +94,7 @@ StyledFont.defaultProps = {
|
|
|
95
94
|
const COMPONENT_ID$8 = 'typography.blockquote';
|
|
96
95
|
const StyledBlockquote = styled__default.default.blockquote.attrs({
|
|
97
96
|
'data-garden-id': COMPONENT_ID$8,
|
|
98
|
-
'data-garden-version': '9.0.0-next.
|
|
97
|
+
'data-garden-version': '9.0.0-next.19'
|
|
99
98
|
}).withConfig({
|
|
100
99
|
displayName: "StyledBlockquote",
|
|
101
100
|
componentId: "sc-1tt3ye0-0"
|
|
@@ -149,7 +148,7 @@ const colorStyles$3 = _ref => {
|
|
|
149
148
|
};
|
|
150
149
|
const StyledCode = styled__default.default(StyledFont).attrs({
|
|
151
150
|
'data-garden-id': COMPONENT_ID$7,
|
|
152
|
-
'data-garden-version': '9.0.0-next.
|
|
151
|
+
'data-garden-version': '9.0.0-next.19',
|
|
153
152
|
as: 'code',
|
|
154
153
|
isMonospace: true
|
|
155
154
|
}).withConfig({
|
|
@@ -163,18 +162,27 @@ StyledCode.defaultProps = {
|
|
|
163
162
|
};
|
|
164
163
|
|
|
165
164
|
const COMPONENT_ID$6 = 'typography.codeblock';
|
|
166
|
-
const colorStyles$2 =
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
const colorStyles$2 = _ref => {
|
|
166
|
+
let {
|
|
167
|
+
theme
|
|
168
|
+
} = _ref;
|
|
169
|
+
const backgroundColor = reactTheming.getColor({
|
|
170
|
+
theme,
|
|
171
|
+
variable: theme.colors.base === 'light' ? 'background.subtle' : 'background.default'
|
|
172
|
+
});
|
|
173
|
+
const foregroundColor = reactTheming.getColor({
|
|
174
|
+
theme,
|
|
175
|
+
variable: 'foreground.default'
|
|
176
|
+
});
|
|
169
177
|
return styled.css(["background-color:", ";color:", ";"], backgroundColor, foregroundColor);
|
|
170
178
|
};
|
|
171
179
|
const StyledCodeBlock = styled__default.default.pre.attrs({
|
|
172
180
|
'data-garden-id': COMPONENT_ID$6,
|
|
173
|
-
'data-garden-version': '9.0.0-next.
|
|
181
|
+
'data-garden-version': '9.0.0-next.19'
|
|
174
182
|
}).withConfig({
|
|
175
183
|
displayName: "StyledCodeBlock",
|
|
176
184
|
componentId: "sc-5wky57-0"
|
|
177
|
-
})(["display:table;margin:0;padding:", "px;box-sizing:border-box;width:100%;direction:ltr;white-space:pre;counter-reset:linenumber;", ";", ";"], props => props.theme.space.base * 3,
|
|
185
|
+
})(["display:table;margin:0;padding:", "px;box-sizing:border-box;width:100%;direction:ltr;white-space:pre;counter-reset:linenumber;", ";", ";"], props => props.theme.space.base * 3, colorStyles$2, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$6, props));
|
|
178
186
|
StyledCodeBlock.defaultProps = {
|
|
179
187
|
theme: reactTheming.DEFAULT_THEME
|
|
180
188
|
};
|
|
@@ -182,7 +190,7 @@ StyledCodeBlock.defaultProps = {
|
|
|
182
190
|
const COMPONENT_ID$5 = 'typography.codeblock_container';
|
|
183
191
|
const StyledCodeBlockContainer = styled__default.default.div.attrs({
|
|
184
192
|
'data-garden-id': COMPONENT_ID$5,
|
|
185
|
-
'data-garden-version': '9.0.0-next.
|
|
193
|
+
'data-garden-version': '9.0.0-next.19'
|
|
186
194
|
}).withConfig({
|
|
187
195
|
displayName: "StyledCodeBlockContainer",
|
|
188
196
|
componentId: "sc-14zgbfw-0"
|
|
@@ -194,42 +202,68 @@ StyledCodeBlockContainer.defaultProps = {
|
|
|
194
202
|
};
|
|
195
203
|
|
|
196
204
|
const COMPONENT_ID$4 = 'typography.codeblock_code';
|
|
197
|
-
const colorStyles$1 =
|
|
205
|
+
const colorStyles$1 = _ref => {
|
|
206
|
+
let {
|
|
207
|
+
theme,
|
|
208
|
+
diff,
|
|
209
|
+
isHighlighted
|
|
210
|
+
} = _ref;
|
|
198
211
|
let backgroundColor;
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
backgroundColor = reactTheming.
|
|
212
|
+
if (diff) {
|
|
213
|
+
const hues = {
|
|
214
|
+
hunk: 'royal',
|
|
215
|
+
add: 'lime',
|
|
216
|
+
delete: 'crimson',
|
|
217
|
+
change: 'lemon'
|
|
218
|
+
};
|
|
219
|
+
backgroundColor = reactTheming.getColor({
|
|
220
|
+
theme,
|
|
221
|
+
hue: hues[diff],
|
|
222
|
+
dark: {
|
|
223
|
+
shade: 600
|
|
224
|
+
},
|
|
225
|
+
light: {
|
|
226
|
+
shade: 400
|
|
227
|
+
},
|
|
228
|
+
transparency: theme.opacity[300]
|
|
229
|
+
});
|
|
230
|
+
} else if (isHighlighted) {
|
|
231
|
+
backgroundColor = reactTheming.getColor({
|
|
232
|
+
theme,
|
|
233
|
+
dark: {
|
|
234
|
+
hue: 'white'
|
|
235
|
+
},
|
|
236
|
+
light: {
|
|
237
|
+
hue: 'neutralHue',
|
|
238
|
+
shade: 700
|
|
239
|
+
},
|
|
240
|
+
transparency: theme.opacity[100]
|
|
241
|
+
});
|
|
219
242
|
}
|
|
220
243
|
return styled.css(["background-color:", ";"], backgroundColor);
|
|
221
244
|
};
|
|
222
|
-
const lineNumberStyles =
|
|
223
|
-
|
|
245
|
+
const lineNumberStyles = _ref2 => {
|
|
246
|
+
let {
|
|
247
|
+
theme,
|
|
248
|
+
language,
|
|
249
|
+
size
|
|
250
|
+
} = _ref2;
|
|
251
|
+
const color = reactTheming.getColor({
|
|
252
|
+
theme,
|
|
253
|
+
variable: 'foreground.subtle',
|
|
254
|
+
light: {
|
|
255
|
+
offset: -100
|
|
256
|
+
}
|
|
257
|
+
});
|
|
224
258
|
let padding;
|
|
225
|
-
if (
|
|
259
|
+
if (language && language === 'diff') {
|
|
226
260
|
padding = 0;
|
|
227
|
-
} else if (
|
|
228
|
-
padding =
|
|
229
|
-
} else if (
|
|
230
|
-
padding =
|
|
261
|
+
} else if (size === 'small') {
|
|
262
|
+
padding = theme.space.base * 4;
|
|
263
|
+
} else if (size === 'large') {
|
|
264
|
+
padding = theme.space.base * 7;
|
|
231
265
|
} else {
|
|
232
|
-
padding =
|
|
266
|
+
padding = theme.space.base * 6;
|
|
233
267
|
}
|
|
234
268
|
return `
|
|
235
269
|
&::before {
|
|
@@ -245,46 +279,185 @@ const lineNumberStyles = props => {
|
|
|
245
279
|
};
|
|
246
280
|
const StyledCodeBlockLine = styled__default.default(StyledFont).attrs({
|
|
247
281
|
'data-garden-id': COMPONENT_ID$4,
|
|
248
|
-
'data-garden-version': '9.0.0-next.
|
|
282
|
+
'data-garden-version': '9.0.0-next.19',
|
|
249
283
|
as: 'code',
|
|
250
284
|
isMonospace: true
|
|
251
285
|
}).withConfig({
|
|
252
286
|
displayName: "StyledCodeBlockLine",
|
|
253
287
|
componentId: "sc-1goay17-0"
|
|
254
|
-
})(["display:table-row;height:", ";direction:ltr;", ";", ";&::after{display:inline-block;width:", "px;content:'';}", ";"], props => props.theme.lineHeights[THEME_SIZES[props.size]],
|
|
288
|
+
})(["display:table-row;height:", ";direction:ltr;", ";", ";&::after{display:inline-block;width:", "px;content:'';}", ";"], props => props.theme.lineHeights[THEME_SIZES[props.size]], colorStyles$1, props => props.isNumbered && lineNumberStyles(props), props => props.theme.space.base * 3, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
255
289
|
StyledCodeBlockLine.defaultProps = {
|
|
256
290
|
theme: reactTheming.DEFAULT_THEME
|
|
257
291
|
};
|
|
258
292
|
|
|
259
293
|
const COMPONENT_ID$3 = 'typography.codeblock_token';
|
|
260
|
-
const colorStyles =
|
|
261
|
-
|
|
294
|
+
const colorStyles = _ref => {
|
|
295
|
+
let {
|
|
296
|
+
theme
|
|
297
|
+
} = _ref;
|
|
262
298
|
const colors = {
|
|
263
|
-
boolean:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
299
|
+
boolean: reactTheming.getColor({
|
|
300
|
+
theme,
|
|
301
|
+
dark: {
|
|
302
|
+
hue: 'azure',
|
|
303
|
+
shade: 600
|
|
304
|
+
},
|
|
305
|
+
light: {
|
|
306
|
+
hue: 'royal',
|
|
307
|
+
shade: 700
|
|
308
|
+
}
|
|
309
|
+
}),
|
|
310
|
+
builtin: reactTheming.getColor({
|
|
311
|
+
theme,
|
|
312
|
+
hue: 'teal',
|
|
313
|
+
dark: {
|
|
314
|
+
shade: 600
|
|
315
|
+
},
|
|
316
|
+
light: {
|
|
317
|
+
shade: 700
|
|
318
|
+
}
|
|
319
|
+
}),
|
|
320
|
+
comment: reactTheming.getColor({
|
|
321
|
+
theme,
|
|
322
|
+
dark: {
|
|
323
|
+
hue: 'mint',
|
|
324
|
+
shade: 600
|
|
325
|
+
},
|
|
326
|
+
light: {
|
|
327
|
+
hue: 'lime',
|
|
328
|
+
shade: 700
|
|
329
|
+
}
|
|
330
|
+
}),
|
|
331
|
+
constant: reactTheming.getColor({
|
|
332
|
+
theme,
|
|
333
|
+
dark: {
|
|
334
|
+
hue: 'blue',
|
|
335
|
+
shade: 600
|
|
336
|
+
},
|
|
337
|
+
light: {
|
|
338
|
+
hue: 'azure',
|
|
339
|
+
shade: 700
|
|
340
|
+
}
|
|
341
|
+
}),
|
|
342
|
+
coord: reactTheming.getColor({
|
|
343
|
+
theme,
|
|
344
|
+
hue: 'blue',
|
|
345
|
+
dark: {
|
|
346
|
+
shade: 200
|
|
347
|
+
},
|
|
348
|
+
light: {
|
|
349
|
+
shade: 800
|
|
350
|
+
}
|
|
351
|
+
}),
|
|
352
|
+
deleted: reactTheming.getColor({
|
|
353
|
+
theme,
|
|
354
|
+
hue: 'red',
|
|
355
|
+
dark: {
|
|
356
|
+
shade: 200
|
|
357
|
+
},
|
|
358
|
+
light: {
|
|
359
|
+
shade: 800
|
|
360
|
+
}
|
|
361
|
+
}),
|
|
362
|
+
diff: reactTheming.getColor({
|
|
363
|
+
theme,
|
|
364
|
+
hue: 'yellow',
|
|
365
|
+
dark: {
|
|
366
|
+
shade: 200
|
|
367
|
+
},
|
|
368
|
+
light: {
|
|
369
|
+
shade: 800
|
|
370
|
+
}
|
|
371
|
+
}),
|
|
372
|
+
function: reactTheming.getColor({
|
|
373
|
+
theme,
|
|
374
|
+
dark: {
|
|
375
|
+
hue: 'yellow',
|
|
376
|
+
shade: 300
|
|
377
|
+
},
|
|
378
|
+
light: {
|
|
379
|
+
hue: 'orange',
|
|
380
|
+
shade: 700
|
|
381
|
+
}
|
|
382
|
+
}),
|
|
383
|
+
inserted: reactTheming.getColor({
|
|
384
|
+
theme,
|
|
385
|
+
hue: 'green',
|
|
386
|
+
dark: {
|
|
387
|
+
shade: 200
|
|
388
|
+
},
|
|
389
|
+
light: {
|
|
390
|
+
shade: 800
|
|
391
|
+
}
|
|
392
|
+
}),
|
|
393
|
+
keyword: reactTheming.getColor({
|
|
394
|
+
theme,
|
|
395
|
+
hue: 'fuschia',
|
|
396
|
+
dark: {
|
|
397
|
+
shade: 600
|
|
398
|
+
},
|
|
399
|
+
light: {
|
|
400
|
+
shade: 700
|
|
401
|
+
}
|
|
402
|
+
}),
|
|
403
|
+
name: reactTheming.getColor({
|
|
404
|
+
theme,
|
|
405
|
+
dark: {
|
|
406
|
+
hue: 'blue',
|
|
407
|
+
shade: 400
|
|
408
|
+
},
|
|
409
|
+
light: {
|
|
410
|
+
hue: 'crimson',
|
|
411
|
+
shade: 700
|
|
412
|
+
}
|
|
413
|
+
}),
|
|
414
|
+
number: reactTheming.getColor({
|
|
415
|
+
theme,
|
|
416
|
+
hue: 'green',
|
|
417
|
+
dark: {
|
|
418
|
+
shade: 400
|
|
419
|
+
},
|
|
420
|
+
light: {
|
|
421
|
+
shade: 700
|
|
422
|
+
}
|
|
423
|
+
}),
|
|
424
|
+
punctuation: reactTheming.getColor({
|
|
425
|
+
theme,
|
|
426
|
+
dark: {
|
|
427
|
+
hue: 'grey',
|
|
428
|
+
shade: 700
|
|
429
|
+
},
|
|
430
|
+
light: {
|
|
431
|
+
hue: 'red',
|
|
432
|
+
shade: 900
|
|
433
|
+
}
|
|
434
|
+
}),
|
|
435
|
+
regex: reactTheming.getColor({
|
|
436
|
+
theme,
|
|
437
|
+
hue: 'red',
|
|
438
|
+
shade: 600
|
|
439
|
+
}),
|
|
440
|
+
value: reactTheming.getColor({
|
|
441
|
+
theme,
|
|
442
|
+
dark: {
|
|
443
|
+
hue: 'crimson',
|
|
444
|
+
shade: 600
|
|
445
|
+
},
|
|
446
|
+
light: {
|
|
447
|
+
hue: 'red',
|
|
448
|
+
shade: 800
|
|
449
|
+
}
|
|
450
|
+
})
|
|
278
451
|
};
|
|
279
452
|
return styled.css(["&.builtin,&.class-name,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script){color:", ";}&.doctype,&.prolog,&.tag.punctuation:not(.attr-value):not(.script):not(.spread){color:", ";}&.attribute.value,&.attr-value,&.atrule,&.cdata,&.string,&.url.content{color:", ";}&.constant,&.interpolation-punctuation{color:", ";}&.attr-name,&.attr-value.spread,&.environment,&.interpolation,&.parameter,&.property,&.property-access,&.variable{color:", ";}&.parameter.punctuation,&.attr-name + .attr-value.punctuation{color:inherit;}&.regex{color:", ";}&.boolean,&.bold:not(.diff),&.entity,&.important,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script):not(.class-name){color:", ";}&.number,&.unit{color:", ";}&.assign-left,&.function,&.selector:not(.attribute){color:", ";}&.atrule.rule,&.keyword{color:", ";}&.blockquote,&.comment,&.shebang{color:", ";}", ".language-css &&.plain{color:", ";}", ".language-diff &&.coord{color:", ";}", ".language-diff &&.deleted{color:", ";}", ".language-diff &&.diff{color:", ";}", ".language-diff &&.inserted{color:", ";}"], colors.builtin, colors.punctuation, colors.value, colors.constant, colors.name, colors.regex, colors.boolean, colors.number, colors.function, colors.keyword, colors.comment, StyledCodeBlock, colors.value, StyledCodeBlock, colors.coord, StyledCodeBlock, colors.deleted, StyledCodeBlock, colors.diff, StyledCodeBlock, colors.inserted);
|
|
280
453
|
};
|
|
281
454
|
const StyledCodeBlockToken = styled__default.default.span.attrs({
|
|
282
455
|
'data-garden-id': COMPONENT_ID$3,
|
|
283
|
-
'data-garden-version': '9.0.0-next.
|
|
456
|
+
'data-garden-version': '9.0.0-next.19'
|
|
284
457
|
}).withConfig({
|
|
285
458
|
displayName: "StyledCodeBlockToken",
|
|
286
459
|
componentId: "sc-1hkshdq-0"
|
|
287
|
-
})(["display:inline-block;&.bold:not(.diff){font-weight:", ";}&.coord{padding-left:0.75em;}&.italic{font-style:italic;}&.prefix{width:2em;text-align:center;}", ";", ";"], props => props.theme.fontWeights.semibold,
|
|
460
|
+
})(["display:inline-block;&.bold:not(.diff){font-weight:", ";}&.coord{padding-left:0.75em;}&.italic{font-style:italic;}&.prefix{width:2em;text-align:center;}", ";", ";"], props => props.theme.fontWeights.semibold, colorStyles, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
288
461
|
StyledCodeBlockToken.defaultProps = {
|
|
289
462
|
theme: reactTheming.DEFAULT_THEME
|
|
290
463
|
};
|
|
@@ -292,7 +465,7 @@ StyledCodeBlockToken.defaultProps = {
|
|
|
292
465
|
const COMPONENT_ID$2 = 'typography.ellipsis';
|
|
293
466
|
const StyledEllipsis = styled__default.default.div.attrs({
|
|
294
467
|
'data-garden-id': COMPONENT_ID$2,
|
|
295
|
-
'data-garden-version': '9.0.0-next.
|
|
468
|
+
'data-garden-version': '9.0.0-next.19'
|
|
296
469
|
}).withConfig({
|
|
297
470
|
displayName: "StyledEllipsis",
|
|
298
471
|
componentId: "sc-1u4uqmy-0"
|
|
@@ -309,7 +482,7 @@ const sizeStyles = props => {
|
|
|
309
482
|
};
|
|
310
483
|
const StyledIcon = styled__default.default(reactTheming.StyledBaseIcon).attrs({
|
|
311
484
|
'data-garden-id': COMPONENT_ID$1,
|
|
312
|
-
'data-garden-version': '9.0.0-next.
|
|
485
|
+
'data-garden-version': '9.0.0-next.19'
|
|
313
486
|
}).withConfig({
|
|
314
487
|
displayName: "StyledIcon",
|
|
315
488
|
componentId: "sc-10rfb5b-0"
|
|
@@ -325,7 +498,7 @@ const listStyles = props => {
|
|
|
325
498
|
const ORDERED_ID$1 = 'typography.ordered_list';
|
|
326
499
|
const StyledOrderedList = styled__default.default.ol.attrs({
|
|
327
500
|
'data-garden-id': ORDERED_ID$1,
|
|
328
|
-
'data-garden-version': '9.0.0-next.
|
|
501
|
+
'data-garden-version': '9.0.0-next.19'
|
|
329
502
|
}).withConfig({
|
|
330
503
|
displayName: "StyledList__StyledOrderedList",
|
|
331
504
|
componentId: "sc-jdbsfi-0"
|
|
@@ -336,7 +509,7 @@ StyledOrderedList.defaultProps = {
|
|
|
336
509
|
const UNORDERED_ID$1 = 'typography.unordered_list';
|
|
337
510
|
const StyledUnorderedList = styled__default.default.ul.attrs({
|
|
338
511
|
'data-garden-id': UNORDERED_ID$1,
|
|
339
|
-
'data-garden-version': '9.0.0-next.
|
|
512
|
+
'data-garden-version': '9.0.0-next.19'
|
|
340
513
|
}).withConfig({
|
|
341
514
|
displayName: "StyledList__StyledUnorderedList",
|
|
342
515
|
componentId: "sc-jdbsfi-1"
|
|
@@ -356,7 +529,7 @@ const listItemStyles = props => {
|
|
|
356
529
|
const ORDERED_ID = 'typography.ordered_list_item';
|
|
357
530
|
const StyledOrderedListItem = styled__default.default(StyledFont).attrs({
|
|
358
531
|
'data-garden-id': ORDERED_ID,
|
|
359
|
-
'data-garden-version': '9.0.0-next.
|
|
532
|
+
'data-garden-version': '9.0.0-next.19',
|
|
360
533
|
as: 'li'
|
|
361
534
|
}).withConfig({
|
|
362
535
|
displayName: "StyledListItem__StyledOrderedListItem",
|
|
@@ -369,7 +542,7 @@ StyledOrderedListItem.defaultProps = {
|
|
|
369
542
|
const UNORDERED_ID = 'typography.unordered_list_item';
|
|
370
543
|
const StyledUnorderedListItem = styled__default.default(StyledFont).attrs({
|
|
371
544
|
'data-garden-id': UNORDERED_ID,
|
|
372
|
-
'data-garden-version': '9.0.0-next.
|
|
545
|
+
'data-garden-version': '9.0.0-next.19',
|
|
373
546
|
as: 'li'
|
|
374
547
|
}).withConfig({
|
|
375
548
|
displayName: "StyledListItem__StyledUnorderedListItem",
|
|
@@ -383,7 +556,7 @@ StyledUnorderedListItem.defaultProps = {
|
|
|
383
556
|
const COMPONENT_ID = 'typography.paragraph';
|
|
384
557
|
const StyledParagraph = styled__default.default.p.attrs({
|
|
385
558
|
'data-garden-id': COMPONENT_ID,
|
|
386
|
-
'data-garden-version': '9.0.0-next.
|
|
559
|
+
'data-garden-version': '9.0.0-next.19'
|
|
387
560
|
}).withConfig({
|
|
388
561
|
displayName: "StyledParagraph",
|
|
389
562
|
componentId: "sc-zkuftz-0"
|
|
@@ -553,8 +726,8 @@ const CodeBlock = React__default.default.forwardRef((_ref, ref) => {
|
|
|
553
726
|
highlightLines,
|
|
554
727
|
isLight,
|
|
555
728
|
isNumbered,
|
|
556
|
-
language,
|
|
557
|
-
size,
|
|
729
|
+
language = 'tsx',
|
|
730
|
+
size = 'medium',
|
|
558
731
|
...other
|
|
559
732
|
} = _ref;
|
|
560
733
|
const containerRef = React.useRef(null);
|
|
@@ -564,6 +737,25 @@ const CodeBlock = React__default.default.forwardRef((_ref, ref) => {
|
|
|
564
737
|
containerRef,
|
|
565
738
|
dependency
|
|
566
739
|
});
|
|
740
|
+
const [isPrismImported, setIsPrismImported] = React.useState(false);
|
|
741
|
+
const win = reactTheming.useWindow();
|
|
742
|
+
const importPrism = React.useCallback(async () => {
|
|
743
|
+
if (win && !isPrismImported) {
|
|
744
|
+
win.Prism = prismReactRenderer.Prism;
|
|
745
|
+
try {
|
|
746
|
+
await import('prismjs/components/prism-bash');
|
|
747
|
+
await import('prismjs/components/prism-diff');
|
|
748
|
+
await import('prismjs/components/prism-json');
|
|
749
|
+
} catch (error) {
|
|
750
|
+
console.error(error);
|
|
751
|
+
} finally {
|
|
752
|
+
setIsPrismImported(true);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}, [win, isPrismImported]);
|
|
756
|
+
React.useEffect(() => {
|
|
757
|
+
importPrism();
|
|
758
|
+
}, [importPrism]);
|
|
567
759
|
const getDiff = line => {
|
|
568
760
|
let retVal;
|
|
569
761
|
if (language === 'diff') {
|
|
@@ -582,11 +774,10 @@ const CodeBlock = React__default.default.forwardRef((_ref, ref) => {
|
|
|
582
774
|
}
|
|
583
775
|
return retVal;
|
|
584
776
|
};
|
|
585
|
-
return React__default.default.createElement(StyledCodeBlockContainer, Object.assign({}, containerProps, {
|
|
777
|
+
return isPrismImported && React__default.default.createElement(StyledCodeBlockContainer, Object.assign({}, containerProps, {
|
|
586
778
|
ref: containerRef,
|
|
587
779
|
tabIndex: containerTabIndex
|
|
588
|
-
}), React__default.default.createElement(
|
|
589
|
-
Prism: Highlight.Prism,
|
|
780
|
+
}), React__default.default.createElement(prismReactRenderer.Highlight, {
|
|
590
781
|
code: code ? code.trim() : '',
|
|
591
782
|
language: LANGUAGES.includes(language) ? language : 'tsx'
|
|
592
783
|
}, _ref2 => {
|
|
@@ -596,33 +787,36 @@ const CodeBlock = React__default.default.forwardRef((_ref, ref) => {
|
|
|
596
787
|
getLineProps,
|
|
597
788
|
getTokenProps
|
|
598
789
|
} = _ref2;
|
|
599
|
-
return React__default.default.createElement(
|
|
790
|
+
return React__default.default.createElement(reactTheming.ThemeProvider, {
|
|
791
|
+
theme: parentTheme => ({
|
|
792
|
+
...parentTheme,
|
|
793
|
+
colors: {
|
|
794
|
+
...parentTheme.colors,
|
|
795
|
+
base: isLight ? 'light' : 'dark'
|
|
796
|
+
}
|
|
797
|
+
})
|
|
798
|
+
}, React__default.default.createElement(StyledCodeBlock, Object.assign({
|
|
600
799
|
className: className,
|
|
601
|
-
ref: ref
|
|
602
|
-
isLight: isLight
|
|
800
|
+
ref: ref
|
|
603
801
|
}, other), tokens.map((line, index) => React__default.default.createElement(StyledCodeBlockLine, Object.assign({}, getLineProps({
|
|
604
802
|
line
|
|
605
803
|
}), {
|
|
606
804
|
key: index,
|
|
607
805
|
language: language,
|
|
608
806
|
isHighlighted: highlightLines && highlightLines.includes(index + 1),
|
|
609
|
-
isLight: isLight,
|
|
610
807
|
isNumbered: isNumbered,
|
|
611
808
|
diff: getDiff(line),
|
|
612
|
-
size: size
|
|
809
|
+
size: size,
|
|
810
|
+
style: undefined
|
|
613
811
|
}), line.map((token, tokenKey) => React__default.default.createElement(StyledCodeBlockToken, Object.assign({}, getTokenProps({
|
|
614
812
|
token
|
|
615
813
|
}), {
|
|
616
814
|
key: tokenKey,
|
|
617
|
-
|
|
618
|
-
}), token.empty ? '\n' : token.content)))));
|
|
815
|
+
style: undefined
|
|
816
|
+
}), token.empty ? '\n' : token.content))))));
|
|
619
817
|
}));
|
|
620
818
|
});
|
|
621
819
|
CodeBlock.displayName = 'CodeBlock';
|
|
622
|
-
CodeBlock.defaultProps = {
|
|
623
|
-
language: 'tsx',
|
|
624
|
-
size: 'medium'
|
|
625
|
-
};
|
|
626
820
|
|
|
627
821
|
const Ellipsis = React.forwardRef((_ref, ref) => {
|
|
628
822
|
let {
|
|
@@ -5,10 +5,7 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import { DefaultTheme } from 'styled-components';
|
|
8
|
-
export interface IStyledCodeBlockProps {
|
|
9
|
-
isLight?: boolean;
|
|
10
|
-
}
|
|
11
8
|
export declare const StyledCodeBlock: import("styled-components").StyledComponent<"pre", DefaultTheme, {
|
|
12
9
|
'data-garden-id': string;
|
|
13
10
|
'data-garden-version': string;
|
|
14
|
-
}
|
|
11
|
+
}, "data-garden-id" | "data-garden-version">;
|
|
@@ -10,15 +10,10 @@ import { Diff, Size } from '../types';
|
|
|
10
10
|
export interface IStyledCodeBlockLineProps {
|
|
11
11
|
language?: Language;
|
|
12
12
|
isHighlighted?: boolean;
|
|
13
|
-
isLight?: boolean;
|
|
14
13
|
isNumbered?: boolean;
|
|
15
14
|
diff?: Diff;
|
|
16
15
|
size?: Size;
|
|
17
16
|
}
|
|
18
|
-
/**
|
|
19
|
-
* 1. Fix line display for mobile.
|
|
20
|
-
* 2. Match parent padding for overflow scroll.
|
|
21
|
-
*/
|
|
22
17
|
export declare const StyledCodeBlockLine: import("styled-components").StyledComponent<"code", DefaultTheme, {
|
|
23
18
|
'data-garden-id': string;
|
|
24
19
|
'data-garden-version': string;
|
|
@@ -5,10 +5,7 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import { DefaultTheme } from 'styled-components';
|
|
8
|
-
export interface IStyledCodeBlockTokenProps {
|
|
9
|
-
isLight?: boolean;
|
|
10
|
-
}
|
|
11
8
|
export declare const StyledCodeBlockToken: import("styled-components").StyledComponent<"span", DefaultTheme, {
|
|
12
9
|
'data-garden-id': string;
|
|
13
10
|
'data-garden-version': string;
|
|
14
|
-
}
|
|
11
|
+
}, "data-garden-id" | "data-garden-version">;
|
|
@@ -10,7 +10,7 @@ export declare const SIZE: readonly ["small", "medium", "large"];
|
|
|
10
10
|
export declare const INHERIT_SIZE: readonly ["inherit", "small", "medium", "large"];
|
|
11
11
|
export declare const TYPE_ORDERED_LIST: readonly ["decimal", "decimal-leading-zero", "lower-alpha", "lower-roman", "upper-alpha", "upper-roman"];
|
|
12
12
|
export declare const TYPE_UNORDERED_LIST: readonly ["circle", "disc", "square"];
|
|
13
|
-
export declare const LANGUAGES: readonly ["
|
|
13
|
+
export declare const LANGUAGES: readonly ["bash", "css", "diff", "graphql", "javascript", "json", "jsx", "markdown", "markup", "python", "typescript", "tsx", "yaml"];
|
|
14
14
|
export type Diff = 'hunk' | 'add' | 'delete' | 'change';
|
|
15
15
|
export type Size = (typeof SIZE)[number];
|
|
16
16
|
export interface ITypescaleProps extends HTMLAttributes<HTMLDivElement> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-typography",
|
|
3
|
-
"version": "9.0.0-next.
|
|
3
|
+
"version": "9.0.0-next.19",
|
|
4
4
|
"description": "Components relating to typography in the Garden Design System",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Zendesk Garden <garden@zendesk.com>",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@zendeskgarden/container-scrollregion": "^1.0.9",
|
|
25
25
|
"polished": "^4.3.1",
|
|
26
|
-
"prism-react-renderer": "^
|
|
26
|
+
"prism-react-renderer": "^2.3.1",
|
|
27
|
+
"prismjs": "^1.29.0",
|
|
27
28
|
"prop-types": "^15.5.7"
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"styled-components": "^5.3.1"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@zendeskgarden/react-theming": "^9.0.0-next.
|
|
37
|
+
"@zendeskgarden/react-theming": "^9.0.0-next.19"
|
|
37
38
|
},
|
|
38
39
|
"keywords": [
|
|
39
40
|
"components",
|
|
@@ -45,5 +46,5 @@
|
|
|
45
46
|
"access": "public"
|
|
46
47
|
},
|
|
47
48
|
"zendeskgarden:src": "src/index.ts",
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "3f18fec721a25bebc274de6af38cd88ab4e63a79"
|
|
49
50
|
}
|