@ornikar/bumper 2.8.1-canary.1768839311.501438316959a9593513e74c70cb87b0597f2db6.0 → 2.8.1-canary.1769087114.a46790da1b5b6361954b6ad25766074d3ed69784.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 +6 -6
- package/dist/definitions/index.d.ts +5 -1
- package/dist/definitions/index.d.ts.map +1 -1
- package/dist/definitions/shared/storybook/StoryTitle.d.ts +1 -1
- package/dist/definitions/shared/storybook/helpers/argsHelpers.d.ts +8 -0
- package/dist/definitions/shared/storybook/helpers/argsHelpers.d.ts.map +1 -0
- package/dist/definitions/system/content/icon/Icon.d.ts +4 -7
- package/dist/definitions/system/content/icon/Icon.d.ts.map +1 -1
- package/dist/definitions/system/content/typography/Typography.d.ts +11 -19
- package/dist/definitions/system/content/typography/Typography.d.ts.map +1 -1
- package/dist/definitions/system/content/typography/TypographyIcon.d.ts +9 -0
- package/dist/definitions/system/content/typography/TypographyIcon.d.ts.map +1 -0
- package/dist/definitions/system/content/typography/TypographyLink.d.ts +9 -0
- package/dist/definitions/system/content/typography/TypographyLink.d.ts.map +1 -0
- package/dist/definitions/system/content/typography/TypographyView.d.ts +18 -0
- package/dist/definitions/system/content/typography/TypographyView.d.ts.map +1 -0
- package/dist/definitions/system/content/typography/index.d.ts +21 -0
- package/dist/definitions/system/content/typography/index.d.ts.map +1 -0
- package/dist/definitions/system/content/typography/utils/getVariantAndWeightValues.d.ts +2 -1
- package/dist/definitions/system/content/typography/utils/getVariantAndWeightValues.d.ts.map +1 -1
- package/dist/definitions/system/content/typography/utils/typographyContext.d.ts +16 -0
- package/dist/definitions/system/content/typography/utils/typographyContext.d.ts.map +1 -0
- package/dist/definitions/system/core/primitives/Image/Image.d.ts +3 -0
- package/dist/definitions/system/core/primitives/Image/Image.d.ts.map +1 -0
- package/dist/definitions/system/core/themes/light/light.d.ts +3 -0
- package/dist/definitions/system/core/themes/light/light.d.ts.map +1 -0
- package/dist/definitions/system/core/themes/themes.d.ts +6 -0
- package/dist/definitions/system/core/themes/themes.d.ts.map +1 -0
- package/dist/definitions/tamagui.config.d.ts +1 -57
- package/dist/definitions/tamagui.config.d.ts.map +1 -1
- package/dist/index-metro.es.android.js +151 -12
- package/dist/index-metro.es.android.js.map +1 -1
- package/dist/index-metro.es.ios.js +151 -12
- package/dist/index-metro.es.ios.js.map +1 -1
- package/dist/index-node-22.22.cjs.js +154 -8
- package/dist/index-node-22.22.cjs.js.map +1 -1
- package/dist/index-node-22.22.cjs.web.js +154 -8
- package/dist/index-node-22.22.cjs.web.js.map +1 -1
- package/dist/index-node-22.22.es.mjs +155 -10
- package/dist/index-node-22.22.es.mjs.map +1 -1
- package/dist/index-node-22.22.es.web.mjs +155 -10
- package/dist/index-node-22.22.es.web.mjs.map +1 -1
- package/dist/index.es.js +149 -12
- package/dist/index.es.js.map +1 -1
- package/dist/index.es.web.js +149 -12
- package/dist/index.es.web.js.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +11 -10
- package/src/index.ts +5 -1
- package/src/shared/storybook/StoryTitle.tsx +1 -1
- package/src/shared/storybook/helpers/argsHelpers.ts +47 -0
- package/src/system/content/icon/Icon.features.stories.tsx +1 -1
- package/src/system/content/icon/Icon.stories.tsx +3 -22
- package/src/system/content/icon/Icon.tsx +4 -14
- package/src/system/content/icon/__snapshots_web__/Icon.features.stories.tsx.snap +2 -2
- package/src/system/content/icon/__snapshots_web__/Icon.stories.tsx.snap +1 -1
- package/src/system/content/typography/Typography.features.stories.tsx +1 -1
- package/src/system/content/typography/Typography.stories.tsx +3 -23
- package/src/system/content/typography/Typography.tsx +24 -27
- package/src/system/content/typography/TypographyIcon.features.stories.tsx +163 -0
- package/src/system/content/typography/TypographyIcon.stories.tsx +35 -0
- package/src/system/content/typography/TypographyIcon.tsx +33 -0
- package/src/system/content/typography/TypographyLink.features.stories.tsx +62 -0
- package/src/system/content/typography/TypographyLink.stories.tsx +72 -0
- package/src/system/content/typography/TypographyLink.tsx +38 -0
- package/src/system/content/typography/TypographyView.tsx +34 -0
- package/src/system/content/typography/__snapshots__/TypographyIcon.features.stories.tsx.snap +839 -0
- package/src/system/content/typography/__snapshots__/TypographyIcon.stories.tsx.snap +31 -0
- package/src/system/content/typography/__snapshots__/TypographyLink.features.stories.tsx.snap +229 -0
- package/src/system/content/typography/__snapshots__/TypographyLink.stories.tsx.snap +41 -0
- package/src/system/content/typography/__snapshots_web__/Typography.features.stories.tsx.snap +7 -7
- package/src/system/content/typography/__snapshots_web__/Typography.stories.tsx.snap +1 -1
- package/src/system/content/typography/__snapshots_web__/TypographyIcon.features.stories.tsx.snap +543 -0
- package/src/system/content/typography/__snapshots_web__/TypographyIcon.stories.tsx.snap +37 -0
- package/src/system/content/typography/__snapshots_web__/TypographyLink.features.stories.tsx.snap +196 -0
- package/src/system/content/typography/__snapshots_web__/TypographyLink.stories.tsx.snap +33 -0
- package/src/system/content/typography/index.ts +15 -0
- package/src/system/content/typography/utils/getVariantAndWeightValues.tsx +2 -6
- package/src/system/content/typography/utils/typographyContext.ts +29 -0
- package/src/system/core/primitives/Center.features.stories.tsx +1 -1
- package/src/system/core/primitives/Center.stories.tsx +6 -89
- package/src/system/core/primitives/Image/Image.stories.tsx +34 -0
- package/src/system/core/primitives/Image/Image.ts +2 -0
- package/src/system/core/primitives/Image/__snapshots__/Image.stories.tsx.snap +30 -0
- package/src/system/core/primitives/Image/__snapshots_web__/Image.stories.tsx.snap +40 -0
- package/src/system/core/primitives/Pressable.features.stories.tsx +1 -1
- package/src/system/core/primitives/Pressable.stories.tsx +4 -53
- package/src/system/core/primitives/ScrollView/ScrollView.features.stories.tsx +1 -1
- package/src/system/core/primitives/ScrollView/ScrollView.stories.tsx +3 -6
- package/src/system/core/primitives/ScrollView/__snapshots_web__/ScrollView.features.stories.tsx.snap +11 -11
- package/src/system/core/primitives/ScrollView/__snapshots_web__/ScrollView.stories.tsx.snap +3 -3
- package/src/system/core/primitives/Stack.features.stories.tsx +1 -1
- package/src/system/core/primitives/Stack.stories.tsx +4 -39
- package/src/system/core/primitives/View.features.stories.tsx +1 -1
- package/src/system/core/primitives/View.stories.tsx +6 -107
- package/src/system/core/primitives/__snapshots_web__/Center.features.stories.tsx.snap +2 -2
- package/src/system/core/primitives/__snapshots_web__/Center.stories.tsx.snap +1 -1
- package/src/system/core/primitives/__snapshots_web__/Pressable.features.stories.tsx.snap +3 -3
- package/src/system/core/primitives/__snapshots_web__/Pressable.stories.tsx.snap +1 -1
- package/src/system/core/primitives/__snapshots_web__/Stack.features.stories.tsx.snap +6 -6
- package/src/system/core/primitives/__snapshots_web__/Stack.stories.tsx.snap +1 -1
- package/src/system/core/primitives/__snapshots_web__/View.features.stories.tsx.snap +11 -11
- package/src/system/core/primitives/__snapshots_web__/View.stories.tsx.snap +1 -1
- package/src/system/core/themes/{__snapshots_web__ → light/__snapshots_web__}/light.stories.tsx.snap +1 -1
- package/src/system/core/themes/{light.stories.tsx → light/light.stories.tsx} +5 -5
- package/src/system/core/themes/{light.ts → light/light.ts} +3 -2
- package/src/system/core/themes/themes.ts +69 -0
- package/src/system/core/tokens/__snapshots_web__/breakpoints.stories.tsx.snap +1 -1
- package/src/system/core/tokens/__snapshots_web__/fonts.stories.tsx.snap +1 -1
- package/src/system/core/tokens/__snapshots_web__/radius.stories.tsx.snap +1 -1
- package/src/system/core/tokens/__snapshots_web__/size.stories.tsx.snap +1 -1
- package/src/system/core/tokens/__snapshots_web__/space.stories.tsx.snap +1 -1
- package/src/system/core/tokens/breakpoints.stories.tsx +1 -1
- package/src/system/core/tokens/fonts.stories.tsx +1 -1
- package/src/system/core/tokens/palettes/__snapshots_web__/deepPurpleColorPalette.stories.tsx.snap +1 -1
- package/src/system/core/tokens/palettes/deepPurpleColorPalette.stories.tsx +1 -1
- package/src/system/core/tokens/radius.stories.tsx +1 -1
- package/src/system/core/tokens/size.stories.tsx +1 -1
- package/src/system/core/tokens/space.stories.tsx +1 -1
- package/src/tamagui.config.ts +1 -1
- package/dist/definitions/system/core/themes/light.d.ts +0 -58
- package/dist/definitions/system/core/themes/light.d.ts.map +0 -1
- /package/src/system/core/themes/{__snapshots__ → light/__snapshots__}/light.stories.tsx.snap +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ornikar/bumper",
|
|
3
|
-
"version": "2.8.1-canary.
|
|
3
|
+
"version": "2.8.1-canary.1769087114.a46790da1b5b6361954b6ad25766074d3ed69784.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "@ornikar/bumper",
|
|
@@ -28,14 +28,15 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@babel/runtime": "^7.24.0",
|
|
31
|
-
"@ornikar/kitt-icons": "14.3.
|
|
31
|
+
"@ornikar/kitt-icons": "^14.3.1",
|
|
32
32
|
"@tamagui/core": "1.144.2",
|
|
33
|
+
"@tamagui/image": "1.144.2",
|
|
33
34
|
"@tamagui/scroll-view": "1.144.2"
|
|
34
35
|
},
|
|
35
36
|
"peerDependencies": {
|
|
36
37
|
"@storybook/preview-api": ">=8.6.15",
|
|
37
|
-
"react": "^
|
|
38
|
-
"react-dom": "^
|
|
38
|
+
"react": "^18.3.1",
|
|
39
|
+
"react-dom": "^18.3.1",
|
|
39
40
|
"react-native": ">=0.76.9"
|
|
40
41
|
},
|
|
41
42
|
"peerDependenciesMeta": {
|
|
@@ -53,13 +54,13 @@
|
|
|
53
54
|
"@babel/core": "7.27.1",
|
|
54
55
|
"@phosphor-icons/core": "2.1.1",
|
|
55
56
|
"@testing-library/dom": "10.4.1",
|
|
56
|
-
"@testing-library/react": "16.3.
|
|
57
|
+
"@testing-library/react": "16.3.2",
|
|
57
58
|
"@testing-library/react-native": "13.3.3",
|
|
58
|
-
"@types/react": "
|
|
59
|
-
"react": "
|
|
60
|
-
"react-dom": "
|
|
61
|
-
"react-native": "0.
|
|
62
|
-
"react-test-renderer": "
|
|
59
|
+
"@types/react": "18.3.27",
|
|
60
|
+
"react": "18.3.1",
|
|
61
|
+
"react-dom": "18.3.1",
|
|
62
|
+
"react-native": "0.76.9",
|
|
63
|
+
"react-test-renderer": "18.3.1"
|
|
63
64
|
},
|
|
64
65
|
"expo": {},
|
|
65
66
|
"exports": {
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { BumperProvider } from './system/core/provider/BumperProvider';
|
|
|
4
4
|
// Primitives
|
|
5
5
|
export type { CenterProps } from './system/core/primitives/Center';
|
|
6
6
|
export { Center } from './system/core/primitives/Center';
|
|
7
|
+
export type { ImageProps } from './system/core/primitives/Image/Image';
|
|
8
|
+
export { Image } from './system/core/primitives/Image/Image';
|
|
7
9
|
export type { PressableProps } from './system/core/primitives/Pressable';
|
|
8
10
|
export { Pressable } from './system/core/primitives/Pressable';
|
|
9
11
|
export type { ScrollViewProps } from './system/core/primitives/ScrollView/ScrollView';
|
|
@@ -14,8 +16,10 @@ export type { ViewProps } from './system/core/primitives/View';
|
|
|
14
16
|
export { View } from './system/core/primitives/View';
|
|
15
17
|
|
|
16
18
|
// Typography
|
|
19
|
+
export { Typography } from './system/content/typography';
|
|
17
20
|
export type { TypographyTextProps } from './system/content/typography/Typography';
|
|
18
|
-
export {
|
|
21
|
+
export type { TypographyIconProps } from './system/content/typography/TypographyIcon';
|
|
22
|
+
export type { TypographyLinkProps } from './system/content/typography/TypographyLink';
|
|
19
23
|
|
|
20
24
|
// Breakpoints
|
|
21
25
|
export { useBreakpointValue } from './system/core/breakpoints/hooks/useBreakpointValue';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ArgTypes } from '@storybook/react';
|
|
2
|
+
import {
|
|
3
|
+
SEMANTIC_TOKENS_BACKGROUND,
|
|
4
|
+
SEMANTIC_TOKENS_BORDER,
|
|
5
|
+
SEMANTIC_TOKENS_CONTENT,
|
|
6
|
+
} from '../../../system/core/themes/themes';
|
|
7
|
+
import { radiusTokens } from '../../../system/core/tokens/radius';
|
|
8
|
+
import { sizeTokens } from '../../../system/core/tokens/size';
|
|
9
|
+
import { spaceTokens } from '../../../system/core/tokens/space';
|
|
10
|
+
|
|
11
|
+
const getTokenKey = (name: string) => `$${name}`;
|
|
12
|
+
|
|
13
|
+
export const backgroundColorArgType: ArgTypes[string] = {
|
|
14
|
+
control: 'select',
|
|
15
|
+
options: SEMANTIC_TOKENS_BACKGROUND.map(getTokenKey),
|
|
16
|
+
description: 'Background color (semantic theme token)',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const spaceArgType: ArgTypes[string] = {
|
|
20
|
+
control: 'select',
|
|
21
|
+
options: Object.keys(spaceTokens).map(getTokenKey),
|
|
22
|
+
description: 'Space value (space token)',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const sizeArgType: ArgTypes[string] = {
|
|
26
|
+
control: 'select',
|
|
27
|
+
options: Object.keys(sizeTokens).map(getTokenKey),
|
|
28
|
+
description: 'Size value (size token)',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const radiusArgType: ArgTypes[string] = {
|
|
32
|
+
control: 'select',
|
|
33
|
+
options: Object.keys(radiusTokens).map(getTokenKey),
|
|
34
|
+
description: 'Border radius (radius token)',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const contentColorArgType: ArgTypes[string] = {
|
|
38
|
+
control: 'select',
|
|
39
|
+
options: SEMANTIC_TOKENS_CONTENT.map(getTokenKey),
|
|
40
|
+
description: 'Content color (semantic theme token)',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const borderColorArgType: ArgTypes[string] = {
|
|
44
|
+
control: 'select',
|
|
45
|
+
options: SEMANTIC_TOKENS_BORDER.map(getTokenKey),
|
|
46
|
+
description: 'Border color (semantic theme token)',
|
|
47
|
+
};
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from '@ornikar/kitt-icons/phosphor';
|
|
7
7
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
8
8
|
import { HStack, VStack } from '../../core/primitives/Stack';
|
|
9
|
-
import { Typography } from '../typography
|
|
9
|
+
import { Typography } from '../typography';
|
|
10
10
|
import { Icon } from './Icon';
|
|
11
11
|
|
|
12
12
|
const meta: Meta<typeof Icon> = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StarRegularIcon } from '@ornikar/kitt-icons/phosphor';
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { contentColorArgType, sizeArgType } from '../../../shared/storybook/helpers/argsHelpers';
|
|
3
4
|
import { Icon } from './Icon';
|
|
4
5
|
|
|
5
6
|
const meta: Meta<typeof Icon> = {
|
|
@@ -7,28 +8,8 @@ const meta: Meta<typeof Icon> = {
|
|
|
7
8
|
component: Icon,
|
|
8
9
|
tags: ['autodocs'],
|
|
9
10
|
argTypes: {
|
|
10
|
-
size:
|
|
11
|
-
|
|
12
|
-
options: ['$size.16', '$size.20', '$size.24', '$size.32', '$size.48', '$size.64', '$size.80', '$size.96'],
|
|
13
|
-
description: 'Icon size (uses size tokens)',
|
|
14
|
-
},
|
|
15
|
-
color: {
|
|
16
|
-
control: 'select',
|
|
17
|
-
options: [
|
|
18
|
-
'$content.base.low',
|
|
19
|
-
'$content.base.mid',
|
|
20
|
-
'$content.base.hi',
|
|
21
|
-
'$content.accent',
|
|
22
|
-
'$content.promo',
|
|
23
|
-
'$content.info',
|
|
24
|
-
'$content.success',
|
|
25
|
-
'$content.warning',
|
|
26
|
-
'$content.danger',
|
|
27
|
-
'$content.muted',
|
|
28
|
-
'$content.disabled',
|
|
29
|
-
],
|
|
30
|
-
description: 'Icon color (semantic theme token)',
|
|
31
|
-
},
|
|
11
|
+
size: sizeArgType,
|
|
12
|
+
color: contentColorArgType,
|
|
32
13
|
},
|
|
33
14
|
};
|
|
34
15
|
|
|
@@ -19,12 +19,8 @@ const IconContainer = styled(View, {
|
|
|
19
19
|
|
|
20
20
|
type IconContainerProps = GetProps<typeof IconContainer>;
|
|
21
21
|
|
|
22
|
-
interface
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface IconProps {
|
|
27
|
-
icon: ReactElement<IconElementProps>;
|
|
22
|
+
interface InternalIconProps {
|
|
23
|
+
icon: ReactElement;
|
|
28
24
|
color?: ColorTokens;
|
|
29
25
|
size?: IconContainerProps['size'];
|
|
30
26
|
testID?: IconContainerProps['testID'];
|
|
@@ -32,15 +28,9 @@ interface IconProps {
|
|
|
32
28
|
alignSelf?: IconContainerProps['alignSelf'];
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
type
|
|
31
|
+
export type IconProps = InternalIconProps & WithMediaProps<InternalIconProps>;
|
|
36
32
|
|
|
37
|
-
export function Icon({
|
|
38
|
-
icon,
|
|
39
|
-
color = '$content.base.hi',
|
|
40
|
-
size = '$size.20',
|
|
41
|
-
testID,
|
|
42
|
-
alignSelf,
|
|
43
|
-
}: IconWithMediaProps): ReactNode {
|
|
33
|
+
export function Icon({ icon, color = '$content.base.hi', size = '$size.20', testID, alignSelf }: IconProps): ReactNode {
|
|
44
34
|
const style = useStyle({ color });
|
|
45
35
|
|
|
46
36
|
const clonedIcon = cloneElement(icon, { color: style.color });
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`Bumper/Content/Icon/Features Colors 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
|
-
class="css-view-
|
|
6
|
+
class="css-view-175oi2r r-flex-13awgt0"
|
|
7
7
|
>
|
|
8
8
|
<span
|
|
9
9
|
class=""
|
|
@@ -175,7 +175,7 @@ exports[`Bumper/Content/Icon/Features Colors 1`] = `
|
|
|
175
175
|
exports[`Bumper/Content/Icon/Features Sizes 1`] = `
|
|
176
176
|
<DocumentFragment>
|
|
177
177
|
<div
|
|
178
|
-
class="css-view-
|
|
178
|
+
class="css-view-175oi2r r-flex-13awgt0"
|
|
179
179
|
>
|
|
180
180
|
<span
|
|
181
181
|
class=""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { VStack } from '../../core/primitives/Stack';
|
|
3
|
-
import { Typography } from '
|
|
3
|
+
import { Typography } from '.';
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof Typography.Text> = {
|
|
6
6
|
title: 'Bumper/Content/Typography/Features',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import {
|
|
2
|
+
import { contentColorArgType } from '../../../shared/storybook/helpers/argsHelpers';
|
|
3
|
+
import { Typography } from '.';
|
|
3
4
|
|
|
4
5
|
const meta: Meta<typeof Typography.Text> = {
|
|
5
6
|
title: 'Bumper/Content/Typography',
|
|
@@ -40,28 +41,7 @@ const meta: Meta<typeof Typography.Text> = {
|
|
|
40
41
|
options: ['regular', 'semibold', 'bold'],
|
|
41
42
|
description: 'Font weight (note: heading/label/content-caps variants have fixed weights)',
|
|
42
43
|
},
|
|
43
|
-
color:
|
|
44
|
-
control: 'select',
|
|
45
|
-
options: [
|
|
46
|
-
'$content.base.low',
|
|
47
|
-
'$content.base.mid',
|
|
48
|
-
'$content.base.hi',
|
|
49
|
-
'$content.base.onContrasted.low',
|
|
50
|
-
'$content.base.onContrasted.mid',
|
|
51
|
-
'$content.base.onContrasted.hi',
|
|
52
|
-
'$content.accent',
|
|
53
|
-
'$content.promo',
|
|
54
|
-
'$content.promo.onContrasted',
|
|
55
|
-
'$content.info',
|
|
56
|
-
'$content.success',
|
|
57
|
-
'$content.warning',
|
|
58
|
-
'$content.danger',
|
|
59
|
-
'$content.muted',
|
|
60
|
-
'$content.disabled',
|
|
61
|
-
'$content.disabled.onContrasted',
|
|
62
|
-
],
|
|
63
|
-
description: 'Text color (semantic theme token)',
|
|
64
|
-
},
|
|
44
|
+
color: contentColorArgType,
|
|
65
45
|
},
|
|
66
46
|
};
|
|
67
47
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { GetProps, GetThemeValueForKey, TamaguiComponent, WithMediaProps } from '@tamagui/core';
|
|
1
|
+
import type { ColorTokens, GetProps, GetThemeValueForKey, TamaguiComponent, WithMediaProps } from '@tamagui/core';
|
|
2
2
|
import { Text, styled } from '@tamagui/core';
|
|
3
|
-
import { createContext, useContext } from 'react';
|
|
4
3
|
import { type Except } from 'type-fest';
|
|
5
4
|
import type {
|
|
6
5
|
BodyFontVariants,
|
|
@@ -10,6 +9,16 @@ import type {
|
|
|
10
9
|
LabelFontVariants,
|
|
11
10
|
} from '../../core/tokens/fonts';
|
|
12
11
|
import { getVariantAndWeightValues } from './utils/getVariantAndWeightValues';
|
|
12
|
+
import {
|
|
13
|
+
TypograhyColorContext,
|
|
14
|
+
TypographyContext,
|
|
15
|
+
TypographyVariantContext,
|
|
16
|
+
TypographyWeightContext,
|
|
17
|
+
useTypographyColor,
|
|
18
|
+
useTypographyContext,
|
|
19
|
+
useTypographyVariant,
|
|
20
|
+
useTypographyWeight,
|
|
21
|
+
} from './utils/typographyContext';
|
|
13
22
|
|
|
14
23
|
// Should use type from tamagui (PropsWithoutMediaStyles) when fixed: https://github.com/tamagui/tamagui/pull/3783
|
|
15
24
|
type PropsWithoutMedia<A> = {
|
|
@@ -55,14 +64,6 @@ const InternalTypography = styled(Text, {
|
|
|
55
64
|
|
|
56
65
|
export type InternalTypographyProps = GetProps<typeof InternalTypography>;
|
|
57
66
|
|
|
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);
|
|
65
|
-
|
|
66
67
|
// Remove font-related style props from InternalTypography Props
|
|
67
68
|
type TypographyExcludedFontStyleProps =
|
|
68
69
|
| 'fontFamily'
|
|
@@ -70,9 +71,12 @@ type TypographyExcludedFontStyleProps =
|
|
|
70
71
|
| 'lineHeight'
|
|
71
72
|
| 'fontStyle'
|
|
72
73
|
| 'fontVariant'
|
|
73
|
-
| 'fontWeight'
|
|
74
|
+
| 'fontWeight'
|
|
75
|
+
| 'color';
|
|
74
76
|
|
|
75
|
-
type TypographyPropsWithoutFontStyleProps = Except<InternalTypographyProps, TypographyExcludedFontStyleProps
|
|
77
|
+
type TypographyPropsWithoutFontStyleProps = Except<InternalTypographyProps, TypographyExcludedFontStyleProps> & {
|
|
78
|
+
color: ColorTokens;
|
|
79
|
+
};
|
|
76
80
|
|
|
77
81
|
export interface BodyProps extends TypographyPropsWithoutFontStyleProps {
|
|
78
82
|
variant?: BodyFontVariants;
|
|
@@ -92,10 +96,11 @@ export type TypographyTextProps =
|
|
|
92
96
|
| OverrideTamaguiComponentProps<HeadingLabelProps>
|
|
93
97
|
| OverrideTamaguiComponentProps<ContentCapsProps>;
|
|
94
98
|
|
|
95
|
-
const TypographyBase = InternalTypography.styleable<TypographyTextProps, TypographyTextProps>((props, ref) => {
|
|
96
|
-
const typographyVariantAncestorValue =
|
|
97
|
-
const typographyWeightAncestorValue =
|
|
98
|
-
const typographyColorAncestorValue =
|
|
99
|
+
export const TypographyBase = InternalTypography.styleable<TypographyTextProps, TypographyTextProps>((props, ref) => {
|
|
100
|
+
const typographyVariantAncestorValue = useTypographyVariant();
|
|
101
|
+
const typographyWeightAncestorValue = useTypographyWeight();
|
|
102
|
+
const typographyColorAncestorValue = useTypographyColor();
|
|
103
|
+
const typographyContext = useTypographyContext();
|
|
99
104
|
|
|
100
105
|
const { variant, weight } = getVariantAndWeightValues(
|
|
101
106
|
props.weight,
|
|
@@ -115,6 +120,8 @@ const TypographyBase = InternalTypography.styleable<TypographyTextProps, Typogra
|
|
|
115
120
|
/>
|
|
116
121
|
);
|
|
117
122
|
|
|
123
|
+
content = typographyContext ? content : <TypographyContext.Provider value>{content}</TypographyContext.Provider>;
|
|
124
|
+
|
|
118
125
|
// If a variant is provided, we set it in the context for children to be able to inherit variant value
|
|
119
126
|
content = props.variant ? (
|
|
120
127
|
<TypographyVariantContext.Provider value={props.variant}>{content}</TypographyVariantContext.Provider>
|
|
@@ -139,18 +146,8 @@ const TypographyBase = InternalTypography.styleable<TypographyTextProps, Typogra
|
|
|
139
146
|
return content;
|
|
140
147
|
});
|
|
141
148
|
|
|
142
|
-
const createHeading = (level: number): TamaguiComponent<TypographyTextProps> => {
|
|
149
|
+
export const createHeading = (level: number): TamaguiComponent<TypographyTextProps> => {
|
|
143
150
|
return TypographyBase.styleable<TypographyTextProps, TypographyTextProps>((props, ref) => {
|
|
144
151
|
return <TypographyBase ref={ref} {...props} role="heading" aria-level={level} />;
|
|
145
152
|
});
|
|
146
153
|
};
|
|
147
|
-
|
|
148
|
-
export const Typography = {
|
|
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),
|
|
156
|
-
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CheckCircleRegularIcon,
|
|
3
|
+
InfoRegularIcon,
|
|
4
|
+
StarRegularIcon,
|
|
5
|
+
WarningRegularIcon,
|
|
6
|
+
} from '@ornikar/kitt-icons/phosphor';
|
|
7
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
8
|
+
import { HStack, VStack } from '../../core/primitives/Stack';
|
|
9
|
+
import { TypographyIcon } from './TypographyIcon';
|
|
10
|
+
import { Typography } from '.';
|
|
11
|
+
|
|
12
|
+
const meta: Meta<typeof TypographyIcon> = {
|
|
13
|
+
title: 'Bumper/Content/TypographyIcon/Features',
|
|
14
|
+
component: TypographyIcon,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
|
|
20
|
+
export const WithExplicitColor: Story = {
|
|
21
|
+
render: () => (
|
|
22
|
+
<HStack gap="$space.16" alignItems="center">
|
|
23
|
+
<VStack alignItems="center" gap="$space.8">
|
|
24
|
+
<TypographyIcon icon={<StarRegularIcon />} size="$size.24" color="$content.accent" />
|
|
25
|
+
<Typography.Text variant="body-xs" color="$content.base.mid">
|
|
26
|
+
Explicit accent
|
|
27
|
+
</Typography.Text>
|
|
28
|
+
</VStack>
|
|
29
|
+
<VStack alignItems="center" gap="$space.8">
|
|
30
|
+
<TypographyIcon icon={<CheckCircleRegularIcon />} size="$size.24" color="$content.success" />
|
|
31
|
+
<Typography.Text variant="body-xs" color="$content.base.mid">
|
|
32
|
+
Explicit success
|
|
33
|
+
</Typography.Text>
|
|
34
|
+
</VStack>
|
|
35
|
+
<VStack alignItems="center" gap="$space.8">
|
|
36
|
+
<TypographyIcon icon={<WarningRegularIcon />} size="$size.24" color="$content.warning" />
|
|
37
|
+
<Typography.Text variant="body-xs" color="$content.base.mid">
|
|
38
|
+
Explicit warning
|
|
39
|
+
</Typography.Text>
|
|
40
|
+
</VStack>
|
|
41
|
+
<VStack alignItems="center" gap="$space.8">
|
|
42
|
+
<TypographyIcon icon={<WarningRegularIcon />} size="$size.24" color="$content.danger" />
|
|
43
|
+
<Typography.Text variant="body-xs" color="$content.base.mid">
|
|
44
|
+
Explicit danger
|
|
45
|
+
</Typography.Text>
|
|
46
|
+
</VStack>
|
|
47
|
+
</HStack>
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const InheritFromTypography: Story = {
|
|
52
|
+
render: () => (
|
|
53
|
+
<VStack gap="$space.24">
|
|
54
|
+
<VStack gap="$space.8">
|
|
55
|
+
<Typography.Text variant="body-s" color="$content.base.mid">
|
|
56
|
+
Icon inherits accent color from Typography
|
|
57
|
+
</Typography.Text>
|
|
58
|
+
<Typography.Text variant="body-m" color="$content.accent">
|
|
59
|
+
<TypographyIcon icon={<StarRegularIcon />} size="$size.20" /> This icon inherits the accent color
|
|
60
|
+
</Typography.Text>
|
|
61
|
+
</VStack>
|
|
62
|
+
|
|
63
|
+
<VStack gap="$space.8">
|
|
64
|
+
<Typography.Text variant="body-s" color="$content.base.mid">
|
|
65
|
+
Icon inherits success color from Typography
|
|
66
|
+
</Typography.Text>
|
|
67
|
+
<Typography.Text variant="body-m" color="$content.success">
|
|
68
|
+
<TypographyIcon icon={<CheckCircleRegularIcon />} size="$size.20" /> Operation completed successfully
|
|
69
|
+
</Typography.Text>
|
|
70
|
+
</VStack>
|
|
71
|
+
|
|
72
|
+
<VStack gap="$space.8">
|
|
73
|
+
<Typography.Text variant="body-s" color="$content.base.mid">
|
|
74
|
+
Icon inherits danger color from Typography
|
|
75
|
+
</Typography.Text>
|
|
76
|
+
<Typography.Text variant="body-m" color="$content.danger">
|
|
77
|
+
<TypographyIcon icon={<WarningRegularIcon />} size="$size.20" /> Error: Something went wrong
|
|
78
|
+
</Typography.Text>
|
|
79
|
+
</VStack>
|
|
80
|
+
|
|
81
|
+
<VStack gap="$space.8">
|
|
82
|
+
<Typography.Text variant="body-s" color="$content.base.mid">
|
|
83
|
+
Icon inherits warning color from Typography
|
|
84
|
+
</Typography.Text>
|
|
85
|
+
<Typography.Text variant="body-m" color="$content.warning">
|
|
86
|
+
<TypographyIcon icon={<InfoRegularIcon />} size="$size.20" /> Warning: Please review this item
|
|
87
|
+
</Typography.Text>
|
|
88
|
+
</VStack>
|
|
89
|
+
</VStack>
|
|
90
|
+
),
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const OverrideInheritedColor: Story = {
|
|
94
|
+
render: () => (
|
|
95
|
+
<VStack gap="$space.24">
|
|
96
|
+
<VStack gap="$space.8">
|
|
97
|
+
<Typography.Text variant="body-s" color="$content.base.mid">
|
|
98
|
+
Typography is accent, but icon explicitly uses success color
|
|
99
|
+
</Typography.Text>
|
|
100
|
+
<Typography.Text variant="body-m" color="$content.accent">
|
|
101
|
+
<TypographyIcon icon={<CheckCircleRegularIcon />} size="$size.20" color="$content.success" /> Icon overrides
|
|
102
|
+
inherited color
|
|
103
|
+
</Typography.Text>
|
|
104
|
+
</VStack>
|
|
105
|
+
|
|
106
|
+
<VStack gap="$space.8">
|
|
107
|
+
<Typography.Text variant="body-s" color="$content.base.mid">
|
|
108
|
+
Typography is success, but icon explicitly uses danger color
|
|
109
|
+
</Typography.Text>
|
|
110
|
+
<Typography.Text variant="body-m" color="$content.success">
|
|
111
|
+
<TypographyIcon icon={<WarningRegularIcon />} size="$size.20" color="$content.danger" /> Mixed color scenario
|
|
112
|
+
</Typography.Text>
|
|
113
|
+
</VStack>
|
|
114
|
+
</VStack>
|
|
115
|
+
),
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const DifferentSizes: Story = {
|
|
119
|
+
render: () => (
|
|
120
|
+
<VStack gap="$space.16">
|
|
121
|
+
<Typography.Text variant="heading-l" color="$content.accent">
|
|
122
|
+
<TypographyIcon icon={<StarRegularIcon />} size="$size.32" /> Large heading with size 32 icon
|
|
123
|
+
</Typography.Text>
|
|
124
|
+
<Typography.Text variant="body-m" color="$content.accent">
|
|
125
|
+
<TypographyIcon icon={<StarRegularIcon />} size="$size.20" /> Body text with size 20 icon
|
|
126
|
+
</Typography.Text>
|
|
127
|
+
<Typography.Text variant="body-s" color="$content.accent">
|
|
128
|
+
<TypographyIcon icon={<StarRegularIcon />} size="$size.16" /> Small text with size 16 icon
|
|
129
|
+
</Typography.Text>
|
|
130
|
+
</VStack>
|
|
131
|
+
),
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const NestedTypographyInheritance: Story = {
|
|
135
|
+
render: () => (
|
|
136
|
+
<VStack gap="$space.24">
|
|
137
|
+
<VStack gap="$space.8">
|
|
138
|
+
<Typography.Text variant="body-s" color="$content.base.mid">
|
|
139
|
+
Nested Typography components - icon inherits from parent
|
|
140
|
+
</Typography.Text>
|
|
141
|
+
<Typography.Text variant="body-l" color="$content.accent">
|
|
142
|
+
<TypographyIcon icon={<StarRegularIcon />} size="$size.20" /> Parent text with icon
|
|
143
|
+
<Typography.Text variant="body-m">
|
|
144
|
+
<TypographyIcon icon={<CheckCircleRegularIcon />} size="$size.16" /> Nested text - icon inherits parent
|
|
145
|
+
color
|
|
146
|
+
</Typography.Text>
|
|
147
|
+
</Typography.Text>
|
|
148
|
+
</VStack>
|
|
149
|
+
|
|
150
|
+
<VStack gap="$space.8">
|
|
151
|
+
<Typography.Text variant="body-s" color="$content.base.mid">
|
|
152
|
+
Nested with override - child overrides parent color
|
|
153
|
+
</Typography.Text>
|
|
154
|
+
<Typography.Text variant="body-l" color="$content.accent">
|
|
155
|
+
<TypographyIcon icon={<StarRegularIcon />} size="$size.20" /> Parent accent color
|
|
156
|
+
<Typography.Text variant="body-m" color="$content.success">
|
|
157
|
+
<TypographyIcon icon={<CheckCircleRegularIcon />} size="$size.16" /> Child overrides to success
|
|
158
|
+
</Typography.Text>
|
|
159
|
+
</Typography.Text>
|
|
160
|
+
</VStack>
|
|
161
|
+
</VStack>
|
|
162
|
+
),
|
|
163
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { StarRegularIcon } from '@ornikar/kitt-icons/phosphor';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { contentColorArgType } from '../../../shared/storybook/helpers/argsHelpers';
|
|
4
|
+
import { TypographyIcon } from './TypographyIcon';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof TypographyIcon> = {
|
|
7
|
+
title: 'Bumper/Content/TypographyIcon',
|
|
8
|
+
component: TypographyIcon,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: {
|
|
11
|
+
icon: {
|
|
12
|
+
control: false,
|
|
13
|
+
description: 'The icon element to render',
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
control: 'select',
|
|
17
|
+
options: ['$size.16', '$size.20', '$size.24', '$size.32', '$size.48', '$size.64', '$size.80', '$size.96'],
|
|
18
|
+
description: 'Icon size (uses size tokens)',
|
|
19
|
+
},
|
|
20
|
+
color: {
|
|
21
|
+
...contentColorArgType,
|
|
22
|
+
description: 'Icon color (semantic theme token). When omitted, inherits from parent Typography context.',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default meta;
|
|
28
|
+
type Story = StoryObj<typeof meta>;
|
|
29
|
+
|
|
30
|
+
export const Default: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
icon: <StarRegularIcon />,
|
|
33
|
+
size: '$size.20',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { Except } from 'type-fest';
|
|
3
|
+
import type { IconProps } from '../icon/Icon';
|
|
4
|
+
import { Icon } from '../icon/Icon';
|
|
5
|
+
import type { TypographyTextProps } from './Typography';
|
|
6
|
+
import { TypographyView } from './TypographyView';
|
|
7
|
+
import { useTypographyColor } from './utils/typographyContext';
|
|
8
|
+
|
|
9
|
+
export interface TypographyIconProps extends Except<IconProps, 'color'> {
|
|
10
|
+
color?: TypographyTextProps['color'];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function TypographyIconInternal(props: TypographyIconProps): ReactNode {
|
|
14
|
+
return (
|
|
15
|
+
<TypographyView>
|
|
16
|
+
<Icon {...props} />
|
|
17
|
+
</TypographyView>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function TypographyIconInheritColor(props: TypographyIconProps): ReactNode {
|
|
22
|
+
const typographyColorAncestorValue = useTypographyColor();
|
|
23
|
+
|
|
24
|
+
return <TypographyIconInternal color={typographyColorAncestorValue || undefined} {...props} />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function TypographyIcon({ color, ...props }: TypographyIconProps): ReactNode {
|
|
28
|
+
if (color) {
|
|
29
|
+
return <TypographyIconInternal color={color} {...props} />;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return <TypographyIconInheritColor {...props} />;
|
|
33
|
+
}
|