@butternutbox/pawprint-native 0.11.1 → 0.12.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 +6 -0
- package/dist/index.cjs +900 -876
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +738 -715
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/Divider/Divider.stories.tsx +71 -0
- package/src/components/atoms/Divider/Divider.test.tsx +25 -0
- package/src/components/atoms/Divider/Divider.tsx +61 -0
- package/src/components/atoms/Divider/index.ts +2 -0
- package/src/components/atoms/index.ts +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { View, StyleSheet } from "react-native"
|
|
3
|
+
import { Divider } from "./Divider"
|
|
4
|
+
import { Typography } from "../Typography"
|
|
5
|
+
import type { DividerProps } from "./Divider"
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Atoms/Divider",
|
|
9
|
+
component: Divider,
|
|
10
|
+
parameters: {
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component:
|
|
14
|
+
"A horizontal rule used to separate content, group related elements, and establish a clear visual hierarchy. Native counterpart to the web Divider."
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
argTypes: {
|
|
19
|
+
size: {
|
|
20
|
+
control: { type: "select" },
|
|
21
|
+
options: ["small", "medium", "large"],
|
|
22
|
+
description:
|
|
23
|
+
"Thickness of the divider (small = 1px, medium = 2px, large = 4px)"
|
|
24
|
+
},
|
|
25
|
+
colour: {
|
|
26
|
+
control: { type: "select" },
|
|
27
|
+
options: ["light", "dark"],
|
|
28
|
+
description: "Colour variant of the divider"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const sizes = ["small", "medium", "large"] as const
|
|
34
|
+
const colours = ["light", "dark"] as const
|
|
35
|
+
|
|
36
|
+
export const Default = (args: DividerProps) => (
|
|
37
|
+
<View style={styles.container}>
|
|
38
|
+
<Divider {...args} />
|
|
39
|
+
</View>
|
|
40
|
+
)
|
|
41
|
+
Default.args = {
|
|
42
|
+
size: "small",
|
|
43
|
+
colour: "light"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const AllVariants = () => (
|
|
47
|
+
<View style={styles.column}>
|
|
48
|
+
{colours.map((colour) => (
|
|
49
|
+
<View key={colour} style={styles.section}>
|
|
50
|
+
<Typography variant="heading" size="sm">
|
|
51
|
+
{colour}
|
|
52
|
+
</Typography>
|
|
53
|
+
{sizes.map((size) => (
|
|
54
|
+
<View key={size} style={styles.row}>
|
|
55
|
+
<Typography variant="body" size="sm">
|
|
56
|
+
{size}
|
|
57
|
+
</Typography>
|
|
58
|
+
<Divider size={size} colour={colour} />
|
|
59
|
+
</View>
|
|
60
|
+
))}
|
|
61
|
+
</View>
|
|
62
|
+
))}
|
|
63
|
+
</View>
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const styles = StyleSheet.create({
|
|
67
|
+
container: { width: 300 },
|
|
68
|
+
column: { width: 300, gap: 24 },
|
|
69
|
+
section: { gap: 12 },
|
|
70
|
+
row: { gap: 4 }
|
|
71
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { describe, it, expect } from "vitest"
|
|
3
|
+
import { renderWithTheme } from "../../../test-utils"
|
|
4
|
+
import { Divider } from "./Divider"
|
|
5
|
+
|
|
6
|
+
describe("Divider", () => {
|
|
7
|
+
it("renders with default size and colour", () => {
|
|
8
|
+
const { container } = renderWithTheme(<Divider />)
|
|
9
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it("renders size and colour variants", () => {
|
|
13
|
+
const { container } = renderWithTheme(
|
|
14
|
+
<Divider size="large" colour="dark" />
|
|
15
|
+
)
|
|
16
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it("forwards ref to the root element", () => {
|
|
20
|
+
const ref = React.createRef<any>()
|
|
21
|
+
renderWithTheme(<Divider ref={ref} />)
|
|
22
|
+
expect(ref.current).toBeTruthy()
|
|
23
|
+
expect(ref.current).toBeInTheDocument()
|
|
24
|
+
})
|
|
25
|
+
})
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { View } from "react-native"
|
|
3
|
+
import styled from "@emotion/native"
|
|
4
|
+
|
|
5
|
+
type DividerSize = "small" | "medium" | "large"
|
|
6
|
+
type DividerColour = "light" | "dark"
|
|
7
|
+
|
|
8
|
+
type DividerOwnProps = {
|
|
9
|
+
size?: DividerSize
|
|
10
|
+
colour?: DividerColour
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type DividerProps = DividerOwnProps &
|
|
14
|
+
Omit<React.ComponentProps<typeof View>, keyof DividerOwnProps>
|
|
15
|
+
|
|
16
|
+
const parseTokenValue = (value: string): number => parseFloat(value)
|
|
17
|
+
|
|
18
|
+
const StyledDivider = styled(View)<{
|
|
19
|
+
dividerSize: DividerSize
|
|
20
|
+
dividerColour: DividerColour
|
|
21
|
+
}>(({ theme, dividerSize, dividerColour }) => {
|
|
22
|
+
const { colour, sizing } = theme.tokens.components.dividers
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
width: "100%",
|
|
26
|
+
height: parseTokenValue(sizing[dividerSize].height),
|
|
27
|
+
backgroundColor: colour[dividerColour]
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A horizontal rule used to separate content, group related elements, and
|
|
33
|
+
* establish a clear visual hierarchy. Native counterpart to the web `Divider`.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* import { Divider } from "@butternutbox/pawprint-native"
|
|
38
|
+
*
|
|
39
|
+
* <Divider />
|
|
40
|
+
* <Divider size="medium" colour="dark" />
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param {"small" | "medium" | "large"} [size="small"] - Thickness variant
|
|
44
|
+
* (small = 1px, medium = 2px, large = 4px).
|
|
45
|
+
* @param {"light" | "dark"} [colour="light"] - Colour variant.
|
|
46
|
+
*/
|
|
47
|
+
const Divider = React.forwardRef<View, DividerProps>(
|
|
48
|
+
({ size = "small", colour = "light", ...rest }, ref) => (
|
|
49
|
+
<StyledDivider
|
|
50
|
+
ref={ref}
|
|
51
|
+
dividerSize={size}
|
|
52
|
+
dividerColour={colour}
|
|
53
|
+
{...rest}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
Divider.displayName = "Divider"
|
|
59
|
+
|
|
60
|
+
export { Divider }
|
|
61
|
+
export type { DividerProps, DividerSize, DividerColour }
|