@zendeskgarden/react-typography 9.0.0-next.8 → 9.0.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/dist/esm/elements/CodeBlock.js +20 -15
- package/dist/esm/elements/span/StartIcon.js +1 -1
- package/dist/esm/styled/StyledBlockquote.js +6 -6
- package/dist/esm/styled/StyledCode.js +42 -10
- package/dist/esm/styled/StyledCodeBlock.js +15 -9
- package/dist/esm/styled/StyledCodeBlockContainer.js +2 -5
- package/dist/esm/styled/StyledCodeBlockLine.js +58 -35
- package/dist/esm/styled/StyledCodeBlockToken.js +159 -23
- package/dist/esm/styled/StyledEllipsis.js +2 -5
- package/dist/esm/styled/StyledFont.js +35 -22
- package/dist/esm/styled/StyledIcon.js +4 -15
- package/dist/esm/styled/StyledList.js +3 -9
- package/dist/esm/styled/StyledListItem.js +3 -3
- package/dist/esm/styled/StyledParagraph.js +2 -5
- package/dist/esm/types/index.js +1 -1
- package/dist/index.cjs.js +341 -152
- package/dist/typings/elements/lists/OrderedList.d.ts +3 -1
- package/dist/typings/elements/lists/UnorderedList.d.ts +3 -1
- package/dist/typings/elements/span/Span.d.ts +3 -1
- package/dist/typings/styled/StyledCode.d.ts +3 -2
- 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/styled/StyledIcon.d.ts +2 -3
- package/dist/typings/types/index.d.ts +5 -3
- package/dist/typings/utils/useOrderedListContext.d.ts +0 -1
- package/dist/typings/utils/useUnorderedListContext.d.ts +0 -1
- package/package.json +8 -9
- package/LICENSE.md +0 -176
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import React, { useRef, useMemo } from 'react';
|
|
8
8
|
import Highlight, { Prism } from 'prism-react-renderer';
|
|
9
9
|
import { useScrollRegion } from '@zendeskgarden/container-scrollregion';
|
|
10
|
+
import { 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);
|
|
@@ -71,32 +72,36 @@ const CodeBlock = React.forwardRef((_ref, ref) => {
|
|
|
71
72
|
getLineProps,
|
|
72
73
|
getTokenProps
|
|
73
74
|
} = _ref2;
|
|
74
|
-
return React.createElement(
|
|
75
|
+
return React.createElement(ThemeProvider, {
|
|
76
|
+
theme: parentTheme => ({
|
|
77
|
+
...parentTheme,
|
|
78
|
+
colors: {
|
|
79
|
+
...parentTheme.colors,
|
|
80
|
+
base: isLight ? 'light' : 'dark'
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}, React.createElement(StyledCodeBlock, Object.assign({
|
|
75
84
|
className: className,
|
|
76
|
-
ref: ref
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
ref: ref
|
|
86
|
+
}, other), tokens.map((line, index) =>
|
|
87
|
+
React.createElement(StyledCodeBlockLine, Object.assign({}, getLineProps({
|
|
79
88
|
line
|
|
80
89
|
}), {
|
|
81
90
|
key: index,
|
|
82
91
|
language: language,
|
|
83
|
-
isHighlighted: highlightLines
|
|
84
|
-
isLight: isLight,
|
|
92
|
+
isHighlighted: highlightLines?.includes(index + 1),
|
|
85
93
|
isNumbered: isNumbered,
|
|
86
94
|
diff: getDiff(line),
|
|
87
|
-
size: size
|
|
95
|
+
size: size,
|
|
96
|
+
style: undefined
|
|
88
97
|
}), line.map((token, tokenKey) => React.createElement(StyledCodeBlockToken, Object.assign({}, getTokenProps({
|
|
89
98
|
token
|
|
90
99
|
}), {
|
|
91
100
|
key: tokenKey,
|
|
92
|
-
|
|
93
|
-
}), token.empty ? '\n' : token.content)))));
|
|
101
|
+
style: undefined
|
|
102
|
+
}), token.empty ? '\n' : token.content))))));
|
|
94
103
|
}));
|
|
95
104
|
});
|
|
96
105
|
CodeBlock.displayName = 'CodeBlock';
|
|
97
|
-
CodeBlock.defaultProps = {
|
|
98
|
-
language: 'tsx',
|
|
99
|
-
size: 'medium'
|
|
100
|
-
};
|
|
101
106
|
|
|
102
107
|
export { CodeBlock };
|
|
@@ -19,7 +19,7 @@ import '../../styled/StyledListItem.js';
|
|
|
19
19
|
import '../../styled/StyledParagraph.js';
|
|
20
20
|
|
|
21
21
|
const StartIconComponent = props => React.createElement(StyledIcon, Object.assign({
|
|
22
|
-
isStart: true
|
|
22
|
+
$isStart: true
|
|
23
23
|
}, props));
|
|
24
24
|
StartIconComponent.displayName = 'Span.StartIcon';
|
|
25
25
|
const StartIcon = StartIconComponent;
|
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import styled from 'styled-components';
|
|
8
|
-
import {
|
|
8
|
+
import { getColor, retrieveComponentStyles } from '@zendeskgarden/react-theming';
|
|
9
9
|
import { THEME_SIZES } from './StyledFont.js';
|
|
10
10
|
|
|
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
|
|
14
|
+
'data-garden-version': '9.0.0'
|
|
15
15
|
}).withConfig({
|
|
16
16
|
displayName: "StyledBlockquote",
|
|
17
17
|
componentId: "sc-1tt3ye0-0"
|
|
18
|
-
})(["margin:0;border-", ":", " solid;border-color:", ";padding:0;padding-", ":", "px;direction:", ";& + &,p + &{margin-top:", ";}", ";"], props => props.theme.rtl ? 'right' : 'left', props => props.theme.shadowWidths.sm, props =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
18
|
+
})(["margin:0;border-", ":", " solid;border-color:", ";padding:0;padding-", ":", "px;direction:", ";& + &,p + &{margin-top:", ";}", ";"], props => props.theme.rtl ? 'right' : 'left', props => props.theme.shadowWidths.sm, props => getColor({
|
|
19
|
+
theme: props.theme,
|
|
20
|
+
variable: 'border.default'
|
|
21
|
+
}), props => props.theme.rtl ? 'right' : 'left', props => props.theme.space.base * 4, props => props.theme.rtl ? 'rtl' : 'ltr', props => props.theme.lineHeights[THEME_SIZES[props.size]], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
22
22
|
|
|
23
23
|
export { StyledBlockquote };
|
|
@@ -5,29 +5,61 @@
|
|
|
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 } from './StyledFont.js';
|
|
10
10
|
|
|
11
11
|
const COMPONENT_ID = 'typography.code';
|
|
12
|
-
const colorStyles =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const colorStyles = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
hue,
|
|
15
|
+
theme
|
|
16
|
+
} = _ref;
|
|
17
|
+
const bgColorArgs = {
|
|
18
|
+
theme,
|
|
19
|
+
light: {
|
|
20
|
+
offset: 100
|
|
21
|
+
},
|
|
22
|
+
dark: {
|
|
23
|
+
offset: -100
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const fgColorArgs = {
|
|
27
|
+
theme
|
|
28
|
+
};
|
|
29
|
+
switch (hue) {
|
|
30
|
+
case 'green':
|
|
31
|
+
bgColorArgs.variable = 'background.success';
|
|
32
|
+
fgColorArgs.variable = 'foreground.successEmphasis';
|
|
33
|
+
break;
|
|
34
|
+
case 'red':
|
|
35
|
+
bgColorArgs.variable = 'background.danger';
|
|
36
|
+
fgColorArgs.variable = 'foreground.dangerEmphasis';
|
|
37
|
+
break;
|
|
38
|
+
case 'yellow':
|
|
39
|
+
bgColorArgs.variable = 'background.warning';
|
|
40
|
+
fgColorArgs.variable = 'foreground.warningEmphasis';
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
fgColorArgs.variable = 'foreground.default';
|
|
44
|
+
bgColorArgs.variable = 'background.subtle';
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
const backgroundColor = getColor(bgColorArgs);
|
|
48
|
+
const foregroundColor = getColor(fgColorArgs);
|
|
17
49
|
return css(["background-color:", ";color:", ";a &{color:inherit;}"], backgroundColor, foregroundColor);
|
|
18
50
|
};
|
|
19
51
|
const StyledCode = styled(StyledFont).attrs({
|
|
20
52
|
'data-garden-id': COMPONENT_ID,
|
|
21
|
-
'data-garden-version': '9.0.0
|
|
22
|
-
as: 'code'
|
|
53
|
+
'data-garden-version': '9.0.0',
|
|
54
|
+
as: 'code',
|
|
55
|
+
isMonospace: true
|
|
23
56
|
}).withConfig({
|
|
24
57
|
displayName: "StyledCode",
|
|
25
58
|
componentId: "sc-l8yvmf-0"
|
|
26
59
|
})(["border-radius:", ";padding:1.5px;", ";", ";"], props => props.theme.borderRadii.sm, props => colorStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
27
60
|
StyledCode.defaultProps = {
|
|
28
61
|
theme: DEFAULT_THEME,
|
|
29
|
-
|
|
30
|
-
hue: 'neutralHue',
|
|
62
|
+
hue: 'grey',
|
|
31
63
|
size: 'inherit'
|
|
32
64
|
};
|
|
33
65
|
|
|
@@ -5,23 +5,29 @@
|
|
|
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,
|
|
8
|
+
import { retrieveComponentStyles, 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: 'background.recessed'
|
|
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
|
|
27
|
+
'data-garden-version': '9.0.0'
|
|
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,
|
|
23
|
-
StyledCodeBlock.defaultProps = {
|
|
24
|
-
theme: DEFAULT_THEME
|
|
25
|
-
};
|
|
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));
|
|
26
32
|
|
|
27
33
|
export { StyledCodeBlock };
|
|
@@ -5,20 +5,17 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import styled from 'styled-components';
|
|
8
|
-
import { focusStyles, retrieveComponentStyles
|
|
8
|
+
import { focusStyles, retrieveComponentStyles } from '@zendeskgarden/react-theming';
|
|
9
9
|
|
|
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
|
|
13
|
+
'data-garden-version': '9.0.0'
|
|
14
14
|
}).withConfig({
|
|
15
15
|
displayName: "StyledCodeBlockContainer",
|
|
16
16
|
componentId: "sc-14zgbfw-0"
|
|
17
17
|
})(["transition:box-shadow 0.1s ease-in-out;overflow:auto;", " ", ";"], props => focusStyles({
|
|
18
18
|
theme: props.theme
|
|
19
19
|
}), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
20
|
-
StyledCodeBlockContainer.defaultProps = {
|
|
21
|
-
theme: DEFAULT_THEME
|
|
22
|
-
};
|
|
23
20
|
|
|
24
21
|
export { StyledCodeBlockContainer };
|
|
@@ -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,
|
|
8
|
+
import { retrieveComponentStyles, 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,15 +86,12 @@ 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
|
|
89
|
+
'data-garden-version': '9.0.0',
|
|
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]],
|
|
70
|
-
StyledCodeBlockLine.defaultProps = {
|
|
71
|
-
theme: DEFAULT_THEME
|
|
72
|
-
};
|
|
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));
|
|
73
96
|
|
|
74
97
|
export { StyledCodeBlockLine };
|
|
@@ -5,40 +5,176 @@
|
|
|
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,
|
|
8
|
+
import { retrieveComponentStyles, 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
|
|
174
|
+
'data-garden-version': '9.0.0'
|
|
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,
|
|
40
|
-
StyledCodeBlockToken.defaultProps = {
|
|
41
|
-
theme: DEFAULT_THEME
|
|
42
|
-
};
|
|
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));
|
|
43
179
|
|
|
44
180
|
export { StyledCodeBlockToken };
|
|
@@ -5,18 +5,15 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import styled from 'styled-components';
|
|
8
|
-
import { retrieveComponentStyles
|
|
8
|
+
import { retrieveComponentStyles } from '@zendeskgarden/react-theming';
|
|
9
9
|
|
|
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
|
|
13
|
+
'data-garden-version': '9.0.0'
|
|
14
14
|
}).withConfig({
|
|
15
15
|
displayName: "StyledEllipsis",
|
|
16
16
|
componentId: "sc-1u4uqmy-0"
|
|
17
17
|
})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;direction:", ";", ";"], props => props.theme.rtl ? 'rtl' : 'ltr', props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
18
|
-
StyledEllipsis.defaultProps = {
|
|
19
|
-
theme: DEFAULT_THEME
|
|
20
|
-
};
|
|
21
18
|
|
|
22
19
|
export { StyledEllipsis };
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import styled, { css } from 'styled-components';
|
|
8
8
|
import { hideVisually, math } from 'polished';
|
|
9
|
-
import { retrieveComponentStyles, DEFAULT_THEME,
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
|
|
10
10
|
import { SIZE } from '../types/index.js';
|
|
11
11
|
|
|
12
12
|
const COMPONENT_ID = 'typography.font';
|
|
@@ -19,42 +19,55 @@ const THEME_SIZES = {
|
|
|
19
19
|
'2xlarge': 'xxl',
|
|
20
20
|
'3xlarge': 'xxxl'
|
|
21
21
|
};
|
|
22
|
-
const fontStyles =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const fontStyles = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
hue,
|
|
25
|
+
isBold,
|
|
26
|
+
isMonospace,
|
|
27
|
+
size,
|
|
28
|
+
theme
|
|
29
|
+
} = _ref;
|
|
30
|
+
const monospace = isMonospace && ['inherit', 'small', 'medium', 'large'].indexOf(size) !== -1;
|
|
31
|
+
const fontFamily = monospace && theme.fonts.mono;
|
|
32
|
+
const direction = theme.rtl ? 'rtl' : 'ltr';
|
|
26
33
|
let fontSize;
|
|
27
34
|
let fontWeight;
|
|
28
35
|
let lineHeight;
|
|
29
36
|
let color;
|
|
30
37
|
if (monospace) {
|
|
31
|
-
if (
|
|
38
|
+
if (size === 'inherit') {
|
|
32
39
|
fontSize = 'calc(1em - 1px)';
|
|
33
40
|
lineHeight = 'normal';
|
|
34
41
|
} else {
|
|
35
|
-
const themeSize = THEME_SIZES[
|
|
36
|
-
fontSize = math(`${
|
|
37
|
-
lineHeight = math(`${
|
|
42
|
+
const themeSize = THEME_SIZES[size];
|
|
43
|
+
fontSize = math(`${theme.fontSizes[themeSize]} - 1px`);
|
|
44
|
+
lineHeight = math(`${theme.lineHeights[themeSize]} - 1px`);
|
|
38
45
|
}
|
|
39
|
-
} else if (
|
|
40
|
-
const themeSize = THEME_SIZES[
|
|
41
|
-
fontSize =
|
|
42
|
-
lineHeight =
|
|
46
|
+
} else if (size !== 'inherit') {
|
|
47
|
+
const themeSize = THEME_SIZES[size];
|
|
48
|
+
fontSize = theme.fontSizes[themeSize];
|
|
49
|
+
lineHeight = theme.lineHeights[themeSize];
|
|
43
50
|
}
|
|
44
|
-
if (
|
|
45
|
-
fontWeight =
|
|
46
|
-
} else if (
|
|
47
|
-
fontWeight =
|
|
51
|
+
if (isBold === true) {
|
|
52
|
+
fontWeight = theme.fontWeights.semibold;
|
|
53
|
+
} else if (isBold === false || size !== 'inherit') {
|
|
54
|
+
fontWeight = theme.fontWeights.regular;
|
|
48
55
|
}
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
|
|
56
|
+
if (hue) {
|
|
57
|
+
const options = hue.includes('.') ? {
|
|
58
|
+
variable: hue,
|
|
59
|
+
theme
|
|
60
|
+
} : {
|
|
61
|
+
hue,
|
|
62
|
+
theme
|
|
63
|
+
};
|
|
64
|
+
color = getColor(options);
|
|
52
65
|
}
|
|
53
|
-
return css(["line-height:", ";color:", ";font-family:", ";font-size:", ";font-weight:", ";direction:", ";"], lineHeight, color, fontFamily, fontSize, fontWeight, direction);
|
|
66
|
+
return css(["transition:color 0.1s ease-in-out;line-height:", ";color:", ";font-family:", ";font-size:", ";font-weight:", ";direction:", ";"], lineHeight, color, fontFamily, fontSize, fontWeight, direction);
|
|
54
67
|
};
|
|
55
68
|
const StyledFont = styled.div.attrs({
|
|
56
69
|
'data-garden-id': COMPONENT_ID,
|
|
57
|
-
'data-garden-version': '9.0.0
|
|
70
|
+
'data-garden-version': '9.0.0'
|
|
58
71
|
}).withConfig({
|
|
59
72
|
displayName: "StyledFont",
|
|
60
73
|
componentId: "sc-1iildbo-0"
|