@ornikar/bumper 3.1.0 → 3.2.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/definitions/shared/storybook/StoryTitle.d.ts +1 -1
  3. package/dist/definitions/system/content/icon/Icon.d.ts +6 -1
  4. package/dist/definitions/system/content/icon/Icon.d.ts.map +1 -1
  5. package/dist/definitions/system/content/typography/Typography.d.ts +10 -52
  6. package/dist/definitions/system/content/typography/Typography.d.ts.map +1 -1
  7. package/dist/definitions/system/content/typography/TypographyIcon.d.ts +5 -2
  8. package/dist/definitions/system/content/typography/TypographyIcon.d.ts.map +1 -1
  9. package/dist/definitions/system/content/typography/TypographyLink.d.ts +1 -1
  10. package/dist/definitions/system/content/typography/TypographyLink.d.ts.map +1 -1
  11. package/dist/definitions/system/content/typography/TypographyView.d.ts +2 -2
  12. package/dist/definitions/system/content/typography/TypographyView.d.ts.map +1 -1
  13. package/dist/definitions/system/content/typography/utils/typographyContext.d.ts +8 -13
  14. package/dist/definitions/system/content/typography/utils/typographyContext.d.ts.map +1 -1
  15. package/dist/definitions/system/core/hooks/useProps.d.ts +3 -0
  16. package/dist/definitions/system/core/hooks/useProps.d.ts.map +1 -0
  17. package/dist/definitions/system/dataDisplays/Badge/Badge.d.ts.map +1 -1
  18. package/dist/definitions/system/types.d.ts +1 -2
  19. package/dist/definitions/system/types.d.ts.map +1 -1
  20. package/dist/index-metro.es.android.js +69 -160
  21. package/dist/index-metro.es.android.js.map +1 -1
  22. package/dist/index-metro.es.ios.js +69 -160
  23. package/dist/index-metro.es.ios.js.map +1 -1
  24. package/dist/index-node-22.22.cjs.js +71 -163
  25. package/dist/index-node-22.22.cjs.js.map +1 -1
  26. package/dist/index-node-22.22.cjs.web.js +71 -163
  27. package/dist/index-node-22.22.cjs.web.js.map +1 -1
  28. package/dist/index-node-22.22.es.mjs +72 -164
  29. package/dist/index-node-22.22.es.mjs.map +1 -1
  30. package/dist/index-node-22.22.es.web.mjs +72 -164
  31. package/dist/index-node-22.22.es.web.mjs.map +1 -1
  32. package/dist/index.es.js +69 -158
  33. package/dist/index.es.js.map +1 -1
  34. package/dist/index.es.web.js +69 -158
  35. package/dist/index.es.web.js.map +1 -1
  36. package/dist/tsbuildinfo +1 -1
  37. package/package.json +1 -1
  38. package/src/.eslintrc.json +2 -2
  39. package/src/system/content/icon/Icon.tsx +10 -4
  40. package/src/system/content/icon/__snapshots_web__/Icon.features.stories.tsx.snap +11 -22
  41. package/src/system/content/typography/Typography.tsx +66 -75
  42. package/src/system/content/typography/TypographyIcon.tsx +14 -19
  43. package/src/system/content/typography/TypographyLink.features.stories.tsx +34 -8
  44. package/src/system/content/typography/TypographyLink.stories.tsx +2 -1
  45. package/src/system/content/typography/TypographyLink.tsx +2 -0
  46. package/src/system/content/typography/TypographyView.tsx +10 -17
  47. package/src/system/content/typography/__snapshots__/TypographyLink.features.stories.tsx.snap +164 -0
  48. package/src/system/content/typography/__snapshots_web__/Typography.features.stories.tsx.snap +40 -86
  49. package/src/system/content/typography/__snapshots_web__/Typography.stories.tsx.snap +0 -1
  50. package/src/system/content/typography/__snapshots_web__/TypographyIcon.features.stories.tsx.snap +42 -67
  51. package/src/system/content/typography/__snapshots_web__/TypographyIcon.stories.tsx.snap +1 -1
  52. package/src/system/content/typography/__snapshots_web__/TypographyLink.features.stories.tsx.snap +120 -20
  53. package/src/system/content/typography/__snapshots_web__/TypographyLink.stories.tsx.snap +1 -2
  54. package/src/system/content/typography/utils/typographyContext.ts +13 -25
  55. package/src/system/core/hooks/useProps.ts +9 -0
  56. package/src/system/core/primitives/ScrollView/__snapshots_web__/ScrollView.features.stories.tsx.snap +37 -74
  57. package/src/system/core/primitives/ScrollView/__snapshots_web__/ScrollView.stories.tsx.snap +10 -20
  58. package/src/system/core/primitives/__snapshots_web__/Center.features.stories.tsx.snap +5 -10
  59. package/src/system/core/primitives/__snapshots_web__/Center.stories.tsx.snap +1 -2
  60. package/src/system/core/primitives/__snapshots_web__/Pressable.features.stories.tsx.snap +9 -18
  61. package/src/system/core/primitives/__snapshots_web__/Pressable.stories.tsx.snap +0 -1
  62. package/src/system/core/primitives/__snapshots_web__/Stack.features.stories.tsx.snap +33 -66
  63. package/src/system/core/primitives/__snapshots_web__/Stack.stories.tsx.snap +3 -6
  64. package/src/system/core/primitives/__snapshots_web__/View.features.stories.tsx.snap +60 -120
  65. package/src/system/core/themes/light/__snapshots_web__/light.stories.tsx.snap +111 -222
  66. package/src/system/core/tokens/__snapshots_web__/breakpoints.stories.tsx.snap +11 -22
  67. package/src/system/core/tokens/__snapshots_web__/bumperIcon.stories.tsx.snap +7 -14
  68. package/src/system/core/tokens/__snapshots_web__/fonts.stories.tsx.snap +67 -134
  69. package/src/system/core/tokens/__snapshots_web__/radius.stories.tsx.snap +11 -22
  70. package/src/system/core/tokens/__snapshots_web__/size.stories.tsx.snap +25 -50
  71. package/src/system/core/tokens/__snapshots_web__/space.stories.tsx.snap +28 -56
  72. package/src/system/core/tokens/palettes/__snapshots_web__/deepPurpleColorPalette.stories.tsx.snap +133 -266
  73. package/src/system/dataDisplays/Badge/Badge.tsx +2 -1
  74. package/src/system/dataDisplays/Badge/__snapshots_web__/Badge.features.stories.tsx.snap +8 -16
  75. package/src/system/dataDisplays/Badge/__snapshots_web__/Badge.stories.tsx.snap +1 -2
  76. package/src/system/loading/loader/__snapshots_web__/Loader.features.stories.tsx.snap +2 -4
  77. package/src/system/types.ts +2 -1
  78. package/dist/definitions/system/content/typography/utils/getVariantAndWeightValues.d.ts +0 -10
  79. package/dist/definitions/system/content/typography/utils/getVariantAndWeightValues.d.ts.map +0 -1
  80. package/src/system/content/typography/utils/getVariantAndWeightValues.test.tsx +0 -178
  81. package/src/system/content/typography/utils/getVariantAndWeightValues.tsx +0 -40
@@ -458,78 +458,61 @@ const VStack = core.styled(core.Stack, {
458
458
  flexDirection: 'column'
459
459
  });
460
460
 
461
- function getVariantAndWeightValues(weightProp, variantProp, typographyWeightAncestorValue, typographyVariantAncestorValue) {
462
- const computedVariant = variantProp || typographyVariantAncestorValue || undefined;
463
- if (computedVariant) {
464
- if (BODY_VARIANTS.includes(computedVariant)) {
465
- const computedWeight = weightProp || typographyWeightAncestorValue || undefined;
466
- return {
467
- weight: computedWeight,
468
- variant: computedVariant
469
- };
470
- }
471
- // Content Caps variant have fixed weights so we override any provided weight
472
- if (CONTENT_CAPS_VARIANTS.includes(computedVariant)) {
473
- return {
474
- weight: 'bold',
475
- variant: computedVariant
476
- };
477
- }
478
- // Heading variants have fixed weights so we override any provided weight
479
- if (HEADING_VARIANTS.includes(computedVariant)) {
480
- return {
481
- weight: 'semibold',
482
- variant: computedVariant
483
- };
484
- }
485
- // Label variants have fixed weights so we override any provided weight
486
- if (LABEL_VARIANTS.includes(computedVariant)) {
487
- return {
488
- weight: 'semibold',
489
- variant: computedVariant
490
- };
491
- }
492
- }
493
- return {
494
- weight: weightProp,
495
- variant: undefined
496
- };
497
- }
498
-
499
- const TypographyVariantContext = /*#__PURE__*/react.createContext(null);
500
- const TypographyWeightContext = /*#__PURE__*/react.createContext(null);
501
- const TypograhyColorContext = /*#__PURE__*/react.createContext(null);
502
- const TypographyContext = /*#__PURE__*/react.createContext(false);
503
- const useTypographyColor = () => {
504
- return react.useContext(TypograhyColorContext);
505
- };
506
- const useTypographyVariant = () => {
507
- return react.useContext(TypographyVariantContext);
508
- };
509
- const useTypographyWeight = () => {
510
- return react.useContext(TypographyWeightContext);
511
- };
512
- const useTypographyContext = () => {
513
- return react.useContext(TypographyContext);
514
- };
461
+ const typographyStyleContext = core.createStyledContext({
462
+ color: undefined,
463
+ weight: undefined,
464
+ variant: undefined
465
+ });
515
466
 
516
- const InternalTypographyBase = core.styled(core.Text, {
467
+ const InternalTypography = core.styled(core.Text, {
468
+ context: typographyStyleContext,
517
469
  fontFamily: '$GTStandard',
470
+ fontSize: '$body-m',
471
+ lineHeight: '$body-m',
472
+ letterSpacing: '$body-m',
473
+ fontWeight: '$regular',
518
474
  color: '$content.base.hi',
519
475
  '$platform-web': {
520
476
  WebkitFontSmoothing: 'antialiased'
521
477
  },
522
478
  variants: {
523
479
  variant: variant => {
524
- if (!variant) return {};
525
- const isContentCapsVariant = CONTENT_CAPS_VARIANTS.includes(variant);
526
- return {
527
- fontFamily: isContentCapsVariant ? '$GTStandardNarrow' : '$GTStandard',
528
- textTransform: isContentCapsVariant ? 'uppercase' : undefined,
480
+ const commonVariantStyles = {
529
481
  fontSize: `$${variant}`,
530
482
  lineHeight: `$${variant}`,
531
483
  letterSpacing: `$${variant}`
532
484
  };
485
+
486
+ // Body variant
487
+ if (BODY_VARIANTS.includes(variant)) {
488
+ return {
489
+ ...commonVariantStyles
490
+ };
491
+ }
492
+ // Content Caps variant
493
+ if (CONTENT_CAPS_VARIANTS.includes(variant)) {
494
+ return {
495
+ fontFamily: '$GTStandardNarrow',
496
+ textTransform: 'uppercase',
497
+ fontWeight: '$bold',
498
+ ...commonVariantStyles
499
+ };
500
+ }
501
+ // Heading variants
502
+ if (HEADING_VARIANTS.includes(variant)) {
503
+ return {
504
+ fontWeight: '$semibold',
505
+ ...commonVariantStyles
506
+ };
507
+ }
508
+ // Label variants
509
+ if (LABEL_VARIANTS.includes(variant)) {
510
+ return {
511
+ fontWeight: '$semibold',
512
+ ...commonVariantStyles
513
+ };
514
+ }
515
+ return undefined;
533
516
  },
534
517
  weight: {
535
518
  regular: {
@@ -544,57 +527,9 @@ const InternalTypographyBase = core.styled(core.Text, {
544
527
  }
545
528
  },
546
529
  defaultVariants: {
547
- variant: 'body-m',
548
530
  weight: 'regular'
549
531
  }
550
532
  });
551
- const InternalTypography = InternalTypographyBase.styleable((props, ref) => {
552
- const typographyVariantAncestorValue = useTypographyVariant();
553
- const typographyWeightAncestorValue = useTypographyWeight();
554
- const typographyColorAncestorValue = useTypographyColor();
555
- const typographyContext = useTypographyContext();
556
- const {
557
- variant,
558
- weight
559
- } = getVariantAndWeightValues(props.weight, props.variant, typographyWeightAncestorValue, typographyVariantAncestorValue);
560
- const color = props.color || typographyColorAncestorValue || undefined;
561
- let content = /*#__PURE__*/jsxRuntime.jsx(InternalTypographyBase, {
562
- ref: ref,
563
- ...props,
564
- ...(color ? {
565
- color
566
- } : undefined),
567
- ...(weight ? {
568
- weight
569
- } : undefined),
570
- ...(variant ? {
571
- variant
572
- } : undefined)
573
- });
574
- content = typographyContext ? content : /*#__PURE__*/jsxRuntime.jsx(TypographyContext.Provider, {
575
- value: true,
576
- children: content
577
- });
578
-
579
- // If a variant is provided, we set it in the context for children to be able to inherit variant value
580
- content = props.variant ? /*#__PURE__*/jsxRuntime.jsx(TypographyVariantContext.Provider, {
581
- value: props.variant,
582
- children: content
583
- }) : content;
584
-
585
- // If a weight is provided, we set it in the context for children to be able to inherit weight value
586
- content = props.weight ? /*#__PURE__*/jsxRuntime.jsx(TypographyWeightContext.Provider, {
587
- value: props.weight,
588
- children: content
589
- }) : content;
590
-
591
- // If a color is provided, we set it in the context for children to be able to inherit color value
592
- content = props.color ? /*#__PURE__*/jsxRuntime.jsx(TypograhyColorContext.Provider, {
593
- value: props.color,
594
- children: content
595
- }) : content;
596
- return content;
597
- });
598
533
  function TypographyBase(props) {
599
534
  return /*#__PURE__*/jsxRuntime.jsx(InternalTypography, {
600
535
  ...props
@@ -611,6 +546,13 @@ const createHeading = level => {
611
546
  };
612
547
  };
613
548
 
549
+ // eslint-disable-next-line no-restricted-imports
550
+ // This hook is a wrapper around Tamagui's useProps to extract only the non-media props from the given props object.
551
+ // It uses our custom PropsWithoutMediaStyles type to ensure that all media props are optional, even if they are required in the original props type. This is necessary for our components which have required media props (like variant for Typography).
552
+ function useProps(props) {
553
+ return core.useProps(props);
554
+ }
555
+
614
556
  const IconContainer = core.styled(core.View, {
615
557
  name: 'Icon',
616
558
  variants: {
@@ -624,83 +566,49 @@ const IconContainer = core.styled(core.View, {
624
566
  }
625
567
  }
626
568
  });
627
- function Icon({
628
- icon,
629
- color = '$content.base.hi',
630
- size = '$icon.m',
631
- testID,
632
- alignSelf
633
- }) {
569
+ const InternalIcon = IconContainer.styleable(props => {
570
+ const flattenProps = useProps(props);
634
571
  const style = core.useStyle({
635
- color
572
+ color: flattenProps.color || '$content.base.hi'
636
573
  });
637
- const clonedIcon = /*#__PURE__*/react.cloneElement(icon, {
574
+ const clonedIcon = /*#__PURE__*/react.cloneElement(flattenProps.icon, {
638
575
  color: style.color
639
576
  });
640
577
  return /*#__PURE__*/jsxRuntime.jsx(IconContainer, {
641
- size: size,
642
- testID: testID,
643
- alignSelf: alignSelf,
578
+ size: flattenProps.size,
579
+ testID: flattenProps.testID,
580
+ alignSelf: flattenProps.alignSelf,
644
581
  children: clonedIcon
645
582
  });
646
- }
583
+ });
647
584
 
648
585
  const InternalTypographyView = core.styled(core.View, {
649
- name: 'TypographyView'
586
+ name: 'TypographyViewInternal',
587
+ '$platform-web': {
588
+ display: 'inline-flex'
589
+ }
650
590
  });
651
- /**
652
- *
653
- * A wrapper component that applies typography styles to its children in order to maintain consistent style between web and native
654
- * In native, it simply renders a View as it renders correctly by default
655
- * In web, it ensures that the display is set to inline-flex when inside a Typography context
656
- *
657
- * React Native Web includes this implementation in its codebase
658
- * but Tamagui does not use React Native Webview, we need to implement it ourselves
659
- *
660
- * Inside a Typography component, always use TypographyView to wrap external components like Icon or Svg
661
- */
662
591
  function TypographyView(props) {
663
- const isInTypographyContext = useTypographyContext();
664
592
  return /*#__PURE__*/jsxRuntime.jsx(InternalTypographyView, {
665
- ...props,
666
- "$platform-web": isInTypographyContext ? {
667
- ...props['$platform-web'],
668
- display: 'inline-flex'
669
- } : props['$platform-web']
593
+ ...props
670
594
  });
671
595
  }
672
596
 
673
- function TypographyIconInternal(props) {
597
+ const TypographyIconInternal = core.styled(InternalIcon, {
598
+ name: 'TypographyIconInternal',
599
+ context: typographyStyleContext
600
+ });
601
+ function TypographyIcon(props) {
674
602
  return /*#__PURE__*/jsxRuntime.jsx(TypographyView, {
675
- children: /*#__PURE__*/jsxRuntime.jsx(Icon, {
603
+ children: /*#__PURE__*/jsxRuntime.jsx(TypographyIconInternal, {
676
604
  ...props
677
605
  })
678
606
  });
679
607
  }
680
- function TypographyIconInheritColor(props) {
681
- const typographyColorAncestorValue = useTypographyColor();
682
- return /*#__PURE__*/jsxRuntime.jsx(TypographyIconInternal, {
683
- color: typographyColorAncestorValue || undefined,
684
- ...props
685
- });
686
- }
687
- function TypographyIcon({
688
- color,
689
- ...props
690
- }) {
691
- if (color) {
692
- return /*#__PURE__*/jsxRuntime.jsx(TypographyIconInternal, {
693
- color: color,
694
- ...props
695
- });
696
- }
697
- return /*#__PURE__*/jsxRuntime.jsx(TypographyIconInheritColor, {
698
- ...props
699
- });
700
- }
701
608
 
702
609
  const InternalTypographyLink = core.styled(InternalTypography, {
703
610
  name: 'TypographyLink',
611
+ context: typographyStyleContext,
704
612
  role: 'link',
705
613
  variants: {
706
614
  disabled: {
@@ -769,7 +677,7 @@ function Badge(props) {
769
677
  const {
770
678
  count,
771
679
  maxCount = 9
772
- } = core.useProps(props);
680
+ } = useProps(props);
773
681
  if (count === undefined) {
774
682
  return /*#__PURE__*/jsxRuntime.jsx(BadgeDot, {});
775
683
  }