@ornikar/bumper 2.5.1-canary.9789a78a274b9d336c93fc42d4a6561d0d61ff73.0 → 2.6.1-canary.5ea5493c945a003792345fbeb7191d0e206ed8da.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 +13 -8
- package/dist/definitions/components/primitives/Pressable.d.ts +26 -0
- package/dist/definitions/components/primitives/Pressable.d.ts.map +1 -0
- package/dist/definitions/components/typography/Typography.d.ts +44 -0
- package/dist/definitions/components/typography/Typography.d.ts.map +1 -0
- package/dist/definitions/components/typography/utils/{getTypeAndWeightValues.d.ts → getVariantAndWeightValues.d.ts} +2 -2
- package/dist/definitions/components/typography/utils/getVariantAndWeightValues.d.ts.map +1 -0
- package/dist/definitions/index.d.ts +4 -2
- package/dist/definitions/index.d.ts.map +1 -1
- package/dist/definitions/story-components/StoryTitle.d.ts +2 -2
- package/dist/definitions/tamagui.config.d.ts +3 -3
- package/dist/definitions/tokens/fonts.d.ts +7 -5
- package/dist/definitions/tokens/fonts.d.ts.map +1 -1
- package/dist/index-metro.es.android.js +114 -32
- package/dist/index-metro.es.android.js.map +1 -1
- package/dist/index-metro.es.ios.js +114 -32
- package/dist/index-metro.es.ios.js.map +1 -1
- package/dist/index-node-22.17.cjs.js +113 -31
- package/dist/index-node-22.17.cjs.js.map +1 -1
- package/dist/index-node-22.17.cjs.web.js +113 -31
- package/dist/index-node-22.17.cjs.web.js.map +1 -1
- package/dist/index-node-22.17.es.mjs +113 -32
- package/dist/index-node-22.17.es.mjs.map +1 -1
- package/dist/index-node-22.17.es.web.mjs +113 -32
- package/dist/index-node-22.17.es.web.mjs.map +1 -1
- package/dist/index.es.js +112 -32
- package/dist/index.es.js.map +1 -1
- package/dist/index.es.web.js +112 -32
- package/dist/index.es.web.js.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/components/breakpoints/__snapshots_web__/breakpoints.stories.tsx.snap +1 -1
- package/src/components/breakpoints/breakpoints.stories.tsx +1 -1
- package/src/components/primitives/Pressable.stories.tsx +25 -0
- package/src/components/primitives/Pressable.tsx +35 -0
- package/src/components/primitives/__snapshots__/Pressable.stories.tsx.snap +53 -0
- package/src/components/primitives/__snapshots_web__/Center.stories.tsx.snap +1 -1
- package/src/components/primitives/__snapshots_web__/Pressable.stories.tsx.snap +37 -0
- package/src/components/primitives/__snapshots_web__/Stack.stories.tsx.snap +1 -1
- package/src/components/primitives/__snapshots_web__/View.stories.tsx.snap +1 -1
- package/src/components/typography/Typography.stories.tsx +45 -17
- package/src/components/typography/{Typograhy.tsx → Typography.tsx} +53 -27
- package/src/components/typography/__snapshots__/Typography.stories.tsx.snap +599 -60
- package/src/components/typography/__snapshots_web__/Typography.stories.tsx.snap +229 -2
- package/src/components/typography/utils/{getTypeAndWeightValues.test.tsx → getVariantAndWeightValues.test.tsx} +32 -2
- package/src/components/typography/utils/{getTypeAndWeightValues.tsx → getVariantAndWeightValues.tsx} +14 -3
- package/src/index.ts +4 -2
- package/src/story-components/StoryTitle.tsx +1 -1
- package/src/themes/__snapshots__/light.stories.tsx.snap +1 -1
- package/src/themes/__snapshots_web__/light.stories.tsx.snap +1 -1
- package/src/themes/light.stories.tsx +1 -1
- package/src/tokens/fonts.ts +45 -10
- package/src/tokens/palettes/__snapshots__/deepPurpleColorPalette.stories.tsx.snap +1 -1
- package/src/tokens/palettes/__snapshots_web__/deepPurpleColorPalette.stories.tsx.snap +1 -1
- package/src/tokens/palettes/deepPurpleColorPalette.stories.tsx +1 -1
- package/dist/definitions/components/typography/Typograhy.d.ts +0 -40
- package/dist/definitions/components/typography/Typograhy.d.ts.map +0 -1
- package/dist/definitions/components/typography/utils/getTypeAndWeightValues.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ornikar/bumper",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1-canary.5ea5493c945a003792345fbeb7191d0e206ed8da.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "@ornikar/bumper",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@storybook/preview-api": ">=8.6.15",
|
|
35
|
-
"react": "^
|
|
36
|
-
"react-dom": "^
|
|
35
|
+
"react": "^19.0.0",
|
|
36
|
+
"react-dom": "^19.0.0",
|
|
37
37
|
"react-native": ">=0.76.9"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"@testing-library/dom": "10.4.1",
|
|
53
53
|
"@testing-library/react": "16.3.1",
|
|
54
54
|
"@testing-library/react-native": "13.3.3",
|
|
55
|
-
"@types/react": "
|
|
56
|
-
"react": "
|
|
57
|
-
"react-dom": "
|
|
58
|
-
"react-native": "0.
|
|
59
|
-
"react-test-renderer": "
|
|
55
|
+
"@types/react": "19.0.10",
|
|
56
|
+
"react": "19.0.0",
|
|
57
|
+
"react-dom": "19.0.0",
|
|
58
|
+
"react-native": "0.79.6",
|
|
59
|
+
"react-test-renderer": "19.0.0"
|
|
60
60
|
},
|
|
61
61
|
"expo": {},
|
|
62
62
|
"exports": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryFn } from '@storybook/react';
|
|
2
2
|
import type { View } from '@tamagui/core';
|
|
3
3
|
import type { ReactElement } from 'react';
|
|
4
|
-
import { Typography } from '../typography/
|
|
4
|
+
import { Typography } from '../typography/Typography';
|
|
5
5
|
import { SwitchBreakpoints } from './SwitchBreakpoins';
|
|
6
6
|
import { useBreakpointValue } from './hooks/useBreakpointValue';
|
|
7
7
|
import { useCurrentBreakpointName } from './hooks/useCurrentBreakpointName';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Meta, StoryFn } from '@storybook/react';
|
|
2
|
+
import { Typography } from '../typography/Typography';
|
|
3
|
+
import type { CenterProps } from './Center';
|
|
4
|
+
import { Center } from './Center';
|
|
5
|
+
import { Pressable } from './Pressable';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'bumper/Primitives',
|
|
9
|
+
component: Center,
|
|
10
|
+
} satisfies Meta<CenterProps>;
|
|
11
|
+
|
|
12
|
+
export const PressableStory: StoryFn<typeof Pressable> = () => (
|
|
13
|
+
<Pressable
|
|
14
|
+
as={Center}
|
|
15
|
+
marginTop="$space.16"
|
|
16
|
+
padding="$space.24"
|
|
17
|
+
backgroundColor="$bg.accent.default"
|
|
18
|
+
pressStyle={{ opacity: 0.7 }}
|
|
19
|
+
onPress={() => null}
|
|
20
|
+
>
|
|
21
|
+
<Typography.Text color="$content.base.onContrasted.hi">Click me</Typography.Text>
|
|
22
|
+
</Pressable>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
PressableStory.storyName = 'Pressable';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { GetProps, TamaguiComponent } from '@tamagui/core';
|
|
2
|
+
import { View, styled } from '@tamagui/core';
|
|
3
|
+
import type { ReactNode } from 'react';
|
|
4
|
+
import type { Except } from 'type-fest';
|
|
5
|
+
|
|
6
|
+
export type PressableProps<C extends TamaguiComponent = typeof View> = {
|
|
7
|
+
/**
|
|
8
|
+
* The Tamagui component to render as (`View`, `Stack`, etc.).
|
|
9
|
+
*
|
|
10
|
+
* @default View
|
|
11
|
+
*/
|
|
12
|
+
as?: C;
|
|
13
|
+
} & Except<GetProps<C>, 'as'>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A polymorphic Pressable component that can render as any Tamagui primitive.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* <Pressable onPress={() => {}} />
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* <Pressable
|
|
23
|
+
* as={HStack}
|
|
24
|
+
* onPress={() => {}}
|
|
25
|
+
* />
|
|
26
|
+
*/
|
|
27
|
+
export function Pressable<C extends TamaguiComponent = typeof View>({ as, ...rest }: PressableProps<C>): ReactNode {
|
|
28
|
+
const Component = styled(as ?? View, {
|
|
29
|
+
name: 'Pressable',
|
|
30
|
+
role: 'button',
|
|
31
|
+
cursor: 'pointer',
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return <Component {...(rest as GetProps<C>)} />;
|
|
35
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`bumper/Primitives Pressable 1`] = `
|
|
4
|
+
<RNCSafeAreaProvider
|
|
5
|
+
onInsetsChange={[Function]}
|
|
6
|
+
style={
|
|
7
|
+
[
|
|
8
|
+
{
|
|
9
|
+
"flex": 1,
|
|
10
|
+
},
|
|
11
|
+
undefined,
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
>
|
|
15
|
+
<View
|
|
16
|
+
onBlur={[Function]}
|
|
17
|
+
onClick={[Function]}
|
|
18
|
+
onFocus={[Function]}
|
|
19
|
+
onResponderGrant={[Function]}
|
|
20
|
+
onResponderMove={[Function]}
|
|
21
|
+
onResponderRelease={[Function]}
|
|
22
|
+
onResponderTerminate={[Function]}
|
|
23
|
+
onResponderTerminationRequest={[Function]}
|
|
24
|
+
onStartShouldSetResponder={[Function]}
|
|
25
|
+
role="button"
|
|
26
|
+
style={
|
|
27
|
+
{
|
|
28
|
+
"alignItems": "center",
|
|
29
|
+
"backgroundColor": "#563B56",
|
|
30
|
+
"justifyContent": "center",
|
|
31
|
+
"marginTop": 16,
|
|
32
|
+
"opacity": 1,
|
|
33
|
+
"paddingBottom": 24,
|
|
34
|
+
"paddingLeft": 24,
|
|
35
|
+
"paddingRight": 24,
|
|
36
|
+
"paddingTop": 24,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
>
|
|
40
|
+
<Text
|
|
41
|
+
style={
|
|
42
|
+
{
|
|
43
|
+
"color": "#ffffff",
|
|
44
|
+
"fontFamily": "GTStandard",
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
suppressHighlighting={true}
|
|
48
|
+
>
|
|
49
|
+
Click me
|
|
50
|
+
</Text>
|
|
51
|
+
</View>
|
|
52
|
+
</RNCSafeAreaProvider>
|
|
53
|
+
`;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`bumper/Primitives Pressable 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="css-view-g5y9jx r-flex-13awgt0"
|
|
7
|
+
>
|
|
8
|
+
<span
|
|
9
|
+
class=""
|
|
10
|
+
style="display: contents;"
|
|
11
|
+
>
|
|
12
|
+
<span
|
|
13
|
+
class=" "
|
|
14
|
+
style="display: contents;"
|
|
15
|
+
>
|
|
16
|
+
<span
|
|
17
|
+
class=" t_light is_Theme"
|
|
18
|
+
style="display: contents;"
|
|
19
|
+
>
|
|
20
|
+
<div
|
|
21
|
+
class="is_Pressable _opacity-0active-0--7 _display-flex _flexDirection-column _flexBasis-auto _boxSizing-border-box _position-relative _minHeight-0px _minWidth-0px _flexShrink-0 _justifyContent-center _alignItems-center _cursor-pointer _marginTop-t-space-spa1366020313 _paddingTop-t-space-spa1366020284 _paddingRight-t-space-spa1366020284 _paddingBottom-t-space-spa1366020284 _paddingLeft-t-space-spa1366020284 _backgroundColor-bg--accent-1633109644"
|
|
22
|
+
role="button"
|
|
23
|
+
tabindex="0"
|
|
24
|
+
>
|
|
25
|
+
<span
|
|
26
|
+
class="font_GTStandard _WebkitFontSmoothing-_platformweb_antialiased _display-inline _boxSizing-border-box _wordWrap-break-word _whiteSpace-pre-wrap _marginTop-0px _marginRight-0px _marginBottom-0px _marginLeft-0px _fontFamily-f-family _color-content--ba254712717"
|
|
27
|
+
data-disable-theme="true"
|
|
28
|
+
>
|
|
29
|
+
Click me
|
|
30
|
+
</span>
|
|
31
|
+
</div>
|
|
32
|
+
</span>
|
|
33
|
+
</span>
|
|
34
|
+
</span>
|
|
35
|
+
</div>
|
|
36
|
+
</DocumentFragment>
|
|
37
|
+
`;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { Meta, StoryFn } from '@storybook/react';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import { StorySection } from '../../story-components/StorySection';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
BodyFontVariants,
|
|
6
|
+
ContentCapsVariants,
|
|
7
|
+
FontVariants,
|
|
8
|
+
HeadingFontVariants,
|
|
9
|
+
LabelFontVariants,
|
|
10
|
+
} from '../../tokens/fonts';
|
|
5
11
|
import { VStack } from '../primitives/Stack';
|
|
6
12
|
import { View } from '../primitives/View';
|
|
7
|
-
import type { TypographyTextProps } from './
|
|
8
|
-
import { Typography } from './
|
|
13
|
+
import type { TypographyTextProps } from './Typography';
|
|
14
|
+
import { Typography } from './Typography';
|
|
9
15
|
|
|
10
16
|
export default {
|
|
11
17
|
title: 'bumper/Typography/Typography',
|
|
@@ -19,12 +25,13 @@ interface TypographyTypeWithComponent<T extends FontVariants> {
|
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
const headingVariants: TypographyTypeWithComponent<HeadingFontVariants>[] = [
|
|
22
|
-
{ component: Typography.Text, variant: 'heading-2xl', weights: [
|
|
23
|
-
{ component: Typography.Text, variant: 'heading-xl', weights: [
|
|
24
|
-
{ component: Typography.Text, variant: 'heading-l', weights: [
|
|
25
|
-
{ component: Typography.Text, variant: 'heading-m', weights: [
|
|
26
|
-
{ component: Typography.Text, variant: 'heading-s', weights: [
|
|
27
|
-
{ component: Typography.Text, variant: 'heading-xs', weights: [
|
|
28
|
+
{ component: Typography.Text, variant: 'heading-2xl', weights: ['semibold'] },
|
|
29
|
+
{ component: Typography.Text, variant: 'heading-xl', weights: ['semibold'] },
|
|
30
|
+
{ component: Typography.Text, variant: 'heading-l', weights: ['semibold'] },
|
|
31
|
+
{ component: Typography.Text, variant: 'heading-m', weights: ['semibold'] },
|
|
32
|
+
{ component: Typography.Text, variant: 'heading-s', weights: ['semibold'] },
|
|
33
|
+
{ component: Typography.Text, variant: 'heading-xs', weights: ['semibold'] },
|
|
34
|
+
{ component: Typography.Text, variant: 'heading-2xs', weights: ['semibold'] },
|
|
28
35
|
];
|
|
29
36
|
|
|
30
37
|
const bodyVariants: TypographyTypeWithComponent<BodyFontVariants>[] = [
|
|
@@ -36,10 +43,20 @@ const bodyVariants: TypographyTypeWithComponent<BodyFontVariants>[] = [
|
|
|
36
43
|
];
|
|
37
44
|
|
|
38
45
|
const labelVariants: TypographyTypeWithComponent<LabelFontVariants>[] = [
|
|
39
|
-
{ component: Typography.Text, variant: 'label-xl', weights: [
|
|
40
|
-
{ component: Typography.Text, variant: 'label-l', weights: [
|
|
41
|
-
{ component: Typography.Text, variant: 'label-m', weights: [
|
|
42
|
-
{ component: Typography.Text, variant: 'label-s', weights: [
|
|
46
|
+
{ component: Typography.Text, variant: 'label-xl', weights: ['semibold'] },
|
|
47
|
+
{ component: Typography.Text, variant: 'label-l', weights: ['semibold'] },
|
|
48
|
+
{ component: Typography.Text, variant: 'label-m', weights: ['semibold'] },
|
|
49
|
+
{ component: Typography.Text, variant: 'label-s', weights: ['semibold'] },
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const contentCapsVariants: TypographyTypeWithComponent<ContentCapsVariants>[] = [
|
|
53
|
+
{ component: Typography.Text, variant: 'content-caps-3xl', weights: ['bold'] },
|
|
54
|
+
{ component: Typography.Text, variant: 'content-caps-2xl', weights: ['bold'] },
|
|
55
|
+
{ component: Typography.Text, variant: 'content-caps-xl', weights: ['bold'] },
|
|
56
|
+
{ component: Typography.Text, variant: 'content-caps-l', weights: ['bold'] },
|
|
57
|
+
{ component: Typography.Text, variant: 'content-caps-m', weights: ['bold'] },
|
|
58
|
+
{ component: Typography.Text, variant: 'content-caps-s', weights: ['bold'] },
|
|
59
|
+
{ component: Typography.Text, variant: 'content-caps-xs', weights: ['bold'] },
|
|
43
60
|
];
|
|
44
61
|
|
|
45
62
|
interface TypographyTypesProps {
|
|
@@ -53,7 +70,7 @@ function TypographyVariants({ types }: TypographyTypesProps) {
|
|
|
53
70
|
return type.weights.map((weight) => (
|
|
54
71
|
<VStack key={`${type.variant}-${weight}`} marginBottom="$space.16">
|
|
55
72
|
<Typography.Text variant="heading-s">{`${type.variant.split('-').join(' ')} - ${
|
|
56
|
-
weight || '
|
|
73
|
+
weight || ''
|
|
57
74
|
}`}</Typography.Text>
|
|
58
75
|
<View
|
|
59
76
|
paddingVertical="$space.4"
|
|
@@ -62,8 +79,8 @@ function TypographyVariants({ types }: TypographyTypesProps) {
|
|
|
62
79
|
backgroundColor="$bg.base.mid.default"
|
|
63
80
|
marginTop="$space.4"
|
|
64
81
|
>
|
|
65
|
-
{/*
|
|
66
|
-
<Typography.Text variant={type.variant
|
|
82
|
+
{/* @ts-expect-error some variants does not support specific weight */}
|
|
83
|
+
<Typography.Text variant={type.variant} weight={weight}>
|
|
67
84
|
The quick brown fox jumps over the lazy dog
|
|
68
85
|
</Typography.Text>
|
|
69
86
|
</View>
|
|
@@ -118,7 +135,7 @@ export const TypographyStory: StoryFn<typeof Typography.Text> = (args) => (
|
|
|
118
135
|
<Typography.Text color="$content.base.hi">color is content.base.hi</Typography.Text>
|
|
119
136
|
</Typography.Text>
|
|
120
137
|
</Typography.Text>
|
|
121
|
-
</Typography.Text>
|
|
138
|
+
</Typography.Text>
|
|
122
139
|
</Typography.Text>
|
|
123
140
|
</StorySection.SubSection>
|
|
124
141
|
<StorySection title="Heading">
|
|
@@ -130,6 +147,17 @@ export const TypographyStory: StoryFn<typeof Typography.Text> = (args) => (
|
|
|
130
147
|
<StorySection title="Label">
|
|
131
148
|
<TypographyVariants types={labelVariants} />
|
|
132
149
|
</StorySection>
|
|
150
|
+
<StorySection title="Content Caps">
|
|
151
|
+
<TypographyVariants types={contentCapsVariants} />
|
|
152
|
+
</StorySection>
|
|
153
|
+
<StorySection title="Accessibility">
|
|
154
|
+
<Typography.Header1>role: heading aria-level: 1</Typography.Header1>
|
|
155
|
+
<Typography.Header2>role: heading aria-level: 2</Typography.Header2>
|
|
156
|
+
<Typography.Header3>role: heading aria-level: 3</Typography.Header3>
|
|
157
|
+
<Typography.Header4>role: heading aria-level: 4</Typography.Header4>
|
|
158
|
+
<Typography.Header5>role: heading aria-level: 5</Typography.Header5>
|
|
159
|
+
<Typography.Header6>role: heading aria-level: 6</Typography.Header6>
|
|
160
|
+
</StorySection>
|
|
133
161
|
</StorySection>
|
|
134
162
|
</>
|
|
135
163
|
);
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import type { GetProps, GetThemeValueForKey } from '@tamagui/core';
|
|
1
|
+
import type { GetProps, GetThemeValueForKey, TamaguiComponent, WithMediaProps } from '@tamagui/core';
|
|
2
2
|
import { Text, styled } from '@tamagui/core';
|
|
3
3
|
import { createContext, useContext } from 'react';
|
|
4
4
|
import { type Except } from 'type-fest';
|
|
5
|
-
import type {
|
|
6
|
-
|
|
5
|
+
import type {
|
|
6
|
+
BodyFontVariants,
|
|
7
|
+
ContentCapsVariants,
|
|
8
|
+
FontVariants,
|
|
9
|
+
HeadingFontVariants,
|
|
10
|
+
LabelFontVariants,
|
|
11
|
+
} from '../../tokens/fonts';
|
|
12
|
+
import { getVariantAndWeightValues } from './utils/getVariantAndWeightValues';
|
|
13
|
+
|
|
14
|
+
// Should use type from tamagui (PropsWithoutMediaStyles) when fixed: https://github.com/tamagui/tamagui/pull/3783
|
|
15
|
+
type PropsWithoutMedia<A> = {
|
|
16
|
+
// remove all media
|
|
17
|
+
[Key in keyof A as Key extends `$${string}` ? never : Key]?: A[Key];
|
|
18
|
+
};
|
|
7
19
|
|
|
8
|
-
|
|
9
|
-
export type TypographyWeightContextValue = 'regular' | 'bold' | null;
|
|
10
|
-
export type TypograhyColorContextValue = TypograhyColorProps | null;
|
|
11
|
-
|
|
12
|
-
const TypographyVariantContext = createContext<TypographyVariantContextValue>(null);
|
|
13
|
-
const TypographyWeightContext = createContext<TypographyWeightContextValue>(null);
|
|
14
|
-
const TypograhyColorContext = createContext<TypograhyColorContextValue>(null);
|
|
20
|
+
type OverrideTamaguiComponentProps<A> = PropsWithoutMedia<A> & WithMediaProps<PropsWithoutMedia<A>>;
|
|
15
21
|
|
|
16
22
|
const InternalTypography = styled(Text, {
|
|
17
23
|
fontFamily: '$GTStandard',
|
|
@@ -49,9 +55,13 @@ const InternalTypography = styled(Text, {
|
|
|
49
55
|
|
|
50
56
|
export type InternalTypographyProps = GetProps<typeof InternalTypography>;
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
type
|
|
54
|
-
type
|
|
58
|
+
export type TypographyVariantContextValue = FontVariants | null;
|
|
59
|
+
export type TypographyWeightContextValue = 'regular' | 'bold' | 'semibold' | null;
|
|
60
|
+
export type TypograhyColorContextValue = InternalTypographyProps['color'] | null;
|
|
61
|
+
|
|
62
|
+
const TypographyVariantContext = createContext<TypographyVariantContextValue>(null);
|
|
63
|
+
const TypographyWeightContext = createContext<TypographyWeightContextValue>(null);
|
|
64
|
+
const TypograhyColorContext = createContext<TypograhyColorContextValue>(null);
|
|
55
65
|
|
|
56
66
|
// Remove font-related style props from InternalTypography Props
|
|
57
67
|
type TypographyExcludedFontStyleProps =
|
|
@@ -61,24 +71,28 @@ type TypographyExcludedFontStyleProps =
|
|
|
61
71
|
| 'fontStyle'
|
|
62
72
|
| 'fontVariant'
|
|
63
73
|
| 'fontWeight';
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
TypographyExcludedFontStyleProps | 'color'
|
|
67
|
-
> & {
|
|
68
|
-
color?: TypograhyColorProps;
|
|
69
|
-
};
|
|
74
|
+
|
|
75
|
+
type TypographyPropsWithoutFontStyleProps = Except<InternalTypographyProps, TypographyExcludedFontStyleProps>;
|
|
70
76
|
|
|
71
77
|
export interface BodyProps extends TypographyPropsWithoutFontStyleProps {
|
|
72
78
|
variant?: BodyFontVariants;
|
|
73
|
-
weight?:
|
|
79
|
+
weight?: 'regular' | 'bold';
|
|
74
80
|
}
|
|
75
81
|
export interface HeadingLabelProps extends TypographyPropsWithoutFontStyleProps {
|
|
76
82
|
variant: HeadingFontVariants | LabelFontVariants;
|
|
77
|
-
weight?:
|
|
83
|
+
weight?: 'semibold';
|
|
78
84
|
}
|
|
79
|
-
export
|
|
85
|
+
export interface ContentCapsProps extends TypographyPropsWithoutFontStyleProps {
|
|
86
|
+
variant: ContentCapsVariants;
|
|
87
|
+
weight?: 'bold';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type TypographyTextProps =
|
|
91
|
+
| OverrideTamaguiComponentProps<BodyProps>
|
|
92
|
+
| OverrideTamaguiComponentProps<HeadingLabelProps>
|
|
93
|
+
| OverrideTamaguiComponentProps<ContentCapsProps>;
|
|
80
94
|
|
|
81
|
-
const
|
|
95
|
+
const TypographyBase = InternalTypography.styleable<TypographyTextProps, TypographyTextProps>((props, ref) => {
|
|
82
96
|
const typographyVariantAncestorValue = useContext(TypographyVariantContext);
|
|
83
97
|
const typographyWeightAncestorValue = useContext(TypographyWeightContext);
|
|
84
98
|
const typographyColorAncestorValue = useContext(TypograhyColorContext);
|
|
@@ -101,22 +115,22 @@ const TypographyText = InternalTypography.styleable<TypographyTextProps>((props,
|
|
|
101
115
|
/>
|
|
102
116
|
);
|
|
103
117
|
|
|
118
|
+
// If a variant is provided, we set it in the context for children to be able to inherit variant value
|
|
104
119
|
content = props.variant ? (
|
|
105
|
-
// If a variant is provided, we set it in the context for children to be able to inherit variant value
|
|
106
120
|
<TypographyVariantContext.Provider value={props.variant}>{content}</TypographyVariantContext.Provider>
|
|
107
121
|
) : (
|
|
108
122
|
content
|
|
109
123
|
);
|
|
110
124
|
|
|
125
|
+
// If a weight is provided, we set it in the context for children to be able to inherit weight value
|
|
111
126
|
content = props.weight ? (
|
|
112
|
-
// If a weight is provided, we set it in the context for children to be able to inherit weight value
|
|
113
127
|
<TypographyWeightContext.Provider value={props.weight}>{content}</TypographyWeightContext.Provider>
|
|
114
128
|
) : (
|
|
115
129
|
content
|
|
116
130
|
);
|
|
117
131
|
|
|
132
|
+
// If a color is provided, we set it in the context for children to be able to inherit color value
|
|
118
133
|
content = props.color ? (
|
|
119
|
-
// If a color is provided, we set it in the context for children to be able to inherit color value
|
|
120
134
|
<TypograhyColorContext.Provider value={props.color}>{content}</TypograhyColorContext.Provider>
|
|
121
135
|
) : (
|
|
122
136
|
content
|
|
@@ -125,6 +139,18 @@ const TypographyText = InternalTypography.styleable<TypographyTextProps>((props,
|
|
|
125
139
|
return content;
|
|
126
140
|
});
|
|
127
141
|
|
|
142
|
+
const createHeading = (level: number): TamaguiComponent<TypographyTextProps> => {
|
|
143
|
+
return TypographyBase.styleable<TypographyTextProps, TypographyTextProps>((props, ref) => {
|
|
144
|
+
return <TypographyBase ref={ref} {...props} role="heading" aria-level={level} />;
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
|
|
128
148
|
export const Typography = {
|
|
129
|
-
Text:
|
|
149
|
+
Text: TypographyBase,
|
|
150
|
+
Header1: createHeading(1),
|
|
151
|
+
Header2: createHeading(2),
|
|
152
|
+
Header3: createHeading(3),
|
|
153
|
+
Header4: createHeading(4),
|
|
154
|
+
Header5: createHeading(5),
|
|
155
|
+
Header6: createHeading(6),
|
|
130
156
|
};
|