@codeplex-sac/tema 0.0.11
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/index.cjs +1 -0
- package/index.d.ts +4 -0
- package/index.js +114 -0
- package/lib/ganchos.d.ts +3 -0
- package/lib/proveedor.d.ts +21 -0
- package/lib/tema.d.ts +1 -0
- package/lib/tipos.d.ts +6 -0
- package/package.json +28 -0
package/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),r=require("react"),d=require("@mui/material"),m=r.createContext(void 0),p="codeplex-theme",f=({children:s,temaPorDefecto:a="light"})=>{const[n,c]=r.useState(()=>{if(typeof window<"u"){const o=localStorage.getItem(p);if(o==="light"||o==="dark")return o;if(window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}return a}),e=r.useCallback(o=>{const u=document.documentElement;u.classList.remove("light","dark"),u.classList.add(o),localStorage.setItem(p,o)},[]);r.useEffect(()=>{e(n)},[n,e]);const t=r.useCallback(o=>{c(o)},[]),h=r.useCallback(()=>{c(o=>o==="light"?"dark":"light")},[]);return i.jsx(m.Provider,{value:{tema:n,alternarTema:h,establecerTema:t},children:s})},y=({defaultTheme:s,...a})=>i.jsx(f,{temaPorDefecto:s,...a}),g=m,l=()=>{const s=r.useContext(m);if(!s)throw new Error("usarTema debe ser usado dentro de un CodeplexProveedorTema");return s},x=l,T=({children:s,sobrescrituraTema:a})=>{const{tema:n}=l(),c=r.useMemo(()=>{const e=n==="dark",t={palette:{mode:n,primary:{main:"#3b82f6"},background:{default:e?"#1b2431":"#f9fafb",paper:e?"#273142":"#ffffff"},text:{primary:e?"#ffffff":"#111827",secondary:e?"rgba(255,255,255,0.7)":"#4b5563"}},typography:{fontFamily:'"Poppins", "Inter", "system-ui", "-apple-system", sans-serif',h1:{fontWeight:600},h2:{fontWeight:600},h3:{fontWeight:600},h4:{fontWeight:600},h5:{fontWeight:600},h6:{fontWeight:600},button:{fontWeight:500,textTransform:"none"}},shape:{borderRadius:8},components:{MuiPaper:{styleOverrides:{root:{backgroundImage:"none"}}},MuiButton:{styleOverrides:{root:{textTransform:"none",fontWeight:600}}}}};return a?d.createTheme(t,a):d.createTheme(t)},[n,a]);return r.useEffect(()=>{const e=document.documentElement,t=c.palette;e.style.setProperty("--cp-primary-main",t.primary.main),e.style.setProperty("--cp-bg-default",t.background.default),e.style.setProperty("--cp-bg-paper",t.background.paper),e.style.setProperty("--cp-text-primary",t.text.primary),e.style.setProperty("--cp-text-secondary",t.text.secondary),e.style.setProperty("--cp-divider",t.divider)},[c]),r.useEffect(()=>{const e="codeplex-google-resources";if(!document.getElementById(e)){const t=document.createElement("link");t.id=e,t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200",document.head.appendChild(t)}},[]),i.jsxs(d.ThemeProvider,{theme:c,children:[i.jsx(d.CssBaseline,{}),s]})};function C(){return"tema"}exports.CodeplexProveedorMui=T;exports.CodeplexProveedorTema=f;exports.CodeplexThemeProvider=y;exports.ContextoTema=m;exports.ThemeContext=g;exports.tema=C;exports.usarTema=l;exports.useTheme=x;
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx as i, jsxs as y } from "react/jsx-runtime";
|
|
2
|
+
import g, { createContext as x, useState as P, useCallback as c, useEffect as d, useMemo as T } from "react";
|
|
3
|
+
import { createTheme as p, ThemeProvider as b, CssBaseline as k } from "@mui/material";
|
|
4
|
+
const m = x(void 0), f = "codeplex-theme", C = ({
|
|
5
|
+
children: r,
|
|
6
|
+
temaPorDefecto: n = "light"
|
|
7
|
+
}) => {
|
|
8
|
+
const [s, a] = P(() => {
|
|
9
|
+
if (typeof window < "u") {
|
|
10
|
+
const o = localStorage.getItem(f);
|
|
11
|
+
if (o === "light" || o === "dark")
|
|
12
|
+
return o;
|
|
13
|
+
if (window.matchMedia("(prefers-color-scheme: dark)").matches)
|
|
14
|
+
return "dark";
|
|
15
|
+
}
|
|
16
|
+
return n;
|
|
17
|
+
}), e = c((o) => {
|
|
18
|
+
const l = document.documentElement;
|
|
19
|
+
l.classList.remove("light", "dark"), l.classList.add(o), localStorage.setItem(f, o);
|
|
20
|
+
}, []);
|
|
21
|
+
d(() => {
|
|
22
|
+
e(s);
|
|
23
|
+
}, [s, e]);
|
|
24
|
+
const t = c((o) => {
|
|
25
|
+
a(o);
|
|
26
|
+
}, []), h = c(() => {
|
|
27
|
+
a((o) => o === "light" ? "dark" : "light");
|
|
28
|
+
}, []);
|
|
29
|
+
return /* @__PURE__ */ i(m.Provider, { value: { tema: s, alternarTema: h, establecerTema: t }, children: r });
|
|
30
|
+
}, w = ({ defaultTheme: r, ...n }) => /* @__PURE__ */ i(C, { temaPorDefecto: r, ...n }), W = m, u = () => {
|
|
31
|
+
const r = g.useContext(m);
|
|
32
|
+
if (!r)
|
|
33
|
+
throw new Error("usarTema debe ser usado dentro de un CodeplexProveedorTema");
|
|
34
|
+
return r;
|
|
35
|
+
}, I = u, A = ({
|
|
36
|
+
children: r,
|
|
37
|
+
sobrescrituraTema: n
|
|
38
|
+
}) => {
|
|
39
|
+
const { tema: s } = u(), a = T(() => {
|
|
40
|
+
const e = s === "dark", t = {
|
|
41
|
+
palette: {
|
|
42
|
+
mode: s,
|
|
43
|
+
primary: {
|
|
44
|
+
main: "#3b82f6"
|
|
45
|
+
},
|
|
46
|
+
background: {
|
|
47
|
+
default: e ? "#1b2431" : "#f9fafb",
|
|
48
|
+
paper: e ? "#273142" : "#ffffff"
|
|
49
|
+
},
|
|
50
|
+
text: {
|
|
51
|
+
primary: e ? "#ffffff" : "#111827",
|
|
52
|
+
secondary: e ? "rgba(255,255,255,0.7)" : "#4b5563"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
typography: {
|
|
56
|
+
fontFamily: '"Poppins", "Inter", "system-ui", "-apple-system", sans-serif',
|
|
57
|
+
h1: { fontWeight: 600 },
|
|
58
|
+
h2: { fontWeight: 600 },
|
|
59
|
+
h3: { fontWeight: 600 },
|
|
60
|
+
h4: { fontWeight: 600 },
|
|
61
|
+
h5: { fontWeight: 600 },
|
|
62
|
+
h6: { fontWeight: 600 },
|
|
63
|
+
button: { fontWeight: 500, textTransform: "none" }
|
|
64
|
+
},
|
|
65
|
+
shape: {
|
|
66
|
+
borderRadius: 8
|
|
67
|
+
},
|
|
68
|
+
components: {
|
|
69
|
+
MuiPaper: {
|
|
70
|
+
styleOverrides: {
|
|
71
|
+
root: {
|
|
72
|
+
backgroundImage: "none"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
MuiButton: {
|
|
77
|
+
styleOverrides: {
|
|
78
|
+
root: {
|
|
79
|
+
textTransform: "none",
|
|
80
|
+
fontWeight: 600
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return n ? p(t, n) : p(t);
|
|
87
|
+
}, [s, n]);
|
|
88
|
+
return d(() => {
|
|
89
|
+
const e = document.documentElement, t = a.palette;
|
|
90
|
+
e.style.setProperty("--cp-primary-main", t.primary.main), e.style.setProperty("--cp-bg-default", t.background.default), e.style.setProperty("--cp-bg-paper", t.background.paper), e.style.setProperty("--cp-text-primary", t.text.primary), e.style.setProperty("--cp-text-secondary", t.text.secondary), e.style.setProperty("--cp-divider", t.divider);
|
|
91
|
+
}, [a]), d(() => {
|
|
92
|
+
const e = "codeplex-google-resources";
|
|
93
|
+
if (!document.getElementById(e)) {
|
|
94
|
+
const t = document.createElement("link");
|
|
95
|
+
t.id = e, t.rel = "stylesheet", t.href = "https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200", document.head.appendChild(t);
|
|
96
|
+
}
|
|
97
|
+
}, []), /* @__PURE__ */ y(b, { theme: a, children: [
|
|
98
|
+
/* @__PURE__ */ i(k, {}),
|
|
99
|
+
r
|
|
100
|
+
] });
|
|
101
|
+
};
|
|
102
|
+
function L() {
|
|
103
|
+
return "tema";
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
A as CodeplexProveedorMui,
|
|
107
|
+
C as CodeplexProveedorTema,
|
|
108
|
+
w as CodeplexThemeProvider,
|
|
109
|
+
m as ContextoTema,
|
|
110
|
+
W as ThemeContext,
|
|
111
|
+
L as tema,
|
|
112
|
+
u as usarTema,
|
|
113
|
+
I as useTheme
|
|
114
|
+
};
|
package/lib/ganchos.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { ThemeOptions } from '@mui/material';
|
|
3
|
+
import { CodeplexTema, ContextoTemaTipo } from './tipos';
|
|
4
|
+
export declare const ContextoTema: React.Context<ContextoTemaTipo | undefined>;
|
|
5
|
+
export interface CodeplexProveedorTemaProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
temaPorDefecto?: CodeplexTema;
|
|
8
|
+
}
|
|
9
|
+
export declare const CodeplexProveedorTema: React.FC<CodeplexProveedorTemaProps>;
|
|
10
|
+
export declare const CodeplexThemeProvider: ({ defaultTheme, ...props }: {
|
|
11
|
+
defaultTheme?: CodeplexTema;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const ThemeContext: React.Context<ContextoTemaTipo | undefined>;
|
|
15
|
+
export declare const usarTema: () => ContextoTemaTipo;
|
|
16
|
+
export declare const useTheme: () => ContextoTemaTipo;
|
|
17
|
+
export interface CodeplexProveedorMuiProps {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
sobrescrituraTema?: ThemeOptions;
|
|
20
|
+
}
|
|
21
|
+
export declare const CodeplexProveedorMui: React.FC<CodeplexProveedorMuiProps>;
|
package/lib/tema.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function tema(): string;
|
package/lib/tipos.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codeplex-sac/tema",
|
|
3
|
+
"version": "0.0.11",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./index.d.ts",
|
|
11
|
+
"import": "./index.js",
|
|
12
|
+
"require": "./index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"react": "^19.0.0",
|
|
20
|
+
"react-dom": "^19.0.0"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@emotion/react": "^11.14.0",
|
|
24
|
+
"@emotion/styled": "^11.14.1",
|
|
25
|
+
"@mui/material": "^7.3.7",
|
|
26
|
+
"@mui/system": "^7.3.7"
|
|
27
|
+
}
|
|
28
|
+
}
|