@spaced-out/ui-design-system 0.0.39 → 0.0.41

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.
@@ -13,17 +13,77 @@ export type TextProps = {
13
13
  color?: ColorTypes,
14
14
  children?: React.Node,
15
15
  className?: string,
16
+ highlightedTextClassName?: string,
17
+ highlightString?: string,
18
+ caseSensitiveHighlighting?: boolean,
19
+ highlightWithBackground?: boolean,
16
20
  ...
17
21
  };
18
22
 
23
+ export type HighlightTextProps = {
24
+ text: string,
25
+ highlight: string,
26
+ highlightClassName?: string,
27
+ caseSensitiveHighlighting?: boolean,
28
+ highlightWithBackground?: boolean,
29
+ };
30
+
31
+ const HighlightText = ({
32
+ text,
33
+ highlight,
34
+ highlightClassName,
35
+ caseSensitiveHighlighting,
36
+ highlightWithBackground,
37
+ }: HighlightTextProps) => {
38
+ // Split text on highlight term, include term itself into parts, ignore case
39
+ const parts = text.split(
40
+ new RegExp(`(${highlight})`, caseSensitiveHighlighting ? '' : 'gi'),
41
+ );
42
+ return (
43
+ <span>
44
+ {parts.map((part) =>
45
+ part.toLowerCase() === highlight.toLowerCase() ? (
46
+ <span
47
+ className={classify(
48
+ css.highlightText,
49
+ {
50
+ [css.bgHighlighting]: highlightWithBackground,
51
+ },
52
+ highlightClassName,
53
+ )}
54
+ >
55
+ {part}
56
+ </span>
57
+ ) : (
58
+ part
59
+ ),
60
+ )}
61
+ </span>
62
+ );
63
+ };
64
+
19
65
  export const JumboMedium = ({
20
66
  color = TEXT_COLORS.primary,
21
67
  children,
22
68
  className,
69
+ highlightedTextClassName,
70
+ highlightString,
71
+ caseSensitiveHighlighting,
72
+ highlightWithBackground,
23
73
  ...props
24
74
  }: TextProps): React.Node => (
25
75
  <span {...props} className={classify(css.jumboMedium, css[color], className)}>
26
- {children}
76
+ {!!highlightString?.length && typeof children === 'string' ? (
77
+ <HighlightText
78
+ text={children}
79
+ highlight={highlightString}
80
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
81
+ highlightClassName={highlightedTextClassName}
82
+ highlightWithBackground={highlightWithBackground}
83
+ />
84
+ ) : (
85
+ children
86
+ )}
27
87
  </span>
28
88
  );
29
89
 
@@ -31,10 +91,24 @@ export const TitleMedium = ({
31
91
  color = TEXT_COLORS.primary,
32
92
  children,
33
93
  className,
94
+ highlightedTextClassName,
95
+ highlightString,
96
+ caseSensitiveHighlighting,
97
+ highlightWithBackground,
34
98
  ...props
35
99
  }: TextProps): React.Node => (
36
100
  <h1 {...props} className={classify(css.titleMedium, css[color], className)}>
37
- {children}
101
+ {!!highlightString?.length && typeof children === 'string' ? (
102
+ <HighlightText
103
+ text={children}
104
+ highlight={highlightString}
105
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
106
+ highlightClassName={highlightedTextClassName}
107
+ highlightWithBackground={highlightWithBackground}
108
+ />
109
+ ) : (
110
+ children
111
+ )}
38
112
  </h1>
39
113
  );
40
114
 
@@ -42,10 +116,24 @@ export const SubTitleLarge = ({
42
116
  color = TEXT_COLORS.primary,
43
117
  children,
44
118
  className,
119
+ highlightedTextClassName,
120
+ highlightString,
121
+ caseSensitiveHighlighting,
122
+ highlightWithBackground,
45
123
  ...props
46
124
  }: TextProps): React.Node => (
47
125
  <h2 {...props} className={classify(css.subTitleLarge, css[color], className)}>
48
- {children}
126
+ {!!highlightString?.length && typeof children === 'string' ? (
127
+ <HighlightText
128
+ text={children}
129
+ highlight={highlightString}
130
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
131
+ highlightClassName={highlightedTextClassName}
132
+ highlightWithBackground={highlightWithBackground}
133
+ />
134
+ ) : (
135
+ children
136
+ )}
49
137
  </h2>
50
138
  );
51
139
 
@@ -53,13 +141,27 @@ export const SubTitleMedium = ({
53
141
  color = TEXT_COLORS.primary,
54
142
  children,
55
143
  className,
144
+ highlightedTextClassName,
145
+ highlightString,
146
+ caseSensitiveHighlighting,
147
+ highlightWithBackground,
56
148
  ...props
57
149
  }: TextProps): React.Node => (
58
150
  <h3
59
151
  {...props}
60
152
  className={classify(css.subTitleMedium, css[color], className)}
61
153
  >
62
- {children}
154
+ {!!highlightString?.length && typeof children === 'string' ? (
155
+ <HighlightText
156
+ text={children}
157
+ highlight={highlightString}
158
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
159
+ highlightClassName={highlightedTextClassName}
160
+ highlightWithBackground={highlightWithBackground}
161
+ />
162
+ ) : (
163
+ children
164
+ )}
63
165
  </h3>
64
166
  );
65
167
 
@@ -67,10 +169,24 @@ export const SubTitleSmall = ({
67
169
  color = TEXT_COLORS.primary,
68
170
  children,
69
171
  className,
172
+ highlightedTextClassName,
173
+ highlightString,
174
+ caseSensitiveHighlighting,
175
+ highlightWithBackground,
70
176
  ...props
71
177
  }: TextProps): React.Node => (
72
178
  <h4 {...props} className={classify(css.subTitleSmall, css[color], className)}>
73
- {children}
179
+ {!!highlightString?.length && typeof children === 'string' ? (
180
+ <HighlightText
181
+ text={children}
182
+ highlight={highlightString}
183
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
184
+ highlightClassName={highlightedTextClassName}
185
+ highlightWithBackground={highlightWithBackground}
186
+ />
187
+ ) : (
188
+ children
189
+ )}
74
190
  </h4>
75
191
  );
76
192
 
@@ -78,13 +194,27 @@ export const SubTitleExtraSmall = ({
78
194
  color = TEXT_COLORS.primary,
79
195
  children,
80
196
  className,
197
+ highlightedTextClassName,
198
+ highlightString,
199
+ caseSensitiveHighlighting,
200
+ highlightWithBackground,
81
201
  ...props
82
202
  }: TextProps): React.Node => (
83
203
  <h5
84
204
  {...props}
85
205
  className={classify(css.subTitleExtraSmall, css[color], className)}
86
206
  >
87
- {children}
207
+ {!!highlightString?.length && typeof children === 'string' ? (
208
+ <HighlightText
209
+ text={children}
210
+ highlight={highlightString}
211
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
212
+ highlightClassName={highlightedTextClassName}
213
+ highlightWithBackground={highlightWithBackground}
214
+ />
215
+ ) : (
216
+ children
217
+ )}
88
218
  </h5>
89
219
  );
90
220
 
@@ -92,13 +222,27 @@ export const ButtonTextMedium = ({
92
222
  color = TEXT_COLORS.primary,
93
223
  children,
94
224
  className,
225
+ highlightedTextClassName,
226
+ highlightString,
227
+ caseSensitiveHighlighting,
228
+ highlightWithBackground,
95
229
  ...props
96
230
  }: TextProps): React.Node => (
97
231
  <span
98
232
  {...props}
99
233
  className={classify(css.buttonTextMedium, css[color], className)}
100
234
  >
101
- {children}
235
+ {!!highlightString?.length && typeof children === 'string' ? (
236
+ <HighlightText
237
+ text={children}
238
+ highlight={highlightString}
239
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
240
+ highlightClassName={highlightedTextClassName}
241
+ highlightWithBackground={highlightWithBackground}
242
+ />
243
+ ) : (
244
+ children
245
+ )}
102
246
  </span>
103
247
  );
104
248
 
@@ -106,13 +250,27 @@ export const ButtonTextSmall = ({
106
250
  color = TEXT_COLORS.primary,
107
251
  children,
108
252
  className,
253
+ highlightedTextClassName,
254
+ highlightString,
255
+ caseSensitiveHighlighting,
256
+ highlightWithBackground,
109
257
  ...props
110
258
  }: TextProps): React.Node => (
111
259
  <span
112
260
  {...props}
113
261
  className={classify(css.buttonTextSmall, css[color], className)}
114
262
  >
115
- {children}
263
+ {!!highlightString?.length && typeof children === 'string' ? (
264
+ <HighlightText
265
+ text={children}
266
+ highlight={highlightString}
267
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
268
+ highlightClassName={highlightedTextClassName}
269
+ highlightWithBackground={highlightWithBackground}
270
+ />
271
+ ) : (
272
+ children
273
+ )}
116
274
  </span>
117
275
  );
118
276
 
@@ -120,13 +278,27 @@ export const ButtonTextExtraSmall = ({
120
278
  color = TEXT_COLORS.primary,
121
279
  children,
122
280
  className,
281
+ highlightedTextClassName,
282
+ highlightString,
283
+ caseSensitiveHighlighting,
284
+ highlightWithBackground,
123
285
  ...props
124
286
  }: TextProps): React.Node => (
125
287
  <span
126
288
  {...props}
127
289
  className={classify(css.buttonTextExtraSmall, css[color], className)}
128
290
  >
129
- {children}
291
+ {!!highlightString?.length && typeof children === 'string' ? (
292
+ <HighlightText
293
+ text={children}
294
+ highlight={highlightString}
295
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
296
+ highlightClassName={highlightedTextClassName}
297
+ highlightWithBackground={highlightWithBackground}
298
+ />
299
+ ) : (
300
+ children
301
+ )}
130
302
  </span>
131
303
  );
132
304
 
@@ -134,13 +306,27 @@ export const FormInputMedium = ({
134
306
  color = TEXT_COLORS.primary,
135
307
  children,
136
308
  className,
309
+ highlightedTextClassName,
310
+ highlightString,
311
+ caseSensitiveHighlighting,
312
+ highlightWithBackground,
137
313
  ...props
138
314
  }: TextProps): React.Node => (
139
315
  <p
140
316
  {...props}
141
317
  className={classify(css.formInputMedium, css[color], className)}
142
318
  >
143
- {children}
319
+ {!!highlightString?.length && typeof children === 'string' ? (
320
+ <HighlightText
321
+ text={children}
322
+ highlight={highlightString}
323
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
324
+ highlightClassName={highlightedTextClassName}
325
+ highlightWithBackground={highlightWithBackground}
326
+ />
327
+ ) : (
328
+ children
329
+ )}
144
330
  </p>
145
331
  );
146
332
 
@@ -148,10 +334,24 @@ export const FormInputSmall = ({
148
334
  color = TEXT_COLORS.primary,
149
335
  children,
150
336
  className,
337
+ highlightedTextClassName,
338
+ highlightString,
339
+ caseSensitiveHighlighting,
340
+ highlightWithBackground,
151
341
  ...props
152
342
  }: TextProps): React.Node => (
153
343
  <p {...props} className={classify(css.formInputSmall, css[color], className)}>
154
- {children}
344
+ {!!highlightString?.length && typeof children === 'string' ? (
345
+ <HighlightText
346
+ text={children}
347
+ highlight={highlightString}
348
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
349
+ highlightClassName={highlightedTextClassName}
350
+ highlightWithBackground={highlightWithBackground}
351
+ />
352
+ ) : (
353
+ children
354
+ )}
155
355
  </p>
156
356
  );
157
357
 
@@ -159,10 +359,24 @@ export const BodyLarge = ({
159
359
  color = TEXT_COLORS.primary,
160
360
  children,
161
361
  className,
362
+ highlightedTextClassName,
363
+ highlightString,
364
+ caseSensitiveHighlighting,
365
+ highlightWithBackground,
162
366
  ...props
163
367
  }: TextProps): React.Node => (
164
368
  <p {...props} className={classify(css.bodyLarge, css[color], className)}>
165
- {children}
369
+ {!!highlightString?.length && typeof children === 'string' ? (
370
+ <HighlightText
371
+ text={children}
372
+ highlight={highlightString}
373
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
374
+ highlightClassName={highlightedTextClassName}
375
+ highlightWithBackground={highlightWithBackground}
376
+ />
377
+ ) : (
378
+ children
379
+ )}
166
380
  </p>
167
381
  );
168
382
 
@@ -170,10 +384,24 @@ export const BodyMedium = ({
170
384
  color = TEXT_COLORS.primary,
171
385
  children,
172
386
  className,
387
+ highlightedTextClassName,
388
+ highlightString,
389
+ caseSensitiveHighlighting,
390
+ highlightWithBackground,
173
391
  ...props
174
392
  }: TextProps): React.Node => (
175
393
  <p {...props} className={classify(css.bodyMedium, css[color], className)}>
176
- {children}
394
+ {!!highlightString?.length && typeof children === 'string' ? (
395
+ <HighlightText
396
+ text={children}
397
+ highlight={highlightString}
398
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
399
+ highlightClassName={highlightedTextClassName}
400
+ highlightWithBackground={highlightWithBackground}
401
+ />
402
+ ) : (
403
+ children
404
+ )}
177
405
  </p>
178
406
  );
179
407
 
@@ -181,10 +409,24 @@ export const BodySmall = ({
181
409
  color = TEXT_COLORS.primary,
182
410
  children,
183
411
  className,
412
+ highlightedTextClassName,
413
+ highlightString,
414
+ caseSensitiveHighlighting,
415
+ highlightWithBackground,
184
416
  ...props
185
417
  }: TextProps): React.Node => (
186
418
  <p {...props} className={classify(css.bodySmall, css[color], className)}>
187
- {children}
419
+ {!!highlightString?.length && typeof children === 'string' ? (
420
+ <HighlightText
421
+ text={children}
422
+ highlight={highlightString}
423
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
424
+ highlightClassName={highlightedTextClassName}
425
+ highlightWithBackground={highlightWithBackground}
426
+ />
427
+ ) : (
428
+ children
429
+ )}
188
430
  </p>
189
431
  );
190
432
 
@@ -192,13 +434,27 @@ export const FormLabelMedium = ({
192
434
  color = TEXT_COLORS.primary,
193
435
  children,
194
436
  className,
437
+ highlightedTextClassName,
438
+ highlightString,
439
+ caseSensitiveHighlighting,
440
+ highlightWithBackground,
195
441
  ...props
196
442
  }: TextProps): React.Node => (
197
443
  <span
198
444
  {...props}
199
445
  className={classify(css.formLabelMedium, css[color], className)}
200
446
  >
201
- {children}
447
+ {!!highlightString?.length && typeof children === 'string' ? (
448
+ <HighlightText
449
+ text={children}
450
+ highlight={highlightString}
451
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
452
+ highlightClassName={highlightedTextClassName}
453
+ highlightWithBackground={highlightWithBackground}
454
+ />
455
+ ) : (
456
+ children
457
+ )}
202
458
  </span>
203
459
  );
204
460
 
@@ -206,12 +462,26 @@ export const FormLabelSmall = ({
206
462
  color = TEXT_COLORS.primary,
207
463
  children,
208
464
  className,
465
+ highlightedTextClassName,
466
+ highlightString,
467
+ caseSensitiveHighlighting,
468
+ highlightWithBackground,
209
469
  ...props
210
470
  }: TextProps): React.Node => (
211
471
  <span
212
472
  {...props}
213
473
  className={classify(css.formLabelSmall, css[color], className)}
214
474
  >
215
- {children}
475
+ {!!highlightString?.length && typeof children === 'string' ? (
476
+ <HighlightText
477
+ text={children}
478
+ highlight={highlightString}
479
+ caseSensitiveHighlighting={caseSensitiveHighlighting}
480
+ highlightClassName={highlightedTextClassName}
481
+ highlightWithBackground={highlightWithBackground}
482
+ />
483
+ ) : (
484
+ children
485
+ )}
216
486
  </span>
217
487
  );
@@ -10,7 +10,8 @@
10
10
  colorTextWarning,
11
11
  colorTextDanger,
12
12
  colorTextInversePrimary,
13
- colorTextInverseSecondary
13
+ colorTextInverseSecondary,
14
+ colorInformationLightest
14
15
  ) from 'variables/_color.css';
15
16
 
16
17
  @value (
@@ -41,6 +42,8 @@
41
42
 
42
43
  @value (size24, size18) from 'variables/_size.css';
43
44
 
45
+ @value (spaceXXSmall, spaceNone) from 'variables/_space.css';
46
+
44
47
  .baseType {
45
48
  /* Design system uses this font */
46
49
  font-family: 'Centra No 2';
@@ -231,3 +234,12 @@
231
234
  overflow: hidden;
232
235
  text-overflow: ellipsis;
233
236
  }
237
+
238
+ .highlightText {
239
+ color: colorTextInformation;
240
+ }
241
+
242
+ .bgHighlighting {
243
+ background-color: colorInformationLightest;
244
+ padding: spaceNone calc(spaceXXSmall / 4);
245
+ }
@@ -38,6 +38,8 @@
38
38
 
39
39
  @value size60: 60px;
40
40
 
41
+ @value size90: 90px;
42
+
41
43
  @value size100: 100px;
42
44
 
43
45
  @value size110: 110px;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.sizeFullViewportWidth = exports.sizeFullViewportHeight = exports.sizeFluid = exports.size960 = exports.size8 = exports.size720 = exports.size60 = exports.size580 = exports.size58 = exports.size500 = exports.size5 = exports.size480 = exports.size48 = exports.size42 = exports.size400 = exports.size40 = exports.size4 = exports.size380 = exports.size38 = exports.size36 = exports.size34 = exports.size300 = exports.size30 = exports.size276 = exports.size260 = exports.size26 = exports.size240 = exports.size24 = exports.size228 = exports.size22 = exports.size20 = exports.size2 = exports.size18 = exports.size160 = exports.size140 = exports.size12 = exports.size110 = exports.size100 = exports.size10 = void 0;
6
+ exports.sizeFullViewportWidth = exports.sizeFullViewportHeight = exports.sizeFluid = exports.size960 = exports.size90 = exports.size8 = exports.size720 = exports.size60 = exports.size580 = exports.size58 = exports.size500 = exports.size5 = exports.size480 = exports.size48 = exports.size42 = exports.size400 = exports.size40 = exports.size4 = exports.size380 = exports.size38 = exports.size36 = exports.size34 = exports.size300 = exports.size30 = exports.size276 = exports.size260 = exports.size26 = exports.size240 = exports.size24 = exports.size228 = exports.size22 = exports.size20 = exports.size2 = exports.size18 = exports.size160 = exports.size140 = exports.size12 = exports.size110 = exports.size100 = exports.size10 = void 0;
7
7
 
8
8
  const size2 = '2px';
9
9
  exports.size2 = size2;
@@ -45,6 +45,8 @@ const size58 = '58px';
45
45
  exports.size58 = size58;
46
46
  const size60 = '60px';
47
47
  exports.size60 = size60;
48
+ const size90 = '90px';
49
+ exports.size90 = size90;
48
50
  const size100 = '100px';
49
51
  exports.size100 = size100;
50
52
  const size110 = '110px';
@@ -40,6 +40,8 @@ export const size58 = '58px';
40
40
 
41
41
  export const size60 = '60px';
42
42
 
43
+ export const size90 = '90px';
44
+
43
45
  export const size100 = '100px';
44
46
 
45
47
  export const size110 = '110px';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {