@widergy/mobile-ui 1.10.0 → 1.10.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.10.1](https://github.com/widergy/mobile-ui/compare/v1.10.0...v1.10.1) (2024-05-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add UTLabel component ([#285](https://github.com/widergy/mobile-ui/issues/285)) ([e530d86](https://github.com/widergy/mobile-ui/commit/e530d86d864f6ef08c7cee661ed40a22be744170))
7
+
1
8
  # [1.10.0](https://github.com/widergy/mobile-ui/compare/v1.9.0...v1.10.0) (2024-05-20)
2
9
 
3
10
 
@@ -0,0 +1,51 @@
1
+ export const SHADES = {
2
+ shade01: '01',
3
+ shade02: '02',
4
+ shade03: '03',
5
+ shade04: '04',
6
+ shade05: '05'
7
+ };
8
+
9
+ export const VARIANTS_SIZES = {
10
+ title1: 30,
11
+ title2: 24,
12
+ title3: 22,
13
+ subtitle1: 18,
14
+ subtitle2: 16,
15
+ body: 16,
16
+ small: 14,
17
+ xsmall: 13,
18
+ th: 16,
19
+ td: 16
20
+ };
21
+
22
+ export const WEIGHTS = {
23
+ thin: 100,
24
+ extralight: 200,
25
+ light: 300,
26
+ regular: 400,
27
+ medium: 500,
28
+ semibold: 600,
29
+ bold: 700,
30
+ extrabold: 800,
31
+ black: 900
32
+ };
33
+
34
+ export const COLOR_THEMES = {
35
+ dark: 'dark',
36
+ gray: 'gray',
37
+ light: 'light',
38
+ success: 'success',
39
+ error: 'error',
40
+ warning: 'warning',
41
+ information: 'information'
42
+ };
43
+
44
+ export const DEFAULT_PROPS = {
45
+ colorTheme: 'dark',
46
+ field: {},
47
+ className: {},
48
+ variant: 'body',
49
+ weight: 'regular',
50
+ withMarkdown: false
51
+ };
@@ -0,0 +1,55 @@
1
+ /* eslint-disable react/no-children-prop */
2
+ import React from 'react';
3
+ import { Text } from 'react-native';
4
+ import Markdown from 'react-native-markdown-display';
5
+ import { any, bool, func, object, objectOf, string } from 'prop-types';
6
+
7
+ import { themeType, withTheme } from '../../theming';
8
+
9
+ import { DEFAULT_PROPS } from './constants';
10
+ import { retrieveStyle } from './theme';
11
+ import { markdownFormat } from './utils';
12
+
13
+ const UTLabel = ({
14
+ children,
15
+ className,
16
+ colorTheme,
17
+ field,
18
+ markdownRenderers,
19
+ shade,
20
+ theme,
21
+ variant,
22
+ weight,
23
+ withMarkdown
24
+ }) => {
25
+ if (!children) return null;
26
+
27
+ const themeStyles = retrieveStyle({ colorTheme, field, shade, theme, variant, weight });
28
+ const labelStyles = [themeStyles, className];
29
+
30
+ const LabelRenderer = withMarkdown ? Markdown : Text;
31
+
32
+ return (
33
+ <LabelRenderer style={withMarkdown ? { body: labelStyles } : labelStyles} rules={markdownRenderers}>
34
+ {withMarkdown ? markdownFormat(children) : children}
35
+ </LabelRenderer>
36
+ );
37
+ };
38
+
39
+ UTLabel.defaultProps = DEFAULT_PROPS;
40
+
41
+ UTLabel.propTypes = {
42
+ // eslint-disable-next-line react/forbid-prop-types
43
+ className: object,
44
+ colorTheme: string,
45
+ // eslint-disable-next-line react/forbid-prop-types
46
+ field: any,
47
+ markdownRenderers: objectOf(func),
48
+ shade: string,
49
+ theme: themeType,
50
+ variant: string,
51
+ weight: string,
52
+ withMarkdown: bool
53
+ };
54
+
55
+ export default withTheme(UTLabel);
@@ -0,0 +1,27 @@
1
+ import { COLOR_THEMES, DEFAULT_PROPS, SHADES, VARIANTS_SIZES, WEIGHTS } from './constants';
2
+
3
+ const getDefaultColorShade = colorTheme =>
4
+ colorTheme === COLOR_THEMES.gray
5
+ ? SHADES.shade04
6
+ : colorTheme === COLOR_THEMES.light
7
+ ? SHADES.shade01
8
+ : SHADES.shade05;
9
+
10
+ const variantsColorTheme = (colorTheme, shade, theme) => {
11
+ const colorThemeDefinition =
12
+ theme.Palette[colorTheme] || theme.Palette.actions[colorTheme] || theme.Palette[DEFAULT_PROPS.colorTheme];
13
+ const colorShade = Object.values(SHADES).includes(shade) ? shade : getDefaultColorShade(colorTheme);
14
+ return colorThemeDefinition[colorShade] || '#000';
15
+ };
16
+
17
+ export const retrieveStyle = ({ colorTheme, field, shade, theme, variant, weight }) => ({
18
+ color: variantsColorTheme(
19
+ field?.configuration?.colorTheme ?? colorTheme,
20
+ field?.configuration?.shade ?? shade,
21
+ theme
22
+ ),
23
+ fontFamily: theme.fonts.fontFamily,
24
+ fontSize: VARIANTS_SIZES[field?.configuration?.variant ?? variant] || VARIANTS_SIZES[DEFAULT_PROPS.variant],
25
+ fontWeight: WEIGHTS[field?.configuration?.weight ?? weight] || WEIGHTS[DEFAULT_PROPS.weight],
26
+ margin: 0
27
+ });
@@ -0,0 +1,5 @@
1
+ export const markdownFormat = content =>
2
+ content
3
+ ?.toString()
4
+ .replace(/(<\s*br\s*\/?>|\n)/gi, '\n\n')
5
+ .replace(/(<\s*hr\s*\/?>)/gi, '\n\n---') || null;
package/lib/index.js CHANGED
@@ -59,6 +59,7 @@ export { default as Loading } from './components/Loading';
59
59
  export { default as UTLoading } from './components/UTLoading';
60
60
  // Text
61
61
  export { default as Label } from './components/Label';
62
+ export { default as UTLabel } from './components/UTLabel';
62
63
  export { default as TransitionText } from './components/TransitionText';
63
64
  // Theming
64
65
  export * from './theming';
@@ -113,6 +113,94 @@ const DefaultTheme = {
113
113
  iconSize: 15
114
114
  },
115
115
  passwordIcons: {}
116
+ },
117
+ Palette: {
118
+ dark: {
119
+ '01': '#575757',
120
+ '02': '#4A4A4A',
121
+ '03': '#3D3D3D',
122
+ '04': '#313130',
123
+ '05': '#0F0F0F'
124
+ },
125
+ gray: {
126
+ '01': '#BDBDBD',
127
+ '02': '#B0B0B0',
128
+ '03': '#969696',
129
+ '04': '#787878',
130
+ '05': '#646464'
131
+ },
132
+ light: {
133
+ '01': '#FFFFFF',
134
+ '02': '#FCFBFA',
135
+ '03': '#F6F6F5',
136
+ '04': '#E7E7E7',
137
+ '05': '#C9C9C9'
138
+ },
139
+ success: {
140
+ '01': '#EEF9E6',
141
+ '02': '#D3F0C0',
142
+ '03': '#80D249',
143
+ '04': '#3F8411',
144
+ '05': '#245702'
145
+ },
146
+ error: {
147
+ '01': '#FFF0EB',
148
+ '02': '#FED9CE',
149
+ '03': '#FD906F',
150
+ '04': '#D03607',
151
+ '05': '#852001'
152
+ },
153
+ warning: {
154
+ '01': '#FFF9E6',
155
+ '02': '#FFEFC1',
156
+ '03': '#FED24F',
157
+ '04': '#A86600',
158
+ '05': '#6F4708'
159
+ },
160
+ information: {
161
+ '01': '#EBFAFD',
162
+ '02': '#CEF3FB',
163
+ '03': '#6BDBF3',
164
+ '04': '#037C96',
165
+ '05': '#025F73'
166
+ },
167
+ actions: {
168
+ accent: {
169
+ '01': '#E7F0EE',
170
+ '02': '#C3D9D5',
171
+ '03': '#4A8D83',
172
+ '04': '#0D6759',
173
+ '05': '#0D6759'
174
+ },
175
+ neutral: {
176
+ '01': '#E8ECED',
177
+ '02': '#C6D0D3',
178
+ '03': '#54737B',
179
+ '04': '#1B444F',
180
+ '05': '#1B444F'
181
+ },
182
+ error: {
183
+ '01': '#FFEBEE',
184
+ '02': '#FECED5',
185
+ '03': '#FD6F85',
186
+ '04': '#E80C2C',
187
+ '05': '#A0041B'
188
+ },
189
+ success: {
190
+ '01': '#EEF9E6',
191
+ '02': '#D3F0C0',
192
+ '03': '#80D249',
193
+ '04': '#3F8411',
194
+ '05': '#245702'
195
+ },
196
+ negative: {
197
+ '01': 'rgba(255, 255, 255, 0.1)',
198
+ '02': 'rgba(255, 255, 255, 0.25)',
199
+ '03': 'rgba(255, 255, 255, 0.5)',
200
+ '04': '#FFFFFF',
201
+ '05': '#FFFFFF'
202
+ }
203
+ }
116
204
  }
117
205
  };
118
206
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@widergy/mobile-ui",
3
3
  "description": "Widergy Mobile Components",
4
4
  "author": "widergy",
5
- "version": "1.10.0",
5
+ "version": "1.10.1",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [