@pollinations/ui 0.1.0-alpha.34 → 0.1.0-alpha.35

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.
@@ -12,23 +12,23 @@ var tabButtonSizeClass = {
12
12
  sm: "polli:px-3 polli:py-1.5 polli:text-sm"
13
13
  };
14
14
  var variantClasses = {
15
- // The default tab look: borderless and monochrome. Selected uses `bg-active`
16
- // — the same light resting fill as the site's normal buttons. Both states
17
- // deepen to `bg-hover` and use the theme's hover label color. Non-selected
18
- // uses the quiet `bg-subtle` token until then.
15
+ // The default tab look: borderless and monochrome. Selected is the `fill` /
16
+ // `on-fill` pair (the orange with dark text, both modes) and does not change
17
+ // on hover. Non-selected is the quiet `bg-subtle`; hover is a pale wash of
18
+ // the fill, so it previews the selection without outshining it.
19
19
  soft: {
20
20
  base: "",
21
- active: "polli:bg-theme-bg-active polli:text-theme-text-strong polli:hover:bg-theme-bg-hover polli:hover:text-theme-text-hover",
22
- mixed: "polli:bg-theme-bg-active/45 polli:text-theme-text-strong polli:hover:bg-theme-bg-hover polli:hover:text-theme-text-hover",
23
- inactive: "polli:bg-theme-bg-subtle polli:text-theme-text-base polli:hover:bg-theme-bg-hover polli:hover:text-theme-text-hover"
21
+ active: "polli:bg-theme-fill polli:text-theme-on-fill",
22
+ mixed: "polli:bg-theme-fill/45 polli:text-theme-text-strong polli:hover:bg-theme-fill polli:hover:text-theme-on-fill",
23
+ inactive: "polli:bg-theme-bg-subtle polli:text-theme-text-base polli:hover:bg-theme-fill-wash polli:hover:text-theme-text-strong"
24
24
  },
25
25
  // Transparent until hovered or selected — for multi-select toggles and
26
26
  // inline rows where a filled idle pill would read as a hard selection.
27
27
  ghost: {
28
28
  base: "polli:border polli:border-transparent",
29
- active: "polli:bg-theme-bg-active polli:text-theme-text-strong polli:hover:bg-theme-bg-hover polli:hover:text-theme-text-hover",
30
- mixed: "polli:bg-theme-bg-active/45 polli:text-theme-text-strong polli:hover:bg-theme-bg-hover polli:hover:text-theme-text-hover",
31
- inactive: "polli:bg-transparent polli:text-theme-text-base polli:hover:bg-theme-bg-hover polli:hover:text-theme-text-hover"
29
+ active: "polli:bg-theme-fill polli:text-theme-on-fill",
30
+ mixed: "polli:bg-theme-fill/45 polli:text-theme-text-strong polli:hover:bg-theme-fill polli:hover:text-theme-on-fill",
31
+ inactive: "polli:bg-transparent polli:text-theme-text-base polli:hover:bg-theme-fill-wash polli:hover:text-theme-text-strong"
32
32
  }
33
33
  };
34
34
  var intentClasses = {
@@ -40,11 +40,11 @@ var intentClasses = {
40
40
  active: "polli:bg-tier-pale polli:text-tier-deep",
41
41
  inactive: "polli:bg-transparent polli:text-tier-deep polli:hover:bg-tier-pale/60"
42
42
  },
43
- // Site navigation: the current page is the one full brand pill; hover
44
- // only previews it, so "where you are" never doubles up.
43
+ // Site navigation: the current page is the one full fill pill, like a
44
+ // selected tab; hover only previews it, so "where you are" never doubles up.
45
45
  brand: {
46
- active: "polli:bg-brand-accent polli:font-bold polli:text-brand-dark",
47
- inactive: "polli:bg-transparent polli:font-bold polli:text-theme-text-strong polli:hover:bg-brand-accent/60 polli:hover:text-brand-dark"
46
+ active: "polli:bg-theme-fill polli:font-bold polli:text-theme-on-fill",
47
+ inactive: "polli:bg-transparent polli:font-bold polli:text-theme-text-strong polli:hover:bg-theme-fill-wash"
48
48
  }
49
49
  };
50
50
  function TabButton({
@@ -109,4 +109,4 @@ function TabButton({
109
109
  export {
110
110
  TabButton
111
111
  };
112
- //# sourceMappingURL=chunk-ZLD4VLUG.js.map
112
+ //# sourceMappingURL=chunk-UG7KV4X3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/primitives/TabButton.tsx"],"sourcesContent":["import type {\n ComponentPropsWithoutRef,\n ElementType,\n MouseEvent as ReactMouseEvent,\n ReactNode,\n} from \"react\";\nimport { cn } from \"../lib/cn.ts\";\n\ntype TabButtonOwnProps = {\n /** `mixed`: a group toggle where only some of its items are selected. */\n active: boolean | \"mixed\";\n /** Omit when rendering as a link (`as`) and navigation carries the change. */\n onClick?: () => void;\n children: ReactNode;\n /** Leading icon, sized to the label like Button's. */\n icon?: ReactNode;\n size?: \"lg\" | \"md\" | \"sm\" | \"xs\";\n variant?: \"soft\" | \"ghost\";\n /**\n * `amber` and `green` fill the selected pill with the wallet's pale paid\n * and Quest Pollen chip colours, which read at the same strength together.\n * `brand` is site navigation: bold labels, the brand accent for the\n * current page and a lighter preview of it on hover.\n */\n intent?: \"neutral\" | \"amber\" | \"green\" | \"brand\";\n /** Muted secondary text after the label, e.g. a model's creator. */\n detail?: ReactNode;\n ariaLabel?: string;\n disabled?: boolean;\n className?: string;\n};\n\n/**\n * Polymorphic like Button, so a tab that navigates can render a real anchor\n * instead of a click handler — middle-click, right-click and crawlers all\n * depend on that. Defaults to <button>, so existing call sites are unchanged.\n */\nexport type TabButtonProps<T extends ElementType = \"button\"> =\n TabButtonOwnProps & { as?: T } & Omit<\n ComponentPropsWithoutRef<T>,\n keyof TabButtonOwnProps | \"as\"\n >;\n\n/**\n * Shared pill shape (no colors) — used by every TabButton variant.\n *\n * `transition-colors`, not `transition-all`: only background and text colour\n * change between the variants, and `all` additionally animates any layout\n * property that happens to differ — which is the usual cause of a control\n * jittering under the pointer on hover.\n */\nconst tabButtonBaseClass =\n \"polli-control polli:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:font-medium polli:leading-normal polli:transition-colors polli:duration-200\";\n\nconst tabButtonSizeClass = {\n xs: \"polli:px-2.5 polli:py-1 polli:text-xs\",\n lg: \"polli:px-5 polli:py-2 polli:text-lg\",\n md: \"polli:px-4 polli:py-1.5 polli:text-base\",\n sm: \"polli:px-3 polli:py-1.5 polli:text-sm\",\n} as const;\n\nconst variantClasses = {\n // The default tab look: borderless and monochrome. Selected is the `fill` /\n // `on-fill` pair (the orange with dark text, both modes) and does not change\n // on hover. Non-selected is the quiet `bg-subtle`; hover is a pale wash of\n // the fill, so it previews the selection without outshining it.\n soft: {\n base: \"\",\n active: \"polli:bg-theme-fill polli:text-theme-on-fill\",\n mixed: \"polli:bg-theme-fill/45 polli:text-theme-text-strong polli:hover:bg-theme-fill polli:hover:text-theme-on-fill\",\n inactive:\n \"polli:bg-theme-bg-subtle polli:text-theme-text-base polli:hover:bg-theme-fill-wash polli:hover:text-theme-text-strong\",\n },\n // Transparent until hovered or selected — for multi-select toggles and\n // inline rows where a filled idle pill would read as a hard selection.\n ghost: {\n base: \"polli:border polli:border-transparent\",\n active: \"polli:bg-theme-fill polli:text-theme-on-fill\",\n mixed: \"polli:bg-theme-fill/45 polli:text-theme-text-strong polli:hover:bg-theme-fill polli:hover:text-theme-on-fill\",\n inactive:\n \"polli:bg-transparent polli:text-theme-text-base polli:hover:bg-theme-fill-wash polli:hover:text-theme-text-strong\",\n },\n} as const;\n\n// Wallet chip pairs: selected fills with the pale tint and deep label; hover\n// previews that fill. Unselected green keeps its green label so it stays\n// recognisable next to amber; unselected amber keeps the neutral label.\nconst intentClasses = {\n amber: {\n active: \"polli:bg-paid-pale polli:text-paid-deep\",\n inactive:\n \"polli:bg-transparent polli:text-theme-text-base polli:hover:bg-paid-pale/60\",\n },\n green: {\n active: \"polli:bg-tier-pale polli:text-tier-deep\",\n inactive:\n \"polli:bg-transparent polli:text-tier-deep polli:hover:bg-tier-pale/60\",\n },\n // Site navigation: the current page is the one full fill pill, like a\n // selected tab; hover only previews it, so \"where you are\" never doubles up.\n brand: {\n active: \"polli:bg-theme-fill polli:font-bold polli:text-theme-on-fill\",\n inactive:\n \"polli:bg-transparent polli:font-bold polli:text-theme-text-strong polli:hover:bg-theme-fill-wash\",\n },\n} as const;\n\nexport function TabButton<T extends ElementType = \"button\">({\n as,\n active,\n onClick,\n children,\n icon,\n size = \"md\",\n variant = \"soft\",\n intent,\n detail,\n ariaLabel,\n disabled = false,\n className,\n ...rest\n}: TabButtonProps<T>) {\n const Component: ElementType = as || \"button\";\n const isButton = Component === \"button\";\n const colors =\n intent === \"neutral\"\n ? variantClasses.soft\n : intent\n ? {\n ...intentClasses[intent],\n mixed: intentClasses[intent].active,\n }\n : variantClasses[variant];\n const handleClick = disabled\n ? (event: ReactMouseEvent) => {\n event.preventDefault();\n event.stopPropagation();\n }\n : onClick;\n\n return (\n <Component\n {...rest}\n {...(isButton ? { type: \"button\", disabled } : {})}\n {...(!isButton && disabled\n ? { \"aria-disabled\": true, tabIndex: -1 }\n : {})}\n {...(Component === \"a\" && disabled ? { href: undefined } : {})}\n onClick={handleClick}\n {...(ariaLabel !== undefined ? { \"aria-label\": ariaLabel } : {})}\n // aria-pressed is for toggles; a link that navigates announces its\n // selected state with aria-current instead.\n {...(isButton\n ? { \"aria-pressed\": active }\n : { \"aria-current\": active === true ? \"page\" : undefined })}\n className={cn(\n tabButtonBaseClass,\n variantClasses[variant].base,\n active === \"mixed\"\n ? colors.mixed\n : active\n ? colors.active\n : colors.inactive,\n disabled &&\n \"polli:pointer-events-none polli:cursor-not-allowed polli:opacity-50\",\n tabButtonSizeClass[size],\n className,\n )}\n >\n {icon && (\n <span\n aria-hidden=\"true\"\n className=\"polli:mr-1.5 polli:flex polli:size-4 polli:shrink-0 polli:[&>svg]:size-full\"\n >\n {icon}\n </span>\n )}\n {children}\n {detail != null && (\n <span className=\"polli:ml-1 polli:font-normal polli:opacity-70\">\n {detail}\n </span>\n )}\n </Component>\n );\n}\n"],"mappings":";;;;;AA6IQ,SA6BQ,KA7BR;AA1FR,IAAM,qBACF;AAEJ,IAAM,qBAAqB;AAAA,EACvB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACR;AAEA,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnB,MAAM;AAAA,IACF,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UACI;AAAA,EACR;AAAA;AAAA;AAAA,EAGA,OAAO;AAAA,IACH,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UACI;AAAA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