@tamagui/logo 1.14.0 → 1.14.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/dist/cjs/TamaguiLogo.js +208 -1
- package/dist/cjs/TamaguiLogo.js.map +2 -2
- package/dist/cjs/index.js +20 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/tints.js +76 -1
- package/dist/cjs/tints.js.map +2 -2
- package/dist/cjs/useTint.js +82 -1
- package/dist/cjs/useTint.js.map +2 -2
- package/dist/esm/TamaguiLogo.js +182 -1
- package/dist/esm/TamaguiLogo.js.map +2 -2
- package/dist/esm/TamaguiLogo.mjs +182 -1
- package/dist/esm/TamaguiLogo.mjs.map +2 -2
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +3 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/tints.js +48 -1
- package/dist/esm/tints.js.map +2 -2
- package/dist/esm/tints.mjs +48 -1
- package/dist/esm/tints.mjs.map +2 -2
- package/dist/esm/useTint.js +54 -1
- package/dist/esm/useTint.js.map +2 -2
- package/dist/esm/useTint.mjs +54 -1
- package/dist/esm/useTint.mjs.map +2 -2
- package/dist/jsx/TamaguiLogo.js +138 -1
- package/dist/jsx/TamaguiLogo.js.map +2 -2
- package/dist/jsx/TamaguiLogo.mjs +138 -1
- package/dist/jsx/TamaguiLogo.mjs.map +2 -2
- package/dist/jsx/index.js +3 -1
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +3 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/tints.js +48 -1
- package/dist/jsx/tints.js.map +2 -2
- package/dist/jsx/tints.mjs +48 -1
- package/dist/jsx/tints.mjs.map +2 -2
- package/dist/jsx/useTint.js +53 -1
- package/dist/jsx/useTint.js.map +2 -2
- package/dist/jsx/useTint.mjs +53 -1
- package/dist/jsx/useTint.mjs.map +2 -2
- package/package.json +3 -3
package/dist/jsx/index.js
CHANGED
package/dist/jsx/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx"],
|
|
4
4
|
"sourcesContent": ["export * from './TamaguiLogo'\nexport * from './tints'\nexport * from './useTint'\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/index.mjs
CHANGED
package/dist/jsx/index.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx"],
|
|
4
4
|
"sourcesContent": ["export * from './TamaguiLogo'\nexport * from './tints'\nexport * from './useTint'\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/tints.js
CHANGED
|
@@ -1,2 +1,49 @@
|
|
|
1
|
-
import{useEffect
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
const familiesValues = {
|
|
3
|
+
tamagui: ["orange", "yellow", "green", "blue", "purple", "pink", "red"],
|
|
4
|
+
xmas: ["red", "green", "red", "green", "red", "green", "red"],
|
|
5
|
+
easter: ["yellow", "pink", "yellow", "pink", "yellow", "pink", "yellow"]
|
|
6
|
+
};
|
|
7
|
+
const familiesNames = Object.keys(familiesValues);
|
|
8
|
+
const families = familiesValues;
|
|
9
|
+
let fam = "tamagui";
|
|
10
|
+
function getTints() {
|
|
11
|
+
return {
|
|
12
|
+
name: fam || "tamagui",
|
|
13
|
+
tints: families[fam] || families.tamagui,
|
|
14
|
+
families
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function useTints() {
|
|
18
|
+
const [val, setVal] = useState(getTints());
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
return onTintFamilyChange(() => {
|
|
21
|
+
setVal(getTints());
|
|
22
|
+
});
|
|
23
|
+
}, []);
|
|
24
|
+
return val;
|
|
25
|
+
}
|
|
26
|
+
const setTintFamily = (next) => {
|
|
27
|
+
if (!families[next])
|
|
28
|
+
throw `impossible`;
|
|
29
|
+
fam = next;
|
|
30
|
+
listeners.forEach((l) => l(next));
|
|
31
|
+
};
|
|
32
|
+
const setNextTintFamily = () => {
|
|
33
|
+
setTintFamily(familiesNames[(familiesNames.indexOf(fam) + 1) % familiesNames.length]);
|
|
34
|
+
};
|
|
35
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
36
|
+
const onTintFamilyChange = (cb) => {
|
|
37
|
+
listeners.add(cb);
|
|
38
|
+
return () => {
|
|
39
|
+
listeners.delete(cb);
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
getTints,
|
|
44
|
+
onTintFamilyChange,
|
|
45
|
+
setNextTintFamily,
|
|
46
|
+
setTintFamily,
|
|
47
|
+
useTints
|
|
48
|
+
};
|
|
2
49
|
//# sourceMappingURL=tints.js.map
|
package/dist/jsx/tints.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tints.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useEffect, useState } from 'react'\nimport { ThemeName } from 'tamagui'\n\nconst familiesValues = {\n tamagui: ['orange', 'yellow', 'green', 'blue', 'purple', 'pink', 'red'],\n xmas: ['red', 'green', 'red', 'green', 'red', 'green', 'red'],\n easter: ['yellow', 'pink', 'yellow', 'pink', 'yellow', 'pink', 'yellow'],\n}\n\ntype Family = keyof typeof familiesValues\n\nconst familiesNames = Object.keys(familiesValues) as any as Family[]\n\nconst families = familiesValues as {\n [key in Family]: ThemeName[]\n}\n\ntype TintFamily = keyof typeof families\n\nlet fam: TintFamily = 'tamagui'\n\nexport function getTints() {\n return {\n name: fam || 'tamagui',\n tints: families[fam] || families.tamagui,\n families,\n }\n}\n\nexport function useTints() {\n const [val, setVal] = useState(getTints())\n\n useEffect(() => {\n return onTintFamilyChange(() => {\n setVal(getTints())\n })\n }, [])\n\n return val\n}\n\nexport const setTintFamily = (next: TintFamily) => {\n if (!families[next]) throw `impossible`\n fam = next\n listeners.forEach((l) => l(next))\n}\n\nexport const setNextTintFamily = () => {\n setTintFamily(familiesNames[(familiesNames.indexOf(fam) + 1) % familiesNames.length])\n}\n\ntype ChangeHandler = (next: TintFamily) => void\n\nconst listeners = new Set<ChangeHandler>()\n\nexport const onTintFamilyChange = (cb: ChangeHandler) => {\n listeners.add(cb)\n return () => {\n listeners.delete(cb)\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,gBAAgB;AAGpC,MAAM,iBAAiB;AAAA,EACrB,SAAS,CAAC,UAAU,UAAU,SAAS,QAAQ,UAAU,QAAQ,KAAK;AAAA,EACtE,MAAM,CAAC,OAAO,SAAS,OAAO,SAAS,OAAO,SAAS,KAAK;AAAA,EAC5D,QAAQ,CAAC,UAAU,QAAQ,UAAU,QAAQ,UAAU,QAAQ,QAAQ;AACzE;AAIA,MAAM,gBAAgB,OAAO,KAAK,cAAc;AAEhD,MAAM,WAAW;AAMjB,IAAI,MAAkB;AAEf,SAAS,WAAW;AACzB,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,OAAO,SAAS,GAAG,KAAK,SAAS;AAAA,IACjC;AAAA,EACF;AACF;AAEO,SAAS,WAAW;AACzB,QAAM,CAAC,KAAK,MAAM,IAAI,SAAS,SAAS,CAAC;AAEzC,YAAU,MAAM;AACd,WAAO,mBAAmB,MAAM;AAC9B,aAAO,SAAS,CAAC;AAAA,IACnB,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;AAEO,MAAM,gBAAgB,CAAC,SAAqB;AACjD,MAAI,CAAC,SAAS,IAAI;AAAG,UAAM;AAC3B,QAAM;AACN,YAAU,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;AAClC;AAEO,MAAM,oBAAoB,MAAM;AACrC,gBAAc,eAAe,cAAc,QAAQ,GAAG,IAAI,KAAK,cAAc,MAAM,CAAC;AACtF;AAIA,MAAM,YAAY,oBAAI,IAAmB;AAElC,MAAM,qBAAqB,CAAC,OAAsB;AACvD,YAAU,IAAI,EAAE;AAChB,SAAO,MAAM;AACX,cAAU,OAAO,EAAE;AAAA,EACrB;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/jsx/tints.mjs
CHANGED
|
@@ -1,2 +1,49 @@
|
|
|
1
|
-
import{useEffect
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
const familiesValues = {
|
|
3
|
+
tamagui: ["orange", "yellow", "green", "blue", "purple", "pink", "red"],
|
|
4
|
+
xmas: ["red", "green", "red", "green", "red", "green", "red"],
|
|
5
|
+
easter: ["yellow", "pink", "yellow", "pink", "yellow", "pink", "yellow"]
|
|
6
|
+
};
|
|
7
|
+
const familiesNames = Object.keys(familiesValues);
|
|
8
|
+
const families = familiesValues;
|
|
9
|
+
let fam = "tamagui";
|
|
10
|
+
function getTints() {
|
|
11
|
+
return {
|
|
12
|
+
name: fam || "tamagui",
|
|
13
|
+
tints: families[fam] || families.tamagui,
|
|
14
|
+
families
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function useTints() {
|
|
18
|
+
const [val, setVal] = useState(getTints());
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
return onTintFamilyChange(() => {
|
|
21
|
+
setVal(getTints());
|
|
22
|
+
});
|
|
23
|
+
}, []);
|
|
24
|
+
return val;
|
|
25
|
+
}
|
|
26
|
+
const setTintFamily = (next) => {
|
|
27
|
+
if (!families[next])
|
|
28
|
+
throw `impossible`;
|
|
29
|
+
fam = next;
|
|
30
|
+
listeners.forEach((l) => l(next));
|
|
31
|
+
};
|
|
32
|
+
const setNextTintFamily = () => {
|
|
33
|
+
setTintFamily(familiesNames[(familiesNames.indexOf(fam) + 1) % familiesNames.length]);
|
|
34
|
+
};
|
|
35
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
36
|
+
const onTintFamilyChange = (cb) => {
|
|
37
|
+
listeners.add(cb);
|
|
38
|
+
return () => {
|
|
39
|
+
listeners.delete(cb);
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
getTints,
|
|
44
|
+
onTintFamilyChange,
|
|
45
|
+
setNextTintFamily,
|
|
46
|
+
setTintFamily,
|
|
47
|
+
useTints
|
|
48
|
+
};
|
|
2
49
|
//# sourceMappingURL=tints.mjs.map
|
package/dist/jsx/tints.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tints.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useEffect, useState } from 'react'\nimport { ThemeName } from 'tamagui'\n\nconst familiesValues = {\n tamagui: ['orange', 'yellow', 'green', 'blue', 'purple', 'pink', 'red'],\n xmas: ['red', 'green', 'red', 'green', 'red', 'green', 'red'],\n easter: ['yellow', 'pink', 'yellow', 'pink', 'yellow', 'pink', 'yellow'],\n}\n\ntype Family = keyof typeof familiesValues\n\nconst familiesNames = Object.keys(familiesValues) as any as Family[]\n\nconst families = familiesValues as {\n [key in Family]: ThemeName[]\n}\n\ntype TintFamily = keyof typeof families\n\nlet fam: TintFamily = 'tamagui'\n\nexport function getTints() {\n return {\n name: fam || 'tamagui',\n tints: families[fam] || families.tamagui,\n families,\n }\n}\n\nexport function useTints() {\n const [val, setVal] = useState(getTints())\n\n useEffect(() => {\n return onTintFamilyChange(() => {\n setVal(getTints())\n })\n }, [])\n\n return val\n}\n\nexport const setTintFamily = (next: TintFamily) => {\n if (!families[next]) throw `impossible`\n fam = next\n listeners.forEach((l) => l(next))\n}\n\nexport const setNextTintFamily = () => {\n setTintFamily(familiesNames[(familiesNames.indexOf(fam) + 1) % familiesNames.length])\n}\n\ntype ChangeHandler = (next: TintFamily) => void\n\nconst listeners = new Set<ChangeHandler>()\n\nexport const onTintFamilyChange = (cb: ChangeHandler) => {\n listeners.add(cb)\n return () => {\n listeners.delete(cb)\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,gBAAgB;AAGpC,MAAM,iBAAiB;AAAA,EACrB,SAAS,CAAC,UAAU,UAAU,SAAS,QAAQ,UAAU,QAAQ,KAAK;AAAA,EACtE,MAAM,CAAC,OAAO,SAAS,OAAO,SAAS,OAAO,SAAS,KAAK;AAAA,EAC5D,QAAQ,CAAC,UAAU,QAAQ,UAAU,QAAQ,UAAU,QAAQ,QAAQ;AACzE;AAIA,MAAM,gBAAgB,OAAO,KAAK,cAAc;AAEhD,MAAM,WAAW;AAMjB,IAAI,MAAkB;AAEf,SAAS,WAAW;AACzB,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,OAAO,SAAS,GAAG,KAAK,SAAS;AAAA,IACjC;AAAA,EACF;AACF;AAEO,SAAS,WAAW;AACzB,QAAM,CAAC,KAAK,MAAM,IAAI,SAAS,SAAS,CAAC;AAEzC,YAAU,MAAM;AACd,WAAO,mBAAmB,MAAM;AAC9B,aAAO,SAAS,CAAC;AAAA,IACnB,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;AAEO,MAAM,gBAAgB,CAAC,SAAqB;AACjD,MAAI,CAAC,SAAS,IAAI;AAAG,UAAM;AAC3B,QAAM;AACN,YAAU,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;AAClC;AAEO,MAAM,oBAAoB,MAAM;AACrC,gBAAc,eAAe,cAAc,QAAQ,GAAG,IAAI,KAAK,cAAc,MAAM,CAAC;AACtF;AAIA,MAAM,YAAY,oBAAI,IAAmB;AAElC,MAAM,qBAAqB,CAAC,OAAsB;AACvD,YAAU,IAAI,EAAE;AAChB,SAAO,MAAM;AACX,cAAU,OAAO,EAAE;AAAA,EACrB;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/jsx/useTint.js
CHANGED
|
@@ -1,2 +1,54 @@
|
|
|
1
|
-
import{startTransition
|
|
1
|
+
import { startTransition, useMemo, useSyncExternalStore } from "react";
|
|
2
|
+
import { Theme } from "tamagui";
|
|
3
|
+
import { getTints, setNextTintFamily, useTints } from "./tints";
|
|
4
|
+
const initialTint = 3;
|
|
5
|
+
let current = initialTint;
|
|
6
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
7
|
+
const onTintChange = (listener) => {
|
|
8
|
+
listeners.add(listener);
|
|
9
|
+
return () => {
|
|
10
|
+
listeners.delete(listener);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const numTints = getTints().tints.length;
|
|
14
|
+
const setTintIndex = (next) => {
|
|
15
|
+
const val = next % numTints;
|
|
16
|
+
if (val === current)
|
|
17
|
+
return;
|
|
18
|
+
current = val;
|
|
19
|
+
startTransition(() => {
|
|
20
|
+
listeners.forEach((x) => x(val));
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const useTint = () => {
|
|
24
|
+
const index = useSyncExternalStore(
|
|
25
|
+
onTintChange,
|
|
26
|
+
() => current,
|
|
27
|
+
() => initialTint
|
|
28
|
+
);
|
|
29
|
+
const tintsContext = useTints();
|
|
30
|
+
const { tints } = tintsContext;
|
|
31
|
+
return {
|
|
32
|
+
...tintsContext,
|
|
33
|
+
tints: tintsContext.tints,
|
|
34
|
+
tintIndex: index,
|
|
35
|
+
tint: tints[index],
|
|
36
|
+
setTintIndex,
|
|
37
|
+
setNextTintFamily,
|
|
38
|
+
setNextTint: () => {
|
|
39
|
+
setTintIndex(index + 1);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const ThemeTint = (props) => {
|
|
44
|
+
const curTint = useTint().tint;
|
|
45
|
+
return <Theme name={props.disable ? null : curTint}>{useMemo(() => props.children, [props.children])}</Theme>;
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
ThemeTint,
|
|
49
|
+
initialTint,
|
|
50
|
+
onTintChange,
|
|
51
|
+
setTintIndex,
|
|
52
|
+
useTint
|
|
53
|
+
};
|
|
2
54
|
//# sourceMappingURL=useTint.js.map
|
package/dist/jsx/useTint.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useTint.tsx"],
|
|
4
4
|
"sourcesContent": ["import { startTransition, useMemo, useSyncExternalStore } from 'react'\nimport { Theme, ThemeName } from 'tamagui'\n\nimport { getTints, setNextTintFamily, useTints } from './tints'\n\n// TODO useSyncExternalStore\n\n// no localstorage because its not important to remember and causes a flicker\n// const tintVal = typeof localStorage !== 'undefined' ? localStorage.getItem('tint') : 0\n// const tint = tintVal ? +tintVal 0\nexport const initialTint = 3\n\nlet current = initialTint\n\nconst listeners = new Set<Function>()\n\nexport const onTintChange = (listener: (cur: number) => void) => {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n}\n\nconst numTints = getTints().tints.length\n\nexport const setTintIndex = (next: number) => {\n const val = next % numTints\n if (val === current) return\n current = val\n startTransition(() => {\n listeners.forEach((x) => x(val))\n })\n}\n\nexport const useTint = () => {\n const index = useSyncExternalStore(\n onTintChange,\n () => current,\n () => initialTint\n )\n const tintsContext = useTints()\n const { tints } = tintsContext\n\n return {\n ...tintsContext,\n tints: tintsContext.tints as ThemeName[],\n tintIndex: index,\n tint: tints[index] as ThemeName,\n setTintIndex,\n setNextTintFamily,\n setNextTint: () => {\n setTintIndex(index + 1)\n },\n } as const\n}\n\nexport const ThemeTint = (props: { children: any; disable?: boolean }) => {\n const curTint = useTint().tint\n return (\n <Theme name={props.disable ? null : curTint}>\n {/* */}\n {useMemo(() => props.children, [props.children])}\n </Theme>\n )\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB,SAAS,4BAA4B;AAC/D,SAAS,aAAwB;AAEjC,SAAS,UAAU,mBAAmB,gBAAgB;AAO/C,MAAM,cAAc;AAE3B,IAAI,UAAU;AAEd,MAAM,YAAY,oBAAI,IAAc;AAE7B,MAAM,eAAe,CAAC,aAAoC;AAC/D,YAAU,IAAI,QAAQ;AACtB,SAAO,MAAM;AACX,cAAU,OAAO,QAAQ;AAAA,EAC3B;AACF;AAEA,MAAM,WAAW,SAAS,EAAE,MAAM;AAE3B,MAAM,eAAe,CAAC,SAAiB;AAC5C,QAAM,MAAM,OAAO;AACnB,MAAI,QAAQ;AAAS;AACrB,YAAU;AACV,kBAAgB,MAAM;AACpB,cAAU,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;AAAA,EACjC,CAAC;AACH;AAEO,MAAM,UAAU,MAAM;AAC3B,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACA,QAAM,eAAe,SAAS;AAC9B,QAAM,EAAE,MAAM,IAAI;AAElB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,aAAa;AAAA,IACpB,WAAW;AAAA,IACX,MAAM,MAAM,KAAK;AAAA,IACjB;AAAA,IACA;AAAA,IACA,aAAa,MAAM;AACjB,mBAAa,QAAQ,CAAC;AAAA,IACxB;AAAA,EACF;AACF;AAEO,MAAM,YAAY,CAAC,UAAgD;AACxE,QAAM,UAAU,QAAQ,EAAE;AAC1B,SACE,CAAC,MAAM,MAAM,MAAM,UAAU,OAAO,UAEjC,QAAQ,MAAM,MAAM,UAAU,CAAC,MAAM,QAAQ,CAAC,EACjD,EAHC;AAKL;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/jsx/useTint.mjs
CHANGED
|
@@ -1,2 +1,54 @@
|
|
|
1
|
-
import{startTransition
|
|
1
|
+
import { startTransition, useMemo, useSyncExternalStore } from "react";
|
|
2
|
+
import { Theme } from "tamagui";
|
|
3
|
+
import { getTints, setNextTintFamily, useTints } from "./tints";
|
|
4
|
+
const initialTint = 3;
|
|
5
|
+
let current = initialTint;
|
|
6
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
7
|
+
const onTintChange = (listener) => {
|
|
8
|
+
listeners.add(listener);
|
|
9
|
+
return () => {
|
|
10
|
+
listeners.delete(listener);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const numTints = getTints().tints.length;
|
|
14
|
+
const setTintIndex = (next) => {
|
|
15
|
+
const val = next % numTints;
|
|
16
|
+
if (val === current)
|
|
17
|
+
return;
|
|
18
|
+
current = val;
|
|
19
|
+
startTransition(() => {
|
|
20
|
+
listeners.forEach((x) => x(val));
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const useTint = () => {
|
|
24
|
+
const index = useSyncExternalStore(
|
|
25
|
+
onTintChange,
|
|
26
|
+
() => current,
|
|
27
|
+
() => initialTint
|
|
28
|
+
);
|
|
29
|
+
const tintsContext = useTints();
|
|
30
|
+
const { tints } = tintsContext;
|
|
31
|
+
return {
|
|
32
|
+
...tintsContext,
|
|
33
|
+
tints: tintsContext.tints,
|
|
34
|
+
tintIndex: index,
|
|
35
|
+
tint: tints[index],
|
|
36
|
+
setTintIndex,
|
|
37
|
+
setNextTintFamily,
|
|
38
|
+
setNextTint: () => {
|
|
39
|
+
setTintIndex(index + 1);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const ThemeTint = (props) => {
|
|
44
|
+
const curTint = useTint().tint;
|
|
45
|
+
return <Theme name={props.disable ? null : curTint}>{useMemo(() => props.children, [props.children])}</Theme>;
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
ThemeTint,
|
|
49
|
+
initialTint,
|
|
50
|
+
onTintChange,
|
|
51
|
+
setTintIndex,
|
|
52
|
+
useTint
|
|
53
|
+
};
|
|
2
54
|
//# sourceMappingURL=useTint.mjs.map
|
package/dist/jsx/useTint.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useTint.tsx"],
|
|
4
4
|
"sourcesContent": ["import { startTransition, useMemo, useSyncExternalStore } from 'react'\nimport { Theme, ThemeName } from 'tamagui'\n\nimport { getTints, setNextTintFamily, useTints } from './tints'\n\n// TODO useSyncExternalStore\n\n// no localstorage because its not important to remember and causes a flicker\n// const tintVal = typeof localStorage !== 'undefined' ? localStorage.getItem('tint') : 0\n// const tint = tintVal ? +tintVal 0\nexport const initialTint = 3\n\nlet current = initialTint\n\nconst listeners = new Set<Function>()\n\nexport const onTintChange = (listener: (cur: number) => void) => {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n}\n\nconst numTints = getTints().tints.length\n\nexport const setTintIndex = (next: number) => {\n const val = next % numTints\n if (val === current) return\n current = val\n startTransition(() => {\n listeners.forEach((x) => x(val))\n })\n}\n\nexport const useTint = () => {\n const index = useSyncExternalStore(\n onTintChange,\n () => current,\n () => initialTint\n )\n const tintsContext = useTints()\n const { tints } = tintsContext\n\n return {\n ...tintsContext,\n tints: tintsContext.tints as ThemeName[],\n tintIndex: index,\n tint: tints[index] as ThemeName,\n setTintIndex,\n setNextTintFamily,\n setNextTint: () => {\n setTintIndex(index + 1)\n },\n } as const\n}\n\nexport const ThemeTint = (props: { children: any; disable?: boolean }) => {\n const curTint = useTint().tint\n return (\n <Theme name={props.disable ? null : curTint}>\n {/* */}\n {useMemo(() => props.children, [props.children])}\n </Theme>\n )\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB,SAAS,4BAA4B;AAC/D,SAAS,aAAwB;AAEjC,SAAS,UAAU,mBAAmB,gBAAgB;AAO/C,MAAM,cAAc;AAE3B,IAAI,UAAU;AAEd,MAAM,YAAY,oBAAI,IAAc;AAE7B,MAAM,eAAe,CAAC,aAAoC;AAC/D,YAAU,IAAI,QAAQ;AACtB,SAAO,MAAM;AACX,cAAU,OAAO,QAAQ;AAAA,EAC3B;AACF;AAEA,MAAM,WAAW,SAAS,EAAE,MAAM;AAE3B,MAAM,eAAe,CAAC,SAAiB;AAC5C,QAAM,MAAM,OAAO;AACnB,MAAI,QAAQ;AAAS;AACrB,YAAU;AACV,kBAAgB,MAAM;AACpB,cAAU,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;AAAA,EACjC,CAAC;AACH;AAEO,MAAM,UAAU,MAAM;AAC3B,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACA,QAAM,eAAe,SAAS;AAC9B,QAAM,EAAE,MAAM,IAAI;AAElB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,aAAa;AAAA,IACpB,WAAW;AAAA,IACX,MAAM,MAAM,KAAK;AAAA,IACjB;AAAA,IACA;AAAA,IACA,aAAa,MAAM;AACjB,mBAAa,QAAQ,CAAC;AAAA,IACxB;AAAA,EACF;AACF;AAEO,MAAM,YAAY,CAAC,UAAgD;AACxE,QAAM,UAAU,QAAQ,EAAE;AAC1B,SACE,CAAC,MAAM,MAAM,MAAM,UAAU,OAAO,UAEjC,QAAQ,MAAM,MAAM,UAAU,CAAC,MAAM,QAAQ,CAAC,EACjD,EAHC;AAKL;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/logo",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"react": "*"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"tamagui": "1.14.
|
|
23
|
+
"tamagui": "1.14.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@tamagui/build": "1.14.
|
|
26
|
+
"@tamagui/build": "1.14.2",
|
|
27
27
|
"react": "^18.2.0"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|