uikit-react-public 0.21.8 → 0.21.9
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/components/Heading/Heading.d.ts +6 -4
- package/dist/components/Heading/Heading.stories.d.ts +8 -6
- package/dist/components/Paragraph/Paragraph.d.ts +5 -2
- package/dist/components/Paragraph/Paragraph.stories.d.ts +6 -3
- package/dist/components/index.d.ts +4 -4
- package/dist/index.js +3852 -3952
- package/lib/components/Heading/Heading.stories.tsx +34 -41
- package/lib/components/Heading/Heading.tsx +180 -49
- package/lib/components/Heading/__tests__/__snapshots__/Heading.test.tsx.snap +4 -4
- package/lib/components/Paragraph/Paragraph.stories.tsx +29 -27
- package/lib/components/Paragraph/Paragraph.tsx +212 -81
- package/lib/components/Paragraph/__tests__/__snapshots__/Paragraph.test.tsx.snap +5 -5
- package/lib/components/index.ts +4 -4
- package/package.json +1 -1
- package/dist/components/HeadingNew/Heading.d.ts +0 -13
- package/dist/components/HeadingNew/index.d.ts +0 -2
- package/dist/components/ParagraphNew/Paragraph.d.ts +0 -13
- package/dist/components/ParagraphNew/index.d.ts +0 -4
- package/lib/components/HeadingNew/Heading.tsx +0 -208
- package/lib/components/HeadingNew/index.ts +0 -2
- package/lib/components/ParagraphNew/Paragraph.tsx +0 -200
- package/lib/components/ParagraphNew/index.ts +0 -6
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { memo, HTMLAttributes, JSX } from 'react';
|
|
2
|
-
import { css, cx } from '@emotion/css';
|
|
3
|
-
import useTheme from '../../theme/useTheme';
|
|
4
|
-
import marginsStyle, { MarginProps } from '../common/marginsStyle';
|
|
5
|
-
|
|
6
|
-
export const NAME = 'ucl-uikit-paragrah';
|
|
7
|
-
|
|
8
|
-
export type ParagraphLevel =
|
|
9
|
-
| 'lg'
|
|
10
|
-
| 'lg-medium'
|
|
11
|
-
| 'lg-semibold'
|
|
12
|
-
| 'lg-bold'
|
|
13
|
-
| 'md'
|
|
14
|
-
| 'md-medium'
|
|
15
|
-
| 'md-semibold'
|
|
16
|
-
| 'md-semibold'
|
|
17
|
-
| 'md-medium-numeric'
|
|
18
|
-
| 'sm'
|
|
19
|
-
| 'sm-medium'
|
|
20
|
-
| 'sm-semibold'
|
|
21
|
-
| 'xs'
|
|
22
|
-
| 'xs-medium';
|
|
23
|
-
|
|
24
|
-
export interface ParagraphBaseProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
25
|
-
level?: ParagraphLevel;
|
|
26
|
-
as?: 'p' | 'div' | 'span';
|
|
27
|
-
testId?: string;
|
|
28
|
-
ref?: React.Ref<HTMLParagraphElement>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type ParagraphProps = ParagraphBaseProps & MarginProps;
|
|
32
|
-
|
|
33
|
-
const Paragraph = ({
|
|
34
|
-
level = 'md',
|
|
35
|
-
as = 'p',
|
|
36
|
-
testId = NAME,
|
|
37
|
-
className,
|
|
38
|
-
ref,
|
|
39
|
-
...props
|
|
40
|
-
}: ParagraphProps) => {
|
|
41
|
-
const [theme] = useTheme();
|
|
42
|
-
|
|
43
|
-
const {
|
|
44
|
-
typography: {
|
|
45
|
-
body: {
|
|
46
|
-
lg,
|
|
47
|
-
lgMedium,
|
|
48
|
-
lgSemibold,
|
|
49
|
-
lgBold,
|
|
50
|
-
md,
|
|
51
|
-
mdMedium,
|
|
52
|
-
mdSemibold,
|
|
53
|
-
mdMediumNumeric,
|
|
54
|
-
sm,
|
|
55
|
-
smMedium,
|
|
56
|
-
smSemibold,
|
|
57
|
-
xs,
|
|
58
|
-
xsMedium,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
} = theme;
|
|
62
|
-
|
|
63
|
-
const baseStyle = css`
|
|
64
|
-
font-family: ${md.fontFamily};
|
|
65
|
-
font-feature-settings: ${md.fontSettings};
|
|
66
|
-
color: ${theme.colour.text.default};
|
|
67
|
-
margin: 0;
|
|
68
|
-
`;
|
|
69
|
-
|
|
70
|
-
const lgStyle = css`
|
|
71
|
-
font-size: ${lg.fontSize}px;
|
|
72
|
-
font-weight: ${lg.fontWeight};
|
|
73
|
-
line-height: ${lg.lineHeight}%;
|
|
74
|
-
`;
|
|
75
|
-
|
|
76
|
-
const lgMediumStyle = css`
|
|
77
|
-
font-size: ${lgMedium.fontSize}px;
|
|
78
|
-
font-weight: ${lgMedium.fontWeight};
|
|
79
|
-
line-height: ${lgMedium.lineHeight}%;
|
|
80
|
-
`;
|
|
81
|
-
|
|
82
|
-
const lgSemiboldStyle = css`
|
|
83
|
-
font-size: ${lgSemibold.fontSize}px;
|
|
84
|
-
font-weight: ${lgSemibold.fontWeight};
|
|
85
|
-
line-height: ${lgSemibold.lineHeight}%;
|
|
86
|
-
`;
|
|
87
|
-
|
|
88
|
-
const lgBoldStyle = css`
|
|
89
|
-
font-size: ${lgBold.fontSize}px;
|
|
90
|
-
font-weight: ${lgBold.fontWeight};
|
|
91
|
-
line-height: ${lgBold.lineHeight}%;
|
|
92
|
-
`;
|
|
93
|
-
|
|
94
|
-
const mdStyle = css`
|
|
95
|
-
font-size: ${md.fontSize}px;
|
|
96
|
-
font-weight: ${md.fontWeight};
|
|
97
|
-
line-height: ${md.lineHeight}%;
|
|
98
|
-
`;
|
|
99
|
-
|
|
100
|
-
const mdMediumStyle = css`
|
|
101
|
-
font-size: ${mdMedium.fontSize}px;
|
|
102
|
-
font-weight: ${mdMedium.fontWeight};
|
|
103
|
-
line-height: ${mdMedium.lineHeight}%;
|
|
104
|
-
`;
|
|
105
|
-
|
|
106
|
-
const mdSemiboldStyle = css`
|
|
107
|
-
font-size: ${mdSemibold.fontSize}px;
|
|
108
|
-
font-weight: ${mdSemibold.fontWeight};
|
|
109
|
-
line-height: ${mdSemibold.lineHeight}%;
|
|
110
|
-
`;
|
|
111
|
-
|
|
112
|
-
const mdMediumNumericStyle = css`
|
|
113
|
-
font-size: ${mdMediumNumeric.fontSize}px;
|
|
114
|
-
font-weight: ${mdMediumNumeric.fontWeight};
|
|
115
|
-
line-height: ${mdMediumNumeric.lineHeight}%;
|
|
116
|
-
`;
|
|
117
|
-
|
|
118
|
-
const smStyle = css`
|
|
119
|
-
font-size: ${sm.fontSize}px;
|
|
120
|
-
font-weight: ${sm.fontWeight};
|
|
121
|
-
line-height: ${sm.lineHeight}%;
|
|
122
|
-
`;
|
|
123
|
-
|
|
124
|
-
const smMediumStyle = css`
|
|
125
|
-
font-size: ${smMedium.fontSize}px;
|
|
126
|
-
font-weight: ${smMedium.fontWeight};
|
|
127
|
-
line-height: ${smMedium.lineHeight}%;
|
|
128
|
-
`;
|
|
129
|
-
|
|
130
|
-
const smSemiboldStyle = css`
|
|
131
|
-
font-size: ${smSemibold.fontSize}px;
|
|
132
|
-
font-weight: ${smSemibold.fontWeight};
|
|
133
|
-
line-height: ${smSemibold.lineHeight}%;
|
|
134
|
-
`;
|
|
135
|
-
|
|
136
|
-
const xsStyle = css`
|
|
137
|
-
font-size: ${xs.fontSize}px;
|
|
138
|
-
font-weight: ${xs.fontWeight};
|
|
139
|
-
line-height: ${xs.lineHeight}%;
|
|
140
|
-
`;
|
|
141
|
-
|
|
142
|
-
const xsMediumStyle = css`
|
|
143
|
-
font-size: ${xsMedium.fontSize}px;
|
|
144
|
-
font-weight: ${xsMedium.fontWeight};
|
|
145
|
-
line-height: ${xsMedium.lineHeight}%;
|
|
146
|
-
`;
|
|
147
|
-
|
|
148
|
-
const style = cx(
|
|
149
|
-
NAME,
|
|
150
|
-
baseStyle,
|
|
151
|
-
level === 'lg' && lgStyle,
|
|
152
|
-
level === 'lg-medium' && lgMediumStyle,
|
|
153
|
-
level === 'lg-semibold' && lgSemiboldStyle,
|
|
154
|
-
level === 'lg-bold' && lgBoldStyle,
|
|
155
|
-
level === 'md' && mdStyle,
|
|
156
|
-
level === 'md-medium' && mdMediumStyle,
|
|
157
|
-
level === 'md-semibold' && mdSemiboldStyle,
|
|
158
|
-
level === 'md-medium-numeric' && mdMediumNumericStyle,
|
|
159
|
-
level === 'sm' && smStyle,
|
|
160
|
-
level === 'sm-medium' && smMediumStyle,
|
|
161
|
-
level === 'sm-semibold' && smSemiboldStyle,
|
|
162
|
-
level === 'xs' && xsStyle,
|
|
163
|
-
level === 'xs-medium' && xsMediumStyle,
|
|
164
|
-
marginsStyle(props, theme),
|
|
165
|
-
className
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
const paragraphTag = as as keyof JSX.IntrinsicElements;
|
|
169
|
-
|
|
170
|
-
return (
|
|
171
|
-
<>
|
|
172
|
-
{paragraphTag === 'p' && (
|
|
173
|
-
<p
|
|
174
|
-
ref={ref}
|
|
175
|
-
className={style}
|
|
176
|
-
data-testid={testId}
|
|
177
|
-
{...props}
|
|
178
|
-
/>
|
|
179
|
-
)}
|
|
180
|
-
{paragraphTag === 'div' && (
|
|
181
|
-
<div
|
|
182
|
-
ref={ref as React.Ref<HTMLDivElement>}
|
|
183
|
-
className={style}
|
|
184
|
-
data-testid={testId}
|
|
185
|
-
{...props}
|
|
186
|
-
/>
|
|
187
|
-
)}
|
|
188
|
-
{paragraphTag === 'span' && (
|
|
189
|
-
<span
|
|
190
|
-
ref={ref as React.Ref<HTMLSpanElement>}
|
|
191
|
-
className={style}
|
|
192
|
-
data-testid={testId}
|
|
193
|
-
{...props}
|
|
194
|
-
/>
|
|
195
|
-
)}
|
|
196
|
-
</>
|
|
197
|
-
);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
export default memo(Paragraph);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { default } from './Paragraph';
|
|
2
|
-
export type { ParagraphProps } from './Paragraph';
|
|
3
|
-
// TODO: Remove aliased export in future breaking release
|
|
4
|
-
// <Paragraph> will be used in place of <Text> in the future
|
|
5
|
-
export { default as Text } from './Paragraph';
|
|
6
|
-
export type { ParagraphProps as TextProps } from './Paragraph';
|