@butternutbox/pawprint-native 0.25.0 → 0.25.1
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/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/Button/Button.stories.tsx +90 -16
- package/src/components/atoms/Button/Button.tsx +13 -2
package/package.json
CHANGED
|
@@ -5,20 +5,18 @@ import type { ButtonProps } from "./Button"
|
|
|
5
5
|
import { Typography } from "../Typography"
|
|
6
6
|
import { Icon } from "../Icon"
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
Facebook,
|
|
9
9
|
IosShare,
|
|
10
10
|
Whatsapp,
|
|
11
|
-
|
|
11
|
+
Mail
|
|
12
12
|
} from "@butternutbox/pawprint-icons/core"
|
|
13
13
|
|
|
14
14
|
const iconElements: Record<string, React.ReactNode> = {
|
|
15
15
|
None: undefined,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Whatsapp: <Icon icon={Whatsapp} colour="primary" />,
|
|
21
|
-
Check: <Icon icon={Check} colour="primary" />
|
|
16
|
+
Facebook: <Icon icon={Facebook} size="sm" colour="action-default" />,
|
|
17
|
+
IosShare: <Icon icon={IosShare} size="sm" colour="action-default" />,
|
|
18
|
+
Whatsapp: <Icon icon={Whatsapp} size="sm" colour="action-default" />,
|
|
19
|
+
Mail: <Icon icon={Mail} size="sm" colour="action-default" />
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
const iconArgType = {
|
|
@@ -155,28 +153,104 @@ export const WithStartIcon = () => (
|
|
|
155
153
|
<View style={styles.row}>
|
|
156
154
|
<Button
|
|
157
155
|
size={size}
|
|
158
|
-
startIcon={
|
|
156
|
+
startIcon={
|
|
157
|
+
<Icon icon={Facebook} size="sm" colour="action-default" />
|
|
158
|
+
}
|
|
159
159
|
>
|
|
160
|
-
|
|
160
|
+
Share
|
|
161
161
|
</Button>
|
|
162
162
|
<Button
|
|
163
163
|
size={size}
|
|
164
|
-
startIcon={
|
|
164
|
+
startIcon={
|
|
165
|
+
<Icon icon={IosShare} size="sm" colour="action-default" />
|
|
166
|
+
}
|
|
165
167
|
>
|
|
166
|
-
|
|
168
|
+
Export
|
|
167
169
|
</Button>
|
|
168
170
|
<Button
|
|
169
171
|
size={size}
|
|
170
|
-
startIcon={
|
|
172
|
+
startIcon={
|
|
173
|
+
<Icon icon={Whatsapp} size="sm" colour="action-default" />
|
|
174
|
+
}
|
|
171
175
|
>
|
|
172
|
-
|
|
176
|
+
Message
|
|
173
177
|
</Button>
|
|
174
178
|
<Button
|
|
175
179
|
size={size}
|
|
176
|
-
startIcon={<Icon icon={
|
|
180
|
+
startIcon={<Icon icon={Mail} size="sm" colour="action-default" />}
|
|
177
181
|
colour="secondary"
|
|
178
182
|
>
|
|
179
|
-
|
|
183
|
+
Send
|
|
184
|
+
</Button>
|
|
185
|
+
</View>
|
|
186
|
+
</View>
|
|
187
|
+
))}
|
|
188
|
+
</View>
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
export const WithEndIcon = () => (
|
|
192
|
+
<View style={styles.column}>
|
|
193
|
+
{(["sm", "md", "lg"] as const).map((size) => (
|
|
194
|
+
<View key={size} style={styles.section}>
|
|
195
|
+
<Typography size="sm" weight="semiBold" color="tertiary">
|
|
196
|
+
{size}
|
|
197
|
+
</Typography>
|
|
198
|
+
<View style={styles.row}>
|
|
199
|
+
<Button
|
|
200
|
+
size={size}
|
|
201
|
+
endIcon={<Icon icon={Facebook} size="sm" colour="action-default" />}
|
|
202
|
+
>
|
|
203
|
+
Connect
|
|
204
|
+
</Button>
|
|
205
|
+
<Button
|
|
206
|
+
size={size}
|
|
207
|
+
endIcon={<Icon icon={IosShare} size="sm" colour="action-default" />}
|
|
208
|
+
>
|
|
209
|
+
Share
|
|
210
|
+
</Button>
|
|
211
|
+
<Button
|
|
212
|
+
size={size}
|
|
213
|
+
endIcon={<Icon icon={Whatsapp} size="sm" colour="action-default" />}
|
|
214
|
+
>
|
|
215
|
+
Chat
|
|
216
|
+
</Button>
|
|
217
|
+
<Button
|
|
218
|
+
size={size}
|
|
219
|
+
endIcon={<Icon icon={Mail} size="sm" colour="action-default" />}
|
|
220
|
+
colour="secondary"
|
|
221
|
+
>
|
|
222
|
+
Email
|
|
223
|
+
</Button>
|
|
224
|
+
</View>
|
|
225
|
+
</View>
|
|
226
|
+
))}
|
|
227
|
+
</View>
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
export const WithBothIcons = () => (
|
|
231
|
+
<View style={styles.column}>
|
|
232
|
+
{(["sm", "md", "lg"] as const).map((size) => (
|
|
233
|
+
<View key={size} style={styles.section}>
|
|
234
|
+
<Typography size="sm" weight="semiBold" color="tertiary">
|
|
235
|
+
{size}
|
|
236
|
+
</Typography>
|
|
237
|
+
<View style={styles.row}>
|
|
238
|
+
<Button
|
|
239
|
+
size={size}
|
|
240
|
+
startIcon={
|
|
241
|
+
<Icon icon={Facebook} size="sm" colour="action-default" />
|
|
242
|
+
}
|
|
243
|
+
endIcon={<Icon icon={IosShare} size="sm" colour="action-default" />}
|
|
244
|
+
>
|
|
245
|
+
Share
|
|
246
|
+
</Button>
|
|
247
|
+
<Button
|
|
248
|
+
size={size}
|
|
249
|
+
startIcon={<Icon icon={Mail} size="sm" colour="action-default" />}
|
|
250
|
+
endIcon={<Icon icon={Whatsapp} size="sm" colour="action-default" />}
|
|
251
|
+
variant="outlined"
|
|
252
|
+
>
|
|
253
|
+
Contact
|
|
180
254
|
</Button>
|
|
181
255
|
</View>
|
|
182
256
|
</View>
|
|
@@ -193,6 +193,17 @@ const Button = React.forwardRef<View, ButtonProps>(
|
|
|
193
193
|
|
|
194
194
|
const variantStyles = getVariantStyles(pressed)
|
|
195
195
|
|
|
196
|
+
const renderIcon = (icon: React.ReactNode): React.ReactNode => {
|
|
197
|
+
if (!React.isValidElement(icon)) return icon
|
|
198
|
+
const iconElement = icon as React.ReactElement<any>
|
|
199
|
+
if (!pressed) {
|
|
200
|
+
return icon
|
|
201
|
+
}
|
|
202
|
+
return React.cloneElement(iconElement, {
|
|
203
|
+
customColour: variantStyles.textColor
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
|
|
196
207
|
return (
|
|
197
208
|
<StyledButton
|
|
198
209
|
ref={ref}
|
|
@@ -220,7 +231,7 @@ const Button = React.forwardRef<View, ButtonProps>(
|
|
|
220
231
|
buttonFullWidth={fullWidth}
|
|
221
232
|
{...rest}
|
|
222
233
|
>
|
|
223
|
-
{startIcon && <IconWrapper>{startIcon}</IconWrapper>}
|
|
234
|
+
{startIcon && <IconWrapper>{renderIcon(startIcon)}</IconWrapper>}
|
|
224
235
|
{/* `Typography` is a DIRECT child of the button row (no wrapping View)
|
|
225
236
|
so its `<Text>` participates in flex shrink and wraps long /
|
|
226
237
|
translated labels to multiple lines under the button's `minHeight`.
|
|
@@ -241,7 +252,7 @@ const Button = React.forwardRef<View, ButtonProps>(
|
|
|
241
252
|
>
|
|
242
253
|
{children}
|
|
243
254
|
</Typography>
|
|
244
|
-
{endIcon && <IconWrapper>{endIcon}</IconWrapper>}
|
|
255
|
+
{endIcon && <IconWrapper>{renderIcon(endIcon)}</IconWrapper>}
|
|
245
256
|
{loading && (
|
|
246
257
|
<StyledSpinnerWrapper>
|
|
247
258
|
<Spinner
|