@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.
- package/CHANGELOG.md +9 -0
- package/dist/definitions/shared/storybook/StoryTitle.d.ts +1 -1
- package/dist/definitions/system/content/icon/Icon.d.ts +6 -1
- package/dist/definitions/system/content/icon/Icon.d.ts.map +1 -1
- package/dist/definitions/system/content/typography/Typography.d.ts +10 -52
- package/dist/definitions/system/content/typography/Typography.d.ts.map +1 -1
- package/dist/definitions/system/content/typography/TypographyIcon.d.ts +5 -2
- package/dist/definitions/system/content/typography/TypographyIcon.d.ts.map +1 -1
- package/dist/definitions/system/content/typography/TypographyLink.d.ts +1 -1
- package/dist/definitions/system/content/typography/TypographyLink.d.ts.map +1 -1
- package/dist/definitions/system/content/typography/TypographyView.d.ts +2 -2
- package/dist/definitions/system/content/typography/TypographyView.d.ts.map +1 -1
- package/dist/definitions/system/content/typography/utils/typographyContext.d.ts +8 -13
- package/dist/definitions/system/content/typography/utils/typographyContext.d.ts.map +1 -1
- package/dist/definitions/system/core/hooks/useProps.d.ts +3 -0
- package/dist/definitions/system/core/hooks/useProps.d.ts.map +1 -0
- package/dist/definitions/system/dataDisplays/Badge/Badge.d.ts.map +1 -1
- package/dist/definitions/system/types.d.ts +1 -2
- package/dist/definitions/system/types.d.ts.map +1 -1
- package/dist/index-metro.es.android.js +69 -160
- package/dist/index-metro.es.android.js.map +1 -1
- package/dist/index-metro.es.ios.js +69 -160
- package/dist/index-metro.es.ios.js.map +1 -1
- package/dist/index-node-22.22.cjs.js +71 -163
- package/dist/index-node-22.22.cjs.js.map +1 -1
- package/dist/index-node-22.22.cjs.web.js +71 -163
- package/dist/index-node-22.22.cjs.web.js.map +1 -1
- package/dist/index-node-22.22.es.mjs +72 -164
- package/dist/index-node-22.22.es.mjs.map +1 -1
- package/dist/index-node-22.22.es.web.mjs +72 -164
- package/dist/index-node-22.22.es.web.mjs.map +1 -1
- package/dist/index.es.js +69 -158
- package/dist/index.es.js.map +1 -1
- package/dist/index.es.web.js +69 -158
- package/dist/index.es.web.js.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/.eslintrc.json +2 -2
- package/src/system/content/icon/Icon.tsx +10 -4
- package/src/system/content/icon/__snapshots_web__/Icon.features.stories.tsx.snap +11 -22
- package/src/system/content/typography/Typography.tsx +66 -75
- package/src/system/content/typography/TypographyIcon.tsx +14 -19
- package/src/system/content/typography/TypographyLink.features.stories.tsx +34 -8
- package/src/system/content/typography/TypographyLink.stories.tsx +2 -1
- package/src/system/content/typography/TypographyLink.tsx +2 -0
- package/src/system/content/typography/TypographyView.tsx +10 -17
- package/src/system/content/typography/__snapshots__/TypographyLink.features.stories.tsx.snap +164 -0
- package/src/system/content/typography/__snapshots_web__/Typography.features.stories.tsx.snap +40 -86
- package/src/system/content/typography/__snapshots_web__/Typography.stories.tsx.snap +0 -1
- package/src/system/content/typography/__snapshots_web__/TypographyIcon.features.stories.tsx.snap +42 -67
- package/src/system/content/typography/__snapshots_web__/TypographyIcon.stories.tsx.snap +1 -1
- package/src/system/content/typography/__snapshots_web__/TypographyLink.features.stories.tsx.snap +120 -20
- package/src/system/content/typography/__snapshots_web__/TypographyLink.stories.tsx.snap +1 -2
- package/src/system/content/typography/utils/typographyContext.ts +13 -25
- package/src/system/core/hooks/useProps.ts +9 -0
- package/src/system/core/primitives/ScrollView/__snapshots_web__/ScrollView.features.stories.tsx.snap +37 -74
- package/src/system/core/primitives/ScrollView/__snapshots_web__/ScrollView.stories.tsx.snap +10 -20
- package/src/system/core/primitives/__snapshots_web__/Center.features.stories.tsx.snap +5 -10
- package/src/system/core/primitives/__snapshots_web__/Center.stories.tsx.snap +1 -2
- package/src/system/core/primitives/__snapshots_web__/Pressable.features.stories.tsx.snap +9 -18
- package/src/system/core/primitives/__snapshots_web__/Pressable.stories.tsx.snap +0 -1
- package/src/system/core/primitives/__snapshots_web__/Stack.features.stories.tsx.snap +33 -66
- package/src/system/core/primitives/__snapshots_web__/Stack.stories.tsx.snap +3 -6
- package/src/system/core/primitives/__snapshots_web__/View.features.stories.tsx.snap +60 -120
- package/src/system/core/themes/light/__snapshots_web__/light.stories.tsx.snap +111 -222
- package/src/system/core/tokens/__snapshots_web__/breakpoints.stories.tsx.snap +11 -22
- package/src/system/core/tokens/__snapshots_web__/bumperIcon.stories.tsx.snap +7 -14
- package/src/system/core/tokens/__snapshots_web__/fonts.stories.tsx.snap +67 -134
- package/src/system/core/tokens/__snapshots_web__/radius.stories.tsx.snap +11 -22
- package/src/system/core/tokens/__snapshots_web__/size.stories.tsx.snap +25 -50
- package/src/system/core/tokens/__snapshots_web__/space.stories.tsx.snap +28 -56
- package/src/system/core/tokens/palettes/__snapshots_web__/deepPurpleColorPalette.stories.tsx.snap +133 -266
- package/src/system/dataDisplays/Badge/Badge.tsx +2 -1
- package/src/system/dataDisplays/Badge/__snapshots_web__/Badge.features.stories.tsx.snap +8 -16
- package/src/system/dataDisplays/Badge/__snapshots_web__/Badge.stories.tsx.snap +1 -2
- package/src/system/loading/loader/__snapshots_web__/Loader.features.stories.tsx.snap +2 -4
- package/src/system/types.ts +2 -1
- package/dist/definitions/system/content/typography/utils/getVariantAndWeightValues.d.ts +0 -10
- package/dist/definitions/system/content/typography/utils/getVariantAndWeightValues.d.ts.map +0 -1
- package/src/system/content/typography/utils/getVariantAndWeightValues.test.tsx +0 -178
- package/src/system/content/typography/utils/getVariantAndWeightValues.tsx +0 -40
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { px, createFont, createTokens, createTamagui, TamaguiProvider, styled, View, Stack,
|
|
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 {
|
|
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
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
620
|
-
|
|
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: '
|
|
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
|
-
|
|
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(
|
|
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: {
|