@metamask-previews/design-system-twrnc-preset 0.0.0-preview.019292f
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/CHANGELOG.md +10 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/Theme/Theme.hooks.d.ts +2 -0
- package/dist/Theme/Theme.hooks.d.ts.map +1 -0
- package/dist/Theme/Theme.hooks.js +11 -0
- package/dist/Theme/Theme.hooks.js.map +1 -0
- package/dist/Theme/Theme.providers.d.ts +6 -0
- package/dist/Theme/Theme.providers.d.ts.map +1 -0
- package/dist/Theme/Theme.providers.js +75 -0
- package/dist/Theme/Theme.providers.js.map +1 -0
- package/dist/Theme/Theme.types.d.ts +20 -0
- package/dist/Theme/Theme.types.d.ts.map +1 -0
- package/dist/Theme/Theme.types.js +10 -0
- package/dist/Theme/Theme.types.js.map +1 -0
- package/dist/Theme/Theme.utilities.d.ts +49 -0
- package/dist/Theme/Theme.utilities.d.ts.map +1 -0
- package/dist/Theme/Theme.utilities.js +90 -0
- package/dist/Theme/Theme.utilities.js.map +1 -0
- package/dist/Theme/index.d.ts +5 -0
- package/dist/Theme/index.d.ts.map +1 -0
- package/dist/Theme/index.js +12 -0
- package/dist/Theme/index.js.map +1 -0
- package/dist/hocs/index.d.ts +2 -0
- package/dist/hocs/index.d.ts.map +1 -0
- package/dist/hocs/index.js +6 -0
- package/dist/hocs/index.js.map +1 -0
- package/dist/hocs/withThemeProvider.d.ts +7 -0
- package/dist/hocs/withThemeProvider.d.ts.map +1 -0
- package/dist/hocs/withThemeProvider.js +53 -0
- package/dist/hocs/withThemeProvider.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/twrnc-settings/colors.d.ts +3 -0
- package/dist/twrnc-settings/colors.d.ts.map +1 -0
- package/dist/twrnc-settings/colors.js +13 -0
- package/dist/twrnc-settings/colors.js.map +1 -0
- package/dist/twrnc-settings/colors.types.d.ts +30 -0
- package/dist/twrnc-settings/colors.types.d.ts.map +1 -0
- package/dist/twrnc-settings/colors.types.js +19 -0
- package/dist/twrnc-settings/colors.types.js.map +1 -0
- package/dist/twrnc-settings/colors.utilities.d.ts +26 -0
- package/dist/twrnc-settings/colors.utilities.d.ts.map +1 -0
- package/dist/twrnc-settings/colors.utilities.js +45 -0
- package/dist/twrnc-settings/colors.utilities.js.map +1 -0
- package/dist/twrnc-settings/index.d.ts +4 -0
- package/dist/twrnc-settings/index.d.ts.map +1 -0
- package/dist/twrnc-settings/index.js +11 -0
- package/dist/twrnc-settings/index.js.map +1 -0
- package/dist/twrnc-settings/typography.d.ts +3 -0
- package/dist/twrnc-settings/typography.d.ts.map +1 -0
- package/dist/twrnc-settings/typography.js +157 -0
- package/dist/twrnc-settings/typography.js.map +1 -0
- package/dist/twrnc-settings/typography.types.d.ts +64 -0
- package/dist/twrnc-settings/typography.types.d.ts.map +1 -0
- package/dist/twrnc-settings/typography.types.js +3 -0
- package/dist/twrnc-settings/typography.types.js.map +1 -0
- package/dist/twrnc-settings/typography.utilities.d.ts +22 -0
- package/dist/twrnc-settings/typography.utilities.d.ts.map +1 -0
- package/dist/twrnc-settings/typography.utilities.js +42 -0
- package/dist/twrnc-settings/typography.utilities.js.map +1 -0
- package/package.json +81 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
[Unreleased]: https://github.com/MetaMask/metamask-design-system/
|
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,15 @@
|
|
|
1
|
+
# `@metamask/design-system-twrnc-preset`
|
|
2
|
+
|
|
3
|
+
Design System twrnc preset
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`yarn add @metamask/design-system-twrnc-preset`
|
|
8
|
+
|
|
9
|
+
or
|
|
10
|
+
|
|
11
|
+
`npm install @metamask/design-system-twrnc-preset`
|
|
12
|
+
|
|
13
|
+
## Contributing
|
|
14
|
+
|
|
15
|
+
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 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.hooks.d.ts","sourceRoot":"","sources":["../../src/Theme/Theme.hooks.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,kCAGvB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTailwind = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const Theme_providers_1 = require("./Theme.providers");
|
|
6
|
+
const useTailwind = () => {
|
|
7
|
+
const { tw } = (0, react_1.useContext)(Theme_providers_1.ThemeContext);
|
|
8
|
+
return tw;
|
|
9
|
+
};
|
|
10
|
+
exports.useTailwind = useTailwind;
|
|
11
|
+
//# sourceMappingURL=Theme.hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.hooks.js","sourceRoot":"","sources":["../../src/Theme/Theme.hooks.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AAEnC,uDAAiD;AAE1C,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,EAAE,EAAE,EAAE,GAAG,IAAA,kBAAU,EAAC,8BAAY,CAAC,CAAC;IACxC,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAHW,QAAA,WAAW,eAGtB","sourcesContent":["import { useContext } from 'react';\n\nimport { ThemeContext } from './Theme.providers';\n\nexport const useTailwind = () => {\n const { tw } = useContext(ThemeContext);\n return tw;\n};\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ThemeContextProps, ThemeProviderProps } from './Theme.types';
|
|
3
|
+
export declare const defaultThemeContextValue: ThemeContextProps;
|
|
4
|
+
export declare const ThemeContext: React.Context<ThemeContextProps>;
|
|
5
|
+
export declare const ThemeProvider: React.FC<ThemeProviderProps>;
|
|
6
|
+
//# sourceMappingURL=Theme.providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.providers.d.ts","sourceRoot":"","sources":["../../src/Theme/Theme.providers.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAKhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAI3E,eAAO,MAAM,wBAAwB,EAAE,iBAMtC,CAAC;AAEF,eAAO,MAAM,YAAY,kCAExB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA6CtD,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 = exports.ThemeContext = exports.defaultThemeContextValue = void 0;
|
|
27
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const react_native_1 = require("react-native");
|
|
30
|
+
const twrnc_1 = require("twrnc");
|
|
31
|
+
const twrnc_settings_1 = require("../twrnc-settings");
|
|
32
|
+
const Theme_types_1 = require("./Theme.types");
|
|
33
|
+
const Theme_utilities_1 = require("./Theme.utilities");
|
|
34
|
+
exports.defaultThemeContextValue = {
|
|
35
|
+
tw: (0, twrnc_1.create)((0, Theme_utilities_1.generateTailwindConfig)(twrnc_settings_1.ColorSet.Brand, twrnc_settings_1.ColorScheme.Light)),
|
|
36
|
+
colorSet: twrnc_settings_1.ColorSet.Brand,
|
|
37
|
+
theme: Theme_types_1.Theme.Light,
|
|
38
|
+
setColorSet: () => { },
|
|
39
|
+
setTheme: () => { },
|
|
40
|
+
};
|
|
41
|
+
exports.ThemeContext = (0, react_1.createContext)(exports.defaultThemeContextValue);
|
|
42
|
+
const ThemeProvider = ({ children, colorSet = twrnc_settings_1.ColorSet.Brand, theme = Theme_types_1.Theme.Default, }) => {
|
|
43
|
+
const [currentColorSet, setCurrentColorSet] = (0, react_1.useState)(colorSet);
|
|
44
|
+
const [currentTheme, setCurrentTheme] = (0, react_1.useState)(theme);
|
|
45
|
+
const systemColorScheme = (0, react_native_1.useColorScheme)(); // 'light' | 'dark' | null
|
|
46
|
+
const activeColorScheme = (0, react_1.useMemo)(() => {
|
|
47
|
+
if (currentTheme === Theme_types_1.Theme.Default) {
|
|
48
|
+
return systemColorScheme === 'dark'
|
|
49
|
+
? twrnc_settings_1.ColorScheme.Dark
|
|
50
|
+
: twrnc_settings_1.ColorScheme.Light;
|
|
51
|
+
}
|
|
52
|
+
if (currentTheme === Theme_types_1.Theme.Light) {
|
|
53
|
+
return twrnc_settings_1.ColorScheme.Light;
|
|
54
|
+
}
|
|
55
|
+
if (currentTheme === Theme_types_1.Theme.Dark) {
|
|
56
|
+
return twrnc_settings_1.ColorScheme.Dark;
|
|
57
|
+
}
|
|
58
|
+
throw new Error('Invalid theme value');
|
|
59
|
+
}, [currentTheme, systemColorScheme]);
|
|
60
|
+
const tw = (0, react_1.useMemo)(() => {
|
|
61
|
+
const tailwindConfig = (0, Theme_utilities_1.generateTailwindConfig)(currentColorSet, activeColorScheme);
|
|
62
|
+
return (0, twrnc_1.create)(tailwindConfig);
|
|
63
|
+
}, [currentColorSet, activeColorScheme]);
|
|
64
|
+
return (<exports.ThemeContext.Provider value={{
|
|
65
|
+
tw,
|
|
66
|
+
colorSet: currentColorSet,
|
|
67
|
+
theme: currentTheme,
|
|
68
|
+
setColorSet: setCurrentColorSet,
|
|
69
|
+
setTheme: setCurrentTheme,
|
|
70
|
+
}}>
|
|
71
|
+
{children}
|
|
72
|
+
</exports.ThemeContext.Provider>);
|
|
73
|
+
};
|
|
74
|
+
exports.ThemeProvider = ThemeProvider;
|
|
75
|
+
//# sourceMappingURL=Theme.providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.providers.js","sourceRoot":"","sources":["../../src/Theme/Theme.providers.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAyD;AACzD,+CAAgE;AAChE,+CAA8C;AAC9C,iCAA+B;AAE/B,sDAA0D;AAE1D,+CAAsC;AACtC,uDAA2D;AAE9C,QAAA,wBAAwB,GAAsB;IACzD,EAAE,EAAE,IAAA,cAAM,EAAC,IAAA,wCAAsB,EAAC,yBAAQ,CAAC,KAAK,EAAE,4BAAW,CAAC,KAAK,CAAC,CAAC;IACrE,QAAQ,EAAE,yBAAQ,CAAC,KAAK;IACxB,KAAK,EAAE,mBAAK,CAAC,KAAK;IAClB,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;CACnB,CAAC;AAEW,QAAA,YAAY,GAAG,IAAA,qBAAa,EACvC,gCAAwB,CACzB,CAAC;AAEK,MAAM,aAAa,GAAiC,CAAC,EAC1D,QAAQ,EACR,QAAQ,GAAG,yBAAQ,CAAC,KAAK,EACzB,KAAK,GAAG,mBAAK,CAAC,OAAO,GACtB,EAAE,EAAE;IACH,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAW,QAAQ,CAAC,CAAC;IAC3E,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAQ,KAAK,CAAC,CAAC;IAC/D,MAAM,iBAAiB,GAAG,IAAA,6BAAc,GAAE,CAAC,CAAC,0BAA0B;IAEtE,MAAM,iBAAiB,GAAgB,IAAA,eAAO,EAAC,GAAG,EAAE;QAClD,IAAI,YAAY,KAAK,mBAAK,CAAC,OAAO,EAAE;YAClC,OAAO,iBAAiB,KAAK,MAAM;gBACjC,CAAC,CAAC,4BAAW,CAAC,IAAI;gBAClB,CAAC,CAAC,4BAAW,CAAC,KAAK,CAAC;SACvB;QACD,IAAI,YAAY,KAAK,mBAAK,CAAC,KAAK,EAAE;YAChC,OAAO,4BAAW,CAAC,KAAK,CAAC;SAC1B;QACD,IAAI,YAAY,KAAK,mBAAK,CAAC,IAAI,EAAE;YAC/B,OAAO,4BAAW,CAAC,IAAI,CAAC;SACzB;QACD,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC,EAAE,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEtC,MAAM,EAAE,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QACtB,MAAM,cAAc,GAAG,IAAA,wCAAsB,EAC3C,eAAe,EACf,iBAAiB,CAClB,CAAC;QACF,OAAO,IAAA,cAAM,EAAC,cAAc,CAAC,CAAC;IAChC,CAAC,EAAE,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEzC,OAAO,CACL,CAAC,oBAAY,CAAC,QAAQ,CACpB,KAAK,CAAC,CAAC;YACL,EAAE;YACF,QAAQ,EAAE,eAAe;YACzB,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,kBAAkB;YAC/B,QAAQ,EAAE,eAAe;SAC1B,CAAC,CAEF;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,oBAAY,CAAC,QAAQ,CAAC,CACzB,CAAC;AACJ,CAAC,CAAC;AA7CW,QAAA,aAAa,iBA6CxB","sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\nimport React, { createContext, useState, useMemo } from 'react';\nimport { useColorScheme } from 'react-native';\nimport { create } from 'twrnc';\n\nimport { ColorSet, ColorScheme } from '../twrnc-settings';\nimport type { ThemeContextProps, ThemeProviderProps } from './Theme.types';\nimport { Theme } from './Theme.types';\nimport { generateTailwindConfig } from './Theme.utilities';\n\nexport const defaultThemeContextValue: ThemeContextProps = {\n tw: create(generateTailwindConfig(ColorSet.Brand, ColorScheme.Light)),\n colorSet: ColorSet.Brand,\n theme: Theme.Light,\n setColorSet: () => {},\n setTheme: () => {},\n};\n\nexport const ThemeContext = createContext<ThemeContextProps>(\n defaultThemeContextValue,\n);\n\nexport const ThemeProvider: React.FC<ThemeProviderProps> = ({\n children,\n colorSet = ColorSet.Brand,\n theme = Theme.Default,\n}) => {\n const [currentColorSet, setCurrentColorSet] = useState<ColorSet>(colorSet);\n const [currentTheme, setCurrentTheme] = useState<Theme>(theme);\n const systemColorScheme = useColorScheme(); // 'light' | 'dark' | null\n\n const activeColorScheme: ColorScheme = useMemo(() => {\n if (currentTheme === Theme.Default) {\n return systemColorScheme === 'dark'\n ? ColorScheme.Dark\n : ColorScheme.Light;\n }\n if (currentTheme === Theme.Light) {\n return ColorScheme.Light;\n }\n if (currentTheme === Theme.Dark) {\n return ColorScheme.Dark;\n }\n throw new Error('Invalid theme value');\n }, [currentTheme, systemColorScheme]);\n\n const tw = useMemo(() => {\n const tailwindConfig = generateTailwindConfig(\n currentColorSet,\n activeColorScheme,\n );\n return create(tailwindConfig);\n }, [currentColorSet, activeColorScheme]);\n\n return (\n <ThemeContext.Provider\n value={{\n tw,\n colorSet: currentColorSet,\n theme: currentTheme,\n setColorSet: setCurrentColorSet,\n setTheme: setCurrentTheme,\n }}\n >\n {children}\n </ThemeContext.Provider>\n );\n};\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { create } from 'twrnc';
|
|
2
|
+
import type { ColorSet } from '../twrnc-settings';
|
|
3
|
+
export declare enum Theme {
|
|
4
|
+
Default = "default",
|
|
5
|
+
Light = "light",
|
|
6
|
+
Dark = "dark"
|
|
7
|
+
}
|
|
8
|
+
export type ThemeContextProps = {
|
|
9
|
+
tw: ReturnType<typeof create>;
|
|
10
|
+
colorSet: ColorSet;
|
|
11
|
+
theme: Theme;
|
|
12
|
+
setColorSet: (theme: ColorSet) => void;
|
|
13
|
+
setTheme: (scheme: Theme) => void;
|
|
14
|
+
};
|
|
15
|
+
export type ThemeProviderProps = {
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
colorSet?: ColorSet;
|
|
18
|
+
theme?: Theme;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=Theme.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.types.d.ts","sourceRoot":"","sources":["../../src/Theme/Theme.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,oBAAY,KAAK;IACf,OAAO,YAAY;IACnB,KAAK,UAAoB;IACzB,IAAI,SAAmB;CACxB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,CAAC,MAAM,EAAE,KAAK,KAAK,IAAI,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Theme = void 0;
|
|
4
|
+
var Theme;
|
|
5
|
+
(function (Theme) {
|
|
6
|
+
Theme["Default"] = "default";
|
|
7
|
+
Theme["Light"] = "light";
|
|
8
|
+
Theme["Dark"] = "dark";
|
|
9
|
+
})(Theme || (exports.Theme = Theme = {}));
|
|
10
|
+
//# sourceMappingURL=Theme.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.types.js","sourceRoot":"","sources":["../../src/Theme/Theme.types.ts"],"names":[],"mappings":";;;AAKA,IAAY,KAIX;AAJD,WAAY,KAAK;IACf,4BAAmB,CAAA;IACnB,wBAAyB,CAAA;IACzB,sBAAuB,CAAA;AACzB,CAAC,EAJW,KAAK,qBAAL,KAAK,QAIhB","sourcesContent":["import type { create } from 'twrnc';\n\nimport { ColorScheme } from '../twrnc-settings';\nimport type { ColorSet } from '../twrnc-settings';\n\nexport enum Theme {\n Default = 'default',\n Light = ColorScheme.Light,\n Dark = ColorScheme.Dark,\n}\n\nexport type ThemeContextProps = {\n tw: ReturnType<typeof create>;\n colorSet: ColorSet;\n theme: Theme;\n setColorSet: (theme: ColorSet) => void;\n setTheme: (scheme: Theme) => void;\n};\n\nexport type ThemeProviderProps = {\n children: React.ReactNode;\n colorSet?: ColorSet;\n theme?: Theme;\n};\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ColorSet, ColorScheme } from '../twrnc-settings';
|
|
2
|
+
/**
|
|
3
|
+
* Generates a Tailwind CSS configuration object based on the specified color set and color scheme.
|
|
4
|
+
* This configuration extends the base Tailwind settings with custom theme colors, typography settings,
|
|
5
|
+
* and other style properties for use in React Native with `twrnc`.
|
|
6
|
+
*
|
|
7
|
+
* @param colorSet - The color set to use (e.g., 'Brand', 'Neutral'). Determines the base palette for the theme.
|
|
8
|
+
* @param colorScheme - The current color scheme ('light' or 'dark'). Specifies whether to use light or dark mode styles.
|
|
9
|
+
* @returns A Tailwind CSS configuration object with extended theme properties and plugins.
|
|
10
|
+
* @example
|
|
11
|
+
* const colorSet = 'Brand';
|
|
12
|
+
* const colorScheme = 'dark';
|
|
13
|
+
*
|
|
14
|
+
* const tailwindConfig = generateTailwindConfig(colorSet, colorScheme);
|
|
15
|
+
* console.log(tailwindConfig);
|
|
16
|
+
*
|
|
17
|
+
* // Output:
|
|
18
|
+
* // {
|
|
19
|
+
* // theme: {
|
|
20
|
+
* // extend: {
|
|
21
|
+
* // colors: {
|
|
22
|
+
* // primary: '#1a202c',
|
|
23
|
+
* // secondary: '#2d3748',
|
|
24
|
+
* // // ...additional flattened colors
|
|
25
|
+
* // },
|
|
26
|
+
* // fontSize: {
|
|
27
|
+
* // 'display-md': [32, { lineHeight: '40', letterSpacing: '0', fontWeight: '700' }],
|
|
28
|
+
* // // ...other font sizes
|
|
29
|
+
* // },
|
|
30
|
+
* // fontFamily: {
|
|
31
|
+
* // sans: ['Euclid Circular B', 'Helvetica Neue', 'Arial', 'sans-serif'],
|
|
32
|
+
* // // ...other font families
|
|
33
|
+
* // },
|
|
34
|
+
* // letterSpacing: {
|
|
35
|
+
* // 'display-md': '0',
|
|
36
|
+
* // // ...other letter spacings
|
|
37
|
+
* // },
|
|
38
|
+
* // lineHeight: {
|
|
39
|
+
* // 'display-md': '40',
|
|
40
|
+
* // // ...other line heights
|
|
41
|
+
* // },
|
|
42
|
+
* // },
|
|
43
|
+
* // },
|
|
44
|
+
* // plugins: [],
|
|
45
|
+
* // }
|
|
46
|
+
* @throws Will log an error and return an empty object if theme colors are not found for the specified color set and color scheme.
|
|
47
|
+
*/
|
|
48
|
+
export declare const generateTailwindConfig: (colorSet: ColorSet, colorScheme: ColorScheme) => {};
|
|
49
|
+
//# sourceMappingURL=Theme.utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.utilities.d.ts","sourceRoot":"","sources":["../../src/Theme/Theme.utilities.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,sBAAsB,aACvB,QAAQ,eACL,WAAW,OAmCzB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateTailwindConfig = void 0;
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
+
const tailwind_config_1 = __importDefault(require("../../tailwind.config"));
|
|
9
|
+
const twrnc_settings_1 = require("../twrnc-settings");
|
|
10
|
+
/**
|
|
11
|
+
* Generates a Tailwind CSS configuration object based on the specified color set and color scheme.
|
|
12
|
+
* This configuration extends the base Tailwind settings with custom theme colors, typography settings,
|
|
13
|
+
* and other style properties for use in React Native with `twrnc`.
|
|
14
|
+
*
|
|
15
|
+
* @param colorSet - The color set to use (e.g., 'Brand', 'Neutral'). Determines the base palette for the theme.
|
|
16
|
+
* @param colorScheme - The current color scheme ('light' or 'dark'). Specifies whether to use light or dark mode styles.
|
|
17
|
+
* @returns A Tailwind CSS configuration object with extended theme properties and plugins.
|
|
18
|
+
* @example
|
|
19
|
+
* const colorSet = 'Brand';
|
|
20
|
+
* const colorScheme = 'dark';
|
|
21
|
+
*
|
|
22
|
+
* const tailwindConfig = generateTailwindConfig(colorSet, colorScheme);
|
|
23
|
+
* console.log(tailwindConfig);
|
|
24
|
+
*
|
|
25
|
+
* // Output:
|
|
26
|
+
* // {
|
|
27
|
+
* // theme: {
|
|
28
|
+
* // extend: {
|
|
29
|
+
* // colors: {
|
|
30
|
+
* // primary: '#1a202c',
|
|
31
|
+
* // secondary: '#2d3748',
|
|
32
|
+
* // // ...additional flattened colors
|
|
33
|
+
* // },
|
|
34
|
+
* // fontSize: {
|
|
35
|
+
* // 'display-md': [32, { lineHeight: '40', letterSpacing: '0', fontWeight: '700' }],
|
|
36
|
+
* // // ...other font sizes
|
|
37
|
+
* // },
|
|
38
|
+
* // fontFamily: {
|
|
39
|
+
* // sans: ['Euclid Circular B', 'Helvetica Neue', 'Arial', 'sans-serif'],
|
|
40
|
+
* // // ...other font families
|
|
41
|
+
* // },
|
|
42
|
+
* // letterSpacing: {
|
|
43
|
+
* // 'display-md': '0',
|
|
44
|
+
* // // ...other letter spacings
|
|
45
|
+
* // },
|
|
46
|
+
* // lineHeight: {
|
|
47
|
+
* // 'display-md': '40',
|
|
48
|
+
* // // ...other line heights
|
|
49
|
+
* // },
|
|
50
|
+
* // },
|
|
51
|
+
* // },
|
|
52
|
+
* // plugins: [],
|
|
53
|
+
* // }
|
|
54
|
+
* @throws Will log an error and return an empty object if theme colors are not found for the specified color set and color scheme.
|
|
55
|
+
*/
|
|
56
|
+
const generateTailwindConfig = (colorSet, colorScheme) => {
|
|
57
|
+
const themeColors = twrnc_settings_1.colorSetList[colorSet][colorScheme];
|
|
58
|
+
if (!themeColors) {
|
|
59
|
+
console.error('Theme colors not found.');
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
...tailwind_config_1.default,
|
|
64
|
+
theme: {
|
|
65
|
+
...tailwind_config_1.default.theme,
|
|
66
|
+
extend: {
|
|
67
|
+
...tailwind_config_1.default.theme?.extend,
|
|
68
|
+
colors: {
|
|
69
|
+
...tailwind_config_1.default.theme?.extend?.colors,
|
|
70
|
+
...themeColors,
|
|
71
|
+
},
|
|
72
|
+
fontSize: {
|
|
73
|
+
...twrnc_settings_1.typographyTailwindConfig.fontSize,
|
|
74
|
+
},
|
|
75
|
+
fontFamily: {
|
|
76
|
+
...twrnc_settings_1.typographyTailwindConfig.fontFamily,
|
|
77
|
+
},
|
|
78
|
+
letterSpacing: {
|
|
79
|
+
...twrnc_settings_1.typographyTailwindConfig.letterSpacing,
|
|
80
|
+
},
|
|
81
|
+
lineHeight: {
|
|
82
|
+
...twrnc_settings_1.typographyTailwindConfig.lineHeight,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
plugins: tailwind_config_1.default.plugins || [],
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
exports.generateTailwindConfig = generateTailwindConfig;
|
|
90
|
+
//# sourceMappingURL=Theme.utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.utilities.js","sourceRoot":"","sources":["../../src/Theme/Theme.utilities.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAuD;AACvD,4EAA+C;AAE/C,sDAA2E;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACI,MAAM,sBAAsB,GAAG,CACpC,QAAkB,EAClB,WAAwB,EACxB,EAAE;IACF,MAAM,WAAW,GAAG,6BAAY,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC;IAExD,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QACzC,OAAO,EAAE,CAAC;KACX;IAED,OAAO;QACL,GAAG,yBAAU;QACb,KAAK,EAAE;YACL,GAAG,yBAAU,CAAC,KAAK;YACnB,MAAM,EAAE;gBACN,GAAG,yBAAU,CAAC,KAAK,EAAE,MAAM;gBAC3B,MAAM,EAAE;oBACN,GAAG,yBAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM;oBACnC,GAAG,WAAW;iBACf;gBACD,QAAQ,EAAE;oBACR,GAAG,yCAAwB,CAAC,QAAQ;iBACrC;gBACD,UAAU,EAAE;oBACV,GAAG,yCAAwB,CAAC,UAAU;iBACvC;gBACD,aAAa,EAAE;oBACb,GAAG,yCAAwB,CAAC,aAAa;iBAC1C;gBACD,UAAU,EAAE;oBACV,GAAG,yCAAwB,CAAC,UAAU;iBACvC;aACF;SACF;QACD,OAAO,EAAE,yBAAU,CAAC,OAAO,IAAI,EAAE;KAClC,CAAC;AACJ,CAAC,CAAC;AArCW,QAAA,sBAAsB,0BAqCjC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport baseConfig from '../../tailwind.config';\nimport type { ColorSet, ColorScheme } from '../twrnc-settings';\nimport { colorSetList, typographyTailwindConfig } from '../twrnc-settings';\n\n/**\n * Generates a Tailwind CSS configuration object based on the specified color set and color scheme.\n * This configuration extends the base Tailwind settings with custom theme colors, typography settings,\n * and other style properties for use in React Native with `twrnc`.\n *\n * @param colorSet - The color set to use (e.g., 'Brand', 'Neutral'). Determines the base palette for the theme.\n * @param colorScheme - The current color scheme ('light' or 'dark'). Specifies whether to use light or dark mode styles.\n * @returns A Tailwind CSS configuration object with extended theme properties and plugins.\n * @example\n * const colorSet = 'Brand';\n * const colorScheme = 'dark';\n *\n * const tailwindConfig = generateTailwindConfig(colorSet, colorScheme);\n * console.log(tailwindConfig);\n *\n * // Output:\n * // {\n * // theme: {\n * // extend: {\n * // colors: {\n * // primary: '#1a202c',\n * // secondary: '#2d3748',\n * // // ...additional flattened colors\n * // },\n * // fontSize: {\n * // 'display-md': [32, { lineHeight: '40', letterSpacing: '0', fontWeight: '700' }],\n * // // ...other font sizes\n * // },\n * // fontFamily: {\n * // sans: ['Euclid Circular B', 'Helvetica Neue', 'Arial', 'sans-serif'],\n * // // ...other font families\n * // },\n * // letterSpacing: {\n * // 'display-md': '0',\n * // // ...other letter spacings\n * // },\n * // lineHeight: {\n * // 'display-md': '40',\n * // // ...other line heights\n * // },\n * // },\n * // },\n * // plugins: [],\n * // }\n * @throws Will log an error and return an empty object if theme colors are not found for the specified color set and color scheme.\n */\nexport const generateTailwindConfig = (\n colorSet: ColorSet,\n colorScheme: ColorScheme,\n) => {\n const themeColors = colorSetList[colorSet][colorScheme];\n\n if (!themeColors) {\n console.error('Theme colors not found.');\n return {};\n }\n\n return {\n ...baseConfig,\n theme: {\n ...baseConfig.theme,\n extend: {\n ...baseConfig.theme?.extend,\n colors: {\n ...baseConfig.theme?.extend?.colors,\n ...themeColors,\n },\n fontSize: {\n ...typographyTailwindConfig.fontSize,\n },\n fontFamily: {\n ...typographyTailwindConfig.fontFamily,\n },\n letterSpacing: {\n ...typographyTailwindConfig.letterSpacing,\n },\n lineHeight: {\n ...typographyTailwindConfig.lineHeight,\n },\n },\n },\n plugins: baseConfig.plugins || [],\n };\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useTailwind } from './Theme.hooks';
|
|
2
|
+
export { ThemeContext, ThemeProvider, defaultThemeContextValue, } from './Theme.providers';
|
|
3
|
+
export { Theme } from './Theme.types';
|
|
4
|
+
export type { ThemeContextProps, ThemeProviderProps } from './Theme.types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Theme = exports.defaultThemeContextValue = exports.ThemeProvider = exports.ThemeContext = exports.useTailwind = void 0;
|
|
4
|
+
var Theme_hooks_1 = require("./Theme.hooks");
|
|
5
|
+
Object.defineProperty(exports, "useTailwind", { enumerable: true, get: function () { return Theme_hooks_1.useTailwind; } });
|
|
6
|
+
var Theme_providers_1 = require("./Theme.providers");
|
|
7
|
+
Object.defineProperty(exports, "ThemeContext", { enumerable: true, get: function () { return Theme_providers_1.ThemeContext; } });
|
|
8
|
+
Object.defineProperty(exports, "ThemeProvider", { enumerable: true, get: function () { return Theme_providers_1.ThemeProvider; } });
|
|
9
|
+
Object.defineProperty(exports, "defaultThemeContextValue", { enumerable: true, get: function () { return Theme_providers_1.defaultThemeContextValue; } });
|
|
10
|
+
var Theme_types_1 = require("./Theme.types");
|
|
11
|
+
Object.defineProperty(exports, "Theme", { enumerable: true, get: function () { return Theme_types_1.Theme; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Theme/index.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,qDAI2B;AAHzB,+GAAA,YAAY,OAAA;AACZ,gHAAA,aAAa,OAAA;AACb,2HAAA,wBAAwB,OAAA;AAE1B,6CAAsC;AAA7B,oGAAA,KAAK,OAAA","sourcesContent":["export { useTailwind } from './Theme.hooks';\nexport {\n ThemeContext,\n ThemeProvider,\n defaultThemeContextValue,\n} from './Theme.providers';\nexport { Theme } from './Theme.types';\nexport type { ThemeContextProps, ThemeProviderProps } from './Theme.types';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hocs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withThemeProvider = void 0;
|
|
4
|
+
var withThemeProvider_1 = require("./withThemeProvider");
|
|
5
|
+
Object.defineProperty(exports, "withThemeProvider", { enumerable: true, get: function () { return withThemeProvider_1.withThemeProvider; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hocs/index.ts"],"names":[],"mappings":";;;AAAA,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA","sourcesContent":["export { withThemeProvider } from './withThemeProvider';\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* HOC to wrap components with ThemeProvider if none is present.
|
|
4
|
+
* @param Component - The component to wrap with ThemeProvider.
|
|
5
|
+
*/
|
|
6
|
+
export declare function withThemeProvider<Props extends object>(Component: React.ComponentType<Props>): React.ForwardRefExoticComponent<React.PropsWithoutRef<Props> & React.RefAttributes<any>>;
|
|
7
|
+
//# sourceMappingURL=withThemeProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withThemeProvider.d.ts","sourceRoot":"","sources":["../../src/hocs/withThemeProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAiC,MAAM,OAAO,CAAC;AAUtD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,MAAM,EACpD,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,4FAoBtC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
/* eslint-disable jsdoc/require-returns */
|
|
4
|
+
// src/hocs/withThemeProvider.tsx
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.withThemeProvider = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const Theme_1 = require("../Theme");
|
|
32
|
+
const twrnc_settings_1 = require("../twrnc-settings");
|
|
33
|
+
/**
|
|
34
|
+
* HOC to wrap components with ThemeProvider if none is present.
|
|
35
|
+
* @param Component - The component to wrap with ThemeProvider.
|
|
36
|
+
*/
|
|
37
|
+
function withThemeProvider(Component) {
|
|
38
|
+
const WrappedComponent = (0, react_1.forwardRef)((props, ref) => {
|
|
39
|
+
// Check if a ThemeProvider is already present
|
|
40
|
+
const themeContext = (0, react_1.useContext)(Theme_1.ThemeContext);
|
|
41
|
+
// If ThemeProvider exists, use the component as is
|
|
42
|
+
if (themeContext !== Theme_1.defaultThemeContextValue) {
|
|
43
|
+
return <Component {...props} ref={ref}/>;
|
|
44
|
+
}
|
|
45
|
+
// Otherwise, wrap with ThemeProvider
|
|
46
|
+
return (<Theme_1.ThemeProvider colorSet={twrnc_settings_1.ColorSet.Brand} theme={Theme_1.Theme.Default}>
|
|
47
|
+
<Component {...props} ref={ref}/>
|
|
48
|
+
</Theme_1.ThemeProvider>);
|
|
49
|
+
});
|
|
50
|
+
return WrappedComponent;
|
|
51
|
+
}
|
|
52
|
+
exports.withThemeProvider = withThemeProvider;
|
|
53
|
+
//# sourceMappingURL=withThemeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withThemeProvider.js","sourceRoot":"","sources":["../../src/hocs/withThemeProvider.tsx"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,0CAA0C;AAC1C,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjC,+CAAsD;AAEtD,oCAKkB;AAClB,sDAA6C;AAE7C;;;GAGG;AACH,SAAgB,iBAAiB,CAC/B,SAAqC;IAErC,MAAM,gBAAgB,GAAG,IAAA,kBAAU,EAAa,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC7D,8CAA8C;QAC9C,MAAM,YAAY,GAAG,IAAA,kBAAU,EAAC,oBAAY,CAAC,CAAC;QAE9C,mDAAmD;QACnD,IAAI,YAAY,KAAK,gCAAwB,EAAE;YAC7C,OAAO,CAAC,SAAS,CAAC,IAAK,KAAe,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAG,CAAC;SACtD;QAED,qCAAqC;QACrC,OAAO,CACL,CAAC,qBAAa,CAAC,QAAQ,CAAC,CAAC,yBAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,aAAK,CAAC,OAAO,CAAC,CAC5D;QAAA,CAAC,SAAS,CAAC,IAAK,KAAe,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAC5C;MAAA,EAAE,qBAAa,CAAC,CACjB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AArBD,8CAqBC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable jsdoc/require-returns */\n// src/hocs/withThemeProvider.tsx\n\nimport React, { forwardRef, useContext } from 'react';\n\nimport {\n ThemeProvider,\n ThemeContext,\n Theme,\n defaultThemeContextValue,\n} from '../Theme';\nimport { ColorSet } from '../twrnc-settings';\n\n/**\n * HOC to wrap components with ThemeProvider if none is present.\n * @param Component - The component to wrap with ThemeProvider.\n */\nexport function withThemeProvider<Props extends object>(\n Component: React.ComponentType<Props>,\n) {\n const WrappedComponent = forwardRef<any, Props>((props, ref) => {\n // Check if a ThemeProvider is already present\n const themeContext = useContext(ThemeContext);\n\n // If ThemeProvider exists, use the component as is\n if (themeContext !== defaultThemeContextValue) {\n return <Component {...(props as Props)} ref={ref} />;\n }\n\n // Otherwise, wrap with ThemeProvider\n return (\n <ThemeProvider colorSet={ColorSet.Brand} theme={Theme.Default}>\n <Component {...(props as Props)} ref={ref} />\n </ThemeProvider>\n );\n });\n\n return WrappedComponent;\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { ThemeContextProps, ThemeProviderProps } from './Theme';
|
|
2
|
+
export { useTailwind, ThemeContext, ThemeProvider, Theme } from './Theme';
|
|
3
|
+
export { ColorSet } from './twrnc-settings';
|
|
4
|
+
export { withThemeProvider } from './hocs';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withThemeProvider = exports.ColorSet = exports.Theme = exports.ThemeProvider = exports.ThemeContext = exports.useTailwind = void 0;
|
|
4
|
+
var Theme_1 = require("./Theme");
|
|
5
|
+
Object.defineProperty(exports, "useTailwind", { enumerable: true, get: function () { return Theme_1.useTailwind; } });
|
|
6
|
+
Object.defineProperty(exports, "ThemeContext", { enumerable: true, get: function () { return Theme_1.ThemeContext; } });
|
|
7
|
+
Object.defineProperty(exports, "ThemeProvider", { enumerable: true, get: function () { return Theme_1.ThemeProvider; } });
|
|
8
|
+
Object.defineProperty(exports, "Theme", { enumerable: true, get: function () { return Theme_1.Theme; } });
|
|
9
|
+
var twrnc_settings_1 = require("./twrnc-settings");
|
|
10
|
+
Object.defineProperty(exports, "ColorSet", { enumerable: true, get: function () { return twrnc_settings_1.ColorSet; } });
|
|
11
|
+
var hocs_1 = require("./hocs");
|
|
12
|
+
Object.defineProperty(exports, "withThemeProvider", { enumerable: true, get: function () { return hocs_1.withThemeProvider; } });
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,iCAA0E;AAAjE,oGAAA,WAAW,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,sGAAA,aAAa,OAAA;AAAE,8FAAA,KAAK,OAAA;AAExD,mDAA4C;AAAnC,0GAAA,QAAQ,OAAA;AAEjB,+BAA2C;AAAlC,yGAAA,iBAAiB,OAAA","sourcesContent":["export type { ThemeContextProps, ThemeProviderProps } from './Theme';\nexport { useTailwind, ThemeContext, ThemeProvider, Theme } from './Theme';\n\nexport { ColorSet } from './twrnc-settings';\n\nexport { withThemeProvider } from './hocs';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/twrnc-settings/colors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,eAAO,MAAM,YAAY,EAAE,iBAK1B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.colorSetList = void 0;
|
|
4
|
+
const design_tokens_1 = require("@metamask-previews/design-tokens");
|
|
5
|
+
const colors_types_1 = require("./colors.types");
|
|
6
|
+
const colors_utilities_1 = require("./colors.utilities");
|
|
7
|
+
exports.colorSetList = {
|
|
8
|
+
[colors_types_1.ColorSet.Brand]: {
|
|
9
|
+
[colors_types_1.ColorScheme.Light]: (0, colors_utilities_1.flattenColors)(design_tokens_1.lightTheme.colors),
|
|
10
|
+
[colors_types_1.ColorScheme.Dark]: (0, colors_utilities_1.flattenColors)(design_tokens_1.darkTheme.colors),
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/twrnc-settings/colors.ts"],"names":[],"mappings":";;;AAAA,oEAAyE;AAGzE,iDAAuD;AACvD,yDAAmD;AAEtC,QAAA,YAAY,GAAsB;IAC7C,CAAC,uBAAQ,CAAC,KAAK,CAAC,EAAE;QAChB,CAAC,0BAAW,CAAC,KAAK,CAAC,EAAE,IAAA,gCAAa,EAAC,0BAAU,CAAC,MAAM,CAAC;QACrD,CAAC,0BAAW,CAAC,IAAI,CAAC,EAAE,IAAA,gCAAa,EAAC,yBAAS,CAAC,MAAM,CAAC;KACpD;CACF,CAAC","sourcesContent":["import { lightTheme, darkTheme } from '@metamask-previews/design-tokens';\n\nimport type { ColorSetListProps } from './colors.types';\nimport { ColorSet, ColorScheme } from './colors.types';\nimport { flattenColors } from './colors.utilities';\n\nexport const colorSetList: ColorSetListProps = {\n [ColorSet.Brand]: {\n [ColorScheme.Light]: flattenColors(lightTheme.colors),\n [ColorScheme.Dark]: flattenColors(darkTheme.colors),\n },\n};\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum for different color set options.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum ColorSet {
|
|
5
|
+
Brand = "brand"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Enum for different color scheme options.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum ColorScheme {
|
|
11
|
+
Light = "light",
|
|
12
|
+
Dark = "dark"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Props for ColorSet. Each color set - color scheme should contain
|
|
16
|
+
* an object with twrnc-className string as key and color string as value.
|
|
17
|
+
* @example
|
|
18
|
+
* // {
|
|
19
|
+
* // 'primary-default': '#abc',
|
|
20
|
+
* // 'primary-alternative ': '#123',
|
|
21
|
+
* // 'secondary': '#456'
|
|
22
|
+
* // }
|
|
23
|
+
*/
|
|
24
|
+
export type ColorSetListProps = {
|
|
25
|
+
brand: {
|
|
26
|
+
[ColorScheme.Light]: Record<string, string>;
|
|
27
|
+
[ColorScheme.Dark]: Record<string, string>;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=colors.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.types.d.ts","sourceRoot":"","sources":["../../src/twrnc-settings/colors.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,QAAQ;IAClB,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE;QACL,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC5C,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ColorScheme = exports.ColorSet = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Enum for different color set options.
|
|
6
|
+
*/
|
|
7
|
+
var ColorSet;
|
|
8
|
+
(function (ColorSet) {
|
|
9
|
+
ColorSet["Brand"] = "brand";
|
|
10
|
+
})(ColorSet || (exports.ColorSet = ColorSet = {}));
|
|
11
|
+
/**
|
|
12
|
+
* Enum for different color scheme options.
|
|
13
|
+
*/
|
|
14
|
+
var ColorScheme;
|
|
15
|
+
(function (ColorScheme) {
|
|
16
|
+
ColorScheme["Light"] = "light";
|
|
17
|
+
ColorScheme["Dark"] = "dark";
|
|
18
|
+
})(ColorScheme || (exports.ColorScheme = ColorScheme = {}));
|
|
19
|
+
//# sourceMappingURL=colors.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.types.js","sourceRoot":"","sources":["../../src/twrnc-settings/colors.types.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,QAEX;AAFD,WAAY,QAAQ;IAClB,2BAAe,CAAA;AACjB,CAAC,EAFW,QAAQ,wBAAR,QAAQ,QAEnB;AAED;;GAEG;AACH,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,4BAAa,CAAA;AACf,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB","sourcesContent":["/**\n * Enum for different color set options.\n */\nexport enum ColorSet {\n Brand = 'brand',\n}\n\n/**\n * Enum for different color scheme options.\n */\nexport enum ColorScheme {\n Light = 'light',\n Dark = 'dark',\n}\n\n/**\n * Props for ColorSet. Each color set - color scheme should contain\n * an object with twrnc-className string as key and color string as value.\n * @example\n * // {\n * // 'primary-default': '#abc',\n * // 'primary-alternative ': '#123',\n * // 'secondary': '#456'\n * // }\n */\nexport type ColorSetListProps = {\n brand: {\n [ColorScheme.Light]: Record<string, string>;\n [ColorScheme.Dark]: Record<string, string>;\n };\n};\n"]}
|