@spelyco/react-native 0.0.1 → 1.0.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.
Files changed (69) hide show
  1. package/README.md +218 -0
  2. package/dist/bootUnistyles.d.ts +2 -0
  3. package/dist/bootUnistyles.d.ts.map +1 -0
  4. package/dist/components/ActionIcon/ActionIcon.d.ts +37 -0
  5. package/dist/components/ActionIcon/ActionIcon.d.ts.map +1 -0
  6. package/dist/components/Box/Box.d.ts +20 -0
  7. package/dist/components/Box/Box.d.ts.map +1 -0
  8. package/dist/components/Box/index.d.ts +2 -0
  9. package/dist/components/Box/index.d.ts.map +1 -0
  10. package/dist/components/Button/Button.d.ts +59 -0
  11. package/dist/components/Button/Button.d.ts.map +1 -0
  12. package/dist/components/Button/index.d.ts +3 -0
  13. package/dist/components/Button/index.d.ts.map +1 -0
  14. package/dist/components/Text/Text.d.ts +12 -0
  15. package/dist/components/Text/Text.d.ts.map +1 -0
  16. package/dist/components/Text/index.d.ts +2 -0
  17. package/dist/components/Text/index.d.ts.map +1 -0
  18. package/dist/components/index.d.ts +4 -0
  19. package/dist/components/index.d.ts.map +1 -0
  20. package/dist/hooks/index.d.ts +3 -0
  21. package/dist/hooks/index.d.ts.map +1 -0
  22. package/dist/hooks/useSpelycoColorScheme.d.ts +14 -0
  23. package/dist/hooks/useSpelycoColorScheme.d.ts.map +1 -0
  24. package/dist/index.d.ts +7 -11
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/provider/SpelycoProvider.d.ts +11 -0
  27. package/dist/provider/SpelycoProvider.d.ts.map +1 -0
  28. package/dist/provider/index.d.ts +4 -0
  29. package/dist/provider/index.d.ts.map +1 -0
  30. package/dist/provider/toNavigationTheme.d.ts +20 -0
  31. package/dist/provider/toNavigationTheme.d.ts.map +1 -0
  32. package/dist/provider/toUnistylesTheme.d.ts +24 -0
  33. package/dist/provider/toUnistylesTheme.d.ts.map +1 -0
  34. package/dist/store/colorScheme.d.ts +31 -0
  35. package/dist/store/colorScheme.d.ts.map +1 -0
  36. package/dist/store/index.d.ts +2 -0
  37. package/dist/store/index.d.ts.map +1 -0
  38. package/dist/types.d.ts +11 -0
  39. package/dist/types.d.ts.map +1 -0
  40. package/package.json +43 -16
  41. package/src/bootUnistyles.ts +27 -0
  42. package/src/components/ActionIcon/ActionIcon.test.ts +59 -0
  43. package/src/components/ActionIcon/ActionIcon.tsx +54 -0
  44. package/src/components/Box/Box.test.ts +42 -0
  45. package/src/components/Box/Box.tsx +48 -0
  46. package/src/components/Box/index.ts +1 -0
  47. package/src/components/Button/Button.test.ts +48 -0
  48. package/src/components/Button/Button.tsx +94 -0
  49. package/src/components/Button/index.ts +2 -0
  50. package/src/components/Text/Text.test.ts +59 -0
  51. package/src/components/Text/Text.tsx +61 -0
  52. package/src/components/Text/index.ts +1 -0
  53. package/src/components/index.ts +3 -0
  54. package/src/hooks/index.ts +2 -0
  55. package/src/hooks/useSpelycoColorScheme.ts +33 -0
  56. package/src/index.ts +14 -0
  57. package/src/provider/SpelycoProvider.tsx +102 -0
  58. package/src/provider/index.ts +3 -0
  59. package/src/provider/toNavigationTheme.ts +41 -0
  60. package/src/provider/toUnistylesTheme.ts +58 -0
  61. package/src/store/colorScheme.test.ts +105 -0
  62. package/src/store/colorScheme.ts +63 -0
  63. package/src/store/index.ts +5 -0
  64. package/src/types.ts +10 -0
  65. package/dist/index.d.mts +0 -11
  66. package/dist/index.js +0 -28
  67. package/dist/index.js.map +0 -1
  68. package/dist/index.mjs +0 -26
  69. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,102 @@
1
+ import { ThemeProvider } from "@react-navigation/native";
2
+ import {
3
+ resolveTheme,
4
+ type SpelycoColorScheme,
5
+ SpelycoThemeContext,
6
+ type SpelycoThemeOverride,
7
+ } from "@spelyco/react-lib";
8
+ import { setBackgroundColorAsync } from "expo-system-ui";
9
+ import { type ReactNode, useEffect, useMemo, useState } from "react";
10
+ import { StatusBar } from "react-native";
11
+ import { UnistylesRuntime } from "react-native-unistyles";
12
+ import {
13
+ setupColorSchemeListener,
14
+ teardownColorSchemeListener,
15
+ useColorSchemeStore,
16
+ } from "../store/colorScheme";
17
+ import { toNavigationTheme } from "./toNavigationTheme";
18
+ import { toUnistylesTheme } from "./toUnistylesTheme";
19
+
20
+ export interface SpelycoProviderProps {
21
+ /** Partial theme override merged on top of `DEFAULT_THEME`. */
22
+ theme?: SpelycoThemeOverride;
23
+ /** User-facing default if no persisted preference exists. */
24
+ defaultColorScheme?: SpelycoColorScheme;
25
+ children: ReactNode;
26
+ }
27
+
28
+ export function SpelycoProvider({
29
+ theme: themeOverride,
30
+ defaultColorScheme = "auto",
31
+ children,
32
+ }: SpelycoProviderProps) {
33
+ const resolvedTheme = useMemo(() => resolveTheme(themeOverride), [themeOverride]);
34
+
35
+ const colorScheme = useColorSchemeStore((s) => s.colorScheme);
36
+ const systemColorScheme = useColorSchemeStore((s) => s.systemColorScheme);
37
+ const setColorScheme = useColorSchemeStore((s) => s.setColorScheme);
38
+
39
+ const computedColorScheme = colorScheme === "auto" ? systemColorScheme : colorScheme;
40
+
41
+ // Honour `defaultColorScheme` on first mount when no preference is persisted.
42
+ useState(() => {
43
+ if (colorScheme === "auto" && defaultColorScheme !== "auto") {
44
+ setColorScheme(defaultColorScheme);
45
+ }
46
+ return null;
47
+ });
48
+
49
+ // Push the user-supplied theme override into Unistyles. Boot already ran
50
+ // with DEFAULT_THEME in `bootUnistyles.ts`; here we replace both schemes if
51
+ // an override exists so components see the merged tokens.
52
+ useEffect(() => {
53
+ if (!themeOverride) return;
54
+ const nextLight = toUnistylesTheme(resolvedTheme, "light");
55
+ const nextDark = toUnistylesTheme(resolvedTheme, "dark");
56
+ UnistylesRuntime.updateTheme("light", () => nextLight);
57
+ UnistylesRuntime.updateTheme("dark", () => nextDark);
58
+ }, [themeOverride, resolvedTheme]);
59
+
60
+ useEffect(() => {
61
+ setupColorSchemeListener();
62
+ return () => teardownColorSchemeListener();
63
+ }, []);
64
+
65
+ useEffect(() => {
66
+ UnistylesRuntime.setTheme(computedColorScheme);
67
+ }, [computedColorScheme]);
68
+
69
+ // System bars: status bar + Android root background. Runs every time the
70
+ // computed scheme flips so the OS chrome stays in sync.
71
+ const systemBars = resolvedTheme.systemBars?.[computedColorScheme];
72
+ useEffect(() => {
73
+ if (systemBars?.statusBarBackgroundColor) {
74
+ setBackgroundColorAsync(systemBars.statusBarBackgroundColor).catch(() => {});
75
+ }
76
+ }, [systemBars?.statusBarBackgroundColor]);
77
+
78
+ const statusBarStyle = (() => {
79
+ const style = systemBars?.statusBarStyle ?? "auto";
80
+ if (style === "light") return "light-content" as const;
81
+ if (style === "dark") return "dark-content" as const;
82
+ return "default" as const;
83
+ })();
84
+
85
+ const navigationTheme = useMemo(
86
+ () => toNavigationTheme(resolvedTheme, computedColorScheme),
87
+ [resolvedTheme, computedColorScheme]
88
+ );
89
+
90
+ return (
91
+ <SpelycoThemeContext.Provider value={resolvedTheme}>
92
+ <ThemeProvider value={navigationTheme}>
93
+ <StatusBar
94
+ barStyle={statusBarStyle}
95
+ backgroundColor={systemBars?.statusBarBackgroundColor}
96
+ animated
97
+ />
98
+ {children}
99
+ </ThemeProvider>
100
+ </SpelycoThemeContext.Provider>
101
+ );
102
+ }
@@ -0,0 +1,3 @@
1
+ export { SpelycoProvider, type SpelycoProviderProps } from "./SpelycoProvider";
2
+ export { toNavigationTheme } from "./toNavigationTheme";
3
+ export { type SpelycoUnistylesTheme, toUnistylesTheme } from "./toUnistylesTheme";
@@ -0,0 +1,41 @@
1
+ import { DefaultTheme, type Theme } from "@react-navigation/native";
2
+ import type { SpelycoComputedColorScheme, SpelycoTheme } from "@spelyco/react-lib";
3
+
4
+ /**
5
+ * Adapts a `SpelycoTheme` into a `@react-navigation/native` `Theme` so the
6
+ * drawer chrome, screen background, headers, dividers and route transitions
7
+ * pick up Spelyco's palette automatically.
8
+ *
9
+ * Colour mapping (10-shade tuples):
10
+ * primary → resolved primary hex (from `theme.primary`)
11
+ * background → neutral[0] / neutral[9]
12
+ * card → neutral[1] / neutral[8] (headers, tab/drawer surface)
13
+ * text → neutral[9] / neutral[0]
14
+ * border → neutral[2] / neutral[7]
15
+ * notification→ red[6] / red[4] (badge/alert colour)
16
+ *
17
+ * Fonts pass through React Navigation's defaults — Phase 1 will wire them to
18
+ * `theme.fontFamily`/`fontFamilyMono` once a typography contract lands.
19
+ */
20
+ export function toNavigationTheme(theme: SpelycoTheme, scheme: SpelycoComputedColorScheme): Theme {
21
+ const primaryShade =
22
+ typeof theme.primaryShade === "number" ? theme.primaryShade : theme.primaryShade[scheme];
23
+ const primary = theme.colors[theme.primaryColor]?.[primaryShade] ?? DefaultTheme.colors.primary;
24
+
25
+ const neutral = theme.colors.neutral;
26
+ const red = theme.colors.red;
27
+ const isDark = scheme === "dark";
28
+
29
+ return {
30
+ dark: isDark,
31
+ colors: {
32
+ primary,
33
+ background: neutral?.[isDark ? 9 : 0] ?? DefaultTheme.colors.background,
34
+ card: neutral?.[isDark ? 8 : 1] ?? DefaultTheme.colors.card,
35
+ text: neutral?.[isDark ? 0 : 9] ?? DefaultTheme.colors.text,
36
+ border: neutral?.[isDark ? 7 : 2] ?? DefaultTheme.colors.border,
37
+ notification: red?.[isDark ? 4 : 6] ?? DefaultTheme.colors.notification,
38
+ },
39
+ fonts: DefaultTheme.fonts,
40
+ };
41
+ }
@@ -0,0 +1,58 @@
1
+ import type {
2
+ SpelycoColors,
3
+ SpelycoComputedColorScheme,
4
+ SpelycoFontSizes,
5
+ SpelycoLineHeights,
6
+ SpelycoRadius,
7
+ SpelycoShadows,
8
+ SpelycoSpacing,
9
+ SpelycoTheme,
10
+ } from "@spelyco/react-lib";
11
+
12
+ /**
13
+ * The shape consumed by Unistyles' `StyleSheet.configure({ themes })`. Each
14
+ * scheme gets its own copy with `colorScheme` and a precomputed `primary`
15
+ * color so component styles can do `theme.primary` without recomputing shades.
16
+ */
17
+ export interface SpelycoUnistylesTheme {
18
+ colorScheme: SpelycoComputedColorScheme;
19
+ colors: SpelycoColors;
20
+ spacing: SpelycoSpacing;
21
+ radius: SpelycoRadius;
22
+ fontSizes: SpelycoFontSizes;
23
+ lineHeights: SpelycoLineHeights;
24
+ shadows: SpelycoShadows;
25
+ primaryColor: string;
26
+ /** Shade index resolved for this color scheme. */
27
+ primaryShade: number;
28
+ /** `colors[primaryColor][primaryShade]` — the actual hex used by components. */
29
+ primary: string;
30
+ fontFamily: string;
31
+ fontFamilyMono: string;
32
+ }
33
+
34
+ export function toUnistylesTheme(
35
+ theme: SpelycoTheme,
36
+ scheme: SpelycoComputedColorScheme
37
+ ): SpelycoUnistylesTheme {
38
+ const primaryShade =
39
+ typeof theme.primaryShade === "number" ? theme.primaryShade : theme.primaryShade[scheme];
40
+
41
+ const primaryTuple = theme.colors[theme.primaryColor];
42
+ const primary = primaryTuple?.[primaryShade] ?? primaryTuple?.[6] ?? "#000000";
43
+
44
+ return {
45
+ colorScheme: scheme,
46
+ colors: theme.colors,
47
+ spacing: theme.spacing,
48
+ radius: theme.radius,
49
+ fontSizes: theme.fontSizes,
50
+ lineHeights: theme.lineHeights,
51
+ shadows: theme.shadows,
52
+ primaryColor: theme.primaryColor,
53
+ primaryShade,
54
+ primary,
55
+ fontFamily: theme.fontFamily,
56
+ fontFamilyMono: theme.fontFamilyMono,
57
+ };
58
+ }
@@ -0,0 +1,105 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+
3
+ const appearanceListeners: Array<
4
+ (event: { colorScheme: "light" | "dark" | null }) => void
5
+ > = [];
6
+
7
+ vi.mock("react-native", () => ({
8
+ Appearance: {
9
+ getColorScheme: () => "light",
10
+ addChangeListener: (
11
+ cb: (event: { colorScheme: "light" | "dark" | null }) => void,
12
+ ) => {
13
+ appearanceListeners.push(cb);
14
+ return {
15
+ remove: () => {
16
+ const i = appearanceListeners.indexOf(cb);
17
+ if (i >= 0) appearanceListeners.splice(i, 1);
18
+ },
19
+ };
20
+ },
21
+ },
22
+ }));
23
+
24
+ vi.mock("@react-native-async-storage/async-storage", () => {
25
+ const store = new Map<string, string>();
26
+ return {
27
+ default: {
28
+ getItem: vi.fn(async (key: string) => store.get(key) ?? null),
29
+ setItem: vi.fn(async (key: string, value: string) => {
30
+ store.set(key, value);
31
+ }),
32
+ removeItem: vi.fn(async (key: string) => {
33
+ store.delete(key);
34
+ }),
35
+ },
36
+ };
37
+ });
38
+
39
+ const {
40
+ useColorSchemeStore,
41
+ setupColorSchemeListener,
42
+ teardownColorSchemeListener,
43
+ } = await import("./colorScheme");
44
+
45
+ const resetStore = () => {
46
+ useColorSchemeStore.setState({
47
+ colorScheme: "auto",
48
+ systemColorScheme: "light",
49
+ });
50
+ teardownColorSchemeListener();
51
+ };
52
+
53
+ describe("colorScheme store", () => {
54
+ beforeEach(() => {
55
+ resetStore();
56
+ });
57
+
58
+ it("starts with 'auto' and resolves system scheme to 'light' by default", () => {
59
+ const state = useColorSchemeStore.getState();
60
+ expect(state.colorScheme).toBe("auto");
61
+ expect(state.systemColorScheme).toBe("light");
62
+ });
63
+
64
+ it("setColorScheme updates the user preference", () => {
65
+ useColorSchemeStore.getState().setColorScheme("dark");
66
+ expect(useColorSchemeStore.getState().colorScheme).toBe("dark");
67
+ });
68
+
69
+ it("toggleColorScheme flips dark <-> light explicitly", () => {
70
+ useColorSchemeStore.getState().setColorScheme("dark");
71
+ useColorSchemeStore.getState().toggleColorScheme();
72
+ expect(useColorSchemeStore.getState().colorScheme).toBe("light");
73
+ useColorSchemeStore.getState().toggleColorScheme();
74
+ expect(useColorSchemeStore.getState().colorScheme).toBe("dark");
75
+ });
76
+
77
+ it("toggleColorScheme from 'auto' uses systemColorScheme as the basis", () => {
78
+ useColorSchemeStore.setState({
79
+ colorScheme: "auto",
80
+ systemColorScheme: "light",
81
+ });
82
+ useColorSchemeStore.getState().toggleColorScheme();
83
+ expect(useColorSchemeStore.getState().colorScheme).toBe("dark");
84
+ });
85
+
86
+ it("clearColorScheme resets back to 'auto'", () => {
87
+ useColorSchemeStore.getState().setColorScheme("dark");
88
+ useColorSchemeStore.getState().clearColorScheme();
89
+ expect(useColorSchemeStore.getState().colorScheme).toBe("auto");
90
+ });
91
+
92
+ it("setupColorSchemeListener is idempotent", () => {
93
+ setupColorSchemeListener();
94
+ setupColorSchemeListener();
95
+ expect(appearanceListeners.length).toBe(1);
96
+ });
97
+
98
+ it("system change events update systemColorScheme", () => {
99
+ setupColorSchemeListener();
100
+ appearanceListeners[0]?.({ colorScheme: "dark" });
101
+ expect(useColorSchemeStore.getState().systemColorScheme).toBe("dark");
102
+ appearanceListeners[0]?.({ colorScheme: null });
103
+ expect(useColorSchemeStore.getState().systemColorScheme).toBe("light");
104
+ });
105
+ });
@@ -0,0 +1,63 @@
1
+ import AsyncStorage from "@react-native-async-storage/async-storage";
2
+ import type { SpelycoColorScheme, SpelycoComputedColorScheme } from "@spelyco/react-lib";
3
+ import { Appearance } from "react-native";
4
+ import { create } from "zustand";
5
+ import { createJSONStorage, persist } from "zustand/middleware";
6
+
7
+ interface ColorSchemeState {
8
+ /** User preference: 'light' | 'dark' | 'auto'. Persisted. */
9
+ colorScheme: SpelycoColorScheme;
10
+ /** Current OS color scheme. Tracked via Appearance, not persisted. */
11
+ systemColorScheme: SpelycoComputedColorScheme;
12
+ setColorScheme: (scheme: SpelycoColorScheme) => void;
13
+ toggleColorScheme: () => void;
14
+ clearColorScheme: () => void;
15
+ }
16
+
17
+ const STORAGE_KEY = "@spelyco/color-scheme";
18
+
19
+ const resolveSystemScheme = (): SpelycoComputedColorScheme => {
20
+ const scheme = Appearance.getColorScheme();
21
+ return scheme === "dark" ? "dark" : "light";
22
+ };
23
+
24
+ export const useColorSchemeStore = create<ColorSchemeState>()(
25
+ persist(
26
+ (set, get) => ({
27
+ colorScheme: "auto",
28
+ systemColorScheme: resolveSystemScheme(),
29
+ setColorScheme: (scheme) => set({ colorScheme: scheme }),
30
+ toggleColorScheme: () => {
31
+ const { colorScheme, systemColorScheme } = get();
32
+ const current = colorScheme === "auto" ? systemColorScheme : colorScheme;
33
+ set({ colorScheme: current === "light" ? "dark" : "light" });
34
+ },
35
+ clearColorScheme: () => set({ colorScheme: "auto" }),
36
+ }),
37
+ {
38
+ name: STORAGE_KEY,
39
+ storage: createJSONStorage(() => AsyncStorage),
40
+ partialize: (state) => ({ colorScheme: state.colorScheme }),
41
+ }
42
+ )
43
+ );
44
+
45
+ let listenerSubscription: { remove: () => void } | null = null;
46
+
47
+ /**
48
+ * Subscribes the store to OS color scheme changes. Idempotent — calling more
49
+ * than once is a no-op. Should be invoked once from `SpelycoProvider`.
50
+ */
51
+ export const setupColorSchemeListener = () => {
52
+ if (listenerSubscription) return;
53
+ listenerSubscription = Appearance.addChangeListener(({ colorScheme }) => {
54
+ useColorSchemeStore.setState({
55
+ systemColorScheme: colorScheme === "dark" ? "dark" : "light",
56
+ });
57
+ });
58
+ };
59
+
60
+ export const teardownColorSchemeListener = () => {
61
+ listenerSubscription?.remove();
62
+ listenerSubscription = null;
63
+ };
@@ -0,0 +1,5 @@
1
+ export {
2
+ setupColorSchemeListener,
3
+ teardownColorSchemeListener,
4
+ useColorSchemeStore,
5
+ } from "./colorScheme";
package/src/types.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { SpelycoBreakpoints } from "@spelyco/react-lib";
2
+ import type { SpelycoUnistylesTheme } from "./provider/toUnistylesTheme";
3
+
4
+ declare module "react-native-unistyles" {
5
+ export interface UnistylesThemes {
6
+ light: SpelycoUnistylesTheme;
7
+ dark: SpelycoUnistylesTheme;
8
+ }
9
+ export interface UnistylesBreakpoints extends SpelycoBreakpoints {}
10
+ }
package/dist/index.d.mts DELETED
@@ -1,11 +0,0 @@
1
- import * as react from 'react';
2
- import { PressableProps } from 'react-native';
3
-
4
- interface ButtonProps extends PressableProps {
5
- variant?: "primary" | "secondary" | "ghost";
6
- size?: "sm" | "md" | "lg";
7
- label: string;
8
- }
9
- declare function Button({ variant, size, label, style, ...props }: ButtonProps): react.JSX.Element;
10
-
11
- export { Button };
package/dist/index.js DELETED
@@ -1,28 +0,0 @@
1
- 'use strict';
2
-
3
- var reactNative = require('react-native');
4
-
5
- // src/components/Button/Button.tsx
6
- function Button({ variant = "primary", size = "md", label, style, ...props }) {
7
- return /* @__PURE__ */ React.createElement(reactNative.Pressable, { style: [styles.base, styles[variant], styles[size], style], ...props }, /* @__PURE__ */ React.createElement(reactNative.Text, { style: styles.label }, label));
8
- }
9
- var styles = reactNative.StyleSheet.create({
10
- base: {
11
- alignItems: "center",
12
- justifyContent: "center",
13
- borderRadius: 8
14
- },
15
- label: {
16
- fontWeight: "600"
17
- },
18
- primary: { backgroundColor: "#6366f1" },
19
- secondary: { backgroundColor: "#e5e7eb" },
20
- ghost: { backgroundColor: "transparent" },
21
- sm: { paddingHorizontal: 12, paddingVertical: 6 },
22
- md: { paddingHorizontal: 16, paddingVertical: 10 },
23
- lg: { paddingHorizontal: 24, paddingVertical: 14 }
24
- });
25
-
26
- exports.Button = Button;
27
- //# sourceMappingURL=index.js.map
28
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/Button/Button.tsx"],"names":["Pressable","Text","StyleSheet"],"mappings":";;;;;AASO,SAAS,MAAA,CAAO,EAAE,OAAA,GAAU,SAAA,EAAW,IAAA,GAAO,MAAM,KAAA,EAAO,KAAA,EAAO,GAAG,KAAA,EAAM,EAAgB;AAChG,EAAA,uBACE,KAAA,CAAA,aAAA,CAACA,yBAAU,KAAA,EAAO,CAAC,OAAO,IAAA,EAAM,MAAA,CAAO,OAAO,CAAA,EAAG,MAAA,CAAO,IAAI,GAAG,KAAkB,CAAA,EAAI,GAAG,KAAA,EAAA,kBACtF,KAAA,CAAA,aAAA,CAACC,oBAAK,KAAA,EAAO,MAAA,CAAO,KAAA,EAAA,EAAQ,KAAM,CACpC,CAAA;AAEJ;AAEA,IAAM,MAAA,GAASC,uBAAW,MAAA,CAAO;AAAA,EAC/B,IAAA,EAAM;AAAA,IACJ,UAAA,EAAY,QAAA;AAAA,IACZ,cAAA,EAAgB,QAAA;AAAA,IAChB,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,KAAA,EAAO;AAAA,IACL,UAAA,EAAY;AAAA,GACd;AAAA,EACA,OAAA,EAAS,EAAE,eAAA,EAAiB,SAAA,EAAU;AAAA,EACtC,SAAA,EAAW,EAAE,eAAA,EAAiB,SAAA,EAAU;AAAA,EACxC,KAAA,EAAO,EAAE,eAAA,EAAiB,aAAA,EAAc;AAAA,EACxC,EAAA,EAAI,EAAE,iBAAA,EAAmB,EAAA,EAAI,iBAAiB,CAAA,EAAE;AAAA,EAChD,EAAA,EAAI,EAAE,iBAAA,EAAmB,EAAA,EAAI,iBAAiB,EAAA,EAAG;AAAA,EACjD,EAAA,EAAI,EAAE,iBAAA,EAAmB,EAAA,EAAI,iBAAiB,EAAA;AAChD,CAAC,CAAA","file":"index.js","sourcesContent":["import type { PressableProps, TextStyle, ViewStyle } from \"react-native\";\nimport { Pressable, StyleSheet, Text } from \"react-native\";\n\nexport interface ButtonProps extends PressableProps {\n variant?: \"primary\" | \"secondary\" | \"ghost\";\n size?: \"sm\" | \"md\" | \"lg\";\n label: string;\n}\n\nexport function Button({ variant = \"primary\", size = \"md\", label, style, ...props }: ButtonProps) {\n return (\n <Pressable style={[styles.base, styles[variant], styles[size], style as ViewStyle]} {...props}>\n <Text style={styles.label}>{label}</Text>\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n base: {\n alignItems: \"center\",\n justifyContent: \"center\",\n borderRadius: 8,\n },\n label: {\n fontWeight: \"600\",\n } as TextStyle,\n primary: { backgroundColor: \"#6366f1\" } as ViewStyle,\n secondary: { backgroundColor: \"#e5e7eb\" } as ViewStyle,\n ghost: { backgroundColor: \"transparent\" } as ViewStyle,\n sm: { paddingHorizontal: 12, paddingVertical: 6 } as ViewStyle,\n md: { paddingHorizontal: 16, paddingVertical: 10 } as ViewStyle,\n lg: { paddingHorizontal: 24, paddingVertical: 14 } as ViewStyle,\n});\n"]}
package/dist/index.mjs DELETED
@@ -1,26 +0,0 @@
1
- import { StyleSheet, Pressable, Text } from 'react-native';
2
-
3
- // src/components/Button/Button.tsx
4
- function Button({ variant = "primary", size = "md", label, style, ...props }) {
5
- return /* @__PURE__ */ React.createElement(Pressable, { style: [styles.base, styles[variant], styles[size], style], ...props }, /* @__PURE__ */ React.createElement(Text, { style: styles.label }, label));
6
- }
7
- var styles = StyleSheet.create({
8
- base: {
9
- alignItems: "center",
10
- justifyContent: "center",
11
- borderRadius: 8
12
- },
13
- label: {
14
- fontWeight: "600"
15
- },
16
- primary: { backgroundColor: "#6366f1" },
17
- secondary: { backgroundColor: "#e5e7eb" },
18
- ghost: { backgroundColor: "transparent" },
19
- sm: { paddingHorizontal: 12, paddingVertical: 6 },
20
- md: { paddingHorizontal: 16, paddingVertical: 10 },
21
- lg: { paddingHorizontal: 24, paddingVertical: 14 }
22
- });
23
-
24
- export { Button };
25
- //# sourceMappingURL=index.mjs.map
26
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/Button/Button.tsx"],"names":[],"mappings":";;;AASO,SAAS,MAAA,CAAO,EAAE,OAAA,GAAU,SAAA,EAAW,IAAA,GAAO,MAAM,KAAA,EAAO,KAAA,EAAO,GAAG,KAAA,EAAM,EAAgB;AAChG,EAAA,uBACE,KAAA,CAAA,aAAA,CAAC,aAAU,KAAA,EAAO,CAAC,OAAO,IAAA,EAAM,MAAA,CAAO,OAAO,CAAA,EAAG,MAAA,CAAO,IAAI,GAAG,KAAkB,CAAA,EAAI,GAAG,KAAA,EAAA,kBACtF,KAAA,CAAA,aAAA,CAAC,QAAK,KAAA,EAAO,MAAA,CAAO,KAAA,EAAA,EAAQ,KAAM,CACpC,CAAA;AAEJ;AAEA,IAAM,MAAA,GAAS,WAAW,MAAA,CAAO;AAAA,EAC/B,IAAA,EAAM;AAAA,IACJ,UAAA,EAAY,QAAA;AAAA,IACZ,cAAA,EAAgB,QAAA;AAAA,IAChB,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,KAAA,EAAO;AAAA,IACL,UAAA,EAAY;AAAA,GACd;AAAA,EACA,OAAA,EAAS,EAAE,eAAA,EAAiB,SAAA,EAAU;AAAA,EACtC,SAAA,EAAW,EAAE,eAAA,EAAiB,SAAA,EAAU;AAAA,EACxC,KAAA,EAAO,EAAE,eAAA,EAAiB,aAAA,EAAc;AAAA,EACxC,EAAA,EAAI,EAAE,iBAAA,EAAmB,EAAA,EAAI,iBAAiB,CAAA,EAAE;AAAA,EAChD,EAAA,EAAI,EAAE,iBAAA,EAAmB,EAAA,EAAI,iBAAiB,EAAA,EAAG;AAAA,EACjD,EAAA,EAAI,EAAE,iBAAA,EAAmB,EAAA,EAAI,iBAAiB,EAAA;AAChD,CAAC,CAAA","file":"index.mjs","sourcesContent":["import type { PressableProps, TextStyle, ViewStyle } from \"react-native\";\nimport { Pressable, StyleSheet, Text } from \"react-native\";\n\nexport interface ButtonProps extends PressableProps {\n variant?: \"primary\" | \"secondary\" | \"ghost\";\n size?: \"sm\" | \"md\" | \"lg\";\n label: string;\n}\n\nexport function Button({ variant = \"primary\", size = \"md\", label, style, ...props }: ButtonProps) {\n return (\n <Pressable style={[styles.base, styles[variant], styles[size], style as ViewStyle]} {...props}>\n <Text style={styles.label}>{label}</Text>\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n base: {\n alignItems: \"center\",\n justifyContent: \"center\",\n borderRadius: 8,\n },\n label: {\n fontWeight: \"600\",\n } as TextStyle,\n primary: { backgroundColor: \"#6366f1\" } as ViewStyle,\n secondary: { backgroundColor: \"#e5e7eb\" } as ViewStyle,\n ghost: { backgroundColor: \"transparent\" } as ViewStyle,\n sm: { paddingHorizontal: 12, paddingVertical: 6 } as ViewStyle,\n md: { paddingHorizontal: 16, paddingVertical: 10 } as ViewStyle,\n lg: { paddingHorizontal: 24, paddingVertical: 14 } as ViewStyle,\n});\n"]}