@butternutbox/pawprint-native 0.15.1 → 0.16.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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +35 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -5
- package/dist/index.d.ts +34 -5
- package/dist/index.js +35 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/Illustration/Illustration.tsx +52 -7
- package/src/components/molecules/Tooltip/Tooltip.stories.tsx +21 -0
- package/src/components/molecules/Tooltip/Tooltip.tsx +9 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
-
import { View, ViewProps } from "react-native"
|
|
2
|
+
import { View, ViewProps, FlexStyle } from "react-native"
|
|
3
3
|
import styled from "@emotion/native"
|
|
4
4
|
import { useTheme } from "@emotion/react"
|
|
5
5
|
|
|
@@ -10,11 +10,20 @@ type PawprintIllustration = React.ComponentType<{
|
|
|
10
10
|
height?: number
|
|
11
11
|
}>
|
|
12
12
|
|
|
13
|
+
type FlexboxProps = {
|
|
14
|
+
align?: FlexStyle["alignItems"]
|
|
15
|
+
justify?: FlexStyle["justifyContent"]
|
|
16
|
+
flexDirection?: FlexStyle["flexDirection"]
|
|
17
|
+
flexWrap?: FlexStyle["flexWrap"]
|
|
18
|
+
alignContent?: FlexStyle["alignContent"]
|
|
19
|
+
alignSelf?: FlexStyle["alignSelf"]
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
type IllustrationOwnProps = {
|
|
14
23
|
illustration: PawprintIllustration
|
|
15
24
|
size?: IllustrationSize
|
|
16
25
|
"aria-label"?: string
|
|
17
|
-
}
|
|
26
|
+
} & FlexboxProps
|
|
18
27
|
|
|
19
28
|
type IllustrationProps = IllustrationOwnProps &
|
|
20
29
|
Omit<ViewProps, keyof IllustrationOwnProps>
|
|
@@ -23,15 +32,20 @@ const parseTokenValue = (value: string): number => parseFloat(value)
|
|
|
23
32
|
|
|
24
33
|
const StyledRoot = styled(View)<{
|
|
25
34
|
illustrationHeight: number
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
flexboxProps: FlexboxProps
|
|
36
|
+
}>(({ illustrationHeight, flexboxProps }) => ({
|
|
37
|
+
alignItems: flexboxProps.align ?? "center",
|
|
38
|
+
justifyContent: flexboxProps.justify ?? "center",
|
|
39
|
+
flexDirection: flexboxProps.flexDirection,
|
|
40
|
+
flexWrap: flexboxProps.flexWrap,
|
|
41
|
+
alignContent: flexboxProps.alignContent,
|
|
42
|
+
alignSelf: flexboxProps.alignSelf,
|
|
29
43
|
flexShrink: 0,
|
|
30
44
|
height: illustrationHeight
|
|
31
45
|
}))
|
|
32
46
|
|
|
33
47
|
/**
|
|
34
|
-
* Renders a multi-colour SVG illustration with token-based sizing.
|
|
48
|
+
* Renders a multi-colour SVG illustration with token-based sizing and flexbox alignment.
|
|
35
49
|
*
|
|
36
50
|
* @example
|
|
37
51
|
* ```tsx
|
|
@@ -42,7 +56,17 @@ const StyledRoot = styled(View)<{
|
|
|
42
56
|
* ```
|
|
43
57
|
*
|
|
44
58
|
* @param illustration - **(required)** Illustration component
|
|
59
|
+
<<<<<<< Updated upstream
|
|
45
60
|
* @param size - *(optional)* Size variant: sm (default), lg, xl, xxl, xxxl
|
|
61
|
+
=======
|
|
62
|
+
* @param size - *(optional)* Size variant: sm (default), lg, xl
|
|
63
|
+
* @param align - *(optional)* Flexbox alignItems (default: center)
|
|
64
|
+
* @param justify - *(optional)* Flexbox justifyContent (default: center)
|
|
65
|
+
* @param flexDirection - *(optional)* Flexbox flex direction
|
|
66
|
+
* @param flexWrap - *(optional)* Flexbox wrap
|
|
67
|
+
* @param alignContent - *(optional)* Flexbox alignContent
|
|
68
|
+
* @param alignSelf - *(optional)* Flexbox alignSelf
|
|
69
|
+
>>>>>>> Stashed changes
|
|
46
70
|
* @param aria-label - *(optional)* Accessible label
|
|
47
71
|
*/
|
|
48
72
|
const Illustration = React.forwardRef<View, IllustrationProps>(
|
|
@@ -50,6 +74,12 @@ const Illustration = React.forwardRef<View, IllustrationProps>(
|
|
|
50
74
|
{
|
|
51
75
|
illustration: IllustrationComponent,
|
|
52
76
|
size = "sm",
|
|
77
|
+
align,
|
|
78
|
+
justify,
|
|
79
|
+
flexDirection,
|
|
80
|
+
flexWrap,
|
|
81
|
+
alignContent,
|
|
82
|
+
alignSelf,
|
|
53
83
|
"aria-label": ariaLabel,
|
|
54
84
|
...rest
|
|
55
85
|
},
|
|
@@ -60,10 +90,20 @@ const Illustration = React.forwardRef<View, IllustrationProps>(
|
|
|
60
90
|
theme.tokens.components.illustrations.sizing.illustrations[size]
|
|
61
91
|
)
|
|
62
92
|
|
|
93
|
+
const flexboxProps: FlexboxProps = {
|
|
94
|
+
align,
|
|
95
|
+
justify,
|
|
96
|
+
flexDirection,
|
|
97
|
+
flexWrap,
|
|
98
|
+
alignContent,
|
|
99
|
+
alignSelf
|
|
100
|
+
}
|
|
101
|
+
|
|
63
102
|
return (
|
|
64
103
|
<StyledRoot
|
|
65
104
|
ref={ref}
|
|
66
105
|
illustrationHeight={dimension}
|
|
106
|
+
flexboxProps={flexboxProps}
|
|
67
107
|
accessibilityRole={ariaLabel ? "image" : undefined}
|
|
68
108
|
accessibilityLabel={ariaLabel}
|
|
69
109
|
accessible={!!ariaLabel}
|
|
@@ -78,4 +118,9 @@ const Illustration = React.forwardRef<View, IllustrationProps>(
|
|
|
78
118
|
Illustration.displayName = "Illustration"
|
|
79
119
|
|
|
80
120
|
export { Illustration }
|
|
81
|
-
export type {
|
|
121
|
+
export type {
|
|
122
|
+
IllustrationProps,
|
|
123
|
+
PawprintIllustration,
|
|
124
|
+
IllustrationSize,
|
|
125
|
+
FlexboxProps
|
|
126
|
+
}
|
|
@@ -143,6 +143,27 @@ export const InContext = () => (
|
|
|
143
143
|
</View>
|
|
144
144
|
)
|
|
145
145
|
|
|
146
|
+
export const RichText = () => (
|
|
147
|
+
<View style={styles.column}>
|
|
148
|
+
<Typography variant="heading" size="sm">
|
|
149
|
+
Rich text — emphasise part of the copy
|
|
150
|
+
</Typography>
|
|
151
|
+
<Tooltip
|
|
152
|
+
alignment="left"
|
|
153
|
+
position="bottom"
|
|
154
|
+
text={
|
|
155
|
+
<React.Fragment>
|
|
156
|
+
Your order is below{" "}
|
|
157
|
+
<Typography variant="body" weight="bold" size="md">
|
|
158
|
+
£8.00
|
|
159
|
+
</Typography>{" "}
|
|
160
|
+
minimum. Add more items to remove this fee.
|
|
161
|
+
</React.Fragment>
|
|
162
|
+
}
|
|
163
|
+
/>
|
|
164
|
+
</View>
|
|
165
|
+
)
|
|
166
|
+
|
|
146
167
|
const styles = StyleSheet.create({
|
|
147
168
|
container: {
|
|
148
169
|
padding: 24,
|
|
@@ -12,7 +12,14 @@ type TooltipAlignment = "left" | "middle" | "right"
|
|
|
12
12
|
type TooltipPosition = "top" | "bottom"
|
|
13
13
|
|
|
14
14
|
type TooltipOwnProps = {
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Tooltip body content. Pass a plain string for simple copy, or a
|
|
17
|
+
* `ReactNode` (e.g. a `<Trans>` / nested `<Text>`) when part of the text
|
|
18
|
+
* needs its own styling — bold, colour, underline, etc. A node is rendered
|
|
19
|
+
* inside the tooltip's own `<Typography>`, so it inherits the base font and
|
|
20
|
+
* only the emphasised spans override it.
|
|
21
|
+
*/
|
|
22
|
+
text: string | React.ReactNode
|
|
16
23
|
alignment?: TooltipAlignment
|
|
17
24
|
position?: TooltipPosition
|
|
18
25
|
/**
|
|
@@ -221,7 +228,7 @@ export const Tooltip = React.forwardRef<View, TooltipProps>(
|
|
|
221
228
|
ref={ref}
|
|
222
229
|
accessible={true}
|
|
223
230
|
accessibilityRole="none"
|
|
224
|
-
accessibilityLabel={text}
|
|
231
|
+
accessibilityLabel={typeof text === "string" ? text : undefined}
|
|
225
232
|
accessibilityLiveRegion="polite"
|
|
226
233
|
{...props}
|
|
227
234
|
>
|