import { type ReactNode, useMemo } from "react";
import { SizableText, XStack, YStack } from "tamagui";
import { PresetContext, usePresetContext } from "./PresetContext";
import { defaultPreset } from "./presets";
import { Tint, useTintDepth } from "./Tint";
export default {
title: "Theme/Tint",
component: Tint,
parameters: {
status: { type: "beta" },
docs: {
description: {
component:
"Tint selects tints[(depth - 1) % tints.length] from the preset and wraps children in that Tamagui sub-theme. The swatch is a Tamagui stack painting $color5 / $color11, so the hue you see is the sub-theme, not the wrapper.",
},
},
},
};
/** Keeps the surrounding knobs, pins the tint family to defaultPreset's four names. */
function WithDefaultTints({ children }: { children: ReactNode }) {
const parent = usePresetContext();
const value = useMemo(
() => ({
preset: { ...(parent?.preset ?? defaultPreset), tints: defaultPreset.tints },
overrides: parent?.overrides,
}),
[parent],
);
return {children};
}
function Swatch({ label }: { label?: string }) {
const depth = useTintDepth();
return (
{label ?? "depth"} {depth}
);
}
/** Five nested Tints: orange, blue, purple, pink, then orange again (modulo). */
export const main = {
name: "Main",
render: () => (
),
};
/** `alt` offsets the depth; `disable` keeps the depth but drops the Theme wrapper. */
export const altAndDisable = {
name: "Alt and disable",
render: () => (
),
};