@ornikar/kitt-universal 3.5.0 → 3.6.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.
@@ -309,31 +309,35 @@ Typography.h4 = createHeading(4, 'header4');
309
309
 
310
310
  Typography.h5 = createHeading(5, 'header5');
311
311
 
312
- const getFirstCharacter = string => string ? string[0] : '';
313
-
314
- const getInitials = (firstname, lastname) => (getFirstCharacter(firstname) + getFirstCharacter(lastname)).toUpperCase();
312
+ const getInitials = (firstname, lastname) => `${firstname[0]}${lastname[0]}`.toUpperCase();
315
313
 
316
314
  const StyledAvatarView = /*#__PURE__*/styled__default(BabelPluginStyledComponentsReactNative.View).withConfig({
317
315
  displayName: "Avatar__StyledAvatarView",
318
316
  componentId: "kitt-universal__sc-9miubv-0"
319
- })(["border-radius:", "px;background-color:", ";height:", "px;width:", "px;overflow:hidden;align-items:center;justify-content:center;"], ({
320
- round,
321
- size
322
- }) => round ? size / 2 : 10, ({
317
+ })(["border-radius:", ";background-color:", ";height:", "px;width:", "px;overflow:hidden;align-items:center;justify-content:center;"], ({
323
318
  theme,
324
- light
325
- }) => light ? theme.kitt.avatar.light.backgroundColor : theme.kitt.avatar.default.backgroundColor, ({
326
- size
327
- }) => size, ({
328
- size
329
- }) => size);
319
+ $isRound,
320
+ $size
321
+ }) => {
322
+ if ($isRound) return `${$size / 2}px`;
323
+ return theme.kitt.avatar.borderRadius;
324
+ }, ({
325
+ theme,
326
+ $isLight
327
+ }) => $isLight ? theme.kitt.avatar.light.backgroundColor : theme.kitt.avatar.default.backgroundColor, ({
328
+ $size
329
+ }) => $size, ({
330
+ $size
331
+ }) => $size);
330
332
 
331
333
  function AvatarContent({
332
- size = 40,
334
+ size,
333
335
  src,
334
336
  firstname,
335
337
  lastname,
336
- light
338
+ alt,
339
+ base,
340
+ isLight
337
341
  }) {
338
342
  if (src) {
339
343
  return /*#__PURE__*/jsxRuntime.jsx(BabelPluginStyledComponentsReactNative.Image, {
@@ -343,34 +347,43 @@ function AvatarContent({
343
347
  style: {
344
348
  width: size,
345
349
  height: size
346
- }
350
+ },
351
+ accessibilityLabel: alt
347
352
  });
348
353
  }
349
354
 
350
355
  if (firstname && lastname) {
351
356
  return /*#__PURE__*/jsxRuntime.jsx(Typography.Text, {
352
- base: "body-small",
357
+ base: base,
353
358
  variant: "bold",
354
- color: light ? 'black' : 'white',
359
+ color: isLight ? 'black' : 'white',
355
360
  children: getInitials(firstname, lastname)
356
361
  });
357
362
  }
358
363
 
359
364
  return /*#__PURE__*/jsxRuntime.jsx(Icon, {
360
365
  icon: /*#__PURE__*/jsxRuntime.jsx(kittIcons.UserIcon, {}),
361
- color: light ? 'black' : 'white',
366
+ color: isLight ? 'black' : 'white',
362
367
  size: size / 2
363
368
  });
364
369
  }
365
370
 
366
371
  function Avatar({
367
372
  size = 40,
368
- ...rest
373
+ base = 'body-small',
374
+ round,
375
+ light,
376
+ ...props
369
377
  }) {
370
- return /*#__PURE__*/jsxRuntime.jsx(StyledAvatarView, { ...rest,
371
- size: size,
372
- children: /*#__PURE__*/jsxRuntime.jsx(AvatarContent, { ...rest,
373
- size: size
378
+ return /*#__PURE__*/jsxRuntime.jsx(StyledAvatarView, {
379
+ $size: size,
380
+ $isRound: round,
381
+ $isLight: light,
382
+ children: /*#__PURE__*/jsxRuntime.jsx(AvatarContent, {
383
+ size: size,
384
+ base: base,
385
+ isLight: light,
386
+ ...props
374
387
  })
375
388
  });
376
389
  }
@@ -2418,17 +2431,6 @@ const lateOceanColorPalette = {
2418
2431
  moonPurpleLight1: '#EDEBFC'
2419
2432
  };
2420
2433
 
2421
- const avatarLateOceanTheme = {
2422
- default: {
2423
- color: lateOceanColorPalette.white,
2424
- backgroundColor: lateOceanColorPalette.lateOcean
2425
- },
2426
- light: {
2427
- color: lateOceanColorPalette.black1000,
2428
- backgroundColor: lateOceanColorPalette.black100
2429
- }
2430
- };
2431
-
2432
2434
  const colorsLateOceanTheme = {
2433
2435
  primary: lateOceanColorPalette.lateOcean,
2434
2436
  primaryLight: lateOceanColorPalette.lateOceanLight1,
@@ -2451,6 +2453,16 @@ const colorsLateOceanTheme = {
2451
2453
  }
2452
2454
  };
2453
2455
 
2456
+ const avatar = {
2457
+ borderRadius: '10px',
2458
+ default: {
2459
+ backgroundColor: colorsLateOceanTheme.primary
2460
+ },
2461
+ light: {
2462
+ backgroundColor: lateOceanColorPalette.black100
2463
+ }
2464
+ };
2465
+
2454
2466
  const buttonLateOceanTheme = {
2455
2467
  borderRadius: '30px',
2456
2468
  borderWidth: {
@@ -2833,7 +2845,7 @@ const theme = {
2833
2845
  palettes: {
2834
2846
  lateOcean: lateOceanColorPalette
2835
2847
  },
2836
- avatar: avatarLateOceanTheme,
2848
+ avatar,
2837
2849
  button: buttonLateOceanTheme,
2838
2850
  card: cardLateOceanTheme,
2839
2851
  feedbackMessage: feedbackMessageLateOceanTheme,
@@ -3299,6 +3311,7 @@ exports.theme = theme;
3299
3311
  exports.useKittTheme = useKittTheme;
3300
3312
  exports.useMatchWindowSize = useMatchWindowSize;
3301
3313
  exports.useStoryBlockColor = useStoryBlockColor;
3314
+ exports.withTheme = withTheme;
3302
3315
  Object.keys(kittIcons).forEach(function (k) {
3303
3316
  if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = kittIcons[k];
3304
3317
  });