@factorialco/f0-react-native 0.32.0 → 0.34.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/README.md +25 -0
- package/lib/module/components/Badge/index.js +1 -1
- package/lib/module/components/Badge/index.js.map +1 -1
- package/lib/module/components/F0Badge/F0Badge.js +2 -0
- package/lib/module/components/F0Badge/F0Badge.js.map +1 -0
- package/lib/module/components/F0Badge/F0Badge.md +67 -0
- package/lib/module/components/F0Badge/F0Badge.styles.js +2 -0
- package/lib/module/components/F0Badge/F0Badge.styles.js.map +1 -0
- package/lib/module/components/F0Badge/F0Badge.types.js +2 -0
- package/lib/module/components/F0Badge/F0Badge.types.js.map +1 -0
- package/lib/module/components/F0Badge/index.js +2 -0
- package/lib/module/components/F0Badge/index.js.map +1 -0
- package/lib/module/components/exports.js +1 -1
- package/lib/module/components/exports.js.map +1 -1
- package/lib/typescript/components/Badge/index.d.ts +28 -54
- package/lib/typescript/components/Badge/index.d.ts.map +1 -1
- package/lib/typescript/components/F0Badge/F0Badge.d.ts +5 -0
- package/lib/typescript/components/F0Badge/F0Badge.d.ts.map +1 -0
- package/lib/typescript/components/F0Badge/F0Badge.styles.d.ts +57 -0
- package/lib/typescript/components/F0Badge/F0Badge.styles.d.ts.map +1 -0
- package/lib/typescript/components/F0Badge/F0Badge.types.d.ts +19 -0
- package/lib/typescript/components/F0Badge/F0Badge.types.d.ts.map +1 -0
- package/lib/typescript/components/F0Badge/index.d.ts +4 -0
- package/lib/typescript/components/F0Badge/index.d.ts.map +1 -0
- package/lib/typescript/components/exports.d.ts +1 -0
- package/lib/typescript/components/exports.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Badge/__tests__/index.spec.tsx +29 -0
- package/src/components/Badge/index.tsx +38 -40
- package/src/components/F0Badge/F0Badge.md +67 -0
- package/src/components/F0Badge/F0Badge.styles.ts +28 -0
- package/src/components/F0Badge/F0Badge.tsx +24 -0
- package/src/components/F0Badge/F0Badge.types.ts +34 -0
- package/src/components/F0Badge/__tests__/F0Badge.spec.tsx +63 -0
- package/src/components/F0Badge/__tests__/__snapshots__/F0Badge.spec.tsx.snap +651 -0
- package/src/components/F0Badge/index.ts +7 -0
- package/src/components/exports.ts +1 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { VariantProps } from "tailwind-variants"
|
|
2
|
+
|
|
3
|
+
import type { IconType } from "../primitives/F0Icon"
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
badgeSizeClasses,
|
|
7
|
+
badgeVariantClasses,
|
|
8
|
+
type badgeVariants,
|
|
9
|
+
} from "./F0Badge.styles"
|
|
10
|
+
|
|
11
|
+
export type F0BadgeVariant = keyof typeof badgeVariantClasses
|
|
12
|
+
|
|
13
|
+
export const F0_BADGE_VARIANTS = Object.keys(
|
|
14
|
+
badgeVariantClasses
|
|
15
|
+
) as ReadonlyArray<F0BadgeVariant>
|
|
16
|
+
|
|
17
|
+
export type F0BadgeSize = keyof typeof badgeSizeClasses
|
|
18
|
+
|
|
19
|
+
export const F0_BADGE_SIZES = Object.keys(
|
|
20
|
+
badgeSizeClasses
|
|
21
|
+
) as ReadonlyArray<F0BadgeSize>
|
|
22
|
+
|
|
23
|
+
export const F0_BADGE_ICON_SIZES = {
|
|
24
|
+
xs: "xs",
|
|
25
|
+
sm: "xs",
|
|
26
|
+
md: "sm",
|
|
27
|
+
lg: "md",
|
|
28
|
+
} as const
|
|
29
|
+
|
|
30
|
+
export interface F0BadgeProps extends VariantProps<typeof badgeVariants> {
|
|
31
|
+
icon: IconType
|
|
32
|
+
variant?: F0BadgeVariant
|
|
33
|
+
size?: F0BadgeSize
|
|
34
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { render } from "@testing-library/react-native"
|
|
2
|
+
import React from "react"
|
|
3
|
+
|
|
4
|
+
import { Add } from "../../../icons/app"
|
|
5
|
+
import { F0Badge } from "../F0Badge"
|
|
6
|
+
|
|
7
|
+
const getClassName = (
|
|
8
|
+
json: ReturnType<ReturnType<typeof render>["toJSON"]>
|
|
9
|
+
) => {
|
|
10
|
+
if (!json || Array.isArray(json)) return ""
|
|
11
|
+
return String(json.props.className ?? "")
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe("F0Badge", () => {
|
|
15
|
+
it("Snapshot - default", () => {
|
|
16
|
+
const { toJSON } = render(<F0Badge icon={Add} />)
|
|
17
|
+
expect(toJSON()).toMatchSnapshot()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it("Snapshot - all variants", () => {
|
|
21
|
+
const variants = [
|
|
22
|
+
"neutral",
|
|
23
|
+
"highlight",
|
|
24
|
+
"positive",
|
|
25
|
+
"critical",
|
|
26
|
+
"warning",
|
|
27
|
+
] as const
|
|
28
|
+
|
|
29
|
+
variants.forEach((variant) => {
|
|
30
|
+
const { toJSON } = render(<F0Badge icon={Add} variant={variant} />)
|
|
31
|
+
expect(toJSON()).toMatchSnapshot()
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it("Snapshot - all sizes", () => {
|
|
36
|
+
const sizes = ["xs", "sm", "md", "lg"] as const
|
|
37
|
+
|
|
38
|
+
sizes.forEach((size) => {
|
|
39
|
+
const { toJSON } = render(<F0Badge icon={Add} size={size} />)
|
|
40
|
+
expect(toJSON()).toMatchSnapshot()
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it("maps xs badge size to xs icon size", () => {
|
|
45
|
+
const { toJSON } = render(<F0Badge icon={Add} size="xs" />)
|
|
46
|
+
expect(getClassName(toJSON())).toContain("stroke-xs")
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it("maps sm badge size to xs icon size", () => {
|
|
50
|
+
const { toJSON } = render(<F0Badge icon={Add} size="sm" />)
|
|
51
|
+
expect(getClassName(toJSON())).toContain("stroke-xs")
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it("maps md badge size to sm icon size", () => {
|
|
55
|
+
const { toJSON } = render(<F0Badge icon={Add} size="md" />)
|
|
56
|
+
expect(getClassName(toJSON())).toContain("stroke-sm")
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it("maps lg badge size to md icon size", () => {
|
|
60
|
+
const { toJSON } = render(<F0Badge icon={Add} size="lg" />)
|
|
61
|
+
expect(getClassName(toJSON())).toContain("stroke-md")
|
|
62
|
+
})
|
|
63
|
+
})
|