@grupalia/rn-ui-kit 0.1.0 → 0.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/lib/commonjs/components/BaseAlert.js +149 -0
- package/lib/commonjs/components/BaseAlert.js.map +1 -0
- package/lib/commonjs/components/BaseBadge.js +18 -21
- package/lib/commonjs/components/BaseBadge.js.map +1 -1
- package/lib/commonjs/components/BaseButton.js +23 -24
- package/lib/commonjs/components/BaseButton.js.map +1 -1
- package/lib/commonjs/components/BaseIcon.js +15 -7
- package/lib/commonjs/components/BaseIcon.js.map +1 -1
- package/lib/commonjs/components/BaseStackedList.js +2 -2
- package/lib/commonjs/components/BaseStackedList.js.map +1 -1
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/hooks/useBreakpoints.js +25 -0
- package/lib/commonjs/hooks/useBreakpoints.js.map +1 -0
- package/lib/commonjs/hooks/useIsAboveBreakpoint.js +15 -0
- package/lib/commonjs/hooks/useIsAboveBreakpoint.js.map +1 -0
- package/lib/commonjs/index.js +17 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/preset.js +5 -1
- package/lib/commonjs/preset.js.map +1 -1
- package/lib/commonjs/styles/background-colors.js +1 -1
- package/lib/commonjs/styles/background-colors.js.map +1 -1
- package/lib/commonjs/styles/border-colors.js +1 -1
- package/lib/commonjs/styles/border-colors.js.map +1 -1
- package/lib/commonjs/styles/foreground-colors.js +0 -12
- package/lib/commonjs/styles/foreground-colors.js.map +1 -1
- package/lib/commonjs/styles/text-colors.js +1 -1
- package/lib/commonjs/styles/text-colors.js.map +1 -1
- package/lib/commonjs/styles/utility-colors.js +124 -124
- package/lib/commonjs/styles/utility-colors.js.map +1 -1
- package/lib/module/components/BaseAlert.js +144 -0
- package/lib/module/components/BaseAlert.js.map +1 -0
- package/lib/module/components/BaseBadge.js +18 -21
- package/lib/module/components/BaseBadge.js.map +1 -1
- package/lib/module/components/BaseButton.js +23 -24
- package/lib/module/components/BaseButton.js.map +1 -1
- package/lib/module/components/BaseIcon.js +14 -7
- package/lib/module/components/BaseIcon.js.map +1 -1
- package/lib/module/components/BaseStackedList.js +2 -2
- package/lib/module/components/BaseStackedList.js.map +1 -1
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/hooks/useBreakpoints.js +20 -0
- package/lib/module/hooks/useBreakpoints.js.map +1 -0
- package/lib/module/hooks/useIsAboveBreakpoint.js +11 -0
- package/lib/module/hooks/useIsAboveBreakpoint.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/preset.js +5 -1
- package/lib/module/preset.js.map +1 -1
- package/lib/module/styles/background-colors.js +1 -1
- package/lib/module/styles/background-colors.js.map +1 -1
- package/lib/module/styles/border-colors.js +1 -1
- package/lib/module/styles/border-colors.js.map +1 -1
- package/lib/module/styles/foreground-colors.js +0 -12
- package/lib/module/styles/foreground-colors.js.map +1 -1
- package/lib/module/styles/text-colors.js +1 -1
- package/lib/module/styles/text-colors.js.map +1 -1
- package/lib/module/styles/utility-colors.js +124 -124
- package/lib/module/styles/utility-colors.js.map +1 -1
- package/lib/typescript/commonjs/components/BaseAlert.d.ts +11 -0
- package/lib/typescript/commonjs/components/BaseAlert.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/BaseBadge.d.ts +2 -2
- package/lib/typescript/commonjs/components/BaseBadge.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/BaseButton.d.ts +2 -2
- package/lib/typescript/commonjs/components/BaseIcon.d.ts +8 -4
- package/lib/typescript/commonjs/components/BaseIcon.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/index.d.ts +1 -0
- package/lib/typescript/commonjs/components/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/useBreakpoints.d.ts +8 -0
- package/lib/typescript/commonjs/hooks/useBreakpoints.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useIsAboveBreakpoint.d.ts +3 -0
- package/lib/typescript/commonjs/hooks/useIsAboveBreakpoint.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +2 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/preset.d.ts.map +1 -1
- package/lib/typescript/commonjs/styles/foreground-colors.d.ts +1 -12
- package/lib/typescript/commonjs/styles/foreground-colors.d.ts.map +1 -1
- package/lib/typescript/commonjs/styles/utility-colors.d.ts +125 -124
- package/lib/typescript/commonjs/styles/utility-colors.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/heroicons.d.ts +1 -2
- package/lib/typescript/commonjs/types/heroicons.d.ts.map +1 -1
- package/lib/typescript/module/components/BaseAlert.d.ts +11 -0
- package/lib/typescript/module/components/BaseAlert.d.ts.map +1 -0
- package/lib/typescript/module/components/BaseBadge.d.ts +2 -2
- package/lib/typescript/module/components/BaseBadge.d.ts.map +1 -1
- package/lib/typescript/module/components/BaseButton.d.ts +2 -2
- package/lib/typescript/module/components/BaseIcon.d.ts +8 -4
- package/lib/typescript/module/components/BaseIcon.d.ts.map +1 -1
- package/lib/typescript/module/components/index.d.ts +1 -0
- package/lib/typescript/module/components/index.d.ts.map +1 -1
- package/lib/typescript/module/hooks/useBreakpoints.d.ts +8 -0
- package/lib/typescript/module/hooks/useBreakpoints.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useIsAboveBreakpoint.d.ts +3 -0
- package/lib/typescript/module/hooks/useIsAboveBreakpoint.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +2 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/preset.d.ts.map +1 -1
- package/lib/typescript/module/styles/foreground-colors.d.ts +1 -12
- package/lib/typescript/module/styles/foreground-colors.d.ts.map +1 -1
- package/lib/typescript/module/styles/utility-colors.d.ts +125 -124
- package/lib/typescript/module/styles/utility-colors.d.ts.map +1 -1
- package/lib/typescript/module/types/heroicons.d.ts +1 -2
- package/lib/typescript/module/types/heroicons.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/components/BaseAlert.tsx +175 -0
- package/src/components/BaseBadge.tsx +21 -23
- package/src/components/BaseButton.tsx +28 -28
- package/src/components/BaseIcon.tsx +26 -12
- package/src/components/BaseStackedList.tsx +2 -2
- package/src/components/index.ts +1 -0
- package/src/preset.ts +4 -0
- package/src/styles/background-colors.ts +1 -1
- package/src/styles/border-colors.ts +1 -1
- package/src/styles/foreground-colors.ts +19 -12
- package/src/styles/text-colors.ts +1 -1
- package/src/styles/utility-colors.ts +250 -124
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { InformationCircleIcon as OutlinedInformationCircleIcon } from 'react-native-heroicons/outline';
|
|
3
|
+
import {
|
|
4
|
+
ExclamationTriangleIcon,
|
|
5
|
+
CheckCircleIcon,
|
|
6
|
+
InformationCircleIcon,
|
|
7
|
+
XCircleIcon,
|
|
8
|
+
} from 'react-native-heroicons/solid';
|
|
9
|
+
|
|
10
|
+
import { View, Text } from '../hoc-components';
|
|
11
|
+
import BaseIcon from './BaseIcon';
|
|
12
|
+
import { useIsAboveBreakpoint } from '../hooks/useIsAboveBreakpoint';
|
|
13
|
+
|
|
14
|
+
interface IconComponentProps {
|
|
15
|
+
type: 'error' | 'success' | 'alert' | 'info' | 'notice';
|
|
16
|
+
variant?: 'primary' | 'secondary';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function IconComponent({ type, variant = 'primary' }: IconComponentProps) {
|
|
20
|
+
const iconColors = {
|
|
21
|
+
error: {
|
|
22
|
+
primary: 'fg-error-primary',
|
|
23
|
+
secondary: 'fg-error-secondary',
|
|
24
|
+
},
|
|
25
|
+
success: {
|
|
26
|
+
primary: 'fg-success-primary',
|
|
27
|
+
secondary: 'fg-success-secondary',
|
|
28
|
+
},
|
|
29
|
+
alert: {
|
|
30
|
+
primary: 'fg-warning-primary',
|
|
31
|
+
secondary: 'fg-warning-secondary',
|
|
32
|
+
},
|
|
33
|
+
info: {
|
|
34
|
+
primary: 'utility-gray-500',
|
|
35
|
+
secondary: 'utility-gray-400',
|
|
36
|
+
},
|
|
37
|
+
notice: {
|
|
38
|
+
primary: 'utility-blue-500',
|
|
39
|
+
secondary: 'utility-blue-400',
|
|
40
|
+
},
|
|
41
|
+
} as const;
|
|
42
|
+
|
|
43
|
+
const icons = {
|
|
44
|
+
error: XCircleIcon,
|
|
45
|
+
success: CheckCircleIcon,
|
|
46
|
+
alert: ExclamationTriangleIcon,
|
|
47
|
+
info: OutlinedInformationCircleIcon,
|
|
48
|
+
notice: InformationCircleIcon,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<BaseIcon
|
|
53
|
+
icon={icons[type]}
|
|
54
|
+
size={20}
|
|
55
|
+
color={iconColors[type][variant]}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface Props extends React.ComponentProps<typeof View> {
|
|
61
|
+
type: 'error' | 'success' | 'alert' | 'info' | 'notice';
|
|
62
|
+
message: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
variant?: 'primary' | 'secondary';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default function AlertComponent({
|
|
68
|
+
type,
|
|
69
|
+
message,
|
|
70
|
+
description,
|
|
71
|
+
variant = 'primary',
|
|
72
|
+
children,
|
|
73
|
+
...props
|
|
74
|
+
}: Props) {
|
|
75
|
+
const largePhone = useIsAboveBreakpoint('xs');
|
|
76
|
+
const alertClasses = () => {
|
|
77
|
+
if (variant === 'secondary') {
|
|
78
|
+
return 'bg-white border';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
switch (type) {
|
|
82
|
+
case 'error':
|
|
83
|
+
return 'bg-error-secondary';
|
|
84
|
+
case 'success':
|
|
85
|
+
return 'bg-success-secondary';
|
|
86
|
+
case 'alert':
|
|
87
|
+
return 'bg-yellow-50 border-yellow-400';
|
|
88
|
+
case 'info':
|
|
89
|
+
return 'bg-white border border-gray-300';
|
|
90
|
+
case 'notice':
|
|
91
|
+
default:
|
|
92
|
+
return 'bg-blue-100';
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const textColor = () => {
|
|
97
|
+
if (variant === 'secondary') {
|
|
98
|
+
switch (type) {
|
|
99
|
+
case 'error':
|
|
100
|
+
return 'text-red-500';
|
|
101
|
+
case 'success':
|
|
102
|
+
return 'text-green-500';
|
|
103
|
+
case 'alert':
|
|
104
|
+
return 'text-yellow-500';
|
|
105
|
+
case 'info':
|
|
106
|
+
case 'notice':
|
|
107
|
+
default:
|
|
108
|
+
return 'text-blue-500';
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
switch (type) {
|
|
112
|
+
case 'error':
|
|
113
|
+
return 'text-red-700';
|
|
114
|
+
case 'success':
|
|
115
|
+
return 'text-green-700';
|
|
116
|
+
case 'alert':
|
|
117
|
+
return 'text-yellow-700';
|
|
118
|
+
case 'info':
|
|
119
|
+
return 'text-gray-500';
|
|
120
|
+
case 'notice':
|
|
121
|
+
default:
|
|
122
|
+
return 'text-blue-700';
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const borderColor = () => {
|
|
128
|
+
if (variant === 'secondary') {
|
|
129
|
+
switch (type) {
|
|
130
|
+
case 'error':
|
|
131
|
+
return 'border-red-300';
|
|
132
|
+
case 'success':
|
|
133
|
+
return 'border-green-300';
|
|
134
|
+
case 'alert':
|
|
135
|
+
return 'border-yellow-300';
|
|
136
|
+
case 'info':
|
|
137
|
+
case 'notice':
|
|
138
|
+
default:
|
|
139
|
+
return 'border-blue-300';
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return '';
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<View
|
|
148
|
+
{...props}
|
|
149
|
+
className={clsx(
|
|
150
|
+
'flex flex-row rounded-lg',
|
|
151
|
+
alertClasses(),
|
|
152
|
+
borderColor(),
|
|
153
|
+
largePhone ? 'px-2 py-4' : 'px-1 py-2',
|
|
154
|
+
)}
|
|
155
|
+
>
|
|
156
|
+
<View className="shrink-0">
|
|
157
|
+
<IconComponent
|
|
158
|
+
type={type}
|
|
159
|
+
variant={variant}
|
|
160
|
+
/>
|
|
161
|
+
</View>
|
|
162
|
+
<View className={clsx('flex flex-1 flex-col', largePhone ? 'ml-3' : 'ml-1')}>
|
|
163
|
+
<Text className={clsx('font-medium', textColor(), largePhone ? 'text-base' : 'text-xs')}>
|
|
164
|
+
{message}
|
|
165
|
+
</Text>
|
|
166
|
+
{description && (
|
|
167
|
+
<Text className={clsx('text-xs text-gray-700', largePhone ? 'mt-3' : 'mt-1')}>
|
|
168
|
+
{description}
|
|
169
|
+
</Text>
|
|
170
|
+
)}
|
|
171
|
+
{children}
|
|
172
|
+
</View>
|
|
173
|
+
</View>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
@@ -4,7 +4,6 @@ import { ViewProps } from 'react-native';
|
|
|
4
4
|
|
|
5
5
|
import { View, Text } from '../hoc-components';
|
|
6
6
|
import BaseIcon from './BaseIcon';
|
|
7
|
-
import utilityColors from '../styles/utility-colors';
|
|
8
7
|
import { HeroIcon } from '../types/heroicons';
|
|
9
8
|
|
|
10
9
|
export type BadgeVariant =
|
|
@@ -29,8 +28,8 @@ interface BaseBadgeProps extends ViewProps {
|
|
|
29
28
|
text: string;
|
|
30
29
|
transparent?: boolean;
|
|
31
30
|
squared?: boolean;
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
leftIcon?: HeroIcon | null;
|
|
32
|
+
rightIcon?: HeroIcon | null;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
function BaseBadge({
|
|
@@ -39,8 +38,8 @@ function BaseBadge({
|
|
|
39
38
|
text,
|
|
40
39
|
transparent = false,
|
|
41
40
|
squared = false,
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
leftIcon = null,
|
|
42
|
+
rightIcon = null,
|
|
44
43
|
...props
|
|
45
44
|
}: BaseBadgeProps) {
|
|
46
45
|
const variantStyles = {
|
|
@@ -146,41 +145,40 @@ function BaseBadge({
|
|
|
146
145
|
right: 'ml-1.5',
|
|
147
146
|
};
|
|
148
147
|
|
|
149
|
-
// @TODO handle dark mode
|
|
150
148
|
const iconColors = {
|
|
151
|
-
gray:
|
|
152
|
-
brand:
|
|
153
|
-
error:
|
|
154
|
-
warning:
|
|
155
|
-
success:
|
|
156
|
-
blue_gray:
|
|
157
|
-
blue_light:
|
|
158
|
-
blue:
|
|
159
|
-
indigo:
|
|
160
|
-
purple:
|
|
161
|
-
pink:
|
|
162
|
-
orange:
|
|
163
|
-
};
|
|
149
|
+
gray: 'utility-gray-500',
|
|
150
|
+
brand: 'utility-brand-500',
|
|
151
|
+
error: 'utility-error-500',
|
|
152
|
+
warning: 'utility-warning-500',
|
|
153
|
+
success: 'utility-success-500',
|
|
154
|
+
blue_gray: 'utility-gray_blue-500',
|
|
155
|
+
blue_light: 'utility-blue_light-500',
|
|
156
|
+
blue: 'utility-blue-500',
|
|
157
|
+
indigo: 'utility-indigo-500',
|
|
158
|
+
purple: 'utility-purple-500',
|
|
159
|
+
pink: 'utility-pink-500',
|
|
160
|
+
orange: 'utility-orange-500',
|
|
161
|
+
} as const;
|
|
164
162
|
|
|
165
163
|
return (
|
|
166
164
|
<View
|
|
167
165
|
className={containerStyles}
|
|
168
166
|
{...props}
|
|
169
167
|
>
|
|
170
|
-
{
|
|
168
|
+
{leftIcon && (
|
|
171
169
|
<View className={iconSpacingStyles.left}>
|
|
172
170
|
<BaseIcon
|
|
173
|
-
icon={
|
|
171
|
+
icon={leftIcon}
|
|
174
172
|
size={iconSizes[size]}
|
|
175
173
|
color={iconColors[variant]}
|
|
176
174
|
/>
|
|
177
175
|
</View>
|
|
178
176
|
)}
|
|
179
177
|
<Text className={textStyles}>{text}</Text>
|
|
180
|
-
{
|
|
178
|
+
{rightIcon && (
|
|
181
179
|
<View className={iconSpacingStyles.right}>
|
|
182
180
|
<BaseIcon
|
|
183
|
-
icon={
|
|
181
|
+
icon={rightIcon}
|
|
184
182
|
size={iconSizes[size]}
|
|
185
183
|
color={iconColors[variant]}
|
|
186
184
|
/>
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Pressable, Text, View, ActivityIndicator,
|
|
8
8
|
} from '../hoc-components';
|
|
9
9
|
import BaseIcon from './BaseIcon';
|
|
10
|
-
import
|
|
10
|
+
import { Color as ForegroundColor } from '../styles/foreground-colors';
|
|
11
11
|
import { HeroIcon } from '../types/heroicons';
|
|
12
12
|
|
|
13
13
|
interface ButtonProps extends PressableProps {
|
|
@@ -17,8 +17,8 @@ interface ButtonProps extends PressableProps {
|
|
|
17
17
|
loading?: boolean;
|
|
18
18
|
disabled?: boolean;
|
|
19
19
|
destructive?: boolean;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
leftIcon?: HeroIcon | null;
|
|
21
|
+
rightIcon?: HeroIcon | null;
|
|
22
22
|
countdownSecs?: number;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -29,8 +29,8 @@ function BaseButton({
|
|
|
29
29
|
loading = false,
|
|
30
30
|
disabled = false,
|
|
31
31
|
destructive = false,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
leftIcon = null,
|
|
33
|
+
rightIcon = null,
|
|
34
34
|
hitSlop = 6,
|
|
35
35
|
countdownSecs = 0,
|
|
36
36
|
...props
|
|
@@ -156,11 +156,11 @@ function BaseButton({
|
|
|
156
156
|
buttonState = 'disabled';
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
const isIconOnly = !text && (
|
|
159
|
+
const isIconOnly = !text && (leftIcon || rightIcon);
|
|
160
160
|
|
|
161
161
|
const buttonStyles = clsx(
|
|
162
162
|
'flex flex-row items-center justify-center',
|
|
163
|
-
isIconOnly ? iconOnlyClasses[size] :
|
|
163
|
+
isIconOnly ? iconOnlyClasses[size] : sizeClasses[size],
|
|
164
164
|
containerClasses[variant][buttonState],
|
|
165
165
|
);
|
|
166
166
|
|
|
@@ -172,29 +172,29 @@ function BaseButton({
|
|
|
172
172
|
|
|
173
173
|
const iconColors = {
|
|
174
174
|
primary: {
|
|
175
|
-
default:
|
|
176
|
-
disabled:
|
|
177
|
-
loading:
|
|
175
|
+
default: 'fg-white',
|
|
176
|
+
disabled: 'fg-disabled',
|
|
177
|
+
loading: 'fg-white',
|
|
178
178
|
},
|
|
179
179
|
secondary: {
|
|
180
|
-
default:
|
|
181
|
-
disabled:
|
|
182
|
-
loading:
|
|
180
|
+
default: 'fg-secondary',
|
|
181
|
+
disabled: 'fg-disabled',
|
|
182
|
+
loading: 'fg-secondary',
|
|
183
183
|
},
|
|
184
184
|
tertiary: {
|
|
185
|
-
default:
|
|
186
|
-
disabled:
|
|
187
|
-
loading:
|
|
185
|
+
default: 'fg-tertiary',
|
|
186
|
+
disabled: 'fg-disabled',
|
|
187
|
+
loading: 'fg-tertiary',
|
|
188
188
|
},
|
|
189
189
|
'link-color': {
|
|
190
|
-
default:
|
|
191
|
-
disabled:
|
|
192
|
-
loading:
|
|
190
|
+
default: 'fg-brand-primary',
|
|
191
|
+
disabled: 'fg-disabled',
|
|
192
|
+
loading: 'fg-brand-primary',
|
|
193
193
|
},
|
|
194
194
|
'link-gray': {
|
|
195
|
-
default:
|
|
196
|
-
disabled:
|
|
197
|
-
loading:
|
|
195
|
+
default: 'fg-secondary',
|
|
196
|
+
disabled: 'fg-disabled',
|
|
197
|
+
loading: 'fg-secondary',
|
|
198
198
|
},
|
|
199
199
|
};
|
|
200
200
|
|
|
@@ -243,11 +243,11 @@ function BaseButton({
|
|
|
243
243
|
{...props}
|
|
244
244
|
>
|
|
245
245
|
<View className={clsx('flex flex-row items-center justify-center', loading && 'opacity-0')}>
|
|
246
|
-
{
|
|
246
|
+
{leftIcon && (
|
|
247
247
|
<BaseIcon
|
|
248
|
-
icon={
|
|
248
|
+
icon={leftIcon}
|
|
249
249
|
size={iconSizes[size]}
|
|
250
|
-
color={iconColors[variant][buttonState]}
|
|
250
|
+
color={iconColors[variant][buttonState] as ForegroundColor}
|
|
251
251
|
className="mr-1.5"
|
|
252
252
|
/>
|
|
253
253
|
)}
|
|
@@ -257,11 +257,11 @@ function BaseButton({
|
|
|
257
257
|
{timer > 0 ? ` (${timer})` : ''}
|
|
258
258
|
</Text>
|
|
259
259
|
)}
|
|
260
|
-
{
|
|
260
|
+
{rightIcon && (
|
|
261
261
|
<BaseIcon
|
|
262
|
-
icon={
|
|
262
|
+
icon={rightIcon}
|
|
263
263
|
size={iconSizes[size]}
|
|
264
|
-
color={iconColors[variant][buttonState]}
|
|
264
|
+
color={iconColors[variant][buttonState] as ForegroundColor}
|
|
265
265
|
className="ml-1.5"
|
|
266
266
|
/>
|
|
267
267
|
)}
|
|
@@ -1,26 +1,40 @@
|
|
|
1
1
|
import { styled } from 'nativewind';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import foregroundColors, { Color as ForegroundColor } from '../styles/foreground-colors';
|
|
4
|
+
import utilityColors, { Color as UtilityColor } from '../styles/utility-colors';
|
|
5
|
+
import { HeroIcon, HeroIconProps } from '../types/heroicons';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
type IconColor = ForegroundColor | UtilityColor;
|
|
8
|
+
|
|
9
|
+
export interface BaseIconProps extends HeroIconProps {
|
|
7
10
|
icon: HeroIcon;
|
|
8
|
-
size?: number;
|
|
9
|
-
color?:
|
|
11
|
+
size?: number | string;
|
|
12
|
+
color?: IconColor;
|
|
13
|
+
strokeWidth?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function isForegroundColor(color: IconColor): color is ForegroundColor {
|
|
17
|
+
return Object.keys(foregroundColors).includes(color as string);
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
function BaseIcon({
|
|
13
21
|
icon: Icon,
|
|
14
22
|
size = 20,
|
|
15
|
-
color,
|
|
23
|
+
color = 'fg-primary',
|
|
24
|
+
strokeWidth = 1,
|
|
25
|
+
...props
|
|
16
26
|
}: BaseIconProps) {
|
|
27
|
+
const colorValue = isForegroundColor(color)
|
|
28
|
+
? foregroundColors[color].light
|
|
29
|
+
: utilityColors[color as UtilityColor].light;
|
|
30
|
+
|
|
17
31
|
return (
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
<Icon
|
|
33
|
+
size={size}
|
|
34
|
+
color={colorValue}
|
|
35
|
+
strokeWidth={strokeWidth}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
24
38
|
);
|
|
25
39
|
}
|
|
26
40
|
|
|
@@ -109,7 +109,7 @@ function BaseStackedList<T>({
|
|
|
109
109
|
variant="secondary"
|
|
110
110
|
onPress={onPrevPage}
|
|
111
111
|
disabled={!hasPrevPage}
|
|
112
|
-
|
|
112
|
+
leftIcon={ArrowLeftIcon}
|
|
113
113
|
/>
|
|
114
114
|
|
|
115
115
|
<Text className="text-sm font-medium text-secondary">
|
|
@@ -126,7 +126,7 @@ function BaseStackedList<T>({
|
|
|
126
126
|
variant="secondary"
|
|
127
127
|
onPress={onNextPage}
|
|
128
128
|
disabled={!hasNextPage}
|
|
129
|
-
|
|
129
|
+
leftIcon={ArrowRightIcon}
|
|
130
130
|
/>
|
|
131
131
|
</View>
|
|
132
132
|
)}
|
package/src/components/index.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { default as BaseBadge } from './BaseBadge';
|
|
|
3
3
|
export { default as BaseSpinner } from './BaseSpinner';
|
|
4
4
|
export { default as BaseStackedList } from './BaseStackedList';
|
|
5
5
|
export { default as BaseIcon } from './BaseIcon';
|
|
6
|
+
export { default as BaseAlert } from './BaseAlert';
|
package/src/preset.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Config } from 'tailwindcss';
|
|
|
2
2
|
|
|
3
3
|
import backgroundColors from './styles/background-colors';
|
|
4
4
|
import borderColors from './styles/border-colors';
|
|
5
|
+
import foregroundColors from './styles/foreground-colors';
|
|
5
6
|
import textColors from './styles/text-colors';
|
|
6
7
|
|
|
7
8
|
type SemanticColorObject = Record<string, { light: string; dark?: string }>;
|
|
@@ -26,6 +27,9 @@ const preset: Config = {
|
|
|
26
27
|
backgroundColor: mapLightColors(backgroundColors, 'bg'),
|
|
27
28
|
textColor: mapLightColors(textColors, 'text'),
|
|
28
29
|
borderColor: mapLightColors(borderColors, 'border'),
|
|
30
|
+
colors: {
|
|
31
|
+
...mapLightColors(foregroundColors, 'fg'),
|
|
32
|
+
},
|
|
29
33
|
},
|
|
30
34
|
},
|
|
31
35
|
plugins: [],
|
|
@@ -138,7 +138,7 @@ const backgroundColors: BackgroundColorsType = {
|
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
Object.entries(utilityColors).forEach(([key, value]) => {
|
|
141
|
-
backgroundColors[`bg
|
|
141
|
+
backgroundColors[`bg-${key}`] = {
|
|
142
142
|
light: value.light,
|
|
143
143
|
dark: value.dark,
|
|
144
144
|
};
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import colors from './colors';
|
|
2
2
|
|
|
3
|
+
export type Color =
|
|
4
|
+
| 'fg-primary'
|
|
5
|
+
| 'fg-secondary'
|
|
6
|
+
| 'fg-tertiary'
|
|
7
|
+
| 'fg-quaternary'
|
|
8
|
+
| 'fg-white'
|
|
9
|
+
| 'fg-disabled'
|
|
10
|
+
| 'fg-disabled_subtle'
|
|
11
|
+
| 'fg-brand-primary'
|
|
12
|
+
| 'fg-brand-primary_alt'
|
|
13
|
+
| 'fg-brand-secondary'
|
|
14
|
+
| 'fg-brand-secondary_alt'
|
|
15
|
+
| 'fg-error-primary'
|
|
16
|
+
| 'fg-error-secondary'
|
|
17
|
+
| 'fg-warning-primary'
|
|
18
|
+
| 'fg-warning-secondary'
|
|
19
|
+
| 'fg-success-primary'
|
|
20
|
+
| 'fg-success-secondary';
|
|
21
|
+
|
|
3
22
|
export default {
|
|
4
23
|
'fg-primary': {
|
|
5
24
|
light: colors.gray_light['900'],
|
|
@@ -9,26 +28,14 @@ export default {
|
|
|
9
28
|
light: colors.gray_light['700'],
|
|
10
29
|
dark: colors.gray_dark['300'],
|
|
11
30
|
},
|
|
12
|
-
'fg-secondary_hover': {
|
|
13
|
-
light: colors.gray_light['800'],
|
|
14
|
-
dark: colors.gray_dark['200'],
|
|
15
|
-
},
|
|
16
31
|
'fg-tertiary': {
|
|
17
32
|
light: colors.gray_light['600'],
|
|
18
33
|
dark: colors.gray_dark['400'],
|
|
19
34
|
},
|
|
20
|
-
'fg-tertiary_hover': {
|
|
21
|
-
light: colors.gray_light['700'],
|
|
22
|
-
dark: colors.gray_dark['300'],
|
|
23
|
-
},
|
|
24
35
|
'fg-quaternary': {
|
|
25
36
|
light: colors.gray_light['400'],
|
|
26
37
|
dark: colors.gray_dark['600'],
|
|
27
38
|
},
|
|
28
|
-
'fg-quaternary_hover': {
|
|
29
|
-
light: colors.gray_light['500'],
|
|
30
|
-
dark: colors.gray_dark['500'],
|
|
31
|
-
},
|
|
32
39
|
'fg-white': {
|
|
33
40
|
light: colors.base.white,
|
|
34
41
|
dark: colors.base.white,
|