creactive 0.0.56 → 0.0.57
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/build/index.js +2 -1656
- package/build/index.js.LICENSE.txt +9 -0
- package/build/web.d.ts +1 -0
- package/build/web.js +2 -0
- package/build/web.js.LICENSE.txt +9 -0
- package/package.json +10 -6
- package/source/components/index.ts +0 -2
- package/source/components/text/constants/color.ts +0 -26
- package/source/components/text/constants/font.ts +0 -32
- package/source/components/text/constants/index.ts +0 -5
- package/source/components/text/constants/role.ts +0 -12
- package/source/components/text/constants/text.ts +0 -22
- package/source/components/text/constants/type.ts +0 -27
- package/source/components/text/index.ts +0 -2
- package/source/components/text/spec/children.spec.tsx +0 -13
- package/source/components/text/spec/color.spec.native.tsx +0 -15
- package/source/components/text/spec/color.spec.tsx +0 -159
- package/source/components/text/spec/color.spec.web.tsx +0 -15
- package/source/components/text/spec/font.spec.tsx +0 -196
- package/source/components/text/spec/position.spec.tsx +0 -15
- package/source/components/text/spec/text.spec.native.tsx +0 -1043
- package/source/components/text/spec/text.spec.tsx +0 -39
- package/source/components/text/spec/text.spec.web.tsx +0 -1043
- package/source/components/text/spec/type.spec.web.tsx +0 -55
- package/source/components/text/text.stories.tsx +0 -46
- package/source/components/text/text.tsx +0 -262
- package/source/components/text/text.types.ts +0 -67
- package/source/constants/index.ts +0 -46
- package/source/constants/theme/color.ts +0 -27
- package/source/constants/theme/font.ts +0 -48
- package/source/constants/theme/index.ts +0 -50
- package/source/constants/theme/text.ts +0 -12
- package/source/contexts/index.ts +0 -15
- package/source/contexts/media/components/index.ts +0 -4
- package/source/contexts/media/components/media/index.ts +0 -2
- package/source/contexts/media/components/media/media.tsx +0 -37
- package/source/contexts/media/components/media/media.types.ts +0 -26
- package/source/contexts/media/components/wrapper/index.ts +0 -2
- package/source/contexts/media/components/wrapper/wrapper.tsx +0 -73
- package/source/contexts/media/components/wrapper/wrapper.types.ts +0 -3
- package/source/contexts/media/constants/breakpoint.ts +0 -18
- package/source/contexts/media/constants/index.ts +0 -6
- package/source/contexts/media/hooks/index.ts +0 -1
- package/source/contexts/media/hooks/use-breakpoint.ts +0 -18
- package/source/contexts/media/index.ts +0 -7
- package/source/contexts/media/media.tsx +0 -36
- package/source/contexts/media/media.types.ts +0 -38
- package/source/contexts/theme/index.ts +0 -8
- package/source/contexts/theme/theme.tsx +0 -280
- package/source/contexts/theme/theme.types.ts +0 -284
- package/source/helpers/index.ts +0 -3
- package/source/helpers/storybook/constants/control.ts +0 -25
- package/source/helpers/storybook/constants/index.ts +0 -1
- package/source/helpers/storybook/control.spec.ts +0 -140
- package/source/helpers/storybook/control.ts +0 -115
- package/source/helpers/storybook/index.ts +0 -1
- package/source/helpers/style/index.ts +0 -2
- package/source/helpers/style/style.spec.web.ts +0 -20
- package/source/helpers/style/style.ts +0 -14
- package/source/helpers/style/style.types.ts +0 -14
- package/source/hooks/index.ts +0 -1
- package/source/hooks/use-theme-style-sheet.ts +0 -135
- package/source/index.ts +0 -24
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { faker } from '@faker-js/faker'
|
|
2
|
-
import { render, screen } from '@testing-library/react'
|
|
3
|
-
import { Text } from '../text'
|
|
4
|
-
|
|
5
|
-
describe('@/components/text', () => {
|
|
6
|
-
describe('type passing as property', () => {
|
|
7
|
-
it('renders provided string into DIV tag by default', () => {
|
|
8
|
-
const text = faker.lorem.words(2)
|
|
9
|
-
render(<Text>{text}</Text>)
|
|
10
|
-
expect(screen.getByText(text).tagName).toEqual('DIV')
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('renders H1 tag when same type prop provided', () => {
|
|
14
|
-
const text = faker.lorem.words(2)
|
|
15
|
-
render(<Text type={Text.Type.H1}>{text}</Text>)
|
|
16
|
-
expect(screen.getByText(text).tagName).toEqual('H1')
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('renders H2 tag when same type prop provided', () => {
|
|
20
|
-
const text = faker.lorem.words(2)
|
|
21
|
-
render(<Text type={Text.Type.H2}>{text}</Text>)
|
|
22
|
-
expect(screen.getByText(text).tagName).toEqual('H2')
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it('renders H3 tag when same type prop provided', () => {
|
|
26
|
-
const text = faker.lorem.words(2)
|
|
27
|
-
render(<Text type={Text.Type.H3}>{text}</Text>)
|
|
28
|
-
expect(screen.getByText(text).tagName).toEqual('H3')
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('renders H4 tag when same type prop provided', () => {
|
|
32
|
-
const text = faker.lorem.words(2)
|
|
33
|
-
render(<Text type={Text.Type.H4}>{text}</Text>)
|
|
34
|
-
expect(screen.getByText(text).tagName).toEqual('H4')
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('renders H5 tag when same type prop provided', () => {
|
|
38
|
-
const text = faker.lorem.words(2)
|
|
39
|
-
render(<Text type={Text.Type.H5}>{text}</Text>)
|
|
40
|
-
expect(screen.getByText(text).tagName).toEqual('H5')
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('renders H6 tag when same type prop provided', () => {
|
|
44
|
-
const text = faker.lorem.words(2)
|
|
45
|
-
render(<Text type={Text.Type.H6}>{text}</Text>)
|
|
46
|
-
expect(screen.getByText(text).tagName).toEqual('H6')
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('renders P tag when same type prop provided', () => {
|
|
50
|
-
const text = faker.lorem.words(2)
|
|
51
|
-
render(<Text type={Text.Type.P}>{text}</Text>)
|
|
52
|
-
expect(screen.getByText(text).tagName).toEqual('P')
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
})
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { StorybookControl } from '@/helpers'
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react'
|
|
3
|
-
import { Text } from './text'
|
|
4
|
-
|
|
5
|
-
const typeControl = StorybookControl.fromNumericEnum(Text.Type, true)
|
|
6
|
-
const alignControl = StorybookControl.fromNumericEnum(Text.Align, true)
|
|
7
|
-
const fontWeightControl = StorybookControl.fromNumericEnum(
|
|
8
|
-
Text.FontWeight,
|
|
9
|
-
true
|
|
10
|
-
)
|
|
11
|
-
const fontSizeControl = StorybookControl.fromNumericEnum(Text.FontSize, true)
|
|
12
|
-
const lineHeightControl = StorybookControl.fromNumericEnum(
|
|
13
|
-
Text.LineHeight,
|
|
14
|
-
true
|
|
15
|
-
)
|
|
16
|
-
const maxLinesControl = StorybookControl.forNumber()
|
|
17
|
-
const colorControl = StorybookControl.fromNumericEnum(Text.Color, true)
|
|
18
|
-
const childrenControl = StorybookControl.forChildren()
|
|
19
|
-
|
|
20
|
-
const meta: Meta<typeof Text> = {
|
|
21
|
-
component: Text,
|
|
22
|
-
decorators: [StorybookControl.getDecorator()],
|
|
23
|
-
argTypes: {
|
|
24
|
-
type: typeControl,
|
|
25
|
-
align: alignControl,
|
|
26
|
-
fontWeight: fontWeightControl,
|
|
27
|
-
fontSize: fontSizeControl,
|
|
28
|
-
lineHeight: lineHeightControl,
|
|
29
|
-
maxLines: maxLinesControl,
|
|
30
|
-
color: colorControl,
|
|
31
|
-
children: childrenControl,
|
|
32
|
-
},
|
|
33
|
-
args: {
|
|
34
|
-
type: typeControl.defaultValue,
|
|
35
|
-
align: alignControl.defaultValue,
|
|
36
|
-
fontWeight: fontWeightControl.defaultValue,
|
|
37
|
-
fontSize: fontSizeControl.defaultValue,
|
|
38
|
-
lineHeight: lineHeightControl.defaultValue,
|
|
39
|
-
maxLines: maxLinesControl.defaultValue,
|
|
40
|
-
color: colorControl.defaultValue,
|
|
41
|
-
children: childrenControl.defaultValue,
|
|
42
|
-
},
|
|
43
|
-
}
|
|
44
|
-
export default meta
|
|
45
|
-
|
|
46
|
-
export const DefaultState: StoryObj<typeof Text> = {}
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import { useThemeContext } from '@/contexts'
|
|
2
|
-
import { useThemeStyleSheet } from '@/hooks'
|
|
3
|
-
import { useMemo } from 'react'
|
|
4
|
-
import type { Role } from 'react-native'
|
|
5
|
-
import { Text as ReactNativeText, StyleSheet } from 'react-native'
|
|
6
|
-
import {
|
|
7
|
-
TEXT_TYPE_HEADING,
|
|
8
|
-
TextAlign,
|
|
9
|
-
TextColor,
|
|
10
|
-
TextFontSize,
|
|
11
|
-
TextFontWeight,
|
|
12
|
-
TextLineHeight,
|
|
13
|
-
TextRole,
|
|
14
|
-
TextType,
|
|
15
|
-
} from './constants'
|
|
16
|
-
import type { TextComponent } from './text.types'
|
|
17
|
-
|
|
18
|
-
const textStyleSheet = StyleSheet.create({
|
|
19
|
-
// To override default position style.
|
|
20
|
-
// Better match with web default behavior.
|
|
21
|
-
textPositionStatic: {
|
|
22
|
-
position: 'static',
|
|
23
|
-
},
|
|
24
|
-
textAlignLeft: {
|
|
25
|
-
textAlign: 'left',
|
|
26
|
-
},
|
|
27
|
-
textAlignCenter: {
|
|
28
|
-
textAlign: 'center',
|
|
29
|
-
},
|
|
30
|
-
textAlignRight: {
|
|
31
|
-
textAlign: 'right',
|
|
32
|
-
},
|
|
33
|
-
textColorTransparent: {
|
|
34
|
-
// Is a shortcut for rgba(0,0,0,0) in React Native, same like in CSS3.
|
|
35
|
-
// We don't use this style when animating, so it is won't be a problem.
|
|
36
|
-
color: 'transparent',
|
|
37
|
-
},
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
const lineHeightStyleSheetCache = new Map()
|
|
41
|
-
const getLineHeightStyleSheet = (fontSize: number, lineHeight: number) => {
|
|
42
|
-
const cacheKey = [fontSize, lineHeight].join('-')
|
|
43
|
-
if (lineHeightStyleSheetCache.has(cacheKey)) {
|
|
44
|
-
return lineHeightStyleSheetCache.get(cacheKey)
|
|
45
|
-
}
|
|
46
|
-
const lineHeightStyleSheet = StyleSheet.create({
|
|
47
|
-
textLineHeight: {
|
|
48
|
-
lineHeight: fontSize * lineHeight,
|
|
49
|
-
},
|
|
50
|
-
})
|
|
51
|
-
lineHeightStyleSheetCache.set(cacheKey, lineHeightStyleSheet)
|
|
52
|
-
return lineHeightStyleSheet
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const Text: TextComponent = ({
|
|
56
|
-
type,
|
|
57
|
-
align = TextAlign.LEFT,
|
|
58
|
-
fontWeight = TextFontWeight.REGULAR,
|
|
59
|
-
fontSize = TextFontSize.MD,
|
|
60
|
-
lineHeight = TextLineHeight.NONE,
|
|
61
|
-
maxLines,
|
|
62
|
-
color = TextColor.BASE_800,
|
|
63
|
-
children,
|
|
64
|
-
}) => {
|
|
65
|
-
const themeContext = useThemeContext()
|
|
66
|
-
const themeStyleSheet = useThemeStyleSheet()
|
|
67
|
-
|
|
68
|
-
const getRole = () => {
|
|
69
|
-
// Casting paragraph role type because it is supported by react-native-web.
|
|
70
|
-
// As a result - text would be rendered to paragraph tag...
|
|
71
|
-
if (TextType.P === type) return TextRole.PARAGRAPH as Role
|
|
72
|
-
if (TEXT_TYPE_HEADING.includes(type)) return TextRole.HEADING
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const getAriaLevel = () => {
|
|
76
|
-
if (TEXT_TYPE_HEADING.includes(type)) {
|
|
77
|
-
if (type === TextType.H1) return 1
|
|
78
|
-
if (type === TextType.H2) return 2
|
|
79
|
-
if (type === TextType.H3) return 3
|
|
80
|
-
if (type === TextType.H4) return 4
|
|
81
|
-
if (type === TextType.H5) return 5
|
|
82
|
-
if (type === TextType.H6) return 6
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const getAlignStyle = () => {
|
|
87
|
-
switch (align) {
|
|
88
|
-
case TextAlign.LEFT:
|
|
89
|
-
return textStyleSheet.textAlignLeft
|
|
90
|
-
case TextAlign.CENTER:
|
|
91
|
-
return textStyleSheet.textAlignCenter
|
|
92
|
-
case TextAlign.RIGHT:
|
|
93
|
-
return textStyleSheet.textAlignRight
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const getFontWeightStyle = () => {
|
|
98
|
-
switch (fontWeight) {
|
|
99
|
-
case TextFontWeight.THIN:
|
|
100
|
-
return themeStyleSheet.fontWeightBaseThin
|
|
101
|
-
case TextFontWeight.EXTRA_LIGHT:
|
|
102
|
-
return themeStyleSheet.fontWeightBaseExtraLight
|
|
103
|
-
case TextFontWeight.LIGHT:
|
|
104
|
-
return themeStyleSheet.fontWeightBaseLight
|
|
105
|
-
case TextFontWeight.REGULAR:
|
|
106
|
-
return themeStyleSheet.fontWeightBaseRegular
|
|
107
|
-
case TextFontWeight.MEDIUM:
|
|
108
|
-
return themeStyleSheet.fontWeightBaseMedium
|
|
109
|
-
case TextFontWeight.SEMIBOLD:
|
|
110
|
-
return themeStyleSheet.fontWeightBaseSemibold
|
|
111
|
-
case TextFontWeight.BOLD:
|
|
112
|
-
return themeStyleSheet.fontWeightBaseBold
|
|
113
|
-
case TextFontWeight.EXTRA_BOLD:
|
|
114
|
-
return themeStyleSheet.fontWeightBaseExtraBold
|
|
115
|
-
case TextFontWeight.BLACK:
|
|
116
|
-
return themeStyleSheet.fontWeightBaseBlack
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const getFontSizeStyle = () => {
|
|
121
|
-
switch (fontSize) {
|
|
122
|
-
case TextFontSize.X2S:
|
|
123
|
-
return themeStyleSheet.fontSizeBaseX2S
|
|
124
|
-
case TextFontSize.XS:
|
|
125
|
-
return themeStyleSheet.fontSizeBaseXS
|
|
126
|
-
case TextFontSize.SM:
|
|
127
|
-
return themeStyleSheet.fontSizeBaseSM
|
|
128
|
-
case TextFontSize.MD:
|
|
129
|
-
return themeStyleSheet.fontSizeBaseMD
|
|
130
|
-
case TextFontSize.LG:
|
|
131
|
-
return themeStyleSheet.fontSizeBaseLG
|
|
132
|
-
case TextFontSize.XL:
|
|
133
|
-
return themeStyleSheet.fontSizeBaseXL
|
|
134
|
-
case TextFontSize.X2L:
|
|
135
|
-
return themeStyleSheet.fontSizeBaseX2L
|
|
136
|
-
case TextFontSize.X3L:
|
|
137
|
-
return themeStyleSheet.fontSizeBaseX3L
|
|
138
|
-
case TextFontSize.X4L:
|
|
139
|
-
return themeStyleSheet.fontSizeBaseX4L
|
|
140
|
-
case TextFontSize.X5L:
|
|
141
|
-
return themeStyleSheet.fontSizeBaseX5L
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const lineHeightStyle = useMemo(() => {
|
|
146
|
-
const getFontSizeTokenValue = () => {
|
|
147
|
-
switch (fontSize) {
|
|
148
|
-
case TextFontSize.X2S:
|
|
149
|
-
return themeContext.fontSizeBaseX2S
|
|
150
|
-
case TextFontSize.XS:
|
|
151
|
-
return themeContext.fontSizeBaseXS
|
|
152
|
-
case TextFontSize.SM:
|
|
153
|
-
return themeContext.fontSizeBaseSM
|
|
154
|
-
case TextFontSize.MD:
|
|
155
|
-
return themeContext.fontSizeBaseMD
|
|
156
|
-
case TextFontSize.LG:
|
|
157
|
-
return themeContext.fontSizeBaseLG
|
|
158
|
-
case TextFontSize.XL:
|
|
159
|
-
return themeContext.fontSizeBaseXL
|
|
160
|
-
case TextFontSize.X2L:
|
|
161
|
-
return themeContext.fontSizeBaseX2L
|
|
162
|
-
case TextFontSize.X3L:
|
|
163
|
-
return themeContext.fontSizeBaseX3L
|
|
164
|
-
case TextFontSize.X4L:
|
|
165
|
-
return themeContext.fontSizeBaseX4L
|
|
166
|
-
case TextFontSize.X5L:
|
|
167
|
-
return themeContext.fontSizeBaseX5L
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const getLineHeightTokenValue = () => {
|
|
172
|
-
switch (lineHeight) {
|
|
173
|
-
case TextLineHeight.NONE:
|
|
174
|
-
return themeContext.lineHeightBaseNone
|
|
175
|
-
case TextLineHeight.TIGHT:
|
|
176
|
-
return themeContext.lineHeightBaseTight
|
|
177
|
-
case TextLineHeight.SNUG:
|
|
178
|
-
return themeContext.lineHeightBaseSnug
|
|
179
|
-
case TextLineHeight.NORMAL:
|
|
180
|
-
return themeContext.lineHeightBaseNormal
|
|
181
|
-
case TextLineHeight.RELAXED:
|
|
182
|
-
return themeContext.lineHeightBaseRelaxed
|
|
183
|
-
case TextLineHeight.LOOSE:
|
|
184
|
-
return themeContext.lineHeightBaseLoose
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const lineHeightStyleSheet = getLineHeightStyleSheet(
|
|
189
|
-
getFontSizeTokenValue(),
|
|
190
|
-
getLineHeightTokenValue()
|
|
191
|
-
)
|
|
192
|
-
return lineHeightStyleSheet.textLineHeight
|
|
193
|
-
}, [fontSize, lineHeight, themeContext])
|
|
194
|
-
|
|
195
|
-
const getColorStyle = () => {
|
|
196
|
-
switch (color) {
|
|
197
|
-
case TextColor.TRANSPARENT:
|
|
198
|
-
return textStyleSheet.textColorTransparent
|
|
199
|
-
case TextColor.BASE_100:
|
|
200
|
-
return themeStyleSheet.colorForegroundBase100
|
|
201
|
-
case TextColor.BASE_200:
|
|
202
|
-
return themeStyleSheet.colorForegroundBase200
|
|
203
|
-
case TextColor.BASE_300:
|
|
204
|
-
return themeStyleSheet.colorForegroundBase300
|
|
205
|
-
case TextColor.BASE_400:
|
|
206
|
-
return themeStyleSheet.colorForegroundBase400
|
|
207
|
-
case TextColor.BASE_500:
|
|
208
|
-
return themeStyleSheet.colorForegroundBase500
|
|
209
|
-
case TextColor.BASE_600:
|
|
210
|
-
return themeStyleSheet.colorForegroundBase600
|
|
211
|
-
case TextColor.BASE_700:
|
|
212
|
-
return themeStyleSheet.colorForegroundBase700
|
|
213
|
-
case TextColor.BASE_800:
|
|
214
|
-
return themeStyleSheet.colorForegroundBase800
|
|
215
|
-
case TextColor.BASE_900:
|
|
216
|
-
return themeStyleSheet.colorForegroundBase900
|
|
217
|
-
case TextColor.INVERSE_100:
|
|
218
|
-
return themeStyleSheet.colorForegroundInverse100
|
|
219
|
-
case TextColor.INVERSE_200:
|
|
220
|
-
return themeStyleSheet.colorForegroundInverse200
|
|
221
|
-
case TextColor.INVERSE_300:
|
|
222
|
-
return themeStyleSheet.colorForegroundInverse300
|
|
223
|
-
case TextColor.INVERSE_400:
|
|
224
|
-
return themeStyleSheet.colorForegroundInverse400
|
|
225
|
-
case TextColor.INVERSE_500:
|
|
226
|
-
return themeStyleSheet.colorForegroundInverse500
|
|
227
|
-
case TextColor.INVERSE_600:
|
|
228
|
-
return themeStyleSheet.colorForegroundInverse600
|
|
229
|
-
case TextColor.INVERSE_700:
|
|
230
|
-
return themeStyleSheet.colorForegroundInverse700
|
|
231
|
-
case TextColor.INVERSE_800:
|
|
232
|
-
return themeStyleSheet.colorForegroundInverse800
|
|
233
|
-
case TextColor.INVERSE_900:
|
|
234
|
-
return themeStyleSheet.colorForegroundInverse900
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return (
|
|
239
|
-
<ReactNativeText
|
|
240
|
-
role={getRole()}
|
|
241
|
-
aria-level={getAriaLevel()}
|
|
242
|
-
style={[
|
|
243
|
-
textStyleSheet.textPositionStatic,
|
|
244
|
-
themeStyleSheet.fontFamilyBase,
|
|
245
|
-
getAlignStyle(),
|
|
246
|
-
getFontWeightStyle(),
|
|
247
|
-
getFontSizeStyle(),
|
|
248
|
-
lineHeightStyle,
|
|
249
|
-
getColorStyle(),
|
|
250
|
-
]}
|
|
251
|
-
numberOfLines={maxLines}
|
|
252
|
-
>
|
|
253
|
-
{children}
|
|
254
|
-
</ReactNativeText>
|
|
255
|
-
)
|
|
256
|
-
}
|
|
257
|
-
Text.Type = TextType
|
|
258
|
-
Text.Align = TextAlign
|
|
259
|
-
Text.FontWeight = TextFontWeight
|
|
260
|
-
Text.FontSize = TextFontSize
|
|
261
|
-
Text.LineHeight = TextLineHeight
|
|
262
|
-
Text.Color = TextColor
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { FunctionComponent, PropsWithChildren } from 'react'
|
|
2
|
-
import type {
|
|
3
|
-
TextAlign,
|
|
4
|
-
TextColor,
|
|
5
|
-
TextFontSize,
|
|
6
|
-
TextFontWeight,
|
|
7
|
-
TextLineHeight,
|
|
8
|
-
TextType,
|
|
9
|
-
} from './constants'
|
|
10
|
-
|
|
11
|
-
export interface TextProps extends PropsWithChildren {
|
|
12
|
-
/**
|
|
13
|
-
* Specific text type if required.
|
|
14
|
-
* Affects appearance, accessibility and semantics.
|
|
15
|
-
* Allows to control HTML element, that will be to rendered.
|
|
16
|
-
* @default undefined - renders into DIV element
|
|
17
|
-
*/
|
|
18
|
-
type?: TextType
|
|
19
|
-
/**
|
|
20
|
-
* Text component align control property.
|
|
21
|
-
* Inner text will be aligned according to this value.
|
|
22
|
-
* @default Text.Align.LEFT
|
|
23
|
-
*/
|
|
24
|
-
align?: TextAlign
|
|
25
|
-
/**
|
|
26
|
-
* Font weight property.
|
|
27
|
-
* Changes font weight, depending on theme.
|
|
28
|
-
* Uses base font weight tokens for mapping.
|
|
29
|
-
* @default Text.FontWeight.REGULAR
|
|
30
|
-
*/
|
|
31
|
-
fontWeight?: TextFontWeight
|
|
32
|
-
/**
|
|
33
|
-
* Specific text size if required.
|
|
34
|
-
* Will change text size, depending on theme.
|
|
35
|
-
* Uses base font size tokens for mapping.
|
|
36
|
-
* @default Text.FontSize.MD
|
|
37
|
-
*/
|
|
38
|
-
fontSize?: TextFontSize
|
|
39
|
-
/**
|
|
40
|
-
* Text line height property.
|
|
41
|
-
* Depends on configured theme token.
|
|
42
|
-
* Calculates using base font size and base line height ratio.
|
|
43
|
-
* @default Text.LineHeight.NONE
|
|
44
|
-
*/
|
|
45
|
-
lineHeight?: TextLineHeight
|
|
46
|
-
/**
|
|
47
|
-
* Limiting text lines count.
|
|
48
|
-
* Text will be truncated with an ellipsis after specified lines count.
|
|
49
|
-
* @default undefined
|
|
50
|
-
*/
|
|
51
|
-
maxLines?: number
|
|
52
|
-
/**
|
|
53
|
-
* Specifying text color property.
|
|
54
|
-
* Allows to change color, depending on theme.
|
|
55
|
-
* Theme independent colors and values may be also available.
|
|
56
|
-
* @default Text.Color.BASE_800
|
|
57
|
-
*/
|
|
58
|
-
color?: TextColor
|
|
59
|
-
}
|
|
60
|
-
export type TextComponent = FunctionComponent<TextProps> & {
|
|
61
|
-
Type: Record<keyof typeof TextType, TextType>
|
|
62
|
-
Align: Record<keyof typeof TextAlign, TextAlign>
|
|
63
|
-
FontWeight: Record<keyof typeof TextFontWeight, TextFontWeight>
|
|
64
|
-
FontSize: Record<keyof typeof TextFontSize, TextFontSize>
|
|
65
|
-
LineHeight: Record<keyof typeof TextLineHeight, TextLineHeight>
|
|
66
|
-
Color: Record<keyof typeof TextColor, TextColor>
|
|
67
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
COLOR_FOREGROUND_BASE_100,
|
|
3
|
-
COLOR_FOREGROUND_BASE_200,
|
|
4
|
-
COLOR_FOREGROUND_BASE_300,
|
|
5
|
-
COLOR_FOREGROUND_BASE_400,
|
|
6
|
-
COLOR_FOREGROUND_BASE_500,
|
|
7
|
-
COLOR_FOREGROUND_BASE_600,
|
|
8
|
-
COLOR_FOREGROUND_BASE_700,
|
|
9
|
-
COLOR_FOREGROUND_BASE_800,
|
|
10
|
-
COLOR_FOREGROUND_BASE_900,
|
|
11
|
-
COLOR_FOREGROUND_INVERSE_100,
|
|
12
|
-
COLOR_FOREGROUND_INVERSE_200,
|
|
13
|
-
COLOR_FOREGROUND_INVERSE_300,
|
|
14
|
-
COLOR_FOREGROUND_INVERSE_400,
|
|
15
|
-
COLOR_FOREGROUND_INVERSE_500,
|
|
16
|
-
COLOR_FOREGROUND_INVERSE_600,
|
|
17
|
-
COLOR_FOREGROUND_INVERSE_700,
|
|
18
|
-
COLOR_FOREGROUND_INVERSE_800,
|
|
19
|
-
COLOR_FOREGROUND_INVERSE_900,
|
|
20
|
-
FONT_FAMILY_BASE,
|
|
21
|
-
FONT_SIZE_BASE_LG,
|
|
22
|
-
FONT_SIZE_BASE_MD,
|
|
23
|
-
FONT_SIZE_BASE_SM,
|
|
24
|
-
FONT_SIZE_BASE_X2L,
|
|
25
|
-
FONT_SIZE_BASE_X2S,
|
|
26
|
-
FONT_SIZE_BASE_X3L,
|
|
27
|
-
FONT_SIZE_BASE_X4L,
|
|
28
|
-
FONT_SIZE_BASE_X5L,
|
|
29
|
-
FONT_SIZE_BASE_XL,
|
|
30
|
-
FONT_SIZE_BASE_XS,
|
|
31
|
-
FONT_WEIGHT_BASE_BLACK,
|
|
32
|
-
FONT_WEIGHT_BASE_BOLD,
|
|
33
|
-
FONT_WEIGHT_BASE_EXTRABOLD,
|
|
34
|
-
FONT_WEIGHT_BASE_EXTRALIGHT,
|
|
35
|
-
FONT_WEIGHT_BASE_LIGHT,
|
|
36
|
-
FONT_WEIGHT_BASE_MEDIUM,
|
|
37
|
-
FONT_WEIGHT_BASE_REGULAR,
|
|
38
|
-
FONT_WEIGHT_BASE_SEMIBOLD,
|
|
39
|
-
FONT_WEIGHT_BASE_THIN,
|
|
40
|
-
LINE_HEIGHT_BASE_LOOSE,
|
|
41
|
-
LINE_HEIGHT_BASE_NONE,
|
|
42
|
-
LINE_HEIGHT_BASE_NORMAL,
|
|
43
|
-
LINE_HEIGHT_BASE_RELAXED,
|
|
44
|
-
LINE_HEIGHT_BASE_SNUG,
|
|
45
|
-
LINE_HEIGHT_BASE_TIGHT,
|
|
46
|
-
} from '@/constants/theme'
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base foreground color constants.
|
|
3
|
-
* Use it for coloring text, icons and etc.
|
|
4
|
-
*/
|
|
5
|
-
export const COLOR_FOREGROUND_BASE_100 = 'rgb(244,244,245)'
|
|
6
|
-
export const COLOR_FOREGROUND_BASE_200 = 'rgb(228,228,231)'
|
|
7
|
-
export const COLOR_FOREGROUND_BASE_300 = 'rgb(212,212,216)'
|
|
8
|
-
export const COLOR_FOREGROUND_BASE_400 = 'rgb(159,159,169)'
|
|
9
|
-
export const COLOR_FOREGROUND_BASE_500 = 'rgb(113,113,123)'
|
|
10
|
-
export const COLOR_FOREGROUND_BASE_600 = 'rgb(82,82,92)'
|
|
11
|
-
export const COLOR_FOREGROUND_BASE_700 = 'rgb(63,63,70)'
|
|
12
|
-
export const COLOR_FOREGROUND_BASE_800 = 'rgb(39,39,42)'
|
|
13
|
-
export const COLOR_FOREGROUND_BASE_900 = 'rgb(24,24,27)'
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Inverse foreground color constants.
|
|
17
|
-
* Use it for coloring inversed elements.
|
|
18
|
-
*/
|
|
19
|
-
export const COLOR_FOREGROUND_INVERSE_100 = 'rgb(24,24,27)'
|
|
20
|
-
export const COLOR_FOREGROUND_INVERSE_200 = 'rgb(39,39,42)'
|
|
21
|
-
export const COLOR_FOREGROUND_INVERSE_300 = 'rgb(63,63,70)'
|
|
22
|
-
export const COLOR_FOREGROUND_INVERSE_400 = 'rgb(82,82,92)'
|
|
23
|
-
export const COLOR_FOREGROUND_INVERSE_500 = 'rgb(113,113,123)'
|
|
24
|
-
export const COLOR_FOREGROUND_INVERSE_600 = 'rgb(159,159,169)'
|
|
25
|
-
export const COLOR_FOREGROUND_INVERSE_700 = 'rgb(212,212,216)'
|
|
26
|
-
export const COLOR_FOREGROUND_INVERSE_800 = 'rgb(228,228,231)'
|
|
27
|
-
export const COLOR_FOREGROUND_INVERSE_900 = 'rgb(244,244,245)'
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base font family constant.
|
|
3
|
-
* Supposed to be used for styling text.
|
|
4
|
-
* Maybe we'll need som extra font family in future..
|
|
5
|
-
*/
|
|
6
|
-
export const FONT_FAMILY_BASE = [
|
|
7
|
-
'ui-sans-serif',
|
|
8
|
-
'-apple-system',
|
|
9
|
-
'BlinkMacSystemFont',
|
|
10
|
-
'"Segoe UI"',
|
|
11
|
-
'Roboto',
|
|
12
|
-
'Helvetica',
|
|
13
|
-
'Arial',
|
|
14
|
-
'sans-serif',
|
|
15
|
-
].join(',')
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Base font weight constants.
|
|
19
|
-
* Supposed to be used for styling text.
|
|
20
|
-
* It seems like we wont need an extra set of font weights.
|
|
21
|
-
* But we named them as base just in case, you know..
|
|
22
|
-
*/
|
|
23
|
-
export const FONT_WEIGHT_BASE_THIN = 100
|
|
24
|
-
export const FONT_WEIGHT_BASE_EXTRALIGHT = 200
|
|
25
|
-
export const FONT_WEIGHT_BASE_LIGHT = 300
|
|
26
|
-
export const FONT_WEIGHT_BASE_REGULAR = 400
|
|
27
|
-
export const FONT_WEIGHT_BASE_MEDIUM = 500
|
|
28
|
-
export const FONT_WEIGHT_BASE_SEMIBOLD = 600
|
|
29
|
-
export const FONT_WEIGHT_BASE_BOLD = 700
|
|
30
|
-
export const FONT_WEIGHT_BASE_EXTRABOLD = 800
|
|
31
|
-
export const FONT_WEIGHT_BASE_BLACK = 900
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Base font size constants.
|
|
35
|
-
* Supposed to be used for styling text.
|
|
36
|
-
* It seems like we wont need an extra set of font sizes.
|
|
37
|
-
* But we named them as base just in case also..
|
|
38
|
-
*/
|
|
39
|
-
export const FONT_SIZE_BASE_X2S = 12
|
|
40
|
-
export const FONT_SIZE_BASE_XS = 14
|
|
41
|
-
export const FONT_SIZE_BASE_SM = 16
|
|
42
|
-
export const FONT_SIZE_BASE_MD = 18
|
|
43
|
-
export const FONT_SIZE_BASE_LG = 20
|
|
44
|
-
export const FONT_SIZE_BASE_XL = 24
|
|
45
|
-
export const FONT_SIZE_BASE_X2L = 30
|
|
46
|
-
export const FONT_SIZE_BASE_X3L = 36
|
|
47
|
-
export const FONT_SIZE_BASE_X4L = 48
|
|
48
|
-
export const FONT_SIZE_BASE_X5L = 60
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
COLOR_FOREGROUND_BASE_100,
|
|
3
|
-
COLOR_FOREGROUND_BASE_200,
|
|
4
|
-
COLOR_FOREGROUND_BASE_300,
|
|
5
|
-
COLOR_FOREGROUND_BASE_400,
|
|
6
|
-
COLOR_FOREGROUND_BASE_500,
|
|
7
|
-
COLOR_FOREGROUND_BASE_600,
|
|
8
|
-
COLOR_FOREGROUND_BASE_700,
|
|
9
|
-
COLOR_FOREGROUND_BASE_800,
|
|
10
|
-
COLOR_FOREGROUND_BASE_900,
|
|
11
|
-
COLOR_FOREGROUND_INVERSE_100,
|
|
12
|
-
COLOR_FOREGROUND_INVERSE_200,
|
|
13
|
-
COLOR_FOREGROUND_INVERSE_300,
|
|
14
|
-
COLOR_FOREGROUND_INVERSE_400,
|
|
15
|
-
COLOR_FOREGROUND_INVERSE_500,
|
|
16
|
-
COLOR_FOREGROUND_INVERSE_600,
|
|
17
|
-
COLOR_FOREGROUND_INVERSE_700,
|
|
18
|
-
COLOR_FOREGROUND_INVERSE_800,
|
|
19
|
-
COLOR_FOREGROUND_INVERSE_900,
|
|
20
|
-
} from './color'
|
|
21
|
-
export {
|
|
22
|
-
FONT_FAMILY_BASE,
|
|
23
|
-
FONT_SIZE_BASE_LG,
|
|
24
|
-
FONT_SIZE_BASE_MD,
|
|
25
|
-
FONT_SIZE_BASE_SM,
|
|
26
|
-
FONT_SIZE_BASE_X2L,
|
|
27
|
-
FONT_SIZE_BASE_X2S,
|
|
28
|
-
FONT_SIZE_BASE_X3L,
|
|
29
|
-
FONT_SIZE_BASE_X4L,
|
|
30
|
-
FONT_SIZE_BASE_X5L,
|
|
31
|
-
FONT_SIZE_BASE_XL,
|
|
32
|
-
FONT_SIZE_BASE_XS,
|
|
33
|
-
FONT_WEIGHT_BASE_BLACK,
|
|
34
|
-
FONT_WEIGHT_BASE_BOLD,
|
|
35
|
-
FONT_WEIGHT_BASE_EXTRABOLD,
|
|
36
|
-
FONT_WEIGHT_BASE_EXTRALIGHT,
|
|
37
|
-
FONT_WEIGHT_BASE_LIGHT,
|
|
38
|
-
FONT_WEIGHT_BASE_MEDIUM,
|
|
39
|
-
FONT_WEIGHT_BASE_REGULAR,
|
|
40
|
-
FONT_WEIGHT_BASE_SEMIBOLD,
|
|
41
|
-
FONT_WEIGHT_BASE_THIN,
|
|
42
|
-
} from './font'
|
|
43
|
-
export {
|
|
44
|
-
LINE_HEIGHT_BASE_LOOSE,
|
|
45
|
-
LINE_HEIGHT_BASE_NONE,
|
|
46
|
-
LINE_HEIGHT_BASE_NORMAL,
|
|
47
|
-
LINE_HEIGHT_BASE_RELAXED,
|
|
48
|
-
LINE_HEIGHT_BASE_SNUG,
|
|
49
|
-
LINE_HEIGHT_BASE_TIGHT,
|
|
50
|
-
} from './text'
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base text line height constants.
|
|
3
|
-
* Supposed to be used for styling text.
|
|
4
|
-
* It seems like we wont need an extra set of line heights.
|
|
5
|
-
* But we named them as base just in case also..
|
|
6
|
-
*/
|
|
7
|
-
export const LINE_HEIGHT_BASE_NONE = 1
|
|
8
|
-
export const LINE_HEIGHT_BASE_TIGHT = 1.25
|
|
9
|
-
export const LINE_HEIGHT_BASE_SNUG = 1.375
|
|
10
|
-
export const LINE_HEIGHT_BASE_NORMAL = 1.5
|
|
11
|
-
export const LINE_HEIGHT_BASE_RELAXED = 1.625
|
|
12
|
-
export const LINE_HEIGHT_BASE_LOOSE = 2
|
package/source/contexts/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export { Media, MediaContextProvider, useMediaContext } from '@/contexts/media'
|
|
2
|
-
export type {
|
|
3
|
-
MediaComponent,
|
|
4
|
-
MediaContextProviderComponent,
|
|
5
|
-
MediaContextValue,
|
|
6
|
-
MediaProps,
|
|
7
|
-
} from '@/contexts/media'
|
|
8
|
-
export { ThemeContextProvider, useThemeContext } from '@/contexts/theme'
|
|
9
|
-
export type {
|
|
10
|
-
ThemeColorRGB,
|
|
11
|
-
ThemeContextProviderComponent,
|
|
12
|
-
ThemeContextProviderProps,
|
|
13
|
-
ThemeContextValue,
|
|
14
|
-
ThemeFontWeight,
|
|
15
|
-
} from '@/contexts/theme'
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
import { Platform } from 'react-native'
|
|
3
|
-
import { MediaBreakpoint } from '../../constants'
|
|
4
|
-
import { useMediaContext } from '../../media'
|
|
5
|
-
import type { MediaComponent, MediaProps } from './media.types'
|
|
6
|
-
|
|
7
|
-
const MediaBase = Platform.select({
|
|
8
|
-
// Web media component with server side rendering support.
|
|
9
|
-
web: ({ isDefault, breakpoint, children }: MediaProps) => {
|
|
10
|
-
const mediaContext = useMediaContext()
|
|
11
|
-
// Hydration flag, allows to detect server and first client render.
|
|
12
|
-
const [isHydrated, setHydrated] = useState(false)
|
|
13
|
-
// Update hydration flag after first render.
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
setHydrated(true)
|
|
16
|
-
}, [])
|
|
17
|
-
// Hydration completed, we have window object and we already rendered once.
|
|
18
|
-
// Server and client first renders matched (but hidden by wrapper).
|
|
19
|
-
// We can switch to correct media content now safely.
|
|
20
|
-
if (isHydrated) {
|
|
21
|
-
if (isDefault && mediaContext.breakpoint === undefined) return children
|
|
22
|
-
if (mediaContext.breakpoint === breakpoint) return children
|
|
23
|
-
} else if (isDefault) {
|
|
24
|
-
// During first or server render we return default media children only.
|
|
25
|
-
return children
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
// Native media component whithout any tricks.
|
|
29
|
-
default: ({ isDefault, breakpoint, children }: MediaProps) => {
|
|
30
|
-
const mediaContext = useMediaContext()
|
|
31
|
-
if (isDefault && mediaContext.breakpoint === undefined) return children
|
|
32
|
-
if (mediaContext.breakpoint === breakpoint) return children
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
export const Media = MediaBase as MediaComponent
|
|
37
|
-
Media.Breakpoint = MediaBreakpoint
|