@metamask/design-system-twrnc-preset 0.1.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 (76) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/LICENSE +20 -0
  3. package/README.md +31 -0
  4. package/dist/Theme.types.cjs +12 -0
  5. package/dist/Theme.types.cjs.map +1 -0
  6. package/dist/Theme.types.d.cts +8 -0
  7. package/dist/Theme.types.d.cts.map +1 -0
  8. package/dist/Theme.types.d.mts +8 -0
  9. package/dist/Theme.types.d.mts.map +1 -0
  10. package/dist/Theme.types.mjs +9 -0
  11. package/dist/Theme.types.mjs.map +1 -0
  12. package/dist/ThemeContext.cjs +13 -0
  13. package/dist/ThemeContext.cjs.map +1 -0
  14. package/dist/ThemeContext.d.cts +15 -0
  15. package/dist/ThemeContext.d.cts.map +1 -0
  16. package/dist/ThemeContext.d.mts +15 -0
  17. package/dist/ThemeContext.d.mts.map +1 -0
  18. package/dist/ThemeContext.mjs +10 -0
  19. package/dist/ThemeContext.mjs.map +1 -0
  20. package/dist/ThemeProvider.cjs +53 -0
  21. package/dist/ThemeProvider.cjs.map +1 -0
  22. package/dist/ThemeProvider.d.cts +15 -0
  23. package/dist/ThemeProvider.d.cts.map +1 -0
  24. package/dist/ThemeProvider.d.mts +15 -0
  25. package/dist/ThemeProvider.d.mts.map +1 -0
  26. package/dist/ThemeProvider.mjs +33 -0
  27. package/dist/ThemeProvider.mjs.map +1 -0
  28. package/dist/colors.cjs +67 -0
  29. package/dist/colors.cjs.map +1 -0
  30. package/dist/colors.d.cts +3 -0
  31. package/dist/colors.d.cts.map +1 -0
  32. package/dist/colors.d.mts +3 -0
  33. package/dist/colors.d.mts.map +1 -0
  34. package/dist/colors.mjs +64 -0
  35. package/dist/colors.mjs.map +1 -0
  36. package/dist/hooks.cjs +47 -0
  37. package/dist/hooks.cjs.map +1 -0
  38. package/dist/hooks.d.cts +35 -0
  39. package/dist/hooks.d.cts.map +1 -0
  40. package/dist/hooks.d.mts +35 -0
  41. package/dist/hooks.d.mts.map +1 -0
  42. package/dist/hooks.mjs +42 -0
  43. package/dist/hooks.mjs.map +1 -0
  44. package/dist/index.cjs +13 -0
  45. package/dist/index.cjs.map +1 -0
  46. package/dist/index.d.cts +4 -0
  47. package/dist/index.d.cts.map +1 -0
  48. package/dist/index.d.mts +4 -0
  49. package/dist/index.d.mts.map +1 -0
  50. package/dist/index.mjs +6 -0
  51. package/dist/index.mjs.map +1 -0
  52. package/dist/tailwind.config.cjs +97 -0
  53. package/dist/tailwind.config.cjs.map +1 -0
  54. package/dist/tailwind.config.d.cts +12 -0
  55. package/dist/tailwind.config.d.cts.map +1 -0
  56. package/dist/tailwind.config.d.mts +12 -0
  57. package/dist/tailwind.config.d.mts.map +1 -0
  58. package/dist/tailwind.config.mjs +93 -0
  59. package/dist/tailwind.config.mjs.map +1 -0
  60. package/dist/typography.cjs +115 -0
  61. package/dist/typography.cjs.map +1 -0
  62. package/dist/typography.d.cts +3 -0
  63. package/dist/typography.d.cts.map +1 -0
  64. package/dist/typography.d.mts +3 -0
  65. package/dist/typography.d.mts.map +1 -0
  66. package/dist/typography.mjs +112 -0
  67. package/dist/typography.mjs.map +1 -0
  68. package/dist/typography.types.cjs +3 -0
  69. package/dist/typography.types.cjs.map +1 -0
  70. package/dist/typography.types.d.cts +70 -0
  71. package/dist/typography.types.d.cts.map +1 -0
  72. package/dist/typography.types.d.mts +70 -0
  73. package/dist/typography.types.d.mts.map +1 -0
  74. package/dist/typography.types.mjs +2 -0
  75. package/dist/typography.types.mjs.map +1 -0
  76. package/package.json +83 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0]
11
+
12
+ ### Added
13
+
14
+ - **Initial release** - MetaMask Design System TWRNC preset
15
+ - **ThemeProvider**: Context provider for theme management
16
+ - **Hooks**: useTailwind, useTheme
17
+ - **Theme Types**: TypeScript definitions for theme configuration
18
+ - MetaMask design token integration for React Native
19
+ - TWRNC preset configuration with MetaMask styling utilities
20
+
21
+ [Unreleased]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-twrnc-preset@0.1.0...HEAD
22
+ [0.1.0]: https://github.com/MetaMask/metamask-design-system/releases/tag/@metamask/design-system-twrnc-preset@0.1.0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 MetaMask
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # `@metamask/design-system-twrnc-preset`
2
+
3
+ Design System twrnc preset
4
+
5
+ ## Installation
6
+
7
+ First, install the package:
8
+
9
+ `yarn add @metamask/design-system-twrnc-preset`
10
+
11
+ or
12
+
13
+ `npm install @metamask/design-system-twrnc-preset`
14
+
15
+ ### Peer Dependencies
16
+
17
+ This package requires the following peer dependencies to be installed in your project:
18
+
19
+ ```bash
20
+ yarn add react@^18.2.0 react-native@0.72.15 twrnc@^4.5.1
21
+ ```
22
+
23
+ or
24
+
25
+ ```bash
26
+ npm install react@^18.2.0 react-native@0.72.15 twrnc@^4.5.1
27
+ ```
28
+
29
+ ## Contributing
30
+
31
+ This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/metamask-design-system#readme).
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Theme = void 0;
4
+ /**
5
+ * Theme enum for light and dark mode support
6
+ */
7
+ var Theme;
8
+ (function (Theme) {
9
+ Theme["Light"] = "light";
10
+ Theme["Dark"] = "dark";
11
+ })(Theme || (exports.Theme = Theme = {}));
12
+ //# sourceMappingURL=Theme.types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Theme.types.cjs","sourceRoot":"","sources":["../src/Theme.types.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,KAGX;AAHD,WAAY,KAAK;IACf,wBAAe,CAAA;IACf,sBAAa,CAAA;AACf,CAAC,EAHW,KAAK,qBAAL,KAAK,QAGhB","sourcesContent":["/**\n * Theme enum for light and dark mode support\n */\nexport enum Theme {\n Light = 'light',\n Dark = 'dark',\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Theme enum for light and dark mode support
3
+ */
4
+ export declare enum Theme {
5
+ Light = "light",
6
+ Dark = "dark"
7
+ }
8
+ //# sourceMappingURL=Theme.types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Theme.types.d.cts","sourceRoot":"","sources":["../src/Theme.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,KAAK;IACf,KAAK,UAAU;IACf,IAAI,SAAS;CACd"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Theme enum for light and dark mode support
3
+ */
4
+ export declare enum Theme {
5
+ Light = "light",
6
+ Dark = "dark"
7
+ }
8
+ //# sourceMappingURL=Theme.types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Theme.types.d.mts","sourceRoot":"","sources":["../src/Theme.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,KAAK;IACf,KAAK,UAAU;IACf,IAAI,SAAS;CACd"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Theme enum for light and dark mode support
3
+ */
4
+ export var Theme;
5
+ (function (Theme) {
6
+ Theme["Light"] = "light";
7
+ Theme["Dark"] = "dark";
8
+ })(Theme || (Theme = {}));
9
+ //# sourceMappingURL=Theme.types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Theme.types.mjs","sourceRoot":"","sources":["../src/Theme.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,KAGX;AAHD,WAAY,KAAK;IACf,wBAAe,CAAA;IACf,sBAAa,CAAA;AACf,CAAC,EAHW,KAAK,KAAL,KAAK,QAGhB","sourcesContent":["/**\n * Theme enum for light and dark mode support\n */\nexport enum Theme {\n Light = 'light',\n Dark = 'dark',\n}\n"]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThemeContext = exports.defaultThemeContextValue = void 0;
4
+ const react_1 = require("react");
5
+ const twrnc_1 = require("twrnc");
6
+ const tailwind_config_1 = require("./tailwind.config.cjs");
7
+ const Theme_types_1 = require("./Theme.types.cjs");
8
+ exports.defaultThemeContextValue = {
9
+ tw: (0, twrnc_1.create)((0, tailwind_config_1.generateTailwindConfig)(Theme_types_1.Theme.Light)),
10
+ theme: Theme_types_1.Theme.Light,
11
+ };
12
+ exports.ThemeContext = (0, react_1.createContext)(exports.defaultThemeContextValue);
13
+ //# sourceMappingURL=ThemeContext.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeContext.cjs","sourceRoot":"","sources":["../src/ThemeContext.ts"],"names":[],"mappings":";;;AAAA,iCAAsC;AACtC,iCAA+B;AAE/B,2DAA2D;AAC3D,mDAAsC;AAUzB,QAAA,wBAAwB,GAAG;IACtC,EAAE,EAAE,IAAA,cAAM,EAAC,IAAA,wCAAsB,EAAC,mBAAK,CAAC,KAAK,CAAC,CAAC;IAC/C,KAAK,EAAE,mBAAK,CAAC,KAAK;CACnB,CAAC;AAEW,QAAA,YAAY,GAAG,IAAA,qBAAa,EACvC,gCAAwB,CACzB,CAAC","sourcesContent":["import { createContext } from 'react';\nimport { create } from 'twrnc';\n\nimport { generateTailwindConfig } from './tailwind.config';\nimport { Theme } from './Theme.types';\n\n/**\n * Theme context properties\n */\nexport type ThemeContextProps = {\n tw: ReturnType<typeof create>;\n theme: Theme;\n};\n\nexport const defaultThemeContextValue = {\n tw: create(generateTailwindConfig(Theme.Light)),\n theme: Theme.Light,\n};\n\nexport const ThemeContext = createContext<ThemeContextProps>(\n defaultThemeContextValue,\n);\n"]}
@@ -0,0 +1,15 @@
1
+ import { create } from "twrnc";
2
+ import { Theme } from "./Theme.types.cjs";
3
+ /**
4
+ * Theme context properties
5
+ */
6
+ export type ThemeContextProps = {
7
+ tw: ReturnType<typeof create>;
8
+ theme: Theme;
9
+ };
10
+ export declare const defaultThemeContextValue: {
11
+ tw: import("twrnc").TailwindFn;
12
+ theme: Theme;
13
+ };
14
+ export declare const ThemeContext: import("react").Context<ThemeContextProps>;
15
+ //# sourceMappingURL=ThemeContext.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeContext.d.cts","sourceRoot":"","sources":["../src/ThemeContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,cAAc;AAG/B,OAAO,EAAE,KAAK,EAAE,0BAAsB;AAEtC;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAGpC,CAAC;AAEF,eAAO,MAAM,YAAY,4CAExB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { create } from "twrnc";
2
+ import { Theme } from "./Theme.types.mjs";
3
+ /**
4
+ * Theme context properties
5
+ */
6
+ export type ThemeContextProps = {
7
+ tw: ReturnType<typeof create>;
8
+ theme: Theme;
9
+ };
10
+ export declare const defaultThemeContextValue: {
11
+ tw: import("twrnc").TailwindFn;
12
+ theme: Theme;
13
+ };
14
+ export declare const ThemeContext: import("react").Context<ThemeContextProps>;
15
+ //# sourceMappingURL=ThemeContext.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeContext.d.mts","sourceRoot":"","sources":["../src/ThemeContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,cAAc;AAG/B,OAAO,EAAE,KAAK,EAAE,0BAAsB;AAEtC;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAGpC,CAAC;AAEF,eAAO,MAAM,YAAY,4CAExB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { createContext } from "react";
2
+ import { create } from "twrnc";
3
+ import { generateTailwindConfig } from "./tailwind.config.mjs";
4
+ import { Theme } from "./Theme.types.mjs";
5
+ export const defaultThemeContextValue = {
6
+ tw: create(generateTailwindConfig(Theme.Light)),
7
+ theme: Theme.Light,
8
+ };
9
+ export const ThemeContext = createContext(defaultThemeContextValue);
10
+ //# sourceMappingURL=ThemeContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeContext.mjs","sourceRoot":"","sources":["../src/ThemeContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc;AACtC,OAAO,EAAE,MAAM,EAAE,cAAc;AAE/B,OAAO,EAAE,sBAAsB,EAAE,8BAA0B;AAC3D,OAAO,EAAE,KAAK,EAAE,0BAAsB;AAUtC,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,EAAE,EAAE,MAAM,CAAC,sBAAsB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/C,KAAK,EAAE,KAAK,CAAC,KAAK;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CACvC,wBAAwB,CACzB,CAAC","sourcesContent":["import { createContext } from 'react';\nimport { create } from 'twrnc';\n\nimport { generateTailwindConfig } from './tailwind.config';\nimport { Theme } from './Theme.types';\n\n/**\n * Theme context properties\n */\nexport type ThemeContextProps = {\n tw: ReturnType<typeof create>;\n theme: Theme;\n};\n\nexport const defaultThemeContextValue = {\n tw: create(generateTailwindConfig(Theme.Light)),\n theme: Theme.Light,\n};\n\nexport const ThemeContext = createContext<ThemeContextProps>(\n defaultThemeContextValue,\n);\n"]}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ThemeProvider = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const twrnc_1 = require("twrnc");
29
+ const tailwind_config_1 = require("./tailwind.config.cjs");
30
+ const ThemeContext_1 = require("./ThemeContext.cjs");
31
+ /**
32
+ * Theme provider component that wraps child components with theme context
33
+ *
34
+ * @param options - Component props
35
+ * @param options.children - Child components to render
36
+ * @param options.theme - Theme to apply (light or dark)
37
+ * @returns React component that provides theme context to children
38
+ */
39
+ const ThemeProvider = ({ children, theme, }) => {
40
+ const contextValue = (0, react_1.useMemo)(() => {
41
+ const tailwindConfig = (0, tailwind_config_1.generateTailwindConfig)(theme);
42
+ const tw = (0, twrnc_1.create)(tailwindConfig);
43
+ return {
44
+ tw,
45
+ theme,
46
+ };
47
+ }, [theme]);
48
+ return (<ThemeContext_1.ThemeContext.Provider value={contextValue}>
49
+ {children}
50
+ </ThemeContext_1.ThemeContext.Provider>);
51
+ };
52
+ exports.ThemeProvider = ThemeProvider;
53
+ //# sourceMappingURL=ThemeProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeProvider.cjs","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAuC;AACvC,iCAA+B;AAE/B,2DAA2D;AAG3D,qDAA8C;AAE9C;;;;;;;GAOG;AACI,MAAM,aAAa,GAAG,CAAC,EAC5B,QAAQ,EACR,KAAK,GAIN,EAAE,EAAE;IACH,MAAM,YAAY,GAAsB,IAAA,eAAO,EAAC,GAAG,EAAE;QACnD,MAAM,cAAc,GAAG,IAAA,wCAAsB,EAAC,KAAK,CAAC,CAAC;QACrD,MAAM,EAAE,GAAG,IAAA,cAAM,EAAC,cAAc,CAAC,CAAC;QAClC,OAAO;YACL,EAAE;YACF,KAAK;SACN,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CACL,CAAC,2BAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CACzC;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,2BAAY,CAAC,QAAQ,CAAC,CACzB,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,aAAa,iBAqBxB","sourcesContent":["import React, { useMemo } from 'react';\nimport { create } from 'twrnc';\n\nimport { generateTailwindConfig } from './tailwind.config';\nimport type { Theme } from './Theme.types';\nimport type { ThemeContextProps } from './ThemeContext';\nimport { ThemeContext } from './ThemeContext';\n\n/**\n * Theme provider component that wraps child components with theme context\n *\n * @param options - Component props\n * @param options.children - Child components to render\n * @param options.theme - Theme to apply (light or dark)\n * @returns React component that provides theme context to children\n */\nexport const ThemeProvider = ({\n children,\n theme,\n}: {\n children: React.ReactNode;\n theme: Theme;\n}) => {\n const contextValue: ThemeContextProps = useMemo(() => {\n const tailwindConfig = generateTailwindConfig(theme);\n const tw = create(tailwindConfig);\n return {\n tw,\n theme,\n };\n }, [theme]);\n\n return (\n <ThemeContext.Provider value={contextValue}>\n {children}\n </ThemeContext.Provider>\n );\n};\n"]}
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import type { Theme } from "./Theme.types.cjs";
3
+ /**
4
+ * Theme provider component that wraps child components with theme context
5
+ *
6
+ * @param options - Component props
7
+ * @param options.children - Child components to render
8
+ * @param options.theme - Theme to apply (light or dark)
9
+ * @returns React component that provides theme context to children
10
+ */
11
+ export declare const ThemeProvider: ({ children, theme, }: {
12
+ children: React.ReactNode;
13
+ theme: Theme;
14
+ }) => React.JSX.Element;
15
+ //# sourceMappingURL=ThemeProvider.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeProvider.d.cts","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,cAAc;AAIvC,OAAO,KAAK,EAAE,KAAK,EAAE,0BAAsB;AAI3C;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;cAId,MAAM,SAAS;WAClB,KAAK;uBAgBb,CAAC"}
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import type { Theme } from "./Theme.types.mjs";
3
+ /**
4
+ * Theme provider component that wraps child components with theme context
5
+ *
6
+ * @param options - Component props
7
+ * @param options.children - Child components to render
8
+ * @param options.theme - Theme to apply (light or dark)
9
+ * @returns React component that provides theme context to children
10
+ */
11
+ export declare const ThemeProvider: ({ children, theme, }: {
12
+ children: React.ReactNode;
13
+ theme: Theme;
14
+ }) => React.JSX.Element;
15
+ //# sourceMappingURL=ThemeProvider.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeProvider.d.mts","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,cAAc;AAIvC,OAAO,KAAK,EAAE,KAAK,EAAE,0BAAsB;AAI3C;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;cAId,MAAM,SAAS;WAClB,KAAK;uBAgBb,CAAC"}
@@ -0,0 +1,33 @@
1
+ function $importDefault(module) {
2
+ if (module?.__esModule) {
3
+ return module.default;
4
+ }
5
+ return module;
6
+ }
7
+ import $React, { useMemo } from "react";
8
+ const React = $importDefault($React);
9
+ import { create } from "twrnc";
10
+ import { generateTailwindConfig } from "./tailwind.config.mjs";
11
+ import { ThemeContext } from "./ThemeContext.mjs";
12
+ /**
13
+ * Theme provider component that wraps child components with theme context
14
+ *
15
+ * @param options - Component props
16
+ * @param options.children - Child components to render
17
+ * @param options.theme - Theme to apply (light or dark)
18
+ * @returns React component that provides theme context to children
19
+ */
20
+ export const ThemeProvider = ({ children, theme, }) => {
21
+ const contextValue = useMemo(() => {
22
+ const tailwindConfig = generateTailwindConfig(theme);
23
+ const tw = create(tailwindConfig);
24
+ return {
25
+ tw,
26
+ theme,
27
+ };
28
+ }, [theme]);
29
+ return (<ThemeContext.Provider value={contextValue}>
30
+ {children}
31
+ </ThemeContext.Provider>);
32
+ };
33
+ //# sourceMappingURL=ThemeProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeProvider.mjs","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,QAAO,EAAE,OAAO,EAAE,cAAc;;AACvC,OAAO,EAAE,MAAM,EAAE,cAAc;AAE/B,OAAO,EAAE,sBAAsB,EAAE,8BAA0B;AAG3D,OAAO,EAAE,YAAY,EAAE,2BAAuB;AAE9C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,QAAQ,EACR,KAAK,GAIN,EAAE,EAAE;IACH,MAAM,YAAY,GAAsB,OAAO,CAAC,GAAG,EAAE;QACnD,MAAM,cAAc,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACrD,MAAM,EAAE,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;QAClC,OAAO;YACL,EAAE;YACF,KAAK;SACN,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CACL,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CACzC;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,YAAY,CAAC,QAAQ,CAAC,CACzB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, { useMemo } from 'react';\nimport { create } from 'twrnc';\n\nimport { generateTailwindConfig } from './tailwind.config';\nimport type { Theme } from './Theme.types';\nimport type { ThemeContextProps } from './ThemeContext';\nimport { ThemeContext } from './ThemeContext';\n\n/**\n * Theme provider component that wraps child components with theme context\n *\n * @param options - Component props\n * @param options.children - Child components to render\n * @param options.theme - Theme to apply (light or dark)\n * @returns React component that provides theme context to children\n */\nexport const ThemeProvider = ({\n children,\n theme,\n}: {\n children: React.ReactNode;\n theme: Theme;\n}) => {\n const contextValue: ThemeContextProps = useMemo(() => {\n const tailwindConfig = generateTailwindConfig(theme);\n const tw = create(tailwindConfig);\n return {\n tw,\n theme,\n };\n }, [theme]);\n\n return (\n <ThemeContext.Provider value={contextValue}>\n {children}\n </ThemeContext.Provider>\n );\n};\n"]}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.themeColors = void 0;
4
+ const design_tokens_1 = require("@metamask/design-tokens");
5
+ const Theme_types_1 = require("./Theme.types.cjs");
6
+ /**
7
+ * Helper function to convert a camelCase / PascalCase string to kebab-case.
8
+ *
9
+ * It inserts a hyphen ("-") before every capital letter (while also handling
10
+ * consecutive capitals), then lower-cases the entire result.
11
+ *
12
+ * @param str - The original camelCase or PascalCase string.
13
+ * @returns The kebab-case representation of the input.
14
+ *
15
+ * @example
16
+ * toKebab('defaultHover'); // → 'default-hover'
17
+ * toKebab('RGBValue'); // → 'r-g-b-value'
18
+ */
19
+ const toKebab = (str) => str
20
+ // place a dash between lower/number → upper transitions
21
+ .replace(/([a-z0-9])([A-Z])/gu, '$1-$2')
22
+ // place a dash between upper → upper+lower transitions (e.g. "RGBValue")
23
+ .replace(/([A-Z])([A-Z][a-z])/gu, '$1-$2')
24
+ .toLowerCase();
25
+ /**
26
+ * Recursively flattens a nested object of colors into a flat object with kebab-case keys.
27
+ *
28
+ * This function is specifically designed to handle MetaMask design token color objects,
29
+ * which can be deeply nested. It converts the structure into a flat object suitable
30
+ * for Tailwind CSS configuration.
31
+ *
32
+ * @param obj - The nested color object to flatten.
33
+ * @param prefix - The current prefix for the keys (used during recursion).
34
+ * @returns A flattened object with kebab-case keys and color values.
35
+ *
36
+ * @example
37
+ * const colors = {
38
+ * background: {
39
+ * default: '#FFFFFF',
40
+ * alternative: '#F2F4F6'
41
+ * }
42
+ * };
43
+ *
44
+ * flattenColors(colors);
45
+ * // Returns: {
46
+ * // 'background-default': '#FFFFFF',
47
+ * // 'background-alternative': '#F2F4F6'
48
+ * // }
49
+ */
50
+ const flattenColors = (obj, prefix = '') => {
51
+ const result = {};
52
+ for (const [key, value] of Object.entries(obj)) {
53
+ const newKey = prefix ? `${prefix}-${toKebab(key)}` : toKebab(key);
54
+ if (typeof value === 'string') {
55
+ result[newKey] = value;
56
+ }
57
+ else if (typeof value === 'object' && value !== null) {
58
+ Object.assign(result, flattenColors(value, newKey));
59
+ }
60
+ }
61
+ return result;
62
+ };
63
+ exports.themeColors = {
64
+ [Theme_types_1.Theme.Light]: flattenColors(design_tokens_1.lightTheme.colors),
65
+ [Theme_types_1.Theme.Dark]: flattenColors(design_tokens_1.darkTheme.colors),
66
+ };
67
+ //# sourceMappingURL=colors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.cjs","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":";;;AAAA,2DAAgE;AAEhE,mDAAsC;AAEtC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,GAAG,CAAC,GAAW,EAAU,EAAE,CACtC,GAAG;IACD,wDAAwD;KACvD,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC;IACxC,yEAAyE;KACxE,OAAO,CAAC,uBAAuB,EAAE,OAAO,CAAC;KACzC,WAAW,EAAE,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,aAAa,GAAG,CACpB,GAA4B,EAC5B,MAAM,GAAG,EAAE,EACa,EAAE;IAC1B,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAEnE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;SACxB;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE;YACtD,MAAM,CAAC,MAAM,CACX,MAAM,EACN,aAAa,CAAC,KAAgC,EAAE,MAAM,CAAC,CACxD,CAAC;SACH;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEW,QAAA,WAAW,GAA0C;IAChE,CAAC,mBAAK,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,0BAAU,CAAC,MAAM,CAAC;IAC/C,CAAC,mBAAK,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,yBAAS,CAAC,MAAM,CAAC;CAC9C,CAAC","sourcesContent":["import { lightTheme, darkTheme } from '@metamask/design-tokens';\n\nimport { Theme } from './Theme.types';\n\n/**\n * Helper function to convert a camelCase / PascalCase string to kebab-case.\n *\n * It inserts a hyphen (\"-\") before every capital letter (while also handling\n * consecutive capitals), then lower-cases the entire result.\n *\n * @param str - The original camelCase or PascalCase string.\n * @returns The kebab-case representation of the input.\n *\n * @example\n * toKebab('defaultHover'); // → 'default-hover'\n * toKebab('RGBValue'); // → 'r-g-b-value'\n */\nconst toKebab = (str: string): string =>\n str\n // place a dash between lower/number → upper transitions\n .replace(/([a-z0-9])([A-Z])/gu, '$1-$2')\n // place a dash between upper → upper+lower transitions (e.g. \"RGBValue\")\n .replace(/([A-Z])([A-Z][a-z])/gu, '$1-$2')\n .toLowerCase();\n\n/**\n * Recursively flattens a nested object of colors into a flat object with kebab-case keys.\n *\n * This function is specifically designed to handle MetaMask design token color objects,\n * which can be deeply nested. It converts the structure into a flat object suitable\n * for Tailwind CSS configuration.\n *\n * @param obj - The nested color object to flatten.\n * @param prefix - The current prefix for the keys (used during recursion).\n * @returns A flattened object with kebab-case keys and color values.\n *\n * @example\n * const colors = {\n * background: {\n * default: '#FFFFFF',\n * alternative: '#F2F4F6'\n * }\n * };\n *\n * flattenColors(colors);\n * // Returns: {\n * // 'background-default': '#FFFFFF',\n * // 'background-alternative': '#F2F4F6'\n * // }\n */\nconst flattenColors = (\n obj: Record<string, unknown>,\n prefix = '',\n): Record<string, string> => {\n const result: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n const newKey = prefix ? `${prefix}-${toKebab(key)}` : toKebab(key);\n\n if (typeof value === 'string') {\n result[newKey] = value;\n } else if (typeof value === 'object' && value !== null) {\n Object.assign(\n result,\n flattenColors(value as Record<string, unknown>, newKey),\n );\n }\n }\n\n return result;\n};\n\nexport const themeColors: Record<Theme, Record<string, string>> = {\n [Theme.Light]: flattenColors(lightTheme.colors),\n [Theme.Dark]: flattenColors(darkTheme.colors),\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import { Theme } from "./Theme.types.cjs";
2
+ export declare const themeColors: Record<Theme, Record<string, string>>;
3
+ //# sourceMappingURL=colors.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.cts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,0BAAsB;AAsEtC,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAG7D,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Theme } from "./Theme.types.mjs";
2
+ export declare const themeColors: Record<Theme, Record<string, string>>;
3
+ //# sourceMappingURL=colors.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.mts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,0BAAsB;AAsEtC,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAG7D,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { lightTheme, darkTheme } from "@metamask/design-tokens";
2
+ import { Theme } from "./Theme.types.mjs";
3
+ /**
4
+ * Helper function to convert a camelCase / PascalCase string to kebab-case.
5
+ *
6
+ * It inserts a hyphen ("-") before every capital letter (while also handling
7
+ * consecutive capitals), then lower-cases the entire result.
8
+ *
9
+ * @param str - The original camelCase or PascalCase string.
10
+ * @returns The kebab-case representation of the input.
11
+ *
12
+ * @example
13
+ * toKebab('defaultHover'); // → 'default-hover'
14
+ * toKebab('RGBValue'); // → 'r-g-b-value'
15
+ */
16
+ const toKebab = (str) => str
17
+ // place a dash between lower/number → upper transitions
18
+ .replace(/([a-z0-9])([A-Z])/gu, '$1-$2')
19
+ // place a dash between upper → upper+lower transitions (e.g. "RGBValue")
20
+ .replace(/([A-Z])([A-Z][a-z])/gu, '$1-$2')
21
+ .toLowerCase();
22
+ /**
23
+ * Recursively flattens a nested object of colors into a flat object with kebab-case keys.
24
+ *
25
+ * This function is specifically designed to handle MetaMask design token color objects,
26
+ * which can be deeply nested. It converts the structure into a flat object suitable
27
+ * for Tailwind CSS configuration.
28
+ *
29
+ * @param obj - The nested color object to flatten.
30
+ * @param prefix - The current prefix for the keys (used during recursion).
31
+ * @returns A flattened object with kebab-case keys and color values.
32
+ *
33
+ * @example
34
+ * const colors = {
35
+ * background: {
36
+ * default: '#FFFFFF',
37
+ * alternative: '#F2F4F6'
38
+ * }
39
+ * };
40
+ *
41
+ * flattenColors(colors);
42
+ * // Returns: {
43
+ * // 'background-default': '#FFFFFF',
44
+ * // 'background-alternative': '#F2F4F6'
45
+ * // }
46
+ */
47
+ const flattenColors = (obj, prefix = '') => {
48
+ const result = {};
49
+ for (const [key, value] of Object.entries(obj)) {
50
+ const newKey = prefix ? `${prefix}-${toKebab(key)}` : toKebab(key);
51
+ if (typeof value === 'string') {
52
+ result[newKey] = value;
53
+ }
54
+ else if (typeof value === 'object' && value !== null) {
55
+ Object.assign(result, flattenColors(value, newKey));
56
+ }
57
+ }
58
+ return result;
59
+ };
60
+ export const themeColors = {
61
+ [Theme.Light]: flattenColors(lightTheme.colors),
62
+ [Theme.Dark]: flattenColors(darkTheme.colors),
63
+ };
64
+ //# sourceMappingURL=colors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.mjs","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,gCAAgC;AAEhE,OAAO,EAAE,KAAK,EAAE,0BAAsB;AAEtC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,GAAG,CAAC,GAAW,EAAU,EAAE,CACtC,GAAG;IACD,wDAAwD;KACvD,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC;IACxC,yEAAyE;KACxE,OAAO,CAAC,uBAAuB,EAAE,OAAO,CAAC;KACzC,WAAW,EAAE,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,aAAa,GAAG,CACpB,GAA4B,EAC5B,MAAM,GAAG,EAAE,EACa,EAAE;IAC1B,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAEnE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;SACxB;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE;YACtD,MAAM,CAAC,MAAM,CACX,MAAM,EACN,aAAa,CAAC,KAAgC,EAAE,MAAM,CAAC,CACxD,CAAC;SACH;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAA0C;IAChE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC;IAC/C,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC;CAC9C,CAAC","sourcesContent":["import { lightTheme, darkTheme } from '@metamask/design-tokens';\n\nimport { Theme } from './Theme.types';\n\n/**\n * Helper function to convert a camelCase / PascalCase string to kebab-case.\n *\n * It inserts a hyphen (\"-\") before every capital letter (while also handling\n * consecutive capitals), then lower-cases the entire result.\n *\n * @param str - The original camelCase or PascalCase string.\n * @returns The kebab-case representation of the input.\n *\n * @example\n * toKebab('defaultHover'); // → 'default-hover'\n * toKebab('RGBValue'); // → 'r-g-b-value'\n */\nconst toKebab = (str: string): string =>\n str\n // place a dash between lower/number → upper transitions\n .replace(/([a-z0-9])([A-Z])/gu, '$1-$2')\n // place a dash between upper → upper+lower transitions (e.g. \"RGBValue\")\n .replace(/([A-Z])([A-Z][a-z])/gu, '$1-$2')\n .toLowerCase();\n\n/**\n * Recursively flattens a nested object of colors into a flat object with kebab-case keys.\n *\n * This function is specifically designed to handle MetaMask design token color objects,\n * which can be deeply nested. It converts the structure into a flat object suitable\n * for Tailwind CSS configuration.\n *\n * @param obj - The nested color object to flatten.\n * @param prefix - The current prefix for the keys (used during recursion).\n * @returns A flattened object with kebab-case keys and color values.\n *\n * @example\n * const colors = {\n * background: {\n * default: '#FFFFFF',\n * alternative: '#F2F4F6'\n * }\n * };\n *\n * flattenColors(colors);\n * // Returns: {\n * // 'background-default': '#FFFFFF',\n * // 'background-alternative': '#F2F4F6'\n * // }\n */\nconst flattenColors = (\n obj: Record<string, unknown>,\n prefix = '',\n): Record<string, string> => {\n const result: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n const newKey = prefix ? `${prefix}-${toKebab(key)}` : toKebab(key);\n\n if (typeof value === 'string') {\n result[newKey] = value;\n } else if (typeof value === 'object' && value !== null) {\n Object.assign(\n result,\n flattenColors(value as Record<string, unknown>, newKey),\n );\n }\n }\n\n return result;\n};\n\nexport const themeColors: Record<Theme, Record<string, string>> = {\n [Theme.Light]: flattenColors(lightTheme.colors),\n [Theme.Dark]: flattenColors(darkTheme.colors),\n};\n"]}
package/dist/hooks.cjs ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTailwind = exports.useTheme = void 0;
4
+ const react_1 = require("react");
5
+ const ThemeContext_1 = require("./ThemeContext.cjs");
6
+ /**
7
+ * Hook that provides access to the current theme.
8
+ * Use this when you need to conditionally render content based on theme.
9
+ *
10
+ * @returns The current theme ('light' or 'dark')
11
+ *
12
+ * @example
13
+ * const theme = useTheme();
14
+ * const inverseTheme = theme === Theme.Light ? Theme.Dark : Theme.Light;
15
+ * return (
16
+ * <ThemeProvider theme={inverseTheme}>
17
+ * <View style={tw`bg-default`}>
18
+ * <Text style={tw`text-default`}>Toast message</Text>
19
+ * </View>
20
+ * </ThemeProvider>
21
+ * );
22
+ */
23
+ const useTheme = () => {
24
+ const { theme } = (0, react_1.useContext)(ThemeContext_1.ThemeContext);
25
+ return theme;
26
+ };
27
+ exports.useTheme = useTheme;
28
+ /**
29
+ * Hook that provides access to the tailwind utility function.
30
+ * Use this when you only need styling capabilities.
31
+ *
32
+ * @returns Tailwind utility function for styling
33
+ *
34
+ * @example
35
+ * const tw = useTailwind();
36
+ * return (
37
+ * <View style={tw`p-4 bg-primary`}>
38
+ * <Text>Styled content</Text>
39
+ * </View>
40
+ * );
41
+ */
42
+ const useTailwind = () => {
43
+ const { tw } = (0, react_1.useContext)(ThemeContext_1.ThemeContext);
44
+ return tw;
45
+ };
46
+ exports.useTailwind = useTailwind;
47
+ //# sourceMappingURL=hooks.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.cjs","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AAGnC,qDAA8C;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,QAAQ,GAAG,GAAU,EAAE;IAClC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,kBAAU,EAAC,2BAAY,CAAC,CAAC;IAC3C,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAHW,QAAA,QAAQ,YAGnB;AAEF;;;;;;;;;;;;;GAaG;AACI,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,EAAE,EAAE,EAAE,GAAG,IAAA,kBAAU,EAAC,2BAAY,CAAC,CAAC;IACxC,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAHW,QAAA,WAAW,eAGtB","sourcesContent":["import { useContext } from 'react';\n\nimport type { Theme } from './Theme.types';\nimport { ThemeContext } from './ThemeContext';\n\n/**\n * Hook that provides access to the current theme.\n * Use this when you need to conditionally render content based on theme.\n *\n * @returns The current theme ('light' or 'dark')\n *\n * @example\n * const theme = useTheme();\n * const inverseTheme = theme === Theme.Light ? Theme.Dark : Theme.Light;\n * return (\n * <ThemeProvider theme={inverseTheme}>\n * <View style={tw`bg-default`}>\n * <Text style={tw`text-default`}>Toast message</Text>\n * </View>\n * </ThemeProvider>\n * );\n */\nexport const useTheme = (): Theme => {\n const { theme } = useContext(ThemeContext);\n return theme;\n};\n\n/**\n * Hook that provides access to the tailwind utility function.\n * Use this when you only need styling capabilities.\n *\n * @returns Tailwind utility function for styling\n *\n * @example\n * const tw = useTailwind();\n * return (\n * <View style={tw`p-4 bg-primary`}>\n * <Text>Styled content</Text>\n * </View>\n * );\n */\nexport const useTailwind = () => {\n const { tw } = useContext(ThemeContext);\n return tw;\n};\n"]}
@@ -0,0 +1,35 @@
1
+ import type { Theme } from "./Theme.types.cjs";
2
+ /**
3
+ * Hook that provides access to the current theme.
4
+ * Use this when you need to conditionally render content based on theme.
5
+ *
6
+ * @returns The current theme ('light' or 'dark')
7
+ *
8
+ * @example
9
+ * const theme = useTheme();
10
+ * const inverseTheme = theme === Theme.Light ? Theme.Dark : Theme.Light;
11
+ * return (
12
+ * <ThemeProvider theme={inverseTheme}>
13
+ * <View style={tw`bg-default`}>
14
+ * <Text style={tw`text-default`}>Toast message</Text>
15
+ * </View>
16
+ * </ThemeProvider>
17
+ * );
18
+ */
19
+ export declare const useTheme: () => Theme;
20
+ /**
21
+ * Hook that provides access to the tailwind utility function.
22
+ * Use this when you only need styling capabilities.
23
+ *
24
+ * @returns Tailwind utility function for styling
25
+ *
26
+ * @example
27
+ * const tw = useTailwind();
28
+ * return (
29
+ * <View style={tw`p-4 bg-primary`}>
30
+ * <Text>Styled content</Text>
31
+ * </View>
32
+ * );
33
+ */
34
+ export declare const useTailwind: () => import("twrnc").TailwindFn;
35
+ //# sourceMappingURL=hooks.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.cts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,0BAAsB;AAG3C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,QAAQ,QAAO,KAG3B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,kCAGvB,CAAC"}