@kivid/native-components 1.0.0-alpha.2 → 1.0.0-alpha.5
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/dist/commonjs/components/Avatar/assets/class-variants.js +23 -0
- package/dist/commonjs/components/Avatar/assets/class-variants.js.map +1 -0
- package/dist/commonjs/components/Avatar/enums/index.js +17 -0
- package/dist/commonjs/components/Avatar/enums/index.js.map +1 -0
- package/dist/commonjs/components/Avatar/enums/size.js +15 -0
- package/dist/commonjs/components/Avatar/enums/size.js.map +1 -0
- package/dist/commonjs/components/Avatar/images/girl.jpg +0 -0
- package/dist/commonjs/components/Avatar/index.js +97 -0
- package/dist/commonjs/components/Avatar/index.js.map +1 -0
- package/dist/commonjs/components/Avatar/types.js +6 -0
- package/dist/commonjs/components/Avatar/types.js.map +1 -0
- package/dist/commonjs/components/Button/assets/class-variants.js +0 -5
- package/dist/commonjs/components/Button/assets/class-variants.js.map +1 -1
- package/dist/commonjs/components/Button/index.js +10 -4
- package/dist/commonjs/components/Button/index.js.map +1 -1
- package/dist/commonjs/components/Chip/index.js +7 -3
- package/dist/commonjs/components/Chip/index.js.map +1 -1
- package/dist/commonjs/components/HighlightedText/index.js +20 -16
- package/dist/commonjs/components/HighlightedText/index.js.map +1 -1
- package/dist/commonjs/components/InputOTP/components/InformationStatus/index.js +3 -3
- package/dist/commonjs/components/InputOTP/components/InformationStatus/index.js.map +1 -1
- package/dist/commonjs/components/InputOTP/enums/index.js +9 -11
- package/dist/commonjs/components/InputOTP/enums/index.js.map +1 -1
- package/dist/commonjs/components/Toggle/enums/variant.js +8 -8
- package/dist/commonjs/components/Toggle/enums/variant.js.map +1 -1
- package/dist/commonjs/components/Toggle/index.js +1 -1
- package/dist/commonjs/components/Toggle/index.js.map +1 -1
- package/dist/commonjs/components/Typography/assets/class-variants.js +59 -0
- package/dist/commonjs/components/Typography/assets/class-variants.js.map +1 -0
- package/dist/commonjs/components/Typography/index.js +9 -5
- package/dist/commonjs/components/Typography/index.js.map +1 -1
- package/dist/commonjs/components/index.js +110 -11
- package/dist/commonjs/components/index.js.map +1 -1
- package/dist/commonjs/hooks/use-fonts.js +8 -0
- package/dist/commonjs/hooks/use-fonts.js.map +1 -1
- package/dist/module/components/Avatar/assets/class-variants.js +20 -0
- package/dist/module/components/Avatar/assets/class-variants.js.map +1 -0
- package/dist/module/components/Avatar/enums/index.js +4 -0
- package/dist/module/components/Avatar/enums/index.js.map +1 -0
- package/dist/module/components/Avatar/enums/size.js +11 -0
- package/dist/module/components/Avatar/enums/size.js.map +1 -0
- package/dist/module/components/Avatar/images/girl.jpg +0 -0
- package/dist/module/components/Avatar/index.js +92 -0
- package/dist/module/components/Avatar/index.js.map +1 -0
- package/dist/module/components/Avatar/types.js +4 -0
- package/dist/module/components/Avatar/types.js.map +1 -0
- package/dist/module/components/Button/assets/class-variants.js +0 -5
- package/dist/module/components/Button/assets/class-variants.js.map +1 -1
- package/dist/module/components/Button/index.js +11 -4
- package/dist/module/components/Button/index.js.map +1 -1
- package/dist/module/components/Chip/index.js +8 -4
- package/dist/module/components/Chip/index.js.map +1 -1
- package/dist/module/components/HighlightedText/index.js +20 -16
- package/dist/module/components/HighlightedText/index.js.map +1 -1
- package/dist/module/components/InputOTP/components/InformationStatus/index.js +1 -1
- package/dist/module/components/InputOTP/components/InformationStatus/index.js.map +1 -1
- package/dist/module/components/InputOTP/enums/index.js +8 -1
- package/dist/module/components/InputOTP/enums/index.js.map +1 -1
- package/dist/module/components/Toggle/enums/variant.js +7 -7
- package/dist/module/components/Toggle/enums/variant.js.map +1 -1
- package/dist/module/components/Toggle/index.js +2 -2
- package/dist/module/components/Toggle/index.js.map +1 -1
- package/dist/module/components/Typography/assets/class-variants.js +55 -0
- package/dist/module/components/Typography/assets/class-variants.js.map +1 -0
- package/dist/module/components/Typography/index.js +9 -5
- package/dist/module/components/Typography/index.js.map +1 -1
- package/dist/module/components/index.js +9 -0
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/hooks/use-fonts.js +8 -0
- package/dist/module/hooks/use-fonts.js.map +1 -1
- package/dist/package.json +1 -2
- package/dist/typescript/components/Avatar/assets/class-variants.d.ts +5 -0
- package/dist/typescript/components/Avatar/enums/index.d.ts +1 -0
- package/dist/typescript/components/Avatar/enums/size.d.ts +7 -0
- package/dist/typescript/components/Avatar/index.d.ts +2 -0
- package/dist/typescript/components/Avatar/types.d.ts +6 -0
- package/dist/typescript/components/Button/assets/class-variants.d.ts +0 -1
- package/dist/typescript/components/Button/index.d.ts +2 -2
- package/dist/typescript/components/Chip/assets/class-variants.d.ts +1 -1
- package/dist/typescript/components/Chip/index.d.ts +2 -1
- package/dist/typescript/components/HighlightedText/index.d.ts +1 -0
- package/dist/typescript/components/HighlightedText/types.d.ts +9 -3
- package/dist/typescript/components/InputOTP/enums/index.d.ts +7 -1
- package/dist/typescript/components/Seal/assets/class-variants.d.ts +1 -1
- package/dist/typescript/components/Toggle/enums/variant.d.ts +1 -1
- package/dist/typescript/components/Toggle/types.d.ts +2 -2
- package/dist/typescript/components/Typography/assets/class-variants.d.ts +4 -0
- package/dist/typescript/components/Typography/index.d.ts +3 -3
- package/dist/typescript/components/Typography/types.d.ts +3 -3
- package/dist/typescript/components/index.d.ts +18 -0
- package/package.json +11 -13
- package/src/components/Avatar/assets/class-variants.ts +22 -0
- package/src/components/Avatar/enums/index.ts +1 -0
- package/src/components/Avatar/enums/size.ts +7 -0
- package/src/components/Avatar/images/girl.jpg +0 -0
- package/src/components/Avatar/index.stories.tsx +84 -0
- package/src/components/Avatar/index.tsx +98 -0
- package/src/components/Avatar/types.ts +7 -0
- package/src/components/Button/assets/class-variants.ts +0 -5
- package/src/components/Button/index.tsx +24 -6
- package/src/components/Chip/index.tsx +16 -8
- package/src/components/HighlightedText/index.stories.tsx +117 -18
- package/src/components/HighlightedText/index.tsx +36 -16
- package/src/components/HighlightedText/types.ts +9 -3
- package/src/components/InputOTP/components/InformationStatus/index.tsx +1 -1
- package/src/components/InputOTP/enums/index.ts +7 -1
- package/src/components/InputOTP/index.stories.tsx +13 -4
- package/src/components/Title/index.stories.tsx +185 -75
- package/src/components/Toggle/enums/variant.ts +1 -1
- package/src/components/Toggle/index.stories.tsx +19 -19
- package/src/components/Toggle/index.tsx +2 -2
- package/src/components/Toggle/types.ts +2 -2
- package/src/components/Typography/assets/class-variants.ts +56 -0
- package/src/components/Typography/index.stories.tsx +117 -159
- package/src/components/Typography/index.tsx +9 -5
- package/src/components/Typography/types.ts +5 -3
- package/src/components/index.ts +28 -0
- package/src/hooks/use-fonts.ts +8 -0
- package/assets/adaptive-icon.png +0 -0
- package/assets/favicon.png +0 -0
- package/assets/fonts/Nunito-Bold.ttf +0 -0
- package/assets/fonts/Nunito-BoldItalic.ttf +0 -0
- package/assets/fonts/Nunito-Italic.ttf +0 -0
- package/assets/fonts/Nunito-Medium.ttf +0 -0
- package/assets/fonts/Nunito-MediumItalic.ttf +0 -0
- package/assets/fonts/Nunito-Regular.ttf +0 -0
- package/assets/fonts/Nunito-SemiBold.ttf +0 -0
- package/assets/fonts/Nunito-SemiBoldItalic.ttf +0 -0
- package/assets/icon.png +0 -0
- package/assets/splash.png +0 -0
- package/dist/commonjs/components/InputOTP/enums/information-status.js +0 -15
- package/dist/commonjs/components/InputOTP/enums/information-status.js.map +0 -1
- package/dist/module/components/InputOTP/enums/information-status.js +0 -11
- package/dist/module/components/InputOTP/enums/information-status.js.map +0 -1
- package/dist/typescript/components/InputOTP/enums/information-status.d.ts +0 -7
- package/src/components/InputOTP/enums/information-status.ts +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kivid/native-components",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.5",
|
|
4
4
|
"description": "A React Native component library for the Butterfly Design System.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
"main": "index.js",
|
|
16
16
|
"files": [
|
|
17
17
|
"dist",
|
|
18
|
-
"src"
|
|
19
|
-
"assets"
|
|
18
|
+
"src"
|
|
20
19
|
],
|
|
21
20
|
"exports": {
|
|
22
21
|
".": {
|
|
@@ -50,21 +49,22 @@
|
|
|
50
49
|
"@react-native-async-storage/async-storage": "2.1.2",
|
|
51
50
|
"@react-native-community/datetimepicker": "8.4.1",
|
|
52
51
|
"@react-native-community/slider": "4.5.6",
|
|
53
|
-
"expo": "~53.0.9",
|
|
54
52
|
"expo-constants": "~17.1.6",
|
|
55
53
|
"expo-font": "~13.3.2",
|
|
56
54
|
"expo-splash-screen": "^0.30.10",
|
|
57
55
|
"expo-status-bar": "~2.2.3",
|
|
56
|
+
"expo": "~53.0.9",
|
|
58
57
|
"nativewind": "^4.1.23",
|
|
59
|
-
"react": "19.0.0",
|
|
60
58
|
"react-dom": "19.0.0",
|
|
61
|
-
"react-native": "0.79.5",
|
|
62
59
|
"react-native-gesture-handler": "~2.24.0",
|
|
63
60
|
"react-native-reanimated": "~3.17.5",
|
|
64
61
|
"react-native-safe-area-context": "5.4.0",
|
|
65
62
|
"react-native-svg": "^15.11.2",
|
|
66
63
|
"react-native-web": "^0.20.0",
|
|
67
|
-
"
|
|
64
|
+
"react-native": "0.79.5",
|
|
65
|
+
"react": "19.0.0",
|
|
66
|
+
"@kivid/tailwind-preset": "1.0.0-alpha.5",
|
|
67
|
+
"@kivid/icons": "1.0.0-alpha.5"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@babel/core": "^7.24.0",
|
|
@@ -95,8 +95,7 @@
|
|
|
95
95
|
"storybook": "^9",
|
|
96
96
|
"tailwindcss": "^3.4.17",
|
|
97
97
|
"typescript": "~5.8.3",
|
|
98
|
-
"vite": "^6.3.5"
|
|
99
|
-
"@kivid/tailwind-preset": "1.0.0-alpha.2"
|
|
98
|
+
"vite": "^6.3.5"
|
|
100
99
|
},
|
|
101
100
|
"peerDependencies": {
|
|
102
101
|
"@lottiefiles/dotlottie-react": "^0.15.1",
|
|
@@ -104,8 +103,7 @@
|
|
|
104
103
|
"lottie-react-native": "^7.2.4",
|
|
105
104
|
"react": "19.0.0",
|
|
106
105
|
"react-native": "0.79.5",
|
|
107
|
-
"@kivid/
|
|
108
|
-
"@kivid/icons": "1.0.0-alpha.2"
|
|
106
|
+
"@kivid/icons": "1.0.0-alpha.5"
|
|
109
107
|
},
|
|
110
108
|
"eslintIgnore": [
|
|
111
109
|
"node_modules/",
|
|
@@ -122,7 +120,7 @@
|
|
|
122
120
|
"build-storybook": "storybook build",
|
|
123
121
|
"storybook-generate": "sb-rn-get-stories",
|
|
124
122
|
"storybook": "cross-env EXPO_PUBLIC_STORYBOOK_ENABLED='true' expo start",
|
|
125
|
-
"storybook:ios": "cross-env EXPO_PUBLIC_STORYBOOK_ENABLED='true' expo start
|
|
126
|
-
"storybook:android": "cross-env EXPO_PUBLIC_STORYBOOK_ENABLED='true' expo
|
|
123
|
+
"storybook:ios": "cross-env EXPO_PUBLIC_STORYBOOK_ENABLED='true' expo start:ios",
|
|
124
|
+
"storybook:android": "cross-env EXPO_PUBLIC_STORYBOOK_ENABLED='true' expo start:android"
|
|
127
125
|
}
|
|
128
126
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
import { AvatarSizeEnum } from "../enums";
|
|
3
|
+
|
|
4
|
+
const avatarVariants = cva(
|
|
5
|
+
"border-[1px] border-chia-400 rounded-full items-center justify-center",
|
|
6
|
+
{
|
|
7
|
+
variants: {
|
|
8
|
+
size: {
|
|
9
|
+
[AvatarSizeEnum.XSMALL]: "w-[32px] h-[32px]",
|
|
10
|
+
[AvatarSizeEnum.SMALL]: "w-[40px] h-[40px]",
|
|
11
|
+
[AvatarSizeEnum.MEDIUM]: "w-[56px] h-[56px]",
|
|
12
|
+
[AvatarSizeEnum.LARGE]: "w-[72px] h-[72px]",
|
|
13
|
+
[AvatarSizeEnum.XLARGE]: "w-[96px] h-[96px]",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
size: AvatarSizeEnum.MEDIUM,
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export { avatarVariants };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./size";
|
|
Binary file
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-native";
|
|
2
|
+
import { Avatar } from "./index";
|
|
3
|
+
import { AvatarSizeEnum } from "./enums";
|
|
4
|
+
import { View, Image } from "react-native";
|
|
5
|
+
|
|
6
|
+
const sizeOptions = Object.values(AvatarSizeEnum);
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof Avatar> = {
|
|
9
|
+
title: "Components/Avatar",
|
|
10
|
+
component: Avatar,
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: "centered",
|
|
13
|
+
},
|
|
14
|
+
tags: ["autodocs"],
|
|
15
|
+
argTypes: {
|
|
16
|
+
src: {
|
|
17
|
+
control: { type: "text" },
|
|
18
|
+
description: "URL da imagem do avatar",
|
|
19
|
+
},
|
|
20
|
+
size: {
|
|
21
|
+
control: { type: "select" },
|
|
22
|
+
options: sizeOptions,
|
|
23
|
+
description: "Tamanho do avatar",
|
|
24
|
+
table: {
|
|
25
|
+
type: { summary: sizeOptions.join(" | ") },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
name: {
|
|
29
|
+
control: { type: "text" },
|
|
30
|
+
description: "Nome do usuário para exibir as iniciais caso a imagem não seja fornecida",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default meta;
|
|
36
|
+
type Story = StoryObj<typeof meta>;
|
|
37
|
+
|
|
38
|
+
const localImageUri = Image.resolveAssetSource(require("./images/girl.jpg")).uri;
|
|
39
|
+
|
|
40
|
+
export const Default: Story = {
|
|
41
|
+
args: {
|
|
42
|
+
src: localImageUri,
|
|
43
|
+
size: AvatarSizeEnum.MEDIUM,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const AllVariants: Story = {
|
|
48
|
+
render: () => (
|
|
49
|
+
<View className="flex flex-col gap-500">
|
|
50
|
+
<View className="flex flex-row gap-400 bg-chia-200">
|
|
51
|
+
{sizeOptions.map((size) => (
|
|
52
|
+
<Avatar
|
|
53
|
+
key={size}
|
|
54
|
+
src=""
|
|
55
|
+
size={size}
|
|
56
|
+
name="John Doe"
|
|
57
|
+
/>
|
|
58
|
+
))}
|
|
59
|
+
</View>
|
|
60
|
+
<View className="flex flex-row gap-400">
|
|
61
|
+
{sizeOptions.map((size) => (
|
|
62
|
+
<Avatar
|
|
63
|
+
key={size}
|
|
64
|
+
src=""
|
|
65
|
+
size={size}
|
|
66
|
+
/>
|
|
67
|
+
))}
|
|
68
|
+
</View>
|
|
69
|
+
<View className="flex flex-row gap-400 bg-chia-700">
|
|
70
|
+
{sizeOptions.map((size) => (
|
|
71
|
+
<Avatar
|
|
72
|
+
key={size}
|
|
73
|
+
src={localImageUri}
|
|
74
|
+
size={size}
|
|
75
|
+
/>
|
|
76
|
+
))}
|
|
77
|
+
</View>
|
|
78
|
+
</View>
|
|
79
|
+
),
|
|
80
|
+
args: {
|
|
81
|
+
src: localImageUri,
|
|
82
|
+
size: AvatarSizeEnum.MEDIUM,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { AvatarProps } from "./types";
|
|
2
|
+
import { Person } from "@kivid/icons/native";
|
|
3
|
+
import { View, Image } from "react-native";
|
|
4
|
+
import { AvatarSizeEnum } from "./enums";
|
|
5
|
+
import { avatarVariants } from "./assets/class-variants";
|
|
6
|
+
import { merge } from "@kivid/tailwind-preset";
|
|
7
|
+
import Typography from "../Typography";
|
|
8
|
+
|
|
9
|
+
export function Avatar(props: AvatarProps) {
|
|
10
|
+
const { src, name, size = AvatarSizeEnum.MEDIUM } = props;
|
|
11
|
+
|
|
12
|
+
const mappedSize = {
|
|
13
|
+
[AvatarSizeEnum.XLARGE]: 96,
|
|
14
|
+
[AvatarSizeEnum.LARGE]: 72,
|
|
15
|
+
[AvatarSizeEnum.MEDIUM]: 56,
|
|
16
|
+
[AvatarSizeEnum.SMALL]: 40,
|
|
17
|
+
[AvatarSizeEnum.XSMALL]: 32,
|
|
18
|
+
}[size];
|
|
19
|
+
|
|
20
|
+
const avatarStyle = avatarVariants({ size });
|
|
21
|
+
|
|
22
|
+
const avatarTextStyleMap = {
|
|
23
|
+
[AvatarSizeEnum.XSMALL]: {
|
|
24
|
+
variant: "body_small" as const,
|
|
25
|
+
fontWeight: "700" as const,
|
|
26
|
+
},
|
|
27
|
+
[AvatarSizeEnum.SMALL]: {
|
|
28
|
+
variant: "title_small" as const,
|
|
29
|
+
fontWeight: "700" as const,
|
|
30
|
+
},
|
|
31
|
+
[AvatarSizeEnum.MEDIUM]: {
|
|
32
|
+
variant: "title_large" as const,
|
|
33
|
+
fontWeight: "700" as const,
|
|
34
|
+
},
|
|
35
|
+
[AvatarSizeEnum.LARGE]: {
|
|
36
|
+
variant: "headline_small" as const,
|
|
37
|
+
fontWeight: "700" as const,
|
|
38
|
+
},
|
|
39
|
+
[AvatarSizeEnum.XLARGE]: {
|
|
40
|
+
variant: "headline_medium" as const,
|
|
41
|
+
fontWeight: "700" as const,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const calulatedInsideImageContainerSize = mappedSize - 1;
|
|
46
|
+
|
|
47
|
+
function renderFallbackType() {
|
|
48
|
+
if (name && !!name.trim()) {
|
|
49
|
+
const [firstName, surname] = name.split(" ");
|
|
50
|
+
|
|
51
|
+
const hasSurname = !!surname;
|
|
52
|
+
const hasName = !!firstName;
|
|
53
|
+
|
|
54
|
+
const firstLetterOfFirstName = hasName ? firstName?.at(0) : "";
|
|
55
|
+
const firstLetterOfSurname = hasSurname ? surname?.at(0) : "";
|
|
56
|
+
|
|
57
|
+
const firstLetters =
|
|
58
|
+
`${firstLetterOfFirstName}${firstLetterOfSurname}`.toUpperCase();
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<View className={avatarStyle}>
|
|
62
|
+
<Typography
|
|
63
|
+
className={"text-chia-600"}
|
|
64
|
+
variant={avatarTextStyleMap[size].variant}
|
|
65
|
+
weight={avatarTextStyleMap[size].fontWeight}
|
|
66
|
+
>
|
|
67
|
+
{firstLetters}
|
|
68
|
+
</Typography>
|
|
69
|
+
</View>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<View
|
|
75
|
+
className={merge(avatarStyle, "bg-chia-300 border-chia-400 max-h-fit")}
|
|
76
|
+
>
|
|
77
|
+
<Person color="#B6C2C2" size={mappedSize} />
|
|
78
|
+
</View>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!src) {
|
|
83
|
+
return renderFallbackType();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<View className={merge(avatarStyle, "border-chia-100 relative")}>
|
|
88
|
+
<Image
|
|
89
|
+
source={{ uri: src }}
|
|
90
|
+
className="rounded-full"
|
|
91
|
+
style={{
|
|
92
|
+
width: calulatedInsideImageContainerSize,
|
|
93
|
+
height: calulatedInsideImageContainerSize,
|
|
94
|
+
}}
|
|
95
|
+
/>
|
|
96
|
+
</View>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Pressable, Animated, GestureResponderEvent } from "react-native";
|
|
3
3
|
import { merge } from "@kivid/tailwind-preset";
|
|
4
4
|
import { LoadingDots } from "../LoadingDots";
|
|
5
5
|
import { LoadingDotsVariant } from "../LoadingDots/types";
|
|
6
|
-
import {
|
|
6
|
+
import type {
|
|
7
|
+
ButtonCorners,
|
|
8
|
+
ButtonProps,
|
|
9
|
+
ButtonSize,
|
|
10
|
+
ButtonVariant,
|
|
11
|
+
} from "./types";
|
|
12
|
+
import { Typography } from "../Typography";
|
|
7
13
|
import {
|
|
8
14
|
textVariants,
|
|
9
15
|
buttonVariants,
|
|
@@ -43,11 +49,18 @@ export function Button(props: ButtonProps) {
|
|
|
43
49
|
ghost: "grape",
|
|
44
50
|
};
|
|
45
51
|
|
|
52
|
+
const typographyVariantMap = {
|
|
53
|
+
small: "label_small" as const,
|
|
54
|
+
medium: "label_medium" as const,
|
|
55
|
+
large: "label_large" as const,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const typographyVariant = typographyVariantMap[size ?? "medium"];
|
|
59
|
+
|
|
46
60
|
function renderContent() {
|
|
47
61
|
const textStyle = merge(
|
|
48
62
|
textVariants({
|
|
49
63
|
variant,
|
|
50
|
-
size,
|
|
51
64
|
selected: selected && (variant === "outline" || variant === "ghost"),
|
|
52
65
|
})
|
|
53
66
|
);
|
|
@@ -63,9 +76,14 @@ export function Button(props: ButtonProps) {
|
|
|
63
76
|
}
|
|
64
77
|
|
|
65
78
|
return (
|
|
66
|
-
<
|
|
79
|
+
<Typography
|
|
80
|
+
variant={typographyVariant}
|
|
81
|
+
weight="700"
|
|
82
|
+
className={textStyle}
|
|
83
|
+
numberOfLines={1}
|
|
84
|
+
>
|
|
67
85
|
{children}
|
|
68
|
-
</
|
|
86
|
+
</Typography>
|
|
69
87
|
);
|
|
70
88
|
}
|
|
71
89
|
|
|
@@ -134,4 +152,4 @@ export function Button(props: ButtonProps) {
|
|
|
134
152
|
|
|
135
153
|
Button.displayName = "Button";
|
|
136
154
|
|
|
137
|
-
export
|
|
155
|
+
export { ButtonProps, ButtonVariant, ButtonSize, ButtonCorners };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { merge } from "@kivid/tailwind-preset";
|
|
2
|
-
import type { ChipProps } from "./types";
|
|
2
|
+
import type { ChipProps, ChipSize, ChipVariant } from "./types";
|
|
3
3
|
import { chipVariants } from "./assets/class-variants";
|
|
4
4
|
import { Seal } from "../Seal";
|
|
5
|
-
import {
|
|
5
|
+
import { View } from "react-native";
|
|
6
6
|
import { SealVariantEnum } from "../Seal/enums";
|
|
7
|
+
import { Typography } from "../Typography";
|
|
7
8
|
|
|
8
9
|
export function Chip(props: ChipProps) {
|
|
9
10
|
const {
|
|
@@ -14,11 +15,10 @@ export function Chip(props: ChipProps) {
|
|
|
14
15
|
variant = "outline",
|
|
15
16
|
} = props;
|
|
16
17
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
variant === "filled" ? "text-chia-200" : "text-chia-900"
|
|
21
|
-
);
|
|
18
|
+
const typographyVariant = size === "medium" ? "label_small" : "label_medium";
|
|
19
|
+
|
|
20
|
+
const textColorClass =
|
|
21
|
+
variant === "filled" ? "text-chia-200" : "text-chia-900";
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<View
|
|
@@ -29,7 +29,15 @@ export function Chip(props: ChipProps) {
|
|
|
29
29
|
inverted={variant === "filled"}
|
|
30
30
|
size="small"
|
|
31
31
|
/>
|
|
32
|
-
<
|
|
32
|
+
<Typography
|
|
33
|
+
variant={typographyVariant}
|
|
34
|
+
weight="700"
|
|
35
|
+
className={merge("mx-auto", textColorClass)}
|
|
36
|
+
>
|
|
37
|
+
{label}
|
|
38
|
+
</Typography>
|
|
33
39
|
</View>
|
|
34
40
|
);
|
|
35
41
|
}
|
|
42
|
+
|
|
43
|
+
export { ChipProps, ChipSize, ChipVariant };
|
|
@@ -15,10 +15,33 @@ const meta = {
|
|
|
15
15
|
highlightText: {
|
|
16
16
|
control: "text",
|
|
17
17
|
},
|
|
18
|
-
|
|
19
|
-
control: "
|
|
18
|
+
variant: {
|
|
19
|
+
control: "select",
|
|
20
|
+
options: [
|
|
21
|
+
"label_small",
|
|
22
|
+
"label_medium",
|
|
23
|
+
"label_large",
|
|
24
|
+
"body_small",
|
|
25
|
+
"body_medium",
|
|
26
|
+
"body_large",
|
|
27
|
+
"title_small",
|
|
28
|
+
"title_medium",
|
|
29
|
+
"title_large",
|
|
30
|
+
"headline_small",
|
|
31
|
+
"headline_medium",
|
|
32
|
+
"headline_large",
|
|
33
|
+
"display_small",
|
|
34
|
+
"display_medium",
|
|
35
|
+
"display_large",
|
|
36
|
+
],
|
|
37
|
+
description: "Typography variant for the base text",
|
|
20
38
|
},
|
|
21
|
-
|
|
39
|
+
weight: {
|
|
40
|
+
control: "select",
|
|
41
|
+
options: ["400", "500", "600", "700"],
|
|
42
|
+
description: "Typography weight for the base text",
|
|
43
|
+
},
|
|
44
|
+
className: {
|
|
22
45
|
control: "text",
|
|
23
46
|
},
|
|
24
47
|
reverse: {
|
|
@@ -26,6 +49,11 @@ const meta = {
|
|
|
26
49
|
description:
|
|
27
50
|
"If true, the highlighted text will be displayed before the regular text.",
|
|
28
51
|
},
|
|
52
|
+
highlightedTextProps: {
|
|
53
|
+
control: "object",
|
|
54
|
+
description:
|
|
55
|
+
"Props for the highlighted text Typography component (className, variant, weight)",
|
|
56
|
+
},
|
|
29
57
|
},
|
|
30
58
|
} satisfies Meta<typeof HighlightedText>;
|
|
31
59
|
|
|
@@ -49,8 +77,12 @@ export const LabelVariant: Story = {
|
|
|
49
77
|
args: {
|
|
50
78
|
text: "Label text",
|
|
51
79
|
highlightText: "important",
|
|
52
|
-
|
|
53
|
-
|
|
80
|
+
variant: "label_medium",
|
|
81
|
+
weight: "400",
|
|
82
|
+
highlightedTextProps: {
|
|
83
|
+
variant: "label_medium",
|
|
84
|
+
weight: "700",
|
|
85
|
+
},
|
|
54
86
|
},
|
|
55
87
|
};
|
|
56
88
|
|
|
@@ -58,8 +90,12 @@ export const BodyVariant: Story = {
|
|
|
58
90
|
args: {
|
|
59
91
|
text: "Body text content",
|
|
60
92
|
highlightText: "highlighted part",
|
|
61
|
-
|
|
62
|
-
|
|
93
|
+
variant: "body_medium",
|
|
94
|
+
weight: "400",
|
|
95
|
+
highlightedTextProps: {
|
|
96
|
+
variant: "body_medium",
|
|
97
|
+
weight: "700",
|
|
98
|
+
},
|
|
63
99
|
},
|
|
64
100
|
};
|
|
65
101
|
|
|
@@ -67,17 +103,25 @@ export const TitleVariant: Story = {
|
|
|
67
103
|
args: {
|
|
68
104
|
text: "Title text content",
|
|
69
105
|
highlightText: "highlighted part",
|
|
70
|
-
|
|
71
|
-
|
|
106
|
+
variant: "title_medium",
|
|
107
|
+
weight: "400",
|
|
108
|
+
highlightedTextProps: {
|
|
109
|
+
variant: "title_medium",
|
|
110
|
+
weight: "700",
|
|
111
|
+
},
|
|
72
112
|
},
|
|
73
113
|
};
|
|
74
114
|
|
|
75
|
-
export const
|
|
115
|
+
export const HeadingVariant: Story = {
|
|
76
116
|
args: {
|
|
77
|
-
text: "
|
|
117
|
+
text: "Heading text content",
|
|
78
118
|
highlightText: "highlighted part",
|
|
79
|
-
|
|
80
|
-
|
|
119
|
+
variant: "headline_medium",
|
|
120
|
+
weight: "400",
|
|
121
|
+
highlightedTextProps: {
|
|
122
|
+
variant: "headline_medium",
|
|
123
|
+
weight: "700",
|
|
124
|
+
},
|
|
81
125
|
},
|
|
82
126
|
};
|
|
83
127
|
|
|
@@ -85,8 +129,12 @@ export const DisplayVariant: Story = {
|
|
|
85
129
|
args: {
|
|
86
130
|
text: "Display text content",
|
|
87
131
|
highlightText: "highlighted part",
|
|
88
|
-
|
|
89
|
-
|
|
132
|
+
variant: "display_medium",
|
|
133
|
+
weight: "400",
|
|
134
|
+
highlightedTextProps: {
|
|
135
|
+
variant: "display_medium",
|
|
136
|
+
weight: "700",
|
|
137
|
+
},
|
|
90
138
|
},
|
|
91
139
|
};
|
|
92
140
|
|
|
@@ -94,8 +142,14 @@ export const WithCustomClasses: Story = {
|
|
|
94
142
|
args: {
|
|
95
143
|
text: "Styled text",
|
|
96
144
|
highlightText: "with custom styling",
|
|
145
|
+
variant: "body_medium",
|
|
146
|
+
weight: "400",
|
|
97
147
|
className: "text-tangerine-900",
|
|
98
|
-
|
|
148
|
+
highlightedTextProps: {
|
|
149
|
+
variant: "body_medium",
|
|
150
|
+
weight: "600",
|
|
151
|
+
className: "text-mango-900 underline",
|
|
152
|
+
},
|
|
99
153
|
},
|
|
100
154
|
};
|
|
101
155
|
|
|
@@ -103,8 +157,53 @@ export const ReverseHighlight: Story = {
|
|
|
103
157
|
args: {
|
|
104
158
|
text: "text with reverse highlight",
|
|
105
159
|
highlightText: "Highlighted first",
|
|
160
|
+
variant: "label_medium",
|
|
161
|
+
weight: "400",
|
|
106
162
|
reverse: true,
|
|
107
|
-
|
|
108
|
-
|
|
163
|
+
highlightedTextProps: {
|
|
164
|
+
variant: "label_medium",
|
|
165
|
+
weight: "700",
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const WeightVariations: Story = {
|
|
171
|
+
args: {
|
|
172
|
+
text: "Different weight for",
|
|
173
|
+
highlightText: "highlighted text",
|
|
174
|
+
variant: "body_medium",
|
|
175
|
+
weight: "400",
|
|
176
|
+
highlightedTextProps: {
|
|
177
|
+
variant: "body_medium",
|
|
178
|
+
weight: "600",
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const MixedStyling: Story = {
|
|
184
|
+
args: {
|
|
185
|
+
text: "Typography props with",
|
|
186
|
+
highlightText: "custom classes",
|
|
187
|
+
variant: "body_medium",
|
|
188
|
+
weight: "400",
|
|
189
|
+
className: "text-blue-600",
|
|
190
|
+
highlightedTextProps: {
|
|
191
|
+
variant: "title_small",
|
|
192
|
+
weight: "700",
|
|
193
|
+
className: "text-red-500 underline",
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export const BaseTextVariations: Story = {
|
|
199
|
+
args: {
|
|
200
|
+
text: "Large title base text with",
|
|
201
|
+
highlightText: "small label highlight",
|
|
202
|
+
variant: "title_large",
|
|
203
|
+
weight: "600",
|
|
204
|
+
highlightedTextProps: {
|
|
205
|
+
variant: "label_small",
|
|
206
|
+
weight: "700",
|
|
207
|
+
},
|
|
109
208
|
},
|
|
110
209
|
};
|
|
@@ -1,38 +1,58 @@
|
|
|
1
1
|
import type { HighlightedTextProps } from "./types";
|
|
2
|
-
import {
|
|
3
|
-
import { Text } from "react-native";
|
|
2
|
+
import { Typography } from "../Typography";
|
|
4
3
|
|
|
5
4
|
export function HighlightedText(props: HighlightedTextProps) {
|
|
6
5
|
const {
|
|
7
6
|
text,
|
|
8
7
|
highlightText,
|
|
9
8
|
className,
|
|
10
|
-
highlightTextClassName,
|
|
11
9
|
reverse,
|
|
12
|
-
|
|
10
|
+
highlightedTextProps = {},
|
|
11
|
+
variant = "label_medium",
|
|
12
|
+
weight = "400",
|
|
13
13
|
...rest
|
|
14
14
|
} = props;
|
|
15
15
|
|
|
16
|
-
const mergeClassName = merge("text-label_medium_300", className);
|
|
17
|
-
const mergeHighlightClassName = merge(
|
|
18
|
-
"text-label_medium_700",
|
|
19
|
-
highlightTextClassName
|
|
20
|
-
);
|
|
21
|
-
|
|
22
16
|
if (reverse) {
|
|
23
17
|
return (
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
<Typography
|
|
19
|
+
variant={variant}
|
|
20
|
+
weight={weight}
|
|
21
|
+
className={className}
|
|
22
|
+
{...rest}
|
|
23
|
+
>
|
|
24
|
+
<Typography
|
|
25
|
+
variant={highlightedTextProps.variant}
|
|
26
|
+
weight={highlightedTextProps.weight}
|
|
27
|
+
{...highlightedTextProps}
|
|
28
|
+
>
|
|
29
|
+
{highlightText}
|
|
30
|
+
</Typography>{" "}
|
|
31
|
+
{text}
|
|
32
|
+
</Typography>
|
|
27
33
|
);
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
return (
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
<Typography
|
|
38
|
+
variant={variant}
|
|
39
|
+
weight={weight}
|
|
40
|
+
className={className}
|
|
41
|
+
{...rest}
|
|
42
|
+
>
|
|
43
|
+
{text}{" "}
|
|
44
|
+
<Typography
|
|
45
|
+
variant={highlightedTextProps.variant || "label_medium"}
|
|
46
|
+
weight={highlightedTextProps.weight || "700"}
|
|
47
|
+
{...highlightedTextProps}
|
|
48
|
+
>
|
|
49
|
+
{highlightText}
|
|
50
|
+
</Typography>
|
|
51
|
+
</Typography>
|
|
34
52
|
);
|
|
35
53
|
}
|
|
36
54
|
|
|
37
55
|
HighlightedText.displayName = "HighlightedText";
|
|
38
56
|
export default HighlightedText;
|
|
57
|
+
|
|
58
|
+
export { HighlightedTextProps };
|