@butternutbox/pawprint-native 1.3.1 → 1.4.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 +9 -9
- package/CHANGELOG.md +15 -0
- package/dist/index.cjs +334 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -3
- package/dist/index.d.ts +62 -3
- package/dist/index.js +302 -77
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/Button/Button.stories.tsx +4 -4
- package/src/components/atoms/Button/Button.test.tsx +9 -2
- package/src/components/atoms/Button/Button.tsx +39 -7
- package/src/components/molecules/NavigationHeader/NavigationHeader.stories.tsx +140 -0
- package/src/components/molecules/NavigationHeader/NavigationHeader.test.tsx +110 -0
- package/src/components/molecules/NavigationHeader/NavigationHeader.tsx +273 -0
- package/src/components/molecules/NavigationHeader/NavigationHeaderButton.tsx +87 -0
- package/src/components/molecules/NavigationHeader/NavigationHeaderContext.ts +38 -0
- package/src/components/molecules/NavigationHeader/index.ts +14 -0
- package/src/components/molecules/index.ts +1 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { View } from "react-native"
|
|
3
|
+
import { Button, type ButtonProps } from "../../atoms/Button"
|
|
4
|
+
import { IconButton, type IconButtonProps } from "../../atoms/IconButton"
|
|
5
|
+
import {
|
|
6
|
+
getButtonDefaults,
|
|
7
|
+
getIconButtonColour,
|
|
8
|
+
useNavigationHeaderContext
|
|
9
|
+
} from "./NavigationHeaderContext"
|
|
10
|
+
|
|
11
|
+
export type NavigationHeaderButtonProps = Omit<
|
|
12
|
+
ButtonProps,
|
|
13
|
+
"size" | "fullWidth"
|
|
14
|
+
>
|
|
15
|
+
|
|
16
|
+
export type NavigationHeaderIconButtonProps = Omit<IconButtonProps, "size">
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Text button for the navigation header action group. A medium `Button` with
|
|
20
|
+
* the header defaults: white `filled` / `tertiary` on the `brand` surface and
|
|
21
|
+
* `outlined` on other surfaces.
|
|
22
|
+
*
|
|
23
|
+
* Passing `variant` or `colour` overrides the default.
|
|
24
|
+
*
|
|
25
|
+
* @param {"filled" | "outlined" | "text"} [variant] - Button style.
|
|
26
|
+
* @param {"primary" | "secondary" | "tertiary"} [colour] - Filled colour.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <NavigationHeader.Button onPress={editQuantity}>
|
|
31
|
+
* Pouch quantity
|
|
32
|
+
* </NavigationHeader.Button>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const NavigationHeaderButton = React.forwardRef<
|
|
36
|
+
View,
|
|
37
|
+
NavigationHeaderButtonProps
|
|
38
|
+
>(({ variant, colour, ...props }, ref) => {
|
|
39
|
+
const defaults = getButtonDefaults(useNavigationHeaderContext())
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Button
|
|
43
|
+
ref={ref}
|
|
44
|
+
size="md"
|
|
45
|
+
variant={variant ?? defaults.variant}
|
|
46
|
+
colour={colour ?? defaults.colour}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
NavigationHeaderButton.displayName = "NavigationHeader.Button"
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Icon button for the navigation header action group. A medium filled
|
|
56
|
+
* `IconButton`, `tertiary` on the `brand` surface and `secondary` on other
|
|
57
|
+
* surfaces.
|
|
58
|
+
*
|
|
59
|
+
* Passing `variant` or `colour` overrides the default.
|
|
60
|
+
*
|
|
61
|
+
* @param {PawprintIcon} icon - **(required)** Icon component.
|
|
62
|
+
* @param {string} aria-label - **(required)** Accessible label.
|
|
63
|
+
* @param {"filled" | "outlined" | "text"} [variant="filled"] - Button style.
|
|
64
|
+
* @param {"primary" | "secondary" | "tertiary"} [colour] - Filled colour.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* <NavigationHeader.IconButton icon={Add} aria-label="Add dog" />
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export const NavigationHeaderIconButton = React.forwardRef<
|
|
72
|
+
View,
|
|
73
|
+
NavigationHeaderIconButtonProps
|
|
74
|
+
>(({ colour, ...props }, ref) => {
|
|
75
|
+
const context = useNavigationHeaderContext()
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<IconButton
|
|
79
|
+
ref={ref}
|
|
80
|
+
size="md"
|
|
81
|
+
colour={colour ?? getIconButtonColour(context)}
|
|
82
|
+
{...props}
|
|
83
|
+
/>
|
|
84
|
+
)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
NavigationHeaderIconButton.displayName = "NavigationHeader.IconButton"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import type { ButtonColour, ButtonVariant } from "../../atoms/Button"
|
|
3
|
+
import type { IconButtonColour } from "../../atoms/IconButton"
|
|
4
|
+
|
|
5
|
+
type NavigationHeaderSurface = "brand" | "subtle" | "plain"
|
|
6
|
+
|
|
7
|
+
type NavigationHeaderContextValue = {
|
|
8
|
+
surface: NavigationHeaderSurface
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const NavigationHeaderContext =
|
|
12
|
+
React.createContext<NavigationHeaderContextValue>({ surface: "brand" })
|
|
13
|
+
|
|
14
|
+
const useNavigationHeaderContext = () =>
|
|
15
|
+
React.useContext(NavigationHeaderContext)
|
|
16
|
+
|
|
17
|
+
const getButtonDefaults = ({
|
|
18
|
+
surface
|
|
19
|
+
}: NavigationHeaderContextValue): {
|
|
20
|
+
variant: ButtonVariant
|
|
21
|
+
colour: ButtonColour
|
|
22
|
+
} =>
|
|
23
|
+
surface === "brand"
|
|
24
|
+
? { variant: "filled", colour: "tertiary" }
|
|
25
|
+
: { variant: "outlined", colour: "primary" }
|
|
26
|
+
|
|
27
|
+
const getIconButtonColour = ({
|
|
28
|
+
surface
|
|
29
|
+
}: NavigationHeaderContextValue): IconButtonColour =>
|
|
30
|
+
surface === "brand" ? "tertiary" : "secondary"
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
NavigationHeaderContext,
|
|
34
|
+
useNavigationHeaderContext,
|
|
35
|
+
getButtonDefaults,
|
|
36
|
+
getIconButtonColour
|
|
37
|
+
}
|
|
38
|
+
export type { NavigationHeaderSurface, NavigationHeaderContextValue }
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { NavigationHeader } from "./NavigationHeader"
|
|
2
|
+
export type {
|
|
3
|
+
NavigationHeaderProps,
|
|
4
|
+
NavigationHeaderVariant,
|
|
5
|
+
NavigationHeaderSurface
|
|
6
|
+
} from "./NavigationHeader"
|
|
7
|
+
export {
|
|
8
|
+
NavigationHeaderButton,
|
|
9
|
+
NavigationHeaderIconButton
|
|
10
|
+
} from "./NavigationHeaderButton"
|
|
11
|
+
export type {
|
|
12
|
+
NavigationHeaderButtonProps,
|
|
13
|
+
NavigationHeaderIconButtonProps
|
|
14
|
+
} from "./NavigationHeaderButton"
|