@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
@@ -1,7 +1,7 @@
1
- import { px, createFont, createTokens, createTamagui, TamaguiProvider, styled, View, Stack, Text, useStyle, useProps, useMedia } from '@tamagui/core';
1
+ import { px, createFont, createTokens, createTamagui, TamaguiProvider, styled, View, Stack, createStyledContext, Text, useProps as useProps$1, useStyle, useMedia } from '@tamagui/core';
2
2
  export { Stack, View } from '@tamagui/core';
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
- import { createContext, useContext, cloneElement, useMemo, useEffect } from 'react';
4
+ import { cloneElement, useMemo, useEffect } from 'react';
5
5
  import Animated, { Easing, useAnimatedProps, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';
6
6
  import Svg, { Circle } from 'react-native-svg';
7
7
  export { Image } from '@tamagui/image';
@@ -450,78 +450,61 @@ const VStack = styled(Stack, {
450
450
  flexDirection: 'column'
451
451
  });
452
452
 
453
- function getVariantAndWeightValues(weightProp, variantProp, typographyWeightAncestorValue, typographyVariantAncestorValue) {
454
- const computedVariant = variantProp || typographyVariantAncestorValue || undefined;
455
- if (computedVariant) {
456
- if (BODY_VARIANTS.includes(computedVariant)) {
457
- const computedWeight = weightProp || typographyWeightAncestorValue || undefined;
458
- return {
459
- weight: computedWeight,
460
- variant: computedVariant
461
- };
462
- }
463
- // Content Caps variant have fixed weights so we override any provided weight
464
- if (CONTENT_CAPS_VARIANTS.includes(computedVariant)) {
465
- return {
466
- weight: 'bold',
467
- variant: computedVariant
468
- };
469
- }
470
- // Heading variants have fixed weights so we override any provided weight
471
- if (HEADING_VARIANTS.includes(computedVariant)) {
472
- return {
473
- weight: 'semibold',
474
- variant: computedVariant
475
- };
476
- }
477
- // Label variants have fixed weights so we override any provided weight
478
- if (LABEL_VARIANTS.includes(computedVariant)) {
479
- return {
480
- weight: 'semibold',
481
- variant: computedVariant
482
- };
483
- }
484
- }
485
- return {
486
- weight: weightProp,
487
- variant: undefined
488
- };
489
- }
490
-
491
- const TypographyVariantContext = /*#__PURE__*/createContext(null);
492
- const TypographyWeightContext = /*#__PURE__*/createContext(null);
493
- const TypograhyColorContext = /*#__PURE__*/createContext(null);
494
- const TypographyContext = /*#__PURE__*/createContext(false);
495
- const useTypographyColor = () => {
496
- return useContext(TypograhyColorContext);
497
- };
498
- const useTypographyVariant = () => {
499
- return useContext(TypographyVariantContext);
500
- };
501
- const useTypographyWeight = () => {
502
- return useContext(TypographyWeightContext);
503
- };
504
- const useTypographyContext = () => {
505
- return useContext(TypographyContext);
506
- };
453
+ const typographyStyleContext = createStyledContext({
454
+ color: undefined,
455
+ weight: undefined,
456
+ variant: undefined
457
+ });
507
458
 
508
- const InternalTypographyBase = styled(Text, {
459
+ const InternalTypography = styled(Text, {
460
+ context: typographyStyleContext,
509
461
  fontFamily: '$GTStandard',
462
+ fontSize: '$body-m',
463
+ lineHeight: '$body-m',
464
+ letterSpacing: '$body-m',
465
+ fontWeight: '$regular',
510
466
  color: '$content.base.hi',
511
467
  '$platform-web': {
512
468
  WebkitFontSmoothing: 'antialiased'
513
469
  },
514
470
  variants: {
515
471
  variant: variant => {
516
- if (!variant) return {};
517
- const isContentCapsVariant = CONTENT_CAPS_VARIANTS.includes(variant);
518
- return {
519
- fontFamily: isContentCapsVariant ? '$GTStandardNarrow' : '$GTStandard',
520
- textTransform: isContentCapsVariant ? 'uppercase' : undefined,
472
+ const commonVariantStyles = {
521
473
  fontSize: `$${variant}`,
522
474
  lineHeight: `$${variant}`,
523
475
  letterSpacing: `$${variant}`
524
476
  };
477
+
478
+ // Body variant
479
+ if (BODY_VARIANTS.includes(variant)) {
480
+ return {
481
+ ...commonVariantStyles
482
+ };
483
+ }
484
+ // Content Caps variant
485
+ if (CONTENT_CAPS_VARIANTS.includes(variant)) {
486
+ return {
487
+ fontFamily: '$GTStandardNarrow',
488
+ textTransform: 'uppercase',
489
+ fontWeight: '$bold',
490
+ ...commonVariantStyles
491
+ };
492
+ }
493
+ // Heading variants
494
+ if (HEADING_VARIANTS.includes(variant)) {
495
+ return {
496
+ fontWeight: '$semibold',
497
+ ...commonVariantStyles
498
+ };
499
+ }
500
+ // Label variants
501
+ if (LABEL_VARIANTS.includes(variant)) {
502
+ return {
503
+ fontWeight: '$semibold',
504
+ ...commonVariantStyles
505
+ };
506
+ }
507
+ return undefined;
525
508
  },
526
509
  weight: {
527
510
  regular: {
@@ -536,57 +519,9 @@ const InternalTypographyBase = styled(Text, {
536
519
  }
537
520
  },
538
521
  defaultVariants: {
539
- variant: 'body-m',
540
522
  weight: 'regular'
541
523
  }
542
524
  });
543
- const InternalTypography = InternalTypographyBase.styleable((props, ref) => {
544
- const typographyVariantAncestorValue = useTypographyVariant();
545
- const typographyWeightAncestorValue = useTypographyWeight();
546
- const typographyColorAncestorValue = useTypographyColor();
547
- const typographyContext = useTypographyContext();
548
- const {
549
- variant,
550
- weight
551
- } = getVariantAndWeightValues(props.weight, props.variant, typographyWeightAncestorValue, typographyVariantAncestorValue);
552
- const color = props.color || typographyColorAncestorValue || undefined;
553
- let content = /*#__PURE__*/jsx(InternalTypographyBase, {
554
- ref: ref,
555
- ...props,
556
- ...(color ? {
557
- color
558
- } : undefined),
559
- ...(weight ? {
560
- weight
561
- } : undefined),
562
- ...(variant ? {
563
- variant
564
- } : undefined)
565
- });
566
- content = typographyContext ? content : /*#__PURE__*/jsx(TypographyContext.Provider, {
567
- value: true,
568
- children: content
569
- });
570
-
571
- // If a variant is provided, we set it in the context for children to be able to inherit variant value
572
- content = props.variant ? /*#__PURE__*/jsx(TypographyVariantContext.Provider, {
573
- value: props.variant,
574
- children: content
575
- }) : content;
576
-
577
- // If a weight is provided, we set it in the context for children to be able to inherit weight value
578
- content = props.weight ? /*#__PURE__*/jsx(TypographyWeightContext.Provider, {
579
- value: props.weight,
580
- children: content
581
- }) : content;
582
-
583
- // If a color is provided, we set it in the context for children to be able to inherit color value
584
- content = props.color ? /*#__PURE__*/jsx(TypograhyColorContext.Provider, {
585
- value: props.color,
586
- children: content
587
- }) : content;
588
- return content;
589
- });
590
525
  function TypographyBase(props) {
591
526
  return /*#__PURE__*/jsx(InternalTypography, {
592
527
  ...props
@@ -603,6 +538,13 @@ const createHeading = level => {
603
538
  };
604
539
  };
605
540
 
541
+ // eslint-disable-next-line no-restricted-imports
542
+ // This hook is a wrapper around Tamagui's useProps to extract only the non-media props from the given props object.
543
+ // 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).
544
+ function useProps(props) {
545
+ return useProps$1(props);
546
+ }
547
+
606
548
  const IconContainer = styled(View, {
607
549
  name: 'Icon',
608
550
  variants: {
@@ -616,83 +558,49 @@ const IconContainer = styled(View, {
616
558
  }
617
559
  }
618
560
  });
619
- function Icon({
620
- icon,
621
- color = '$content.base.hi',
622
- size = '$icon.m',
623
- testID,
624
- alignSelf
625
- }) {
561
+ const InternalIcon = IconContainer.styleable(props => {
562
+ const flattenProps = useProps(props);
626
563
  const style = useStyle({
627
- color
564
+ color: flattenProps.color || '$content.base.hi'
628
565
  });
629
- const clonedIcon = /*#__PURE__*/cloneElement(icon, {
566
+ const clonedIcon = /*#__PURE__*/cloneElement(flattenProps.icon, {
630
567
  color: style.color
631
568
  });
632
569
  return /*#__PURE__*/jsx(IconContainer, {
633
- size: size,
634
- testID: testID,
635
- alignSelf: alignSelf,
570
+ size: flattenProps.size,
571
+ testID: flattenProps.testID,
572
+ alignSelf: flattenProps.alignSelf,
636
573
  children: clonedIcon
637
574
  });
638
- }
575
+ });
639
576
 
640
577
  const InternalTypographyView = styled(View, {
641
- name: 'TypographyView'
578
+ name: 'TypographyViewInternal',
579
+ '$platform-web': {
580
+ display: 'inline-flex'
581
+ }
642
582
  });
643
- /**
644
- *
645
- * A wrapper component that applies typography styles to its children in order to maintain consistent style between web and native
646
- * In native, it simply renders a View as it renders correctly by default
647
- * In web, it ensures that the display is set to inline-flex when inside a Typography context
648
- *
649
- * React Native Web includes this implementation in its codebase
650
- * but Tamagui does not use React Native Webview, we need to implement it ourselves
651
- *
652
- * Inside a Typography component, always use TypographyView to wrap external components like Icon or Svg
653
- */
654
583
  function TypographyView(props) {
655
- const isInTypographyContext = useTypographyContext();
656
584
  return /*#__PURE__*/jsx(InternalTypographyView, {
657
- ...props,
658
- "$platform-web": isInTypographyContext ? {
659
- ...props['$platform-web'],
660
- display: 'inline-flex'
661
- } : props['$platform-web']
585
+ ...props
662
586
  });
663
587
  }
664
588
 
665
- function TypographyIconInternal(props) {
589
+ const TypographyIconInternal = styled(InternalIcon, {
590
+ name: 'TypographyIconInternal',
591
+ context: typographyStyleContext
592
+ });
593
+ function TypographyIcon(props) {
666
594
  return /*#__PURE__*/jsx(TypographyView, {
667
- children: /*#__PURE__*/jsx(Icon, {
595
+ children: /*#__PURE__*/jsx(TypographyIconInternal, {
668
596
  ...props
669
597
  })
670
598
  });
671
599
  }
672
- function TypographyIconInheritColor(props) {
673
- const typographyColorAncestorValue = useTypographyColor();
674
- return /*#__PURE__*/jsx(TypographyIconInternal, {
675
- color: typographyColorAncestorValue || undefined,
676
- ...props
677
- });
678
- }
679
- function TypographyIcon({
680
- color,
681
- ...props
682
- }) {
683
- if (color) {
684
- return /*#__PURE__*/jsx(TypographyIconInternal, {
685
- color: color,
686
- ...props
687
- });
688
- }
689
- return /*#__PURE__*/jsx(TypographyIconInheritColor, {
690
- ...props
691
- });
692
- }
693
600
 
694
601
  const InternalTypographyLink = styled(InternalTypography, {
695
602
  name: 'TypographyLink',
603
+ context: typographyStyleContext,
696
604
  role: 'link',
697
605
  variants: {
698
606
  disabled: {