@zendeskgarden/react-typography 9.0.0-next.2 → 9.0.0-next.21
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/Blockquote.js +34 -0
- package/dist/esm/elements/Code.js +43 -0
- package/dist/esm/elements/CodeBlock.js +124 -0
- package/dist/esm/elements/Ellipsis.js +50 -0
- package/dist/esm/elements/LG.js +43 -0
- package/dist/esm/elements/MD.js +43 -0
- package/dist/esm/elements/Paragraph.js +34 -0
- package/dist/esm/elements/SM.js +43 -0
- package/dist/esm/elements/XL.js +42 -0
- package/dist/esm/elements/XXL.js +42 -0
- package/dist/esm/elements/XXXL.js +42 -0
- package/dist/esm/elements/lists/OrderedList.js +53 -0
- package/dist/esm/elements/lists/OrderedListItem.js +34 -0
- package/dist/esm/elements/lists/UnorderedList.js +53 -0
- package/dist/esm/elements/lists/UnorderedListItem.js +34 -0
- package/dist/esm/elements/span/Icon.js +25 -0
- package/dist/esm/elements/span/Span.js +49 -0
- package/dist/esm/elements/span/StartIcon.js +27 -0
- package/dist/esm/index.js +20 -0
- package/dist/esm/styled/StyledBlockquote.js +26 -0
- package/dist/esm/styled/StyledCode.js +66 -0
- package/dist/esm/styled/StyledCodeBlock.js +36 -0
- package/dist/esm/styled/StyledCodeBlockContainer.js +24 -0
- package/dist/esm/styled/StyledCodeBlockLine.js +100 -0
- package/dist/esm/styled/StyledCodeBlockToken.js +183 -0
- package/dist/esm/styled/StyledEllipsis.js +22 -0
- package/dist/esm/styled/StyledFont.js +76 -0
- package/dist/esm/styled/StyledIcon.js +27 -0
- package/dist/esm/styled/StyledList.js +37 -0
- package/dist/esm/styled/StyledListItem.js +48 -0
- package/dist/esm/styled/StyledParagraph.js +23 -0
- package/dist/esm/types/index.js +14 -0
- package/dist/esm/utils/useOrderedListContext.js +18 -0
- package/dist/esm/utils/useUnorderedListContext.js +18 -0
- package/dist/index.cjs.js +377 -162
- package/dist/typings/elements/span/Icon.d.ts +3 -3
- package/dist/typings/elements/span/StartIcon.d.ts +3 -3
- 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 +3 -3
- package/dist/typings/types/index.d.ts +1 -1
- package/package.json +10 -9
- package/dist/index.esm.js +0 -769
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { hideVisually, math } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
|
|
10
|
+
import { SIZE } from '../types/index.js';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_ID = 'typography.font';
|
|
13
|
+
[...SIZE, 'extralarge', '2xlarge', '3xlarge'];
|
|
14
|
+
const THEME_SIZES = {
|
|
15
|
+
small: 'sm',
|
|
16
|
+
medium: 'md',
|
|
17
|
+
large: 'lg',
|
|
18
|
+
extralarge: 'xl',
|
|
19
|
+
'2xlarge': 'xxl',
|
|
20
|
+
'3xlarge': 'xxxl'
|
|
21
|
+
};
|
|
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';
|
|
33
|
+
let fontSize;
|
|
34
|
+
let fontWeight;
|
|
35
|
+
let lineHeight;
|
|
36
|
+
let color;
|
|
37
|
+
if (monospace) {
|
|
38
|
+
if (size === 'inherit') {
|
|
39
|
+
fontSize = 'calc(1em - 1px)';
|
|
40
|
+
lineHeight = 'normal';
|
|
41
|
+
} else {
|
|
42
|
+
const themeSize = THEME_SIZES[size];
|
|
43
|
+
fontSize = math(`${theme.fontSizes[themeSize]} - 1px`);
|
|
44
|
+
lineHeight = math(`${theme.lineHeights[themeSize]} - 1px`);
|
|
45
|
+
}
|
|
46
|
+
} else if (size !== 'inherit') {
|
|
47
|
+
const themeSize = THEME_SIZES[size];
|
|
48
|
+
fontSize = theme.fontSizes[themeSize];
|
|
49
|
+
lineHeight = theme.lineHeights[themeSize];
|
|
50
|
+
}
|
|
51
|
+
if (isBold === true) {
|
|
52
|
+
fontWeight = theme.fontWeights.semibold;
|
|
53
|
+
} else if (isBold === false || size !== 'inherit') {
|
|
54
|
+
fontWeight = theme.fontWeights.regular;
|
|
55
|
+
}
|
|
56
|
+
if (hue) {
|
|
57
|
+
color = getColor({
|
|
58
|
+
hue,
|
|
59
|
+
theme
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return css(["line-height:", ";color:", ";font-family:", ";font-size:", ";font-weight:", ";direction:", ";"], lineHeight, color, fontFamily, fontSize, fontWeight, direction);
|
|
63
|
+
};
|
|
64
|
+
const StyledFont = styled.div.attrs({
|
|
65
|
+
'data-garden-id': COMPONENT_ID,
|
|
66
|
+
'data-garden-version': '9.0.0-next.21'
|
|
67
|
+
}).withConfig({
|
|
68
|
+
displayName: "StyledFont",
|
|
69
|
+
componentId: "sc-1iildbo-0"
|
|
70
|
+
})(["", ";&[hidden]{display:inline;", ";}", ";"], props => !props.hidden && fontStyles(props), hideVisually(), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
71
|
+
StyledFont.defaultProps = {
|
|
72
|
+
theme: DEFAULT_THEME,
|
|
73
|
+
size: 'inherit'
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { StyledFont, THEME_SIZES };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { StyledBaseIcon, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'typography.icon';
|
|
11
|
+
const sizeStyles = props => {
|
|
12
|
+
const margin = props.$isStart && `${props.theme.space.base * 2}px`;
|
|
13
|
+
const size = props.theme.iconSizes.md;
|
|
14
|
+
return css(["margin-", ":", ";width:", ";height:", ";"], props.theme.rtl ? 'left' : 'right', margin, size, size);
|
|
15
|
+
};
|
|
16
|
+
const StyledIcon = styled(StyledBaseIcon).attrs({
|
|
17
|
+
'data-garden-id': COMPONENT_ID,
|
|
18
|
+
'data-garden-version': '9.0.0-next.21'
|
|
19
|
+
}).withConfig({
|
|
20
|
+
displayName: "StyledIcon",
|
|
21
|
+
componentId: "sc-10rfb5b-0"
|
|
22
|
+
})(["position:relative;top:-1px;vertical-align:middle;", ";", ";"], props => sizeStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
23
|
+
StyledIcon.defaultProps = {
|
|
24
|
+
theme: DEFAULT_THEME
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { StyledIcon };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const listStyles = props => {
|
|
11
|
+
const rtl = props.theme.rtl;
|
|
12
|
+
return css(["direction:", ";margin:0;margin-", ":24px;padding:0;list-style-position:outside;list-style-type:", ";"], rtl ? 'rtl' : 'ltr', rtl ? 'right' : 'left', props.listType);
|
|
13
|
+
};
|
|
14
|
+
const ORDERED_ID = 'typography.ordered_list';
|
|
15
|
+
const StyledOrderedList = styled.ol.attrs({
|
|
16
|
+
'data-garden-id': ORDERED_ID,
|
|
17
|
+
'data-garden-version': '9.0.0-next.21'
|
|
18
|
+
}).withConfig({
|
|
19
|
+
displayName: "StyledList__StyledOrderedList",
|
|
20
|
+
componentId: "sc-jdbsfi-0"
|
|
21
|
+
})(["", ";", ";"], props => listStyles(props), props => retrieveComponentStyles(ORDERED_ID, props));
|
|
22
|
+
StyledOrderedList.defaultProps = {
|
|
23
|
+
theme: DEFAULT_THEME
|
|
24
|
+
};
|
|
25
|
+
const UNORDERED_ID = 'typography.unordered_list';
|
|
26
|
+
const StyledUnorderedList = styled.ul.attrs({
|
|
27
|
+
'data-garden-id': UNORDERED_ID,
|
|
28
|
+
'data-garden-version': '9.0.0-next.21'
|
|
29
|
+
}).withConfig({
|
|
30
|
+
displayName: "StyledList__StyledUnorderedList",
|
|
31
|
+
componentId: "sc-jdbsfi-1"
|
|
32
|
+
})(["", ";", ";"], props => listStyles(props), props => retrieveComponentStyles(UNORDERED_ID, props));
|
|
33
|
+
StyledUnorderedList.defaultProps = {
|
|
34
|
+
theme: DEFAULT_THEME
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { StyledOrderedList, StyledUnorderedList };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { math } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getLineHeight } from '@zendeskgarden/react-theming';
|
|
10
|
+
import { StyledOrderedList, StyledUnorderedList } from './StyledList.js';
|
|
11
|
+
import { StyledFont } from './StyledFont.js';
|
|
12
|
+
|
|
13
|
+
const listItemPaddingStyles = props => {
|
|
14
|
+
const base = props.theme.space.base;
|
|
15
|
+
const paddingTop = props.space === 'large' ? `${base * 2}px` : `${base}px`;
|
|
16
|
+
return css(["padding-top:", ";", " > &:first-child,", " > &:first-child{padding-top:0;}", " ", " > &:first-child,", " ", " > &:first-child,", " ", " > &:first-child,", " ", " > &:first-child{padding-top:", ";}"], paddingTop, StyledOrderedList, StyledUnorderedList, StyledOrderedList, StyledOrderedList, StyledOrderedList, StyledUnorderedList, StyledUnorderedList, StyledUnorderedList, StyledUnorderedList, StyledUnorderedList, paddingTop);
|
|
17
|
+
};
|
|
18
|
+
const listItemStyles = props => {
|
|
19
|
+
return css(["line-height:", ";", ";"], getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md), props.space !== 'small' && listItemPaddingStyles(props));
|
|
20
|
+
};
|
|
21
|
+
const ORDERED_ID = 'typography.ordered_list_item';
|
|
22
|
+
const StyledOrderedListItem = styled(StyledFont).attrs({
|
|
23
|
+
'data-garden-id': ORDERED_ID,
|
|
24
|
+
'data-garden-version': '9.0.0-next.21',
|
|
25
|
+
as: 'li'
|
|
26
|
+
}).withConfig({
|
|
27
|
+
displayName: "StyledListItem__StyledOrderedListItem",
|
|
28
|
+
componentId: "sc-9rsipg-0"
|
|
29
|
+
})(["margin-", ":", ";padding-", ":", ";", ";", ";"], props => props.theme.rtl ? 'right' : 'left', props => math(`${props.theme.space.base} * -1px`), props => props.theme.rtl ? 'right' : 'left', props => math(`${props.theme.space.base} * 1px`), props => listItemStyles(props), props => retrieveComponentStyles(ORDERED_ID, props));
|
|
30
|
+
StyledOrderedListItem.defaultProps = {
|
|
31
|
+
space: 'medium',
|
|
32
|
+
theme: DEFAULT_THEME
|
|
33
|
+
};
|
|
34
|
+
const UNORDERED_ID = 'typography.unordered_list_item';
|
|
35
|
+
const StyledUnorderedListItem = styled(StyledFont).attrs({
|
|
36
|
+
'data-garden-id': UNORDERED_ID,
|
|
37
|
+
'data-garden-version': '9.0.0-next.21',
|
|
38
|
+
as: 'li'
|
|
39
|
+
}).withConfig({
|
|
40
|
+
displayName: "StyledListItem__StyledUnorderedListItem",
|
|
41
|
+
componentId: "sc-9rsipg-1"
|
|
42
|
+
})(["", ";", ";"], props => listItemStyles(props), props => retrieveComponentStyles(UNORDERED_ID, props));
|
|
43
|
+
StyledUnorderedListItem.defaultProps = {
|
|
44
|
+
space: 'medium',
|
|
45
|
+
theme: DEFAULT_THEME
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { StyledOrderedListItem, StyledUnorderedListItem };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { THEME_SIZES } from './StyledFont.js';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'typography.paragraph';
|
|
12
|
+
const StyledParagraph = styled.p.attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '9.0.0-next.21'
|
|
15
|
+
}).withConfig({
|
|
16
|
+
displayName: "StyledParagraph",
|
|
17
|
+
componentId: "sc-zkuftz-0"
|
|
18
|
+
})(["margin:0;padding:0;direction:", ";& + &,blockquote + &{margin-top:", ";}", ";"], props => props.theme.rtl ? 'rtl' : 'ltr', props => props.theme.lineHeights[THEME_SIZES[props.size]], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
19
|
+
StyledParagraph.defaultProps = {
|
|
20
|
+
theme: DEFAULT_THEME
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { StyledParagraph };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
const HUE = ['grey', 'red', 'green', 'yellow'];
|
|
8
|
+
const SIZE = ['small', 'medium', 'large'];
|
|
9
|
+
const INHERIT_SIZE = ['inherit', ...SIZE];
|
|
10
|
+
const TYPE_ORDERED_LIST = ['decimal', 'decimal-leading-zero', 'lower-alpha', 'lower-roman', 'upper-alpha', 'upper-roman'];
|
|
11
|
+
const TYPE_UNORDERED_LIST = ['circle', 'disc', 'square'];
|
|
12
|
+
const LANGUAGES = ['bash', 'css', 'diff', 'graphql', 'javascript', 'json', 'jsx', 'markdown', 'markup', 'python', 'typescript', 'tsx', 'yaml'];
|
|
13
|
+
|
|
14
|
+
export { HUE, INHERIT_SIZE, LANGUAGES, SIZE, TYPE_ORDERED_LIST, TYPE_UNORDERED_LIST };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { createContext, useContext } from 'react';
|
|
8
|
+
|
|
9
|
+
const OrderedListContext = createContext(undefined);
|
|
10
|
+
const useOrderedListContext = () => {
|
|
11
|
+
const listContext = useContext(OrderedListContext);
|
|
12
|
+
if (!listContext) {
|
|
13
|
+
throw new Error('This component must be rendered within an `OrderedList` component.');
|
|
14
|
+
}
|
|
15
|
+
return listContext;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { OrderedListContext, useOrderedListContext as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { createContext, useContext } from 'react';
|
|
8
|
+
|
|
9
|
+
const UnorderedListContext = createContext(undefined);
|
|
10
|
+
const useUnorderedListContext = () => {
|
|
11
|
+
const listContext = useContext(UnorderedListContext);
|
|
12
|
+
if (!listContext) {
|
|
13
|
+
throw new Error('This component must be rendered within an `UnorderedList` component.');
|
|
14
|
+
}
|
|
15
|
+
return listContext;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { UnorderedListContext, useUnorderedListContext as default };
|