@tamagui/logo 2.0.0-rc.11 → 2.0.0-rc.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/logo",
3
- "version": "2.0.0-rc.11",
3
+ "version": "2.0.0-rc.12",
4
4
  "source": "src/index.tsx",
5
5
  "files": [
6
6
  "src",
@@ -42,12 +42,12 @@
42
42
  "clean:build": "tamagui-build clean:build"
43
43
  },
44
44
  "dependencies": {
45
- "@tamagui/use-element-layout": "2.0.0-rc.11",
46
- "@tamagui/web": "2.0.0-rc.11",
47
- "tamagui": "2.0.0-rc.11"
45
+ "@tamagui/use-element-layout": "2.0.0-rc.12",
46
+ "@tamagui/web": "2.0.0-rc.12",
47
+ "tamagui": "2.0.0-rc.12"
48
48
  },
49
49
  "devDependencies": {
50
- "@tamagui/build": "2.0.0-rc.11",
50
+ "@tamagui/build": "2.0.0-rc.12",
51
51
  "react": ">=19"
52
52
  },
53
53
  "peerDependencies": {
@@ -4,8 +4,8 @@
4
4
  "sources": [
5
5
  "src/LogoIcon.tsx"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
9
  "import { YStack } from 'tamagui'\nimport { TamaguiIconSvg } from './TamaguiLogoSvg'\nimport type { JSX } from 'react/jsx-runtime'\n\nexport const LogoIcon = ({\n downscale = 2,\n color,\n}: {\n downscale?: number\n color?: string\n}): JSX.Element => {\n return (\n <YStack\n render=\"span\"\n className=\"unselectable\"\n alignSelf=\"center\"\n marginVertical={-10}\n pressStyle={{\n opacity: 0.7,\n scaleX: -1,\n }}\n >\n <TamaguiIconSvg\n className=\"tamagui-icon\"\n width={450 / 8 / downscale}\n height={420 / 8 / downscale}\n color={color}\n />\n </YStack>\n )\n}\n"
9
- ],
10
- "version": 3
10
+ ]
11
11
  }
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import type { XStackProps } from "tamagui";
3
- export declare const LogoWords: React.MemoExoticComponent<({ downscale, animated,...props }: XStackProps & {
3
+ export declare const LogoWords: React.MemoExoticComponent<({ downscale, animated, ...props }: XStackProps & {
4
4
  downscale?: number;
5
5
  animated?: boolean;
6
6
  }) => import("react/jsx-runtime").JSX.Element>;
@@ -1,13 +1,11 @@
1
1
  {
2
- "mappings": "AACA,OAAO,WAAoC;AAC3C,cAAc,mBAAmB;AA2BjC,OAAO,cAAMA,WAAW,MAAM,qBAC3B,EACC,WACA,SACA,GAAG,SACF,cAAc;CACf;CACA;aACW",
3
- "names": [
4
- "LogoWords: React.MemoExoticComponent<\n ({\n downscale,\n animated,\n ...props\n }: XStackProps & {\n downscale?: number\n animated?: boolean\n }) => import('react/jsx-runtime').JSX.Element\n>"
5
- ],
2
+ "mappings": "AACA,OAAO,WAAoC;AAC3C,cAAc,mBAAmB;AA2BjC,OAAO,cAAM,WAAW,MAAM,qBAC3B,EACC,WACA,UACA,GAAG,SACF,cAAc;CACf;CACA;aACW",
3
+ "names": [],
6
4
  "sources": [
7
5
  "src/LogoWords.tsx"
8
6
  ],
7
+ "version": 3,
9
8
  "sourcesContent": [
10
9
  "import type { LayoutValue } from '@tamagui/use-element-layout'\nimport React, { useEffect, useState } from 'react'\nimport type { XStackProps } from 'tamagui'\nimport { Circle, XStack } from 'tamagui'\nimport { useTint } from './useTint'\n\n// T A M A G U I\n// default: white white white white red green blue\n// hover: yellow yellow yellow color12 red green blue\nconst defaultColors = [\n 'var(--color12)',\n 'var(--color12)',\n 'var(--color12)',\n 'var(--color12)',\n 'var(--red9)',\n 'var(--green9)',\n 'var(--blue9)',\n]\n\nconst hoveredColors = [\n 'var(--yellow9)',\n 'var(--yellow9)',\n 'var(--yellow9)',\n 'var(--color12)',\n 'var(--red9)',\n 'var(--green9)',\n 'var(--blue9)',\n]\n\nexport const LogoWords: React.MemoExoticComponent<\n ({\n downscale,\n animated,\n ...props\n }: XStackProps & {\n downscale?: number\n animated?: boolean\n }) => import('react/jsx-runtime').JSX.Element\n> = React.memo(({ downscale = 1, animated, ...props }) => {\n const Tint = useTint()\n const [hovered, setHovered] = React.useState(false)\n const [mounted, setMounted] = React.useState<'start' | 'animate' | 'done'>('start')\n\n const { tintIndex: index } = Tint\n\n useEffect(() => {\n const idle = window.requestIdleCallback || setTimeout\n idle(() => {\n setTimeout(() => {\n setMounted('animate')\n }, 50)\n\n setTimeout(() => {\n setMounted('done')\n }, 1500)\n })\n }, [])\n\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const index = Number.parseInt(event.key, 10) - 1 // Convert key to index (0-based)\n if (!Number.isNaN(index) && index >= 0 && index < Tint.tints.length) {\n Tint.setTintIndex(index)\n }\n }\n\n window.addEventListener('keydown', handleKeyDown)\n\n return () => {\n window.removeEventListener('keydown', handleKeyDown)\n }\n }, [Tint])\n\n const getColor = (i: number) => {\n if (hovered) return `var(--${Tint.tints[i]}9)`\n return defaultColors[i]\n }\n\n const x = Math.round(\n index * 18.5 + (18 / 2) * (index / defaultColors.length) + 3 + (index === 6 ? -3 : 0)\n )\n\n const [layout, setLayout] = useState<LayoutValue>()\n\n return (\n <XStack\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n paddingVertical=\"$2\"\n data-tauri-drag-region\n marginVertical=\"$-2\"\n position=\"relative\"\n className=\"logo-words\"\n onLayout={(e) => {\n setLayout(e.nativeEvent.layout as any)\n }}\n // @ts-ignore\n onMouseMove={(e: MouseEvent) => {\n if (!layout) return\n const x = e.clientX - layout.pageX\n // Total width divided into 7 sections (one for each letter)\n const sectionWidth = layout.width / 7\n // Calculate which section we're in (0-6)\n const section = Math.min(6, Math.floor(x / sectionWidth))\n Tint.setTintIndex(section)\n }}\n {...props}\n >\n {animated && (\n <Circle\n transition=\"medium\"\n position=\"absolute\"\n top={0}\n left={0}\n y={mounted === 'start' ? -30 : -4}\n // the last i is less wide\n x={x}\n size={4}\n backgroundColor=\"$color12\"\n />\n )}\n\n <svg\n data-tauri-drag-region\n width={373 * (1 / downscale) * 0.3333333}\n height={41 * (1 / downscale) * 0.3333333}\n viewBox=\"0 0 373 41\"\n >\n <polygon\n data-tauri-drag-region\n shapeRendering=\"crispEdges\"\n fill={getColor(0)}\n points=\"24.3870968 40.1612903 24.3870968 8.67741935 32.2580645 8.67741935 32.2580645 0.806451613 0.774193548 0.806451613 0.774193548 8.67741935 8.64516129 8.67741935 8.64516129 40.1612903\"\n // onMouseEnter={() => Tint.setTintIndex(0)}\n />\n\n <path\n shapeRendering=\"crispEdges\"\n fill={getColor(1)}\n d=\"M87.3548387,0.806451613 L87.3548387,8.67741935 L95.2258065,8.67741935 L95.2258065,40.1612903 L79.483871,40.1612903 L79.483871,24.4193548 L71.6129032,24.4193548 L71.6129032,40.1612903 L55.8709677,40.1612903 L55.8709677,8.67741935 L63.7419355,8.67741935 L63.7419355,0.806451613 L87.3548387,0.806451613 Z M79.483871,8.67741935 L71.6129032,8.67741935 L71.6129032,16.5483871 L79.483871,16.5483871 L79.483871,8.67741935 Z\"\n fillRule=\"nonzero\"\n // onMouseEnter={() => Tint.setTintIndex(1)}\n />\n\n <polygon\n data-tauri-drag-region\n shapeRendering=\"crispEdges\"\n fill={getColor(2)}\n points=\"130.645161 40.1612903 130.645161 22.4516129 138.516129 22.4516129 138.516129 40.1612903 154.258065 40.1612903 154.258065 0.806451613 142.451613 0.806451613 142.451613 8.67741935 126.709677 8.67741935 126.709677 0.806451613 114.903226 0.806451613 114.903226 40.1612903\"\n // onMouseEnter={() => Tint.setTintIndex(2)}\n />\n\n <path\n fill={getColor(3)}\n d=\"M205.419355,0.806451613 L205.419355,8.67741935 L213.290323,8.67741935 L213.290323,40.1612903 L197.548387,40.1612903 L197.548387,24.4193548 L189.677419,24.4193548 L189.677419,40.1612903 L173.935484,40.1612903 L173.935484,8.67741935 L181.806452,8.67741935 L181.806452,0.806451613 L205.419355,0.806451613 Z M197.548387,8.67741935 L189.677419,8.67741935 L189.677419,16.5483871 L197.548387,16.5483871 L197.548387,8.67741935 Z\"\n fillRule=\"nonzero\"\n // onMouseEnter={() => Tint.setTintIndex(3)}\n />\n\n <polygon\n data-tauri-drag-region\n shapeRendering=\"crispEdges\"\n fill={getColor(4)}\n points=\"264.451613 40.1612903 264.451613 32.2903226 272.322581 32.2903226 272.322581 16.5483871 256.580645 16.5483871 256.580645 32.2903226 248.709677 32.2903226 248.709677 8.67741935 272.322581 8.67741935 272.322581 0.806451613 240.83871 0.806451613 240.83871 8.67741935 232.967742 8.67741935 232.967742 32.2903226 240.83871 32.2903226 240.83871 40.1612903\"\n // onMouseEnter={() => Tint.setTintIndex(4)}\n />\n\n <polygon\n data-tauri-drag-region\n shapeRendering=\"crispEdges\"\n fill={getColor(5)}\n points=\"323.483871 40.1612903 323.483871 32.2903226 331.354839 32.2903226 331.354839 0.806451613 315.612903 0.806451613 315.612903 32.2903226 307.741935 32.2903226 307.741935 0.806451613 292 0.806451613 292 32.2903226 299.870968 32.2903226 299.870968 40.1612903\"\n // onMouseEnter={() => Tint.setTintIndex(5)}\n />\n\n <polygon\n data-tauri-drag-region\n shapeRendering=\"crispEdges\"\n fill={getColor(6)}\n points=\"372.677419 40.1612903 372.677419 0.806451613 356.935484 0.806451613 356.935484 40.1612903\"\n // onMouseEnter={() => Tint.setTintIndex(6)}\n />\n </svg>\n </XStack>\n )\n})\n"
11
- ],
12
- "version": 3
10
+ ]
13
11
  }
@@ -4,8 +4,8 @@
4
4
  "sources": [
5
5
  "src/SeasonProvider.tsx"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
9
  "import type React from 'react'\nimport { useEffect } from 'react'\nimport { setTintFamily, type TintFamily } from './tints'\n\n// inline script that runs before hydration to set season class on html\n// auto-detects season from current date\nfunction getInlineScript() {\n return `(function(){\n var d = new Date();\n var m = d.getMonth();\n var day = d.getDate();\n var season = 'tamagui';\n\n if (m === 11 && day >= 14) season = 'xmas';\n else if (m === 9 && day >= 20) season = 'halloween';\n else if (m === 2 && day >= 10 && day <= 17) season = 'stpatricks';\n else if (m === 2 && day >= 30 || m === 3 && day <= 20) season = 'easter';\n else if (m === 1 && day >= 7 && day <= 14) season = 'valentine';\n else if (m === 0 && day >= 20 || m === 1 && day <= 12) season = 'lunar';\n\n if (season !== 'tamagui') {\n document.documentElement.classList.add(season + '-season');\n }\n window.__TAMAGUI_SEASON__ = season;\n})();`\n}\n\n// syncs the tint family with the value computed by the inline script\nfunction useSeasonSync() {\n useEffect(() => {\n const computed = (window as any).__TAMAGUI_SEASON__ as TintFamily | undefined\n if (computed) {\n setTintFamily(computed)\n }\n }, [])\n}\n\nexport function SeasonProvider({\n children,\n}: {\n children: React.ReactNode\n}): React.ReactNode {\n useSeasonSync()\n\n return (\n <>\n {/* disabled because were launchig v2 and its lunar new year */}\n {/* <script\n suppressHydrationWarning\n dangerouslySetInnerHTML={{\n __html: getInlineScript(),\n }}\n /> */}\n {children}\n </>\n )\n}\n"
9
- ],
10
- "version": 3
10
+ ]
11
11
  }
@@ -7,7 +7,7 @@ type LogoProps = {
7
7
  color?: string;
8
8
  ref?: any;
9
9
  } & XStackProps;
10
- export declare const TamaguiLogo: ({ showWords, downscale, animated, color, ref,...props }: LogoProps) => JSX.Element;
10
+ export declare const TamaguiLogo: ({ showWords, downscale, animated, color, ref, ...props }: LogoProps) => JSX.Element;
11
11
  export {};
12
12
 
13
13
  //# sourceMappingURL=TamaguiLogo.d.ts.map
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": "AAAA,cAAc,WAAW;AACzB,cAAc,mBAAmB;KAK5B,YAAY;CACf;CACA;CACA;CACA;CACA;IACE;AAEJ,OAAO,cAAM,cAAe,EAC1B,WACA,WACA,UACA,OACA,IACA,GAAG,SACF,cAAY,IAAI",
2
+ "mappings": "AAAA,cAAc,WAAW;AACzB,cAAc,mBAAmB;KAK5B,YAAY;CACf;CACA;CACA;CACA;CACA;IACE;AAEJ,OAAO,cAAM,cAAe,EAC1B,WACA,WACA,UACA,OACA,KACA,GAAG,SACF,cAAY,IAAI",
3
3
  "names": [],
4
4
  "sources": [
5
5
  "src/TamaguiLogo.tsx"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
9
  "import type { JSX } from 'react/jsx-runtime'\nimport type { XStackProps } from 'tamagui'\nimport { XStack, YStack } from 'tamagui'\nimport { LogoIcon } from './LogoIcon'\nimport { LogoWords } from './LogoWords'\n\ntype LogoProps = {\n showWords?: boolean\n downscale?: number\n animated?: boolean\n color?: string\n ref?: any\n} & XStackProps\n\nexport const TamaguiLogo = ({\n showWords,\n downscale,\n animated,\n color,\n ref,\n ...props\n}: LogoProps): JSX.Element => {\n return (\n <XStack\n render=\"span\"\n ref={ref}\n alignItems=\"center\"\n justifyContent=\"center\"\n gap=\"$5\"\n {...props}\n >\n <LogoIcon downscale={(downscale ?? 1) * (showWords ? 2 : 1.5)} color={color} />\n {showWords && (\n <YStack render=\"span\" marginBottom={-4}>\n <LogoWords animated={animated} downscale={downscale ?? 2} />\n </YStack>\n )}\n </XStack>\n )\n}\n"
9
- ],
10
- "version": 3
10
+ ]
11
11
  }
@@ -2,7 +2,7 @@ import type { JSX } from "react/jsx-runtime";
2
2
  type TamaguiIconSvgProps = React.SVGProps<SVGSVGElement> & {
3
3
  color?: string;
4
4
  };
5
- export declare const TamaguiIconSvg: ({ color,...props }: TamaguiIconSvgProps) => JSX.Element;
5
+ export declare const TamaguiIconSvg: ({ color, ...props }: TamaguiIconSvgProps) => JSX.Element;
6
6
  export {};
7
7
 
8
8
  //# sourceMappingURL=TamaguiLogoSvg.d.ts.map
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": "AAAA,cAAc,WAAW;KAEpB,sBAAsB,MAAM,SAAS,iBAAiB;CACzD;;AAGF,OAAO,cAAM,iBAAkB,EAC7B,MACA,GAAG,SACF,wBAAsB,IAAI",
2
+ "mappings": "AAAA,cAAc,WAAW;KAEpB,sBAAsB,MAAM,SAAS,iBAAiB;CACzD;;AAGF,OAAO,cAAM,iBAAkB,EAC7B,OACA,GAAG,SACF,wBAAsB,IAAI",
3
3
  "names": [],
4
4
  "sources": [
5
5
  "src/TamaguiLogoSvg.tsx"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
9
  "import type { JSX } from 'react/jsx-runtime'\n\ntype TamaguiIconSvgProps = React.SVGProps<SVGSVGElement> & {\n color?: string\n}\n\nexport const TamaguiIconSvg = ({\n color = '#ECD20A',\n ...props\n}: TamaguiIconSvgProps): JSX.Element => (\n <svg width=\"160px\" height=\"160px\" viewBox=\"0 0 160 160\" {...props}>\n <g id=\"duck\" stroke=\"none\" strokeWidth=\"1\" fill=\"none\" fillRule=\"evenodd\">\n <circle id=\"Oval\" cx=\"80\" cy=\"80\" r=\"145\"></circle>\n <g id=\"Group-Copy-5\">\n <path\n d=\"M10,110 L10,100 L20,100 L20,90 L30,90 L30,80 L40,80 L40,30 L50,30 L50,10 L70,10 L70,0 L120,0 L120,10 L130,10 L130,20 L140,20 L140,40 L160,40 L160,50 L150,50 L150,60 L160,60 L160,70 L150,70 L150,80 L140,80 L140,100 L150,100 L150,110 L160,110 L160,140 L150,140 L150,150 L130,150 L130,160 L40,160 L40,150 L20,150 L20,140 L10,140 L10,130 L0,130 L0,110 L10,110 Z M90,40 L80,40 L80,50 L90,50 L90,40 Z M120,30 L110,30 L110,40 L120,40 L120,30 Z\"\n id=\"Combined-Shape\"\n fill={color}\n ></path>\n <g id=\"Group\" transform=\"translate(80, 30)\" fill=\"#000000\">\n <rect id=\"Rectangle-Copy-117\" x=\"0\" y=\"10\" width=\"10\" height=\"10\"></rect>\n <rect id=\"Rectangle-Copy-141\" x=\"30\" y=\"0\" width=\"10\" height=\"10\"></rect>\n </g>\n </g>\n </g>\n </svg>\n)\n"
9
- ],
10
- "version": 3
10
+ ]
11
11
  }
@@ -1,9 +1,9 @@
1
1
  import { type ThemeProps } from "@tamagui/web";
2
2
  import type { JSX } from "react/jsx-runtime";
3
- export declare const ThemeTint: ({ disable, children,...rest }: ThemeProps & {
3
+ export declare const ThemeTint: ({ disable, children, ...rest }: ThemeProps & {
4
4
  disable?: boolean;
5
5
  }) => JSX.Element;
6
- export declare const ThemeTintAlt: ({ children, disable, offset,...rest }: ThemeProps & {
6
+ export declare const ThemeTintAlt: ({ children, disable, offset, ...rest }: ThemeProps & {
7
7
  disable?: boolean;
8
8
  offset?: number;
9
9
  }) => JSX.Element;
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": "AAAA,cAAc,kBAAyB;AACvC,cAAc,WAAW;AAGzB,OAAO,cAAM,YAAa,EACxB,SACA,SACA,GAAG,QACF,aAAa;CAAE;MAAsB,IAAI;AAU5C,OAAO,cAAM,eAAgB,EAC3B,UACA,SACA,OACA,GAAG,QACF,aAAa;CAAE;CAAmB;MAAoB,IAAI",
2
+ "mappings": "AAAA,cAAc,kBAAyB;AACvC,cAAc,WAAW;AAGzB,OAAO,cAAM,YAAa,EACxB,SACA,UACA,GAAG,QACF,aAAa;CAAE;MAAsB,IAAI;AAU5C,OAAO,cAAM,eAAgB,EAC3B,UACA,SACA,QACA,GAAG,QACF,aAAa;CAAE;CAAmB;MAAoB,IAAI",
3
3
  "names": [],
4
4
  "sources": [
5
5
  "src/ThemeTint.tsx"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
9
  "import { type ThemeProps, Theme } from '@tamagui/web'\nimport type { JSX } from 'react/jsx-runtime'\nimport { useTint } from './useTint'\n\nexport const ThemeTint = ({\n disable,\n children,\n ...rest\n}: ThemeProps & { disable?: boolean }): JSX.Element => {\n const curTint = useTint().tint\n\n return (\n <Theme {...rest} name={disable ? null : curTint}>\n {children}\n </Theme>\n )\n}\n\nexport const ThemeTintAlt = ({\n children,\n disable,\n offset = 1,\n ...rest\n}: ThemeProps & { disable?: boolean; offset?: number }): JSX.Element => {\n const curTint = useTint(offset).tintAlt\n const name = disable ? null : curTint\n return (\n <Theme name={name} {...rest}>\n {children}\n </Theme>\n )\n}\n"
9
- ],
10
- "version": 3
10
+ ]
11
11
  }
@@ -4,8 +4,8 @@
4
4
  "sources": [
5
5
  "src/index.tsx"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
9
  "export * from './TamaguiLogo'\nexport * from './LogoWords'\nexport * from './LogoIcon'\nexport * from './tints'\nexport * from './useTint'\nexport * from './ThemeTint'\nexport * from './SeasonProvider'\n"
9
- ],
10
- "version": 3
10
+ ]
11
11
  }
@@ -4,8 +4,8 @@
4
4
  "sources": [
5
5
  "src/tints.tsx"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
9
  "import React from 'react'\nimport type { ThemeName } from 'tamagui'\n\ntype ChangeHandler = (next: TintFamily) => void\n\nconst listeners = new Set<ChangeHandler>()\n\n// T A M A G U I\n// Maps to logo letters - index 3 (A) is the \"none\" theme position\nconst familiesValues = {\n tamagui: ['yellow', 'yellow', 'yellow', 'gray', 'red', 'green', 'blue'] as ThemeName[],\n xmas: ['red', 'green', 'red', 'green', 'red', 'green', 'red'] as ThemeName[],\n easter: [\n 'yellow',\n 'yellow',\n 'yellow',\n 'yellow',\n 'yellow',\n 'yellow',\n 'yellow',\n ] as ThemeName[],\n halloween: [\n 'yellow',\n 'gray',\n 'yellow',\n 'gray',\n 'yellow',\n 'gray',\n 'yellow',\n ] as ThemeName[],\n valentine: ['red', 'red', 'red', 'red', 'red', 'red', 'red'] as ThemeName[],\n lunar: ['yellow', 'red', 'red', 'red', 'red', 'red', 'yellow'] as ThemeName[],\n stpatricks: ['green', 'teal', 'green', 'teal', 'green', 'teal', 'green'] as ThemeName[],\n}\n\ntype Family = keyof typeof familiesValues\n\nconst DEFAULT_FAMILY: Family = 'tamagui'\n\nconst familiesNames = Object.keys(familiesValues) as any as Family[]\n\ntype Families = { [key in Family]: ThemeName[] }\nconst families = familiesValues as Families\n\nexport type TintFamily = keyof typeof families\n\nlet fam: TintFamily = DEFAULT_FAMILY\n\nexport function getTints(): {\n name: string\n tints: ThemeName[]\n families: Families\n} {\n return {\n name: fam || DEFAULT_FAMILY,\n tints: families[fam] || families.tamagui,\n families,\n }\n}\n\nexport function useTints(): {\n name: string\n tints: ThemeName[]\n families: Families\n} {\n const [val, setVal] = React.useState(getTints())\n\n React.useEffect(() => {\n return onTintFamilyChange(() => {\n React.startTransition(() => {\n setVal(getTints())\n })\n })\n }, [])\n\n return val\n}\n\nexport function setTintFamily(next: TintFamily): void {\n if (!families[next]) throw `impossible`\n fam = next\n\n // update DOM class for CSS-based styling (e.g., rainbow gradients)\n if (typeof document !== 'undefined') {\n const root = document.documentElement.classList\n // remove all season classes\n familiesNames.forEach((s) => {\n if (s !== 'tamagui') {\n root.remove(`${s}-season`)\n }\n })\n // add the new one if not tamagui\n if (next !== 'tamagui') {\n root.add(`${next}-season`)\n }\n }\n\n React.startTransition(() => {\n listeners.forEach((l) => l(next))\n })\n}\n\nexport const setNextTintFamily = (): void => {\n setTintFamily(familiesNames[(familiesNames.indexOf(fam) + 1) % familiesNames.length])\n}\n\nexport const onTintFamilyChange = (cb: ChangeHandler) => {\n listeners.add(cb)\n return (): void => {\n listeners.delete(cb)\n }\n}\n"
9
- ],
10
- "version": 3
10
+ ]
11
11
  }
@@ -1,13 +1,11 @@
1
1
  {
2
- "mappings": "AAAA,OAAO,WAA+D;AACtE,cAA+B,iBAAiB;AAShD,OAAO,cAAM,eAAgB,WAAW;AASxC,OAAO,cAAM,eAAgB;AAQ7B,OAAO,cAAM,sBAAuB;AAMpC,OAAO,cAAM;AAEb,OAAO,iBAAS,eAAe,mBAAmB,aAAa,OAAO;AAYtE,OAAO,cAAMA,oBAAoB,MAAM;AAEvC,OAAO,cAAM,UACX,uBACC;CACD,OAAO;CACP;CACA;CACA,MAAM;CACN,SAAS;CACT,eAAe;CACf;CACA;CACA,sBAAsB;CACtB;CACA;CACA,UAAU;EACR;EACA;EACA;EACA;EACA;EACA",
3
- "names": [
4
- "InitialPathContext: React.Context<number>"
5
- ],
2
+ "mappings": "AAAA,OAAO,WAA+D;AACtE,cAA+B,iBAAiB;AAShD,OAAO,cAAM,eAAgB,WAAW;AASxC,OAAO,cAAM,eAAgB;AAQ7B,OAAO,cAAM,sBAAuB;AAMpC,OAAO,cAAM;AAEb,OAAO,iBAAS,eAAe,mBAAmB,aAAa,OAAO;AAYtE,OAAO,cAAM,oBAAoB,MAAM;AAEvC,OAAO,cAAM,UACX,uBACC;CACD,OAAO;CACP;CACA;CACA,MAAM;CACN,SAAS;CACT,eAAe;CACf;CACA;CACA,sBAAsB;CACtB;CACA;CACA,UAAU;EACR;EACA;EACA;EACA;EACA;EACA",
3
+ "names": [],
6
4
  "sources": [
7
5
  "src/useTint.tsx"
8
6
  ],
7
+ "version": 3,
9
8
  "sourcesContent": [
10
9
  "import React, { createContext, useContext, useEffect, useState } from 'react'\nimport { useDidFinishSSR, type ThemeName } from 'tamagui'\nimport { getTints, setNextTintFamily, useTints } from './tints'\n\nlet current = 3\nlet disableTintTheme = false\n\nconst listeners = new Set<Function>()\nconst disableListeners = new Set<Function>()\n\nexport const onTintChange = (listener: (cur: number) => void) => {\n listeners.add(listener)\n return (): void => {\n listeners.delete(listener)\n }\n}\n\nconst numTints = getTints().tints.length\n\nexport const setTintIndex = (next: number): void => {\n const val = Math.max(0, next % numTints)\n if (val === current) return\n current = val\n listeners.forEach((x) => x(val))\n}\n\n// when true, useTint returns null for tint/tintAlt so ThemeTint doesn't apply sub-themes\nexport const setDisableTintTheme = (disable: boolean): void => {\n if (disable === disableTintTheme) return\n disableTintTheme = disable\n disableListeners.forEach((x) => x(disable))\n}\n\nexport const getDisableTintTheme = (): boolean => disableTintTheme\n\nexport function getDocsSection(pathname: string): 'compiler' | 'ui' | 'core' | null {\n return pathname === '/docs/intro/compiler-install' ||\n pathname === '/docs/intro/benchmarks' ||\n pathname === '/docs/intro/why-a-compiler'\n ? 'compiler'\n : pathname.startsWith('/ui/')\n ? 'ui'\n : pathname.startsWith('/docs/')\n ? 'core'\n : null\n}\n\nexport const InitialPathContext: React.Context<number> = createContext(3)\n\nexport const useTint = (\n altOffset = -1\n): {\n tints: ThemeName[]\n tintIndex: number\n tintAltIndex: number\n tint: ThemeName\n tintAlt: ThemeName\n setTintIndex: (next: number) => void\n setNextTintFamily: () => void\n setNextTint: () => void\n setDisableTintTheme: (disable: boolean) => void\n disableTintTheme: boolean\n name: string\n families: {\n tamagui: string[]\n xmas: string[]\n easter: string[]\n halloween: string[]\n valentine: string[]\n lunar: string[]\n }\n} => {\n const initial = useContext(InitialPathContext)\n const didHydrate = useDidFinishSSR()\n const [index, setIndex] = useState(didHydrate ? current : initial)\n const [disabled, setDisabled] = useState(disableTintTheme)\n const tintsContext = useTints()\n const { tints } = tintsContext\n const tintAltIndex = Math.abs((index + altOffset) % tints.length)\n\n useEffect(() => {\n return onTintChange((cur) => {\n setIndex(cur)\n })\n }, [])\n\n useEffect(() => {\n const cb = (val: boolean) => setDisabled(val)\n disableListeners.add(cb)\n return () => {\n disableListeners.delete(cb)\n }\n }, [])\n\n // return null for tint when disabled or at the \"none\" position (index 3)\n const tint = disabled || index === 3 ? null : tints[index]\n const tintAlt = disabled || tintAltIndex === 3 ? null : tints[tintAltIndex]\n\n return {\n ...tintsContext,\n tints: tintsContext.tints as ThemeName[],\n tintIndex: index,\n tintAltIndex,\n tint: tint as ThemeName,\n tintAlt: tintAlt as ThemeName,\n setTintIndex,\n setNextTintFamily,\n setDisableTintTheme,\n disableTintTheme: disabled,\n setNextTint: () => {\n React.startTransition(() => {\n setTintIndex(index + 1)\n })\n },\n } as const\n}\n"
11
- ],
12
- "version": 3
10
+ ]
13
11
  }