cyhip-dynamic-themes 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,9 +7,9 @@ Implement dynamic color themes in your React apps with Tailwind CSS in a simple
7
7
 
8
8
  ## Examples
9
9
 
10
- - **Vite + React-ts: [cyhip-dynamic-themes](https://cyhip-dynamic-themes.vercel.app/)**
10
+ - **Vite + React-ts: [cyhip-dynamic-themes](https://cyhip-dynamic-themes.vercel.app/)**
11
11
 
12
- - **Nextjs + React-ts: [cyhip-dynamic-themes-nextjs-example](https://cyhip-dynamic-themes-nextjs-example.vercel.app/)**
12
+ - **Nextjs + React-ts: [cyhip-dynamic-themes-nextjs-example](https://cyhip-dynamic-themes-nextjs-example.vercel.app/)**
13
13
 
14
14
  ## Features
15
15
 
@@ -22,10 +22,10 @@ Inspired by the excellent [article](https://evilmartians.com/chronicles/better-d
22
22
 
23
23
  `cyhip-dynamic-themes` simplifies theme setup with a unique approach:
24
24
 
25
- - **Single Hue Input**: Define just the **Hue** value, and the package automatically generates all color variants across the spectrum.
26
- - **Automatic Color Variants**: Unlike traditional methods, there’s no need to set up each shade manually—simply select a hue, and the package takes care of the rest.
25
+ - **Single Hue Input**: Define just the **Hue** value, and the package automatically generates all color variants across the spectrum.
26
+ - **Automatic Color Variants**: Unlike traditional methods, there’s no need to set up each shade manually—simply select a hue, and the package takes care of the rest.
27
27
 
28
- - **Custom Hook for Dynamic Theme Switching**: Allow your users to switch themes dynamically with the `useColorTheme` hook.
28
+ - **Custom Hook for Dynamic Theme Switching**: Allow your users to switch themes dynamically with the `useColorTheme` hook.
29
29
 
30
30
  ## Installation
31
31
 
@@ -55,7 +55,7 @@ This command generates the following files in the `/themes/` folder:
55
55
 
56
56
  ```bash
57
57
  /themes/
58
- ├── theme.config.ts.ts # To set your available hue-based colors.
58
+ ├── theme.config.ts # To set your available hue-based colors.
59
59
  ├── root.css # Main CSS file for styling.
60
60
  ├── theme-colors.ts # Includes color definitions for Tailwind.
61
61
  └── theme-switcher.tsx # Example component for theme switching.
@@ -67,12 +67,12 @@ To enable dynamic colors and dark mode, modify your `tailwind.config.ts` as foll
67
67
 
68
68
  ```ts
69
69
  // tailwind.config.ts
70
- import type { Config } from "tailwindcss";
71
- import { themeColors } from "./src/themes/theme-colors";
70
+ import type { Config } from 'tailwindcss';
71
+ import { themeColors } from './src/themes/theme-colors';
72
72
 
73
73
  export default {
74
- content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
75
- darkMode: "class",
74
+ content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
75
+ darkMode: 'class',
76
76
  theme: {
77
77
  extend: {
78
78
  colors: themeColors,
@@ -84,29 +84,26 @@ export default {
84
84
 
85
85
  **Note:** After updating the configuration, restart your application to apply the changes.
86
86
 
87
-
88
-
89
87
  ### Import `root.css`
90
88
 
91
89
  To apply CSS styles linked to the defined themes, add `/themes/root.css` to your root TSX file:
92
90
 
93
91
  ```tsx
94
92
  // src/main.tsx
95
- import { StrictMode } from "react";
96
- import { createRoot } from "react-dom/client";
97
- import App from "./App.tsx";
93
+ import { StrictMode } from 'react';
94
+ import { createRoot } from 'react-dom/client';
95
+ import App from './App.tsx';
98
96
 
99
97
  // Import CSS
100
- import "./themes/root.css";
98
+ import './themes/root.css';
101
99
 
102
- createRoot(document.getElementById("root")!).render(
100
+ createRoot(document.getElementById('root')!).render(
103
101
  <StrictMode>
104
102
  <App />
105
103
  </StrictMode>
106
104
  );
107
105
  ```
108
106
 
109
-
110
107
  ### Theme Provider
111
108
 
112
109
  Use the `ThemeProvider` to initialize a default theme.
@@ -133,7 +130,6 @@ createRoot(document.getElementById('root')!).render(
133
130
  </ThemeProvider>
134
131
  </StrictMode>
135
132
  );
136
-
137
133
  ```
138
134
 
139
135
  ### Switching Themes Dynamically
@@ -142,7 +138,7 @@ Switching the main color palette can be done using the `ThemeSwitcher` component
142
138
 
143
139
  ```tsx
144
140
  // App.tsx
145
- import { ThemeSwitcher } from "./themes/theme-switcher";
141
+ import { ThemeSwitcher } from './themes/theme-switcher';
146
142
  function App() {
147
143
  return (
148
144
  <>
@@ -183,12 +179,12 @@ You can add or modify hue palettes by visiting [OKLCH Color Preview](https://okl
183
179
  */
184
180
 
185
181
  const hueScheme: Record<string, string> = {
186
- white: "-1",
187
- blue: "250",
188
- green: "150",
189
- orange: "35",
190
- pink: "0",
191
- purple: "316",
182
+ white: '-1',
183
+ blue: '250',
184
+ green: '150',
185
+ orange: '35',
186
+ pink: '0',
187
+ purple: '316',
192
188
  };
193
189
 
194
190
  export { hueScheme };
@@ -197,24 +193,24 @@ export { hueScheme };
197
193
  ## API
198
194
 
199
195
  ### `Type ThemeConfig`
196
+
200
197
  The `ThemeConfig` type represents the configuration settings for an application's theme, specifically controlling color and mode settings. This type provides key properties for determining color hues, dark or light mode, and chromatic adjustments based on a data record.
201
198
 
202
- - **Properties:**
199
+ - **Properties:**
203
200
 
204
- - `hue`: `number`
205
- It determines the primary color base; if set to -1, the theme uses a white color based scheme.
201
+ - `hue`: `number`
202
+ It determines the primary color base; if set to -1, the theme uses a white color based scheme.
206
203
 
207
- - `mode`: `'light' | 'dark'`
208
- Defines whether the theme is in "light" or "dark" mode. Acceptable
204
+ - `mode`: `'light' | 'dark'`
205
+ Defines whether the theme is in "light" or "dark" mode. Acceptable
209
206
 
210
- - `chromaData`: `Record<number,number>`
211
- A record that maps specific numeric values to chroma levels. This data allows for dynamic chromatic adjustments, enabling fine-tuning of the theme's color saturation or intensity.
207
+ - `chromaData`: `Record<number,number>`
208
+ A record that maps specific numeric values to chroma levels. This data allows for dynamic chromatic adjustments, enabling fine-tuning of the theme's color saturation or intensity.
212
209
 
213
210
  ### `useColorTheme(theme: ThemeConfig)`
214
211
 
215
212
  A custom hook that manages the application of color themes based on the provided HUE value and dark mode setting.
216
213
 
217
-
218
214
  ### `getThemeProperties(hue: number, darkMode: boolean, chromaData: Record<number,number>)`
219
215
 
220
216
  Defines CSS class and style properties based on the provided HUE value and dark mode setting.
@@ -225,7 +221,8 @@ Defines CSS class and style properties based on the provided HUE value and dark
225
221
 
226
222
  - `darkMode`: A boolean indicating if dark mode is active.
227
223
 
228
- - `chromaData`
224
+ - `chromaData`
225
+
229
226
  - **Returns:**
230
227
 
231
228
  - An object containing:
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cyhip-dynamic-themes",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Tailwind-powered dynamic color themes for React apps.",
5
5
  "author": "@KassioRF, @CyberHippie-io",
6
6
  "license": "MIT",
@@ -1,10 +1,9 @@
1
+ 'use client'; // enable on Nextjs
1
2
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- // 'use client'; // enable on Nextjs
3
3
  import { updateTheme, useTheme } from './theme-hook';
4
4
  import { useEffect, useState } from 'react';
5
5
  var ThemeProvider = function (_a) {
6
6
  var children = _a.children, themeConfig = _a.themeConfig;
7
- /**@TODO Get this values from user cookie */
8
7
  var theme = useTheme().theme;
9
8
  var _b = useState(false), isInitialized = _b[0], setIsInitialized = _b[1];
10
9
  useEffect(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cyhip-dynamic-themes",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Tailwind-powered dynamic color themes for React apps.",
5
5
  "author": "@KassioRF, @CyberHippie-io",
6
6
  "license": "MIT",