@jobber/components-native 0.7.0 → 0.8.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/src/StatusLabel/StatusLabel.js +21 -0
- package/dist/src/StatusLabel/StatusLabel.style.js +27 -0
- package/dist/src/StatusLabel/index.js +1 -0
- package/dist/src/Typography/Typography.style.js +101 -164
- package/dist/src/Typography/webFonts.js +34 -0
- package/dist/src/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/StatusLabel/StatusLabel.d.ts +22 -0
- package/dist/types/src/StatusLabel/StatusLabel.style.d.ts +23 -0
- package/dist/types/src/StatusLabel/index.d.ts +2 -0
- package/dist/types/src/Typography/Typography.style.d.ts +6 -6
- package/dist/types/src/Typography/webFonts.d.ts +4 -0
- package/dist/types/src/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/StatusLabel/StatusLabel.style.ts +30 -0
- package/src/StatusLabel/StatusLabel.test.tsx +68 -0
- package/src/StatusLabel/StatusLabel.tsx +73 -0
- package/src/StatusLabel/__snapshots__/StatusLabel.test.tsx.snap +554 -0
- package/src/StatusLabel/index.ts +2 -0
- package/src/Typography/Typography.style.ts +33 -18
- package/src/Typography/webFonts.ts +43 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { styles } from "./StatusLabel.style";
|
|
4
|
+
import { tokens } from "../utils/design";
|
|
5
|
+
import { Text } from "../Text";
|
|
6
|
+
export function StatusLabel({ text, alignment = "end", status = "success", }) {
|
|
7
|
+
return (React.createElement(View, { style: [
|
|
8
|
+
styles.statusLabelRow,
|
|
9
|
+
alignment === "start" && styles.labelTextStartAligned,
|
|
10
|
+
] },
|
|
11
|
+
React.createElement(View, { style: styles.statusLabelText },
|
|
12
|
+
React.createElement(Text, { align: alignment, level: "textSupporting", variation: "subdued" }, text)),
|
|
13
|
+
React.createElement(View, { style: styles.innerPad }),
|
|
14
|
+
React.createElement(StatusLabelIcon, { status: status })));
|
|
15
|
+
}
|
|
16
|
+
function StatusLabelIcon({ status }) {
|
|
17
|
+
return (React.createElement(View, { testID: `${status}LabelIcon`, style: [
|
|
18
|
+
styles.statusLabelIcon,
|
|
19
|
+
{ backgroundColor: tokens[`color-${status}`] },
|
|
20
|
+
] }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../utils/design";
|
|
3
|
+
const statusLabelIconDiameter = tokens["space-base"] - tokens["space-smaller"]; //12px
|
|
4
|
+
const indicatorOffset = tokens["space-smallest"] + tokens["space-minuscule"];
|
|
5
|
+
export const styles = StyleSheet.create({
|
|
6
|
+
statusLabelRow: {
|
|
7
|
+
flexDirection: "row",
|
|
8
|
+
justifyContent: "flex-end",
|
|
9
|
+
flexWrap: "nowrap",
|
|
10
|
+
},
|
|
11
|
+
statusLabelText: {
|
|
12
|
+
flexShrink: 1,
|
|
13
|
+
},
|
|
14
|
+
statusLabelIcon: {
|
|
15
|
+
borderRadius: tokens["radius-base"],
|
|
16
|
+
backgroundColor: tokens["color-success"],
|
|
17
|
+
width: statusLabelIconDiameter,
|
|
18
|
+
height: statusLabelIconDiameter,
|
|
19
|
+
marginTop: indicatorOffset,
|
|
20
|
+
},
|
|
21
|
+
labelTextStartAligned: {
|
|
22
|
+
flexDirection: "row-reverse",
|
|
23
|
+
},
|
|
24
|
+
innerPad: {
|
|
25
|
+
width: tokens["space-small"],
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StatusLabel } from "./StatusLabel";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { StyleSheet } from "react-native";
|
|
1
|
+
import { Platform, StyleSheet } from "react-native";
|
|
2
|
+
import { webFonts } from "./webFonts";
|
|
2
3
|
import { tokens } from "../utils/design";
|
|
3
4
|
const extravagantLineHeight = tokens["typography--lineHeight-extravagant"];
|
|
4
5
|
const jumboLineHeight = tokens["typography--lineHeight-jumbo"];
|
|
@@ -8,22 +9,7 @@ const largeLineHeight = tokens["typography--lineHeight-large"];
|
|
|
8
9
|
const baseLineHeight = tokens["typography--lineHeight-base"];
|
|
9
10
|
const tightLineHeight = tokens["typography--lineHeight-tight"];
|
|
10
11
|
const minisculeLineHeight = tokens["typography--lineHeight-miniscule"];
|
|
11
|
-
|
|
12
|
-
* `StyleSheet` for Typography.tsx.
|
|
13
|
-
*
|
|
14
|
-
* If you find yourself needing to use what's inside this object on files other
|
|
15
|
-
* than `<Typography />`, please import from `@jobber/components-native` instead.
|
|
16
|
-
*
|
|
17
|
-
* ```
|
|
18
|
-
* import { typographyStyles } from "@jobber/components-native"
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* Reusable typography tokens to ensure consistency for any client facing texts.
|
|
23
|
-
*/
|
|
24
|
-
export const typographyTokens = {
|
|
25
|
-
// This follows a pattern of
|
|
26
|
-
// { fontFamily }{ fontStyle }{ fontWeight }
|
|
12
|
+
const deviceFonts = {
|
|
27
13
|
baseRegularRegular: {
|
|
28
14
|
fontFamily: "inter-regular",
|
|
29
15
|
},
|
|
@@ -48,233 +34,184 @@ export const typographyTokens = {
|
|
|
48
34
|
displayRegularBlack: {
|
|
49
35
|
fontFamily: "jobberpro-blk",
|
|
50
36
|
},
|
|
51
|
-
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* We need to use web fonts for rendering Typography on Storybook
|
|
40
|
+
* because it uses font files (.ttf) to render them on devices.
|
|
41
|
+
* As we don't want to expose the font files, we are setting the fonts
|
|
42
|
+
* in CSS.
|
|
43
|
+
*/
|
|
44
|
+
const fonts = Platform.select({
|
|
45
|
+
web: webFonts,
|
|
46
|
+
default: deviceFonts,
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Reusable typography tokens to ensure consistency for any client facing texts.
|
|
50
|
+
*/
|
|
51
|
+
export const typographyTokens = Object.assign(Object.assign({}, fonts), { startAlign: {
|
|
52
52
|
textAlign: "left",
|
|
53
|
-
},
|
|
54
|
-
endAlign: {
|
|
53
|
+
}, endAlign: {
|
|
55
54
|
textAlign: "right",
|
|
56
|
-
},
|
|
57
|
-
centerAlign: {
|
|
55
|
+
}, centerAlign: {
|
|
58
56
|
textAlign: "center",
|
|
59
|
-
},
|
|
60
|
-
justifyAlign: {
|
|
57
|
+
}, justifyAlign: {
|
|
61
58
|
textAlign: "justify",
|
|
62
|
-
},
|
|
63
|
-
blue: {
|
|
59
|
+
}, blue: {
|
|
64
60
|
color: tokens["color-heading"],
|
|
65
|
-
},
|
|
66
|
-
blueDark: {
|
|
61
|
+
}, blueDark: {
|
|
67
62
|
color: tokens["color-blue--dark"],
|
|
68
|
-
},
|
|
69
|
-
white: {
|
|
63
|
+
}, white: {
|
|
70
64
|
color: tokens["color-white"],
|
|
71
|
-
},
|
|
72
|
-
green: {
|
|
65
|
+
}, green: {
|
|
73
66
|
color: tokens["color-green"],
|
|
74
|
-
},
|
|
75
|
-
greenDark: {
|
|
67
|
+
}, greenDark: {
|
|
76
68
|
color: tokens["color-green--dark"],
|
|
77
|
-
},
|
|
78
|
-
grey: {
|
|
69
|
+
}, grey: {
|
|
79
70
|
color: tokens["color-grey"],
|
|
80
|
-
},
|
|
81
|
-
greyDark: {
|
|
71
|
+
}, greyDark: {
|
|
82
72
|
color: tokens["color-grey--dark"],
|
|
83
|
-
},
|
|
84
|
-
greyBlue: {
|
|
73
|
+
}, greyBlue: {
|
|
85
74
|
color: tokens["color-greyBlue"],
|
|
86
|
-
},
|
|
87
|
-
greyBlueDark: {
|
|
75
|
+
}, greyBlueDark: {
|
|
88
76
|
color: tokens["color-greyBlue--dark"],
|
|
89
|
-
},
|
|
90
|
-
lightBlue: {
|
|
77
|
+
}, lightBlue: {
|
|
91
78
|
color: tokens["color-lightBlue"],
|
|
92
|
-
},
|
|
93
|
-
lightBlueDark: {
|
|
79
|
+
}, lightBlueDark: {
|
|
94
80
|
color: tokens["color-lightBlue--dark"],
|
|
95
|
-
},
|
|
96
|
-
red: {
|
|
81
|
+
}, red: {
|
|
97
82
|
color: tokens["color-red"],
|
|
98
|
-
},
|
|
99
|
-
redDark: {
|
|
83
|
+
}, redDark: {
|
|
100
84
|
color: tokens["color-red--dark"],
|
|
101
|
-
},
|
|
102
|
-
yellow: {
|
|
85
|
+
}, yellow: {
|
|
103
86
|
color: tokens["color-yellow"],
|
|
104
|
-
},
|
|
105
|
-
yellowDark: {
|
|
87
|
+
}, yellowDark: {
|
|
106
88
|
color: tokens["color-yellow--dark"],
|
|
107
|
-
},
|
|
108
|
-
yellowGreenDark: {
|
|
89
|
+
}, yellowGreenDark: {
|
|
109
90
|
color: tokens["color-yellowGreen--dark"],
|
|
110
|
-
},
|
|
111
|
-
orangeDark: {
|
|
91
|
+
}, orangeDark: {
|
|
112
92
|
color: tokens["color-orange--dark"],
|
|
113
|
-
},
|
|
114
|
-
navyDark: {
|
|
93
|
+
}, navyDark: {
|
|
115
94
|
color: tokens["color-navy--dark"],
|
|
116
|
-
},
|
|
117
|
-
limeDark: {
|
|
95
|
+
}, limeDark: {
|
|
118
96
|
color: tokens["color-lime--dark"],
|
|
119
|
-
},
|
|
120
|
-
purpleDark: {
|
|
97
|
+
}, purpleDark: {
|
|
121
98
|
color: tokens["color-purple--dark"],
|
|
122
|
-
},
|
|
123
|
-
pinkDark: {
|
|
99
|
+
}, pinkDark: {
|
|
124
100
|
color: tokens["color-pink--dark"],
|
|
125
|
-
},
|
|
126
|
-
tealDark: {
|
|
101
|
+
}, tealDark: {
|
|
127
102
|
color: tokens["color-teal--dark"],
|
|
128
|
-
},
|
|
129
|
-
indigoDark: {
|
|
103
|
+
}, indigoDark: {
|
|
130
104
|
color: tokens["color-indigo--dark"],
|
|
131
|
-
},
|
|
132
|
-
navy: {
|
|
105
|
+
}, navy: {
|
|
133
106
|
color: tokens["color-navy"],
|
|
134
|
-
},
|
|
135
|
-
heading: {
|
|
107
|
+
}, heading: {
|
|
136
108
|
color: tokens["color-heading"],
|
|
137
|
-
},
|
|
138
|
-
headingReverse: {
|
|
109
|
+
}, headingReverse: {
|
|
139
110
|
color: tokens["color-text--reverse"],
|
|
140
|
-
},
|
|
141
|
-
text: {
|
|
111
|
+
}, text: {
|
|
142
112
|
color: tokens["color-text"],
|
|
143
|
-
},
|
|
144
|
-
textSecondary: {
|
|
113
|
+
}, textSecondary: {
|
|
145
114
|
color: tokens["color-text--secondary"],
|
|
146
|
-
},
|
|
147
|
-
textReverse: {
|
|
115
|
+
}, textReverse: {
|
|
148
116
|
color: tokens["color-text--reverse"],
|
|
149
|
-
},
|
|
150
|
-
textReverseSecondary: {
|
|
117
|
+
}, textReverseSecondary: {
|
|
151
118
|
color: tokens["color-text--reverse--secondary"],
|
|
152
|
-
},
|
|
153
|
-
success: {
|
|
119
|
+
}, success: {
|
|
154
120
|
color: tokens["color-success--onSurface"],
|
|
155
|
-
},
|
|
156
|
-
error: {
|
|
121
|
+
}, error: {
|
|
157
122
|
color: tokens["color-critical"],
|
|
158
|
-
},
|
|
159
|
-
base: {
|
|
123
|
+
}, base: {
|
|
160
124
|
color: tokens["color-text"],
|
|
161
|
-
},
|
|
162
|
-
subdued: {
|
|
125
|
+
}, subdued: {
|
|
163
126
|
color: tokens["color-text--secondary"],
|
|
164
|
-
},
|
|
165
|
-
warn: {
|
|
127
|
+
}, warn: {
|
|
166
128
|
color: tokens["color-warning--onSurface"],
|
|
167
|
-
},
|
|
168
|
-
info: {
|
|
129
|
+
}, info: {
|
|
169
130
|
color: tokens["color-informative--onSurface"],
|
|
170
|
-
},
|
|
171
|
-
critical: {
|
|
131
|
+
}, critical: {
|
|
172
132
|
color: tokens["color-critical"],
|
|
173
|
-
},
|
|
174
|
-
successReverse: {
|
|
133
|
+
}, successReverse: {
|
|
175
134
|
color: tokens["color-success"],
|
|
176
|
-
},
|
|
177
|
-
errorReverse: {
|
|
135
|
+
}, errorReverse: {
|
|
178
136
|
color: tokens["color-critical"],
|
|
179
|
-
},
|
|
180
|
-
baseReverse: {
|
|
137
|
+
}, baseReverse: {
|
|
181
138
|
color: tokens["color-text--reverse"],
|
|
182
|
-
},
|
|
183
|
-
subduedReverse: {
|
|
139
|
+
}, subduedReverse: {
|
|
184
140
|
color: tokens["color-text--reverse--secondary"],
|
|
185
|
-
},
|
|
186
|
-
warnReverse: {
|
|
141
|
+
}, warnReverse: {
|
|
187
142
|
color: tokens["color-warning"],
|
|
188
|
-
},
|
|
189
|
-
infoReverse: {
|
|
143
|
+
}, infoReverse: {
|
|
190
144
|
color: tokens["color-informative"],
|
|
191
|
-
},
|
|
192
|
-
criticalReverse: {
|
|
145
|
+
}, criticalReverse: {
|
|
193
146
|
color: tokens["color-critical"],
|
|
194
|
-
},
|
|
195
|
-
interactive: {
|
|
147
|
+
}, interactive: {
|
|
196
148
|
color: tokens["color-interactive"],
|
|
197
|
-
},
|
|
198
|
-
destructive: {
|
|
149
|
+
}, destructive: {
|
|
199
150
|
color: tokens["color-destructive"],
|
|
200
|
-
},
|
|
201
|
-
learning: {
|
|
151
|
+
}, learning: {
|
|
202
152
|
color: tokens["color-informative"],
|
|
203
|
-
},
|
|
204
|
-
subtle: {
|
|
153
|
+
}, subtle: {
|
|
205
154
|
color: tokens["color-interactive--subtle"],
|
|
206
|
-
},
|
|
207
|
-
onPrimary: {
|
|
155
|
+
}, onPrimary: {
|
|
208
156
|
color: tokens["color-surface"],
|
|
209
|
-
},
|
|
210
|
-
disabled: {
|
|
157
|
+
}, disabled: {
|
|
211
158
|
color: tokens["color-disabled"],
|
|
212
|
-
},
|
|
213
|
-
smallestSize: {
|
|
159
|
+
}, smallestSize: {
|
|
214
160
|
fontSize: tokens["typography--fontSize-smallest"],
|
|
215
161
|
lineHeight: minisculeLineHeight,
|
|
216
|
-
},
|
|
217
|
-
smallerSize: {
|
|
162
|
+
}, smallerSize: {
|
|
218
163
|
fontSize: tokens["typography--fontSize-smaller"],
|
|
219
164
|
lineHeight: tightLineHeight,
|
|
220
|
-
},
|
|
221
|
-
smallSize: {
|
|
165
|
+
}, smallSize: {
|
|
222
166
|
fontSize: tokens["typography--fontSize-small"],
|
|
223
167
|
lineHeight: tightLineHeight,
|
|
224
|
-
},
|
|
225
|
-
defaultSize: {
|
|
168
|
+
}, defaultSize: {
|
|
226
169
|
fontSize: tokens["typography--fontSize-base"],
|
|
227
170
|
lineHeight: baseLineHeight,
|
|
228
|
-
},
|
|
229
|
-
largeSize: {
|
|
171
|
+
}, largeSize: {
|
|
230
172
|
fontSize: tokens["typography--fontSize-large"],
|
|
231
173
|
lineHeight: largeLineHeight,
|
|
232
|
-
},
|
|
233
|
-
largerSize: {
|
|
174
|
+
}, largerSize: {
|
|
234
175
|
fontSize: tokens["typography--fontSize-larger"],
|
|
235
176
|
lineHeight: largeLineHeight,
|
|
236
|
-
},
|
|
237
|
-
largestSize: {
|
|
177
|
+
}, largestSize: {
|
|
238
178
|
fontSize: tokens["typography--fontSize-largest"],
|
|
239
179
|
lineHeight: largerLineHeight,
|
|
240
|
-
},
|
|
241
|
-
jumboSize: {
|
|
180
|
+
}, jumboSize: {
|
|
242
181
|
fontSize: tokens["typography--fontSize-jumbo"],
|
|
243
182
|
lineHeight: jumboLineHeight,
|
|
244
|
-
},
|
|
245
|
-
extravagantSize: {
|
|
183
|
+
}, extravagantSize: {
|
|
246
184
|
fontSize: tokens["typography--fontSize-extravagant"],
|
|
247
185
|
lineHeight: extravagantLineHeight,
|
|
248
|
-
},
|
|
249
|
-
extravagantLineHeight: {
|
|
186
|
+
}, extravagantLineHeight: {
|
|
250
187
|
lineHeight: extravagantLineHeight,
|
|
251
|
-
},
|
|
252
|
-
jumboLineHeight: {
|
|
188
|
+
}, jumboLineHeight: {
|
|
253
189
|
lineHeight: jumboLineHeight,
|
|
254
|
-
},
|
|
255
|
-
largestLineHeight: {
|
|
190
|
+
}, largestLineHeight: {
|
|
256
191
|
lineHeight: largestLineHeight,
|
|
257
|
-
},
|
|
258
|
-
largerLineHeight: {
|
|
192
|
+
}, largerLineHeight: {
|
|
259
193
|
lineHeight: largerLineHeight,
|
|
260
|
-
},
|
|
261
|
-
largeLineHeight: {
|
|
194
|
+
}, largeLineHeight: {
|
|
262
195
|
lineHeight: largeLineHeight,
|
|
263
|
-
},
|
|
264
|
-
baseLineHeight: {
|
|
196
|
+
}, baseLineHeight: {
|
|
265
197
|
lineHeight: baseLineHeight,
|
|
266
|
-
},
|
|
267
|
-
tightLineHeight: {
|
|
198
|
+
}, tightLineHeight: {
|
|
268
199
|
lineHeight: tightLineHeight,
|
|
269
|
-
},
|
|
270
|
-
baseLetterSpacing: {
|
|
200
|
+
}, baseLetterSpacing: {
|
|
271
201
|
letterSpacing: tokens["typography--letterSpacing-base"],
|
|
272
|
-
},
|
|
273
|
-
looseLetterSpacing: {
|
|
202
|
+
}, looseLetterSpacing: {
|
|
274
203
|
letterSpacing: tokens["typography--letterSpacing-loose"],
|
|
275
|
-
},
|
|
276
|
-
strikeThrough: {
|
|
204
|
+
}, strikeThrough: {
|
|
277
205
|
textDecorationLine: "line-through",
|
|
278
|
-
}
|
|
279
|
-
|
|
206
|
+
} });
|
|
207
|
+
/**
|
|
208
|
+
* `StyleSheet` for Typography.tsx.
|
|
209
|
+
*
|
|
210
|
+
* If you find yourself needing to use what's inside this object on files other
|
|
211
|
+
* than `<Typography />`, please import from `@jobber/components-native` instead.
|
|
212
|
+
*
|
|
213
|
+
* ```
|
|
214
|
+
* import { typographyStyles } from "@jobber/components-native"
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
280
217
|
export const typographyStyles = StyleSheet.create(typographyTokens);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const webFonts = {
|
|
2
|
+
baseRegularRegular: {
|
|
3
|
+
fontFamily: "'Inter', Helvetica, Arial, sans-serif",
|
|
4
|
+
fontWeight: "400",
|
|
5
|
+
},
|
|
6
|
+
baseRegularMedium: {
|
|
7
|
+
fontFamily: "'Inter', Helvetica, Arial, sans-serif",
|
|
8
|
+
fontWeight: "500",
|
|
9
|
+
},
|
|
10
|
+
baseRegularSemiBold: {
|
|
11
|
+
fontFamily: "'Inter', Helvetica, Arial, sans-serif",
|
|
12
|
+
fontWeight: "600",
|
|
13
|
+
},
|
|
14
|
+
baseRegularBold: {
|
|
15
|
+
fontFamily: "'Inter', Helvetica, Arial, sans-serif",
|
|
16
|
+
fontWeight: "700",
|
|
17
|
+
},
|
|
18
|
+
baseRegularExtraBold: {
|
|
19
|
+
fontFamily: "'Inter', Helvetica, Arial, sans-serif",
|
|
20
|
+
fontWeight: "800",
|
|
21
|
+
},
|
|
22
|
+
displayRegularBold: {
|
|
23
|
+
fontFamily: "'Jobber Pro', 'Poppins', Helvetica, Arial, sans-serif",
|
|
24
|
+
fontWeight: "700",
|
|
25
|
+
},
|
|
26
|
+
displayRegularExtraBold: {
|
|
27
|
+
fontFamily: "'Jobber Pro', 'Poppins', Helvetica, Arial, sans-serif",
|
|
28
|
+
fontWeight: "800",
|
|
29
|
+
},
|
|
30
|
+
displayRegularBlack: {
|
|
31
|
+
fontFamily: "'Jobber Pro', 'Poppins', Helvetica, Arial, sans-serif",
|
|
32
|
+
fontWeight: "900",
|
|
33
|
+
},
|
|
34
|
+
};
|