@tryghost/shade 0.1.0-alpha.55 → 0.1.0-alpha.57

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.
@@ -1,6 +1,5 @@
1
1
  import { calculateYAxisWidth, cn, formatNumber, getYRange } from "../../lib/ds-utils.js";
2
2
  import { formatDisplayDateWithRange } from "../../lib/date-utils.js";
3
- import { useShade } from "../../providers/shade-context.js";
4
3
  import { AlignedAxisTick, ChartContainer, ChartTooltip } from "../ui/chart.js";
5
4
  import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts";
6
5
  import { TrendingDown, TrendingUp } from "lucide-react";
@@ -51,7 +50,6 @@ var GhCustomTooltipContent = ({ active, payload, range, showHours, color }) => {
51
50
  });
52
51
  };
53
52
  var GhAreaChart = ({ data, range, yAxisRange, color = "var(--chart-blue)", id, className, syncId, allowDataOverflow = false, showYAxisValues = true, showHorizontalLines = true, dataFormatter = formatNumber, showHours = false, tooltipContent }) => {
54
- const { admin7Design } = useShade();
55
53
  const yRange = yAxisRange || [getYRange(data).min, getYRange(data).max];
56
54
  const chartConfig = { value: { label: data[0]?.label || "Value" } };
57
55
  const baseValue = yRange[0];
@@ -128,11 +126,11 @@ var GhAreaChart = ({ data, range, yAxisRange, color = "var(--chart-blue)", id, c
128
126
  children: [/* @__PURE__ */ jsx("stop", {
129
127
  offset: "5%",
130
128
  stopColor: color,
131
- stopOpacity: admin7Design ? .5 : .8
129
+ stopOpacity: .5
132
130
  }), /* @__PURE__ */ jsx("stop", {
133
131
  offset: "95%",
134
132
  stopColor: color,
135
- stopOpacity: admin7Design ? .5 : .1
133
+ stopOpacity: .5
136
134
  })]
137
135
  }) }),
138
136
  /* @__PURE__ */ jsx(Area, {
@@ -1 +1 @@
1
- {"version":3,"file":"gh-chart.js","names":[],"sources":["../../../src/components/patterns/gh-chart.tsx"],"sourcesContent":["import {\n calculateYAxisWidth,\n cn,\n formatDisplayDateWithRange,\n formatNumber,\n getYRange,\n} from '@/lib/utils';\nimport React from 'react';\nimport { AlignedAxisTick, ChartConfig, ChartContainer, ChartTooltip } from '@/components/ui/chart';\nimport { Area, AreaChart, CartesianGrid, XAxis, YAxis } from 'recharts';\nimport { TrendingDown, TrendingUp } from 'lucide-react';\nimport { useShade } from '@/providers/shade-context';\n\n// A Ghost specific charts for analytics re-using ShadCN/UI and Recharts components\n\ninterface TooltipPayload {\n value: number;\n payload: {\n date?: string;\n formattedValue?: string;\n label?: string;\n diffValue?: null | number;\n formattedDiffValue?: null | string;\n };\n}\n\ninterface TooltipProps {\n active?: boolean;\n payload?: TooltipPayload[];\n range?: number;\n showHours?: boolean;\n color?: string;\n}\n\nconst GhCustomTooltipContent = ({ active, payload, range, showHours, color }: TooltipProps) => {\n if (!active || !payload?.length) {\n return null;\n }\n\n const { date, formattedValue, label, diffValue, formattedDiffValue } = payload[0].payload;\n const displayValue = formattedValue || payload[0].value;\n\n return (\n <div className=\"min-w-[120px] rounded-lg border bg-background px-3 py-2 shadow-lg\">\n {date && (\n <div className=\"text-sm text-foreground\">\n {formatDisplayDateWithRange(date, range || 0, showHours)}\n </div>\n )}\n <div className=\"flex items-start gap-2\">\n <span\n className=\"mt-1.5 inline-block size-2 rounded-full opacity-50\"\n style={{ backgroundColor: color || 'var(--chart-blue)' }}\n ></span>\n <div className=\"flex grow items-start justify-between gap-5\">\n {label && <div className=\"text-sm text-muted-foreground\">{label}</div>}\n <div className=\"flex flex-col items-end font-mono font-medium\">\n {displayValue}\n\n {diffValue ? (\n diffValue < 0 && (\n <div className=\"flex items-center gap-0.5 text-state-danger\">\n <TrendingDown size={14} strokeWidth={1.5} />\n <span>{formattedDiffValue}</span>\n </div>\n )\n ) : (\n <></>\n )}\n {diffValue ? (\n diffValue > 0 && (\n <div className=\"flex items-center gap-0.5 text-state-success\">\n <TrendingUp size={14} strokeWidth={1.5} />\n <span>{formattedDiffValue}</span>\n </div>\n )\n ) : (\n <></>\n )}\n {/* {diffValue !== undefined ? diffValue === 0 && (\n <span>&mdash;</span>\n ) : <></>} */}\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport type GhAreaChartDataItem = {\n date: string;\n value: number;\n formattedValue: string;\n label: string;\n};\n\ninterface GhAreaChartProps {\n data: GhAreaChartDataItem[];\n range: number;\n yAxisRange?: [number, number];\n color?: string;\n id: string;\n className?: string;\n syncId?: string;\n allowDataOverflow?: boolean;\n showYAxisValues?: boolean;\n showHorizontalLines?: boolean;\n dataFormatter?: (value: number) => string;\n showHours?: boolean;\n tooltipContent?: React.ReactElement;\n}\n\nconst GhAreaChart: React.FC<GhAreaChartProps> = ({\n data,\n range,\n yAxisRange,\n color = 'var(--chart-blue)',\n id,\n className,\n syncId,\n allowDataOverflow = false,\n showYAxisValues = true,\n showHorizontalLines = true,\n dataFormatter = formatNumber,\n showHours = false,\n tooltipContent,\n}) => {\n const { admin7Design } = useShade();\n const yRange = yAxisRange || [getYRange(data).min, getYRange(data).max];\n const chartConfig = {\n value: {\n label: data[0]?.label || 'Value',\n },\n } satisfies ChartConfig;\n\n // Use yRange as domain and set baseValue to the minimum\n const baseValue = yRange[0];\n\n // Calculate midpoint and create ticks array\n const midValue = (yRange[0] + yRange[1]) / 2;\n const isWholeMid = Number.isInteger(midValue);\n const yTicks = isWholeMid ? [yRange[0], midValue, yRange[1]] : yRange;\n\n const xTickHoursOnly = showHours && range === 1;\n const xTicks = data.length > 0 ? [...new Set([data[0].date, data[data.length - 1].date])] : [];\n\n return (\n <ChartContainer className={cn('w-full', className)} config={chartConfig}>\n <AreaChart\n data={data}\n margin={{\n left: 4,\n right: 4,\n top: showHorizontalLines ? 24 : 4,\n }}\n syncId={syncId}\n >\n <CartesianGrid horizontal={showHorizontalLines} stroke=\"var(--border)\" vertical={false} />\n <XAxis\n axisLine={{ stroke: 'var(--border)', strokeWidth: 1 }}\n dataKey=\"date\"\n interval={0}\n tick={(props) => (\n <AlignedAxisTick\n {...props}\n formatter={(value) =>\n formatDisplayDateWithRange(String(value), range, showHours, xTickHoursOnly)\n }\n textAnchor={xTicks.length === 1 ? 'middle' : undefined}\n />\n )}\n tickFormatter={(value) => formatDisplayDateWithRange(String(value), range, showHours)}\n tickLine={false}\n tickMargin={10}\n ticks={xTicks}\n />\n <YAxis\n allowDataOverflow={allowDataOverflow}\n axisLine={false}\n domain={allowDataOverflow ? undefined : yRange}\n scale=\"linear\"\n tickFormatter={(value: number) => {\n return dataFormatter(value);\n }}\n tickLine={false}\n ticks={yTicks}\n width={showYAxisValues ? calculateYAxisWidth(yRange, dataFormatter) : 0}\n />\n <ChartTooltip\n content={\n tooltipContent || (\n <GhCustomTooltipContent color={color} range={range} showHours={showHours} />\n )\n }\n cursor={true}\n isAnimationActive={false}\n position={{ y: 10 }}\n />\n <defs>\n <linearGradient id={`fillChart-${id}`} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n {/* admin7Design charts are flat: an even tint under the line. */}\n <stop offset=\"5%\" stopColor={color} stopOpacity={admin7Design ? 0.5 : 0.8} />\n <stop offset=\"95%\" stopColor={color} stopOpacity={admin7Design ? 0.5 : 0.1} />\n </linearGradient>\n </defs>\n <Area\n baseValue={baseValue}\n dataKey=\"value\"\n fill={`url(#fillChart-${id})`}\n fillOpacity={0.2}\n isAnimationActive={false}\n stroke={color}\n strokeWidth={1.5}\n type=\"linear\"\n />\n </AreaChart>\n </ChartContainer>\n );\n};\n\nexport { GhAreaChart, GhCustomTooltipContent };\n\nexport type { TooltipProps };\n"],"mappings":";;;;;;;;;AAkCA,IAAM,0BAA0B,EAAE,QAAQ,SAAS,OAAO,WAAW,YAA0B;CAC7F,IAAI,CAAC,UAAU,CAAC,SAAS,QACvB,OAAO;CAGT,MAAM,EAAE,MAAM,gBAAgB,OAAO,WAAW,uBAAuB,QAAQ,EAAE,CAAC;CAClF,MAAM,eAAe,kBAAkB,QAAQ,EAAE,CAAC;CAElD,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACG,QACC,oBAAC,OAAD;GAAK,WAAU;a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;eAA/D,CAEE,oBAAC,QAAD;MAAM,QAAO;MAAK,WAAW;MAAO,aAAa,eAAe,KAAM;KAAM,CAAA,GAC5E,oBAAC,QAAD;MAAM,QAAO;MAAM,WAAW;MAAO,aAAa,eAAe,KAAM;KAAM,CAAA,CAC/D;OACZ,CAAA;IACN,oBAAC,MAAD;KACa;KACX,SAAQ;KACR,MAAM,kBAAkB,GAAG;KAC3B,aAAa;KACb,mBAAmB;KACnB,QAAQ;KACR,aAAa;KACb,MAAK;IACN,CAAA;GACQ;;CACG,CAAA;AAEpB"}
1
+ {"version":3,"file":"gh-chart.js","names":[],"sources":["../../../src/components/patterns/gh-chart.tsx"],"sourcesContent":["import {\n calculateYAxisWidth,\n cn,\n formatDisplayDateWithRange,\n formatNumber,\n getYRange,\n} from '@/lib/utils';\nimport React from 'react';\nimport { AlignedAxisTick, ChartConfig, ChartContainer, ChartTooltip } from '@/components/ui/chart';\nimport { Area, AreaChart, CartesianGrid, XAxis, YAxis } from 'recharts';\nimport { TrendingDown, TrendingUp } from 'lucide-react';\n\n// A Ghost specific charts for analytics re-using ShadCN/UI and Recharts components\n\ninterface TooltipPayload {\n value: number;\n payload: {\n date?: string;\n formattedValue?: string;\n label?: string;\n diffValue?: null | number;\n formattedDiffValue?: null | string;\n };\n}\n\ninterface TooltipProps {\n active?: boolean;\n payload?: TooltipPayload[];\n range?: number;\n showHours?: boolean;\n color?: string;\n}\n\nconst GhCustomTooltipContent = ({ active, payload, range, showHours, color }: TooltipProps) => {\n if (!active || !payload?.length) {\n return null;\n }\n\n const { date, formattedValue, label, diffValue, formattedDiffValue } = payload[0].payload;\n const displayValue = formattedValue || payload[0].value;\n\n return (\n <div className=\"min-w-[120px] rounded-lg border bg-background px-3 py-2 shadow-lg\">\n {date && (\n <div className=\"text-sm text-foreground\">\n {formatDisplayDateWithRange(date, range || 0, showHours)}\n </div>\n )}\n <div className=\"flex items-start gap-2\">\n <span\n className=\"mt-1.5 inline-block size-2 rounded-full opacity-50\"\n style={{ backgroundColor: color || 'var(--chart-blue)' }}\n ></span>\n <div className=\"flex grow items-start justify-between gap-5\">\n {label && <div className=\"text-sm text-muted-foreground\">{label}</div>}\n <div className=\"flex flex-col items-end font-mono font-medium\">\n {displayValue}\n\n {diffValue ? (\n diffValue < 0 && (\n <div className=\"flex items-center gap-0.5 text-state-danger\">\n <TrendingDown size={14} strokeWidth={1.5} />\n <span>{formattedDiffValue}</span>\n </div>\n )\n ) : (\n <></>\n )}\n {diffValue ? (\n diffValue > 0 && (\n <div className=\"flex items-center gap-0.5 text-state-success\">\n <TrendingUp size={14} strokeWidth={1.5} />\n <span>{formattedDiffValue}</span>\n </div>\n )\n ) : (\n <></>\n )}\n {/* {diffValue !== undefined ? diffValue === 0 && (\n <span>&mdash;</span>\n ) : <></>} */}\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport type GhAreaChartDataItem = {\n date: string;\n value: number;\n formattedValue: string;\n label: string;\n};\n\ninterface GhAreaChartProps {\n data: GhAreaChartDataItem[];\n range: number;\n yAxisRange?: [number, number];\n color?: string;\n id: string;\n className?: string;\n syncId?: string;\n allowDataOverflow?: boolean;\n showYAxisValues?: boolean;\n showHorizontalLines?: boolean;\n dataFormatter?: (value: number) => string;\n showHours?: boolean;\n tooltipContent?: React.ReactElement;\n}\n\nconst GhAreaChart: React.FC<GhAreaChartProps> = ({\n data,\n range,\n yAxisRange,\n color = 'var(--chart-blue)',\n id,\n className,\n syncId,\n allowDataOverflow = false,\n showYAxisValues = true,\n showHorizontalLines = true,\n dataFormatter = formatNumber,\n showHours = false,\n tooltipContent,\n}) => {\n const yRange = yAxisRange || [getYRange(data).min, getYRange(data).max];\n const chartConfig = {\n value: {\n label: data[0]?.label || 'Value',\n },\n } satisfies ChartConfig;\n\n // Use yRange as domain and set baseValue to the minimum\n const baseValue = yRange[0];\n\n // Calculate midpoint and create ticks array\n const midValue = (yRange[0] + yRange[1]) / 2;\n const isWholeMid = Number.isInteger(midValue);\n const yTicks = isWholeMid ? [yRange[0], midValue, yRange[1]] : yRange;\n\n const xTickHoursOnly = showHours && range === 1;\n const xTicks = data.length > 0 ? [...new Set([data[0].date, data[data.length - 1].date])] : [];\n\n return (\n <ChartContainer className={cn('w-full', className)} config={chartConfig}>\n <AreaChart\n data={data}\n margin={{\n left: 4,\n right: 4,\n top: showHorizontalLines ? 24 : 4,\n }}\n syncId={syncId}\n >\n <CartesianGrid horizontal={showHorizontalLines} stroke=\"var(--border)\" vertical={false} />\n <XAxis\n axisLine={{ stroke: 'var(--border)', strokeWidth: 1 }}\n dataKey=\"date\"\n interval={0}\n tick={(props) => (\n <AlignedAxisTick\n {...props}\n formatter={(value) =>\n formatDisplayDateWithRange(String(value), range, showHours, xTickHoursOnly)\n }\n textAnchor={xTicks.length === 1 ? 'middle' : undefined}\n />\n )}\n tickFormatter={(value) => formatDisplayDateWithRange(String(value), range, showHours)}\n tickLine={false}\n tickMargin={10}\n ticks={xTicks}\n />\n <YAxis\n allowDataOverflow={allowDataOverflow}\n axisLine={false}\n domain={allowDataOverflow ? undefined : yRange}\n scale=\"linear\"\n tickFormatter={(value: number) => {\n return dataFormatter(value);\n }}\n tickLine={false}\n ticks={yTicks}\n width={showYAxisValues ? calculateYAxisWidth(yRange, dataFormatter) : 0}\n />\n <ChartTooltip\n content={\n tooltipContent || (\n <GhCustomTooltipContent color={color} range={range} showHours={showHours} />\n )\n }\n cursor={true}\n isAnimationActive={false}\n position={{ y: 10 }}\n />\n <defs>\n <linearGradient id={`fillChart-${id}`} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n {/* Charts are flat: an even tint under the line. */}\n <stop offset=\"5%\" stopColor={color} stopOpacity={0.5} />\n <stop offset=\"95%\" stopColor={color} stopOpacity={0.5} />\n </linearGradient>\n </defs>\n <Area\n baseValue={baseValue}\n dataKey=\"value\"\n fill={`url(#fillChart-${id})`}\n fillOpacity={0.2}\n isAnimationActive={false}\n stroke={color}\n strokeWidth={1.5}\n type=\"linear\"\n />\n </AreaChart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AAO,cAAc,KAAK;KAC5B;KACA,UAAU;KACV,OAAO;KACP,OAAO,kBAAkB,oBAAoB,QAAQ,aAAa,IAAI;IACvE,CAAA;IACD,oBAAC,cAAD;KACE,SACE,kBACE,oBAAC,wBAAD;MAA+B;MAAc;MAAkB;KAAY,CAAA;KAG/E,QAAQ;KACR,mBAAmB;KACnB,UAAU,EAAE,GAAG,GAAG;IACnB,CAAA;IACD,oBAAC,QAAD,EAAA,UACE,qBAAC,kBAAD;KAAgB,IAAI,aAAa;KAAM,IAAG;KAAI,IAAG;KAAI,IAAG;KAAI,IAAG;eAA/D,CAEE,oBAAC,QAAD;MAAM,QAAO;MAAK,WAAW;MAAO,aAAa;KAAM,CAAA,GACvD,oBAAC,QAAD;MAAM,QAAO;MAAM,WAAW;MAAO,aAAa;KAAM,CAAA,CAC1C;OACZ,CAAA;IACN,oBAAC,MAAD;KACa;KACX,SAAQ;KACR,MAAM,kBAAkB,GAAG;KAC3B,aAAa;KACb,mBAAmB;KACnB,QAAQ;KACR,aAAa;KACb,MAAK;IACN,CAAA;GACQ;;CACG,CAAA;AAEpB"}
@@ -1,5 +1,4 @@
1
- import { cn, stringToHslColor, stringToTonalAvatarClasses } from "../../lib/ds-utils.js";
2
- import { useShade } from "../../providers/shade-context.js";
1
+ import { cn, stringToTonalAvatarClasses } from "../../lib/ds-utils.js";
3
2
  import { User } from "lucide-react";
4
3
  import * as React$1 from "react";
5
4
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -33,18 +32,14 @@ function ValidatedAvatarImage({ src }) {
33
32
  });
34
33
  }
35
34
  var Avatar = React$1.forwardRef(({ className, children, src, initials, colorSeed, ...props }, ref) => {
36
- const { admin7Design } = useShade();
37
35
  const hasInitials = !!initials;
38
36
  const seed = colorSeed || initials || "";
39
- const tonal = hasInitials && admin7Design;
40
- const bgColor = hasInitials && !tonal ? stringToHslColor(seed, "45", "55") : void 0;
41
37
  return /* @__PURE__ */ jsx(AvatarPrimitive.Root, {
42
38
  ref,
43
39
  className: cn("relative flex size-8 shrink-0 overflow-hidden rounded-full", className),
44
40
  ...props,
45
41
  children: children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(AvatarFallback, {
46
- className: cn("text-xs text-muted-foreground md:text-sm [&_svg]:size-3 md:[&_svg]:size-4", hasInitials && "font-semibold", hasInitials && (tonal ? stringToTonalAvatarClasses(seed) : "text-white")),
47
- style: bgColor ? { backgroundColor: bgColor } : void 0,
42
+ className: cn("text-xs text-muted-foreground md:text-sm [&_svg]:size-3 md:[&_svg]:size-4", hasInitials && "font-semibold", hasInitials && stringToTonalAvatarClasses(seed)),
48
43
  children: initials ?? /* @__PURE__ */ jsx(User, {})
49
44
  }), src && /* @__PURE__ */ jsx(ValidatedAvatarImage, { src })] })
50
45
  });
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.js","names":[],"sources":["../../../src/components/ui/avatar.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AvatarPrimitive from '@radix-ui/react-avatar';\nimport { User } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\nimport { stringToHslColor, stringToTonalAvatarClasses } from '@/lib/ds-utils';\nimport { useShade } from '@/providers/shade-context';\n\nconst AvatarImage = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Image>,\n React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>\n>(({ className, ...props }, ref) => (\n <AvatarPrimitive.Image\n ref={ref}\n className={cn('aspect-square size-full', className)}\n {...props}\n />\n));\nAvatarImage.displayName = AvatarPrimitive.Image.displayName;\n\nconst AvatarFallback = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Fallback>,\n React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>\n>(({ className, ...props }, ref) => (\n <AvatarPrimitive.Fallback\n ref={ref}\n className={cn(\n 'flex size-full items-center justify-center rounded-full bg-muted [&_svg]:size-4',\n className,\n )}\n {...props}\n />\n));\nAvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;\n\n// Gravatar's `d=blank` parameter returns a 1×1 transparent PNG when no avatar\n// exists for the given email. The HTTP response is 200, so Radix's AvatarImage\n// would treat it as a valid image and hide the fallback. We render the image\n// ourselves and only reveal it once it loads with non-trivial dimensions.\nfunction ValidatedAvatarImage({ src }: { src: string }) {\n const [loaded, setLoaded] = React.useState(false);\n\n React.useEffect(() => {\n setLoaded(false);\n }, [src]);\n\n return (\n <img\n alt=\"\"\n className={cn('absolute inset-0 size-full object-cover', !loaded && 'invisible')}\n src={src}\n onLoad={(e) => {\n const { naturalWidth, naturalHeight } = e.currentTarget;\n if (naturalWidth > 1 && naturalHeight > 1) {\n setLoaded(true);\n }\n }}\n />\n );\n}\n\ninterface AvatarProps extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> {\n src?: string | null;\n initials?: string | null;\n /**\n * Seeds the fallback background hue. Defaults to the initials, but callers\n * should pass the richer identity string they derived the initials from\n * (name/email) so distinct people keep distinct hues.\n */\n colorSeed?: string | null;\n}\n\nconst Avatar = React.forwardRef<React.ElementRef<typeof AvatarPrimitive.Root>, AvatarProps>(\n ({ className, children, src, initials, colorSeed, ...props }, ref) => {\n const { admin7Design } = useShade();\n const hasInitials = !!initials;\n const seed = colorSeed || initials || '';\n const tonal = hasInitials && admin7Design;\n const bgColor = hasInitials && !tonal ? stringToHslColor(seed, '45', '55') : undefined;\n\n return (\n <AvatarPrimitive.Root\n ref={ref}\n className={cn('relative flex size-8 shrink-0 overflow-hidden rounded-full', className)}\n {...props}\n >\n {children ?? (\n <>\n <AvatarFallback\n className={cn(\n 'text-xs text-muted-foreground md:text-sm [&_svg]:size-3 md:[&_svg]:size-4',\n hasInitials && 'font-semibold',\n hasInitials && (tonal ? stringToTonalAvatarClasses(seed) : 'text-white'),\n )}\n style={bgColor ? { backgroundColor: bgColor } : undefined}\n >\n {initials ?? <User />}\n </AvatarFallback>\n {src && <ValidatedAvatarImage src={src} />}\n </>\n )}\n </AvatarPrimitive.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BAAC,gBAAD;GACE,WAAW,GACT,6EACA,eAAe,iBACf,gBAAgB,QAAQ,2BAA2B,IAAI,IAAI,aAC7D;GACA,OAAO,UAAU,EAAE,iBAAiB,QAAQ,IAAI,KAAA;aAE/C,YAAY,oBAAC,MAAD,CAAO,CAAA;EACN,CAAA,GACf,OAAO,oBAAC,sBAAD,EAA2B,IAAM,CAAA,CACzC,EAAA,CAAA;CAEgB,CAAA;AAE1B,CACF;AACA,OAAO,cAAc,gBAAgB,KAAK"}
1
+ {"version":3,"file":"avatar.js","names":[],"sources":["../../../src/components/ui/avatar.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AvatarPrimitive from '@radix-ui/react-avatar';\nimport { User } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\nimport { stringToTonalAvatarClasses } from '@/lib/ds-utils';\n\nconst AvatarImage = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Image>,\n React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>\n>(({ className, ...props }, ref) => (\n <AvatarPrimitive.Image\n ref={ref}\n className={cn('aspect-square size-full', className)}\n {...props}\n />\n));\nAvatarImage.displayName = AvatarPrimitive.Image.displayName;\n\nconst AvatarFallback = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Fallback>,\n React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>\n>(({ className, ...props }, ref) => (\n <AvatarPrimitive.Fallback\n ref={ref}\n className={cn(\n 'flex size-full items-center justify-center rounded-full bg-muted [&_svg]:size-4',\n className,\n )}\n {...props}\n />\n));\nAvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;\n\n// Gravatar's `d=blank` parameter returns a 1×1 transparent PNG when no avatar\n// exists for the given email. The HTTP response is 200, so Radix's AvatarImage\n// would treat it as a valid image and hide the fallback. We render the image\n// ourselves and only reveal it once it loads with non-trivial dimensions.\nfunction ValidatedAvatarImage({ src }: { src: string }) {\n const [loaded, setLoaded] = React.useState(false);\n\n React.useEffect(() => {\n setLoaded(false);\n }, [src]);\n\n return (\n <img\n alt=\"\"\n className={cn('absolute inset-0 size-full object-cover', !loaded && 'invisible')}\n src={src}\n onLoad={(e) => {\n const { naturalWidth, naturalHeight } = e.currentTarget;\n if (naturalWidth > 1 && naturalHeight > 1) {\n setLoaded(true);\n }\n }}\n />\n );\n}\n\ninterface AvatarProps extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> {\n src?: string | null;\n initials?: string | null;\n /**\n * Seeds the fallback background hue. Defaults to the initials, but callers\n * should pass the richer identity string they derived the initials from\n * (name/email) so distinct people keep distinct hues.\n */\n colorSeed?: string | null;\n}\n\nconst Avatar = React.forwardRef<React.ElementRef<typeof AvatarPrimitive.Root>, AvatarProps>(\n ({ className, children, src, initials, colorSeed, ...props }, ref) => {\n const hasInitials = !!initials;\n const seed = colorSeed || initials || '';\n\n return (\n <AvatarPrimitive.Root\n ref={ref}\n className={cn('relative flex size-8 shrink-0 overflow-hidden rounded-full', className)}\n {...props}\n >\n {children ?? (\n <>\n <AvatarFallback\n className={cn(\n 'text-xs text-muted-foreground md:text-sm [&_svg]:size-3 md:[&_svg]:size-4',\n hasInitials && 'font-semibold',\n hasInitials && stringToTonalAvatarClasses(seed),\n )}\n >\n {initials ?? <User />}\n </AvatarFallback>\n {src && <ValidatedAvatarImage src={src} />}\n </>\n )}\n </AvatarPrimitive.Root>\n );\n },\n);\nAvatar.displayName = AvatarPrimitive.Root.displayName;\n\nexport { Avatar, AvatarImage, AvatarFallback };\n"],"mappings":";;;;;;AAOA,IAAM,cAAc,QAAM,YAGvB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,gBAAgB,OAAjB;CACO;CACL,WAAW,GAAG,2BAA2B,SAAS;CAClD,GAAI;AACL,CAAA,CACF;AACD,YAAY,cAAc,gBAAgB,MAAM;AAEhD,IAAM,iBAAiB,QAAM,YAG1B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,gBAAgB,UAAjB;CACO;CACL,WAAW,GACT,mFACA,SACF;CACA,GAAI;AACL,CAAA,CACF;AACD,eAAe,cAAc,gBAAgB,SAAS;AAMtD,SAAS,qBAAqB,EAAE,OAAwB;CACtD,MAAM,CAAC,QAAQ,aAAa,QAAM,SAAS,KAAK;CAEhD,QAAM,gBAAgB;EACpB,UAAU,KAAK;CACjB,GAAG,CAAC,GAAG,CAAC;CAER,OACE,oBAAC,OAAD;EACE,KAAI;EACJ,WAAW,GAAG,2CAA2C,CAAC,UAAU,WAAW;EAC1E;EACL,SAAS,MAAM;GACb,MAAM,EAAE,cAAc,kBAAkB,EAAE;GAC1C,IAAI,eAAe,KAAK,gBAAgB,GACtC,UAAU,IAAI;EAElB;CACD,CAAA;AAEL;AAaA,IAAM,SAAS,QAAM,YAClB,EAAE,WAAW,UAAU,KAAK,UAAU,WAAW,GAAG,SAAS,QAAQ;CACpE,MAAM,cAAc,CAAC,CAAC;CACtB,MAAM,OAAO,aAAa,YAAY;CAEtC,OACE,oBAAC,gBAAgB,MAAjB;EACO;EACL,WAAW,GAAG,8DAA8D,SAAS;EACrF,GAAI;YAEH,YACC,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,gBAAD;GACE,WAAW,GACT,6EACA,eAAe,iBACf,eAAe,2BAA2B,IAAI,CAChD;aAEC,YAAY,oBAAC,MAAD,CAAO,CAAA;EACN,CAAA,GACf,OAAO,oBAAC,sBAAD,EAA2B,IAAM,CAAA,CACzC,EAAA,CAAA;CAEgB,CAAA;AAE1B,CACF;AACA,OAAO,cAAc,gBAAgB,KAAK"}
@@ -108,7 +108,7 @@ var TONAL_AVATAR_CLASSES = [
108
108
  "bg-purple-200 text-purple-800 dark:bg-purple-800 dark:text-purple-200",
109
109
  "bg-pink-200 text-pink-800 dark:bg-pink-800 dark:text-pink-200"
110
110
  ];
111
- /** The admin7Design initials avatar colours: one palette family picked by the string's hash. */
111
+ /** Initials avatar colours: one palette family picked by the string's hash. */
112
112
  var stringToTonalAvatarClasses = (str) => TONAL_AVATAR_CLASSES[Math.abs(stringHash(str)) % TONAL_AVATAR_CLASSES.length];
113
113
  var getYRange = (data) => {
114
114
  if (!data.length) return {
@@ -1 +1 @@
1
- {"version":3,"file":"ds-utils.js","names":[],"sources":["../../src/lib/ds-utils.ts"],"sourcesContent":["import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/* Generic helper functions\n/* -------------------------------------------------------------------------- */\n\n// Helper to merge Tailwind classes\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n// Helper to debounce a function\nexport function debounce<T extends unknown[]>(\n func: (...args: T) => void,\n wait: number,\n immediate: boolean = false,\n): (...args: T) => void {\n let timeoutId: ReturnType<typeof setTimeout> | null;\n\n return function (this: unknown, ...args: T): void {\n const later = () => {\n timeoutId = null;\n if (!immediate) {\n func.apply(this, args);\n }\n };\n\n const callNow = immediate && !timeoutId;\n\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(later, wait);\n\n if (callNow) {\n func.apply(this, args);\n }\n };\n}\n\n// Helper to find scroll parent of element\nexport function getScrollParent(node: Node | null): HTMLElement | null {\n if (!node) {\n return null;\n }\n\n if (node instanceof HTMLElement) {\n const overflowY = window.getComputedStyle(node).overflowY;\n const isScrollable = overflowY !== 'visible' && overflowY !== 'hidden';\n\n if (isScrollable && node.scrollHeight >= node.clientHeight) {\n return node;\n }\n }\n\n return getScrollParent(node.parentNode) || document.body;\n}\n\n/* Data formatters\n/* -------------------------------------------------------------------------- */\n\n// Helper to convert kebab-case to PascalCase with numbers\nexport const kebabToPascalCase = (str: string): string => {\n const processed = str.replace(/[-_]([a-z0-9])/gi, (_, char) => char.toUpperCase());\n return processed.charAt(0).toUpperCase() + processed.slice(1);\n};\n\n// Helper function to format timestamp\nexport const formatTimestamp = (timestamp: string) => {\n const date = new Date(timestamp);\n const now = new Date();\n\n // Handle invalid dates\n if (isNaN(date.getTime())) {\n return 'Unknown';\n }\n\n // Both dates are now in the same timezone context (local)\n // The timestamp from DB is UTC but Date constructor handles the conversion\n const diffMs = now.getTime() - date.getTime();\n\n // Handle negative differences (future dates)\n if (diffMs < 0) {\n return 'Just now';\n }\n\n const diffMins = Math.floor(diffMs / (1000 * 60));\n const diffHours = Math.floor(diffMs / (1000 * 60 * 60));\n const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));\n\n if (diffMins < 1) {\n return 'Just now';\n } else if (diffMins < 60) {\n return `${diffMins} min ago`;\n } else if (diffHours < 24) {\n return `${diffHours} hr ago`;\n } else if (diffDays === 1) {\n return 'Yesterday';\n } else if (diffDays < 7) {\n return `${diffDays} days ago`;\n } else {\n return date.toLocaleDateString('en-US', {\n month: 'short',\n day: 'numeric',\n year: diffDays > 365 ? 'numeric' : undefined,\n });\n }\n};\n\n// Add thousands indicator to numbers\nexport const formatNumber = (\n value: number,\n options?: Pick<Intl.NumberFormatOptions, 'minimumFractionDigits' | 'maximumFractionDigits'>,\n): string => {\n if (isNaN(value) || !isFinite(value)) {\n return '0';\n }\n\n const formattedValue = options ? value : Math.round(value);\n return new Intl.NumberFormat('en-US', options).format(formattedValue);\n};\n\n// Abbreviate numbers\nexport function abbreviateNumber(number: number): string {\n const num = Number(number);\n\n if (Number.isNaN(num) || !Number.isFinite(number)) {\n return formatNumber(num);\n }\n\n if (num < 0) {\n return `-${abbreviateNumber(-num)}`;\n }\n\n if (num < 1000) {\n return formatNumber(num);\n }\n\n if (num < 1000000) {\n // For thousands: round to nearest 100 for 10.3k, nearest 1000 for 101k\n const roundTo = num < 100000 ? 100 : 1000;\n\n const rounded = Math.round(num / roundTo) * roundTo;\n const abbreviated = rounded / 1000;\n\n if (abbreviated === 1000) {\n return '1M';\n }\n\n const formatted = abbreviated % 1 === 0 ? abbreviated.toString() : abbreviated.toFixed(1);\n return `${formatted}k`;\n }\n\n // For millions: round to nearest 100,000 for 1.1M\n const roundTo = 100000;\n const rounded = Math.round(num / roundTo) * roundTo;\n const abbreviated = rounded / 1000000;\n const formatted = abbreviated % 1 === 0 ? abbreviated.toString() : abbreviated.toFixed(1);\n return `${formatted}M`;\n}\n\n// Format time duration\nexport const formatDuration = (seconds: number): string => {\n const hours = Math.floor(seconds / 3600);\n const minutes = Math.floor((seconds % 3600) / 60);\n const remainingSeconds = Math.floor(seconds % 60);\n\n if (hours <= 0) {\n if (minutes <= 0) {\n return `${remainingSeconds}s`;\n }\n return `${minutes}m ${remainingSeconds}s`;\n }\n\n return `${hours}h ${minutes}m ${remainingSeconds}s`;\n};\n\n// Format a fraction to percentage\nexport const formatPercentage = (value: number) => {\n const percentage = value * 100;\n if (percentage === 0) {\n return '0%';\n } else if (percentage < 0.1) {\n return `${percentage.toFixed(2)}%`;\n } else if (percentage < 1) {\n return `${percentage.toFixed(1)}%`;\n }\n const rounded = Math.round(percentage);\n return `${new Intl.NumberFormat('en-US').format(rounded)}%`;\n};\n\n// Converts a country code to corresponding flag emoji\nexport function getCountryFlag(countryCode: string) {\n if (\n !countryCode ||\n countryCode === null ||\n countryCode.toUpperCase() === 'NULL' ||\n countryCode === 'ᴺᵁᴸᴸ' ||\n countryCode === 'ᴺᵁ'\n ) {\n return '🏳️';\n }\n return countryCode\n .toUpperCase()\n .replace(/./g, (char) => String.fromCodePoint(char.charCodeAt(0) + 127397));\n}\n\nconst stringHash = (str: string) => {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = str.charCodeAt(i) + ((hash << 5) - hash);\n }\n return hash;\n};\n\nexport const stringToHslColor = (str: string, saturation: string, lightness: string) => {\n const h = stringHash(str) % 360;\n return 'hsl(' + h + ', ' + saturation + '%, ' + lightness + '%)';\n};\n\n// Tonal pairings (Shapeshifter style): a palette family's 200 behind its 800,\n// reversed in dark mode.\n// Written out in full so Tailwind generates every class.\nconst TONAL_AVATAR_CLASSES = [\n 'bg-red-200 text-red-800 dark:bg-red-800 dark:text-red-200',\n 'bg-orange-200 text-orange-800 dark:bg-orange-800 dark:text-orange-200',\n 'bg-yellow-200 text-yellow-800 dark:bg-yellow-800 dark:text-yellow-200',\n 'bg-green-200 text-green-800 dark:bg-green-800 dark:text-green-200',\n 'bg-blue-200 text-blue-800 dark:bg-blue-800 dark:text-blue-200',\n 'bg-purple-200 text-purple-800 dark:bg-purple-800 dark:text-purple-200',\n 'bg-pink-200 text-pink-800 dark:bg-pink-800 dark:text-pink-200',\n];\n\n/** The admin7Design initials avatar colours: one palette family picked by the string's hash. */\nexport const stringToTonalAvatarClasses = (str: string) =>\n TONAL_AVATAR_CLASSES[Math.abs(stringHash(str)) % TONAL_AVATAR_CLASSES.length];\n\n/* Chart formatters\n/* -------------------------------------------------------------------------- */\n\nexport const getYRange = (data: { value: number }[]): { min: number; max: number } => {\n if (!data.length) {\n return { min: 0, max: 1 };\n }\n\n const values = data.map((d) => Number(d.value));\n let min = Math.min(...values);\n let max = Math.max(...values);\n\n if (min === max) {\n const value = min;\n return { min: Math.max(0, value - 1), max: value + 1 };\n }\n\n // Use a percentage-based padding (10% of the range)\n const padding = 0.02;\n\n // Add padding and ensure min is not negative\n min = Math.max(0, min - min * padding);\n max = max + max * padding;\n\n const range = max - min;\n\n // Determine the order of magnitude for rounding based on the range\n const rangeMagnitude = Math.floor(Math.log10(range));\n // Always round to at least 10s, but use larger steps for bigger ranges\n // const roundTo = Math.max(10, Math.pow(10, rangeMagnitude));\n const roundTo = Math.pow(10, rangeMagnitude);\n\n // Round min and max to the appropriate precision\n const roundedMax = Math.round(max / roundTo) * roundTo;\n max = roundedMax < max ? Math.ceil(max / roundTo) * roundTo : roundedMax;\n\n const roundedMin = Math.round(min / roundTo) * roundTo;\n min = roundedMin > min ? Math.floor(min / roundTo) * roundTo : roundedMin;\n min = Math.max(0, min);\n\n // Ensure we have a visible range even after rounding\n if (min === max) {\n const midPoint = (min + max) / 2;\n const smallRange = Math.max(Math.abs(midPoint) * padding, roundTo);\n min = Math.max(0, Math.floor(midPoint - smallRange));\n max = Math.ceil(midPoint + smallRange);\n }\n\n // Final safety check to ensure min is never negative\n min = Math.max(0, min);\n\n return { min, max };\n};\n\n// Calculates the width needed for the Y-axis based on the formatted tick values\nexport const calculateYAxisWidth = (\n ticks: number[],\n formatter: (value: number) => string,\n): number => {\n if (!ticks.length) {\n return 40;\n }\n\n // Get the longest formatted tick value\n const maxFormattedLength = Math.max(...ticks.map((tick) => formatter(tick).length));\n\n // Approximate width based on character count (assuming monospace font)\n // Add padding for safety\n const width = Math.max(20, maxFormattedLength * 8 + 20);\n return width;\n};\n"],"mappings":";;;AAOA,SAAgB,GAAG,GAAG,QAAsB;CAC1C,OAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;AAGA,SAAgB,SACd,MACA,MACA,YAAqB,OACC;CACtB,IAAI;CAEJ,OAAO,SAAyB,GAAG,MAAe;EAChD,MAAM,cAAc;GAClB,YAAY;GACZ,IAAI,CAAC,WACH,KAAK,MAAM,MAAM,IAAI;EAEzB;EAEA,MAAM,UAAU,aAAa,CAAC;EAE9B,IAAI,WACF,aAAa,SAAS;EAGxB,YAAY,WAAW,OAAO,IAAI;EAElC,IAAI,SACF,KAAK,MAAM,MAAM,IAAI;CAEzB;AACF;AAGA,SAAgB,gBAAgB,MAAuC;CACrE,IAAI,CAAC,MACH,OAAO;CAGT,IAAI,gBAAgB,aAAa;EAC/B,MAAM,YAAY,OAAO,iBAAiB,IAAI,CAAC,CAAC;EAGhD,IAFqB,cAAc,aAAa,cAAc,YAE1C,KAAK,gBAAgB,KAAK,cAC5C,OAAO;CAEX;CAEA,OAAO,gBAAgB,KAAK,UAAU,KAAK,SAAS;AACtD;AAMA,IAAa,qBAAqB,QAAwB;CACxD,MAAM,YAAY,IAAI,QAAQ,qBAAqB,GAAG,SAAS,KAAK,YAAY,CAAC;CACjF,OAAO,UAAU,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,UAAU,MAAM,CAAC;AAC9D;AAGA,IAAa,mBAAmB,cAAsB;CACpD,MAAM,OAAO,IAAI,KAAK,SAAS;CAC/B,MAAM,sBAAM,IAAI,KAAK;CAGrB,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,IAAI,GAAG,KAAK,MAAM,WAAW,UAAU,CAAC;EACnD,MAAM,KAAK,KAAK,WAAW,UAAU;CACvC;CAGA,MAAM,KAAK,IAAI,GAAG,GAAG;CAErB,OAAO;EAAE;EAAK;CAAI;AACpB;AAGA,IAAa,uBACX,OACA,cACW;CACX,IAAI,CAAC,MAAM,QACT,OAAO;CAIT,MAAM,qBAAqB,KAAK,IAAI,GAAG,MAAM,KAAK,SAAS,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC;CAKlF,OADc,KAAK,IAAI,IAAI,qBAAqB,IAAI,EAC7C;AACT"}
1
+ {"version":3,"file":"ds-utils.js","names":[],"sources":["../../src/lib/ds-utils.ts"],"sourcesContent":["import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/* Generic helper functions\n/* -------------------------------------------------------------------------- */\n\n// Helper to merge Tailwind classes\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n// Helper to debounce a function\nexport function debounce<T extends unknown[]>(\n func: (...args: T) => void,\n wait: number,\n immediate: boolean = false,\n): (...args: T) => void {\n let timeoutId: ReturnType<typeof setTimeout> | null;\n\n return function (this: unknown, ...args: T): void {\n const later = () => {\n timeoutId = null;\n if (!immediate) {\n func.apply(this, args);\n }\n };\n\n const callNow = immediate && !timeoutId;\n\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(later, wait);\n\n if (callNow) {\n func.apply(this, args);\n }\n };\n}\n\n// Helper to find scroll parent of element\nexport function getScrollParent(node: Node | null): HTMLElement | null {\n if (!node) {\n return null;\n }\n\n if (node instanceof HTMLElement) {\n const overflowY = window.getComputedStyle(node).overflowY;\n const isScrollable = overflowY !== 'visible' && overflowY !== 'hidden';\n\n if (isScrollable && node.scrollHeight >= node.clientHeight) {\n return node;\n }\n }\n\n return getScrollParent(node.parentNode) || document.body;\n}\n\n/* Data formatters\n/* -------------------------------------------------------------------------- */\n\n// Helper to convert kebab-case to PascalCase with numbers\nexport const kebabToPascalCase = (str: string): string => {\n const processed = str.replace(/[-_]([a-z0-9])/gi, (_, char) => char.toUpperCase());\n return processed.charAt(0).toUpperCase() + processed.slice(1);\n};\n\n// Helper function to format timestamp\nexport const formatTimestamp = (timestamp: string) => {\n const date = new Date(timestamp);\n const now = new Date();\n\n // Handle invalid dates\n if (isNaN(date.getTime())) {\n return 'Unknown';\n }\n\n // Both dates are now in the same timezone context (local)\n // The timestamp from DB is UTC but Date constructor handles the conversion\n const diffMs = now.getTime() - date.getTime();\n\n // Handle negative differences (future dates)\n if (diffMs < 0) {\n return 'Just now';\n }\n\n const diffMins = Math.floor(diffMs / (1000 * 60));\n const diffHours = Math.floor(diffMs / (1000 * 60 * 60));\n const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));\n\n if (diffMins < 1) {\n return 'Just now';\n } else if (diffMins < 60) {\n return `${diffMins} min ago`;\n } else if (diffHours < 24) {\n return `${diffHours} hr ago`;\n } else if (diffDays === 1) {\n return 'Yesterday';\n } else if (diffDays < 7) {\n return `${diffDays} days ago`;\n } else {\n return date.toLocaleDateString('en-US', {\n month: 'short',\n day: 'numeric',\n year: diffDays > 365 ? 'numeric' : undefined,\n });\n }\n};\n\n// Add thousands indicator to numbers\nexport const formatNumber = (\n value: number,\n options?: Pick<Intl.NumberFormatOptions, 'minimumFractionDigits' | 'maximumFractionDigits'>,\n): string => {\n if (isNaN(value) || !isFinite(value)) {\n return '0';\n }\n\n const formattedValue = options ? value : Math.round(value);\n return new Intl.NumberFormat('en-US', options).format(formattedValue);\n};\n\n// Abbreviate numbers\nexport function abbreviateNumber(number: number): string {\n const num = Number(number);\n\n if (Number.isNaN(num) || !Number.isFinite(number)) {\n return formatNumber(num);\n }\n\n if (num < 0) {\n return `-${abbreviateNumber(-num)}`;\n }\n\n if (num < 1000) {\n return formatNumber(num);\n }\n\n if (num < 1000000) {\n // For thousands: round to nearest 100 for 10.3k, nearest 1000 for 101k\n const roundTo = num < 100000 ? 100 : 1000;\n\n const rounded = Math.round(num / roundTo) * roundTo;\n const abbreviated = rounded / 1000;\n\n if (abbreviated === 1000) {\n return '1M';\n }\n\n const formatted = abbreviated % 1 === 0 ? abbreviated.toString() : abbreviated.toFixed(1);\n return `${formatted}k`;\n }\n\n // For millions: round to nearest 100,000 for 1.1M\n const roundTo = 100000;\n const rounded = Math.round(num / roundTo) * roundTo;\n const abbreviated = rounded / 1000000;\n const formatted = abbreviated % 1 === 0 ? abbreviated.toString() : abbreviated.toFixed(1);\n return `${formatted}M`;\n}\n\n// Format time duration\nexport const formatDuration = (seconds: number): string => {\n const hours = Math.floor(seconds / 3600);\n const minutes = Math.floor((seconds % 3600) / 60);\n const remainingSeconds = Math.floor(seconds % 60);\n\n if (hours <= 0) {\n if (minutes <= 0) {\n return `${remainingSeconds}s`;\n }\n return `${minutes}m ${remainingSeconds}s`;\n }\n\n return `${hours}h ${minutes}m ${remainingSeconds}s`;\n};\n\n// Format a fraction to percentage\nexport const formatPercentage = (value: number) => {\n const percentage = value * 100;\n if (percentage === 0) {\n return '0%';\n } else if (percentage < 0.1) {\n return `${percentage.toFixed(2)}%`;\n } else if (percentage < 1) {\n return `${percentage.toFixed(1)}%`;\n }\n const rounded = Math.round(percentage);\n return `${new Intl.NumberFormat('en-US').format(rounded)}%`;\n};\n\n// Converts a country code to corresponding flag emoji\nexport function getCountryFlag(countryCode: string) {\n if (\n !countryCode ||\n countryCode === null ||\n countryCode.toUpperCase() === 'NULL' ||\n countryCode === 'ᴺᵁᴸᴸ' ||\n countryCode === 'ᴺᵁ'\n ) {\n return '🏳️';\n }\n return countryCode\n .toUpperCase()\n .replace(/./g, (char) => String.fromCodePoint(char.charCodeAt(0) + 127397));\n}\n\nconst stringHash = (str: string) => {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = str.charCodeAt(i) + ((hash << 5) - hash);\n }\n return hash;\n};\n\nexport const stringToHslColor = (str: string, saturation: string, lightness: string) => {\n const h = stringHash(str) % 360;\n return 'hsl(' + h + ', ' + saturation + '%, ' + lightness + '%)';\n};\n\n// Tonal pairings (Shapeshifter style): a palette family's 200 behind its 800,\n// reversed in dark mode.\n// Written out in full so Tailwind generates every class.\nconst TONAL_AVATAR_CLASSES = [\n 'bg-red-200 text-red-800 dark:bg-red-800 dark:text-red-200',\n 'bg-orange-200 text-orange-800 dark:bg-orange-800 dark:text-orange-200',\n 'bg-yellow-200 text-yellow-800 dark:bg-yellow-800 dark:text-yellow-200',\n 'bg-green-200 text-green-800 dark:bg-green-800 dark:text-green-200',\n 'bg-blue-200 text-blue-800 dark:bg-blue-800 dark:text-blue-200',\n 'bg-purple-200 text-purple-800 dark:bg-purple-800 dark:text-purple-200',\n 'bg-pink-200 text-pink-800 dark:bg-pink-800 dark:text-pink-200',\n];\n\n/** Initials avatar colours: one palette family picked by the string's hash. */\nexport const stringToTonalAvatarClasses = (str: string) =>\n TONAL_AVATAR_CLASSES[Math.abs(stringHash(str)) % TONAL_AVATAR_CLASSES.length];\n\n/* Chart formatters\n/* -------------------------------------------------------------------------- */\n\nexport const getYRange = (data: { value: number }[]): { min: number; max: number } => {\n if (!data.length) {\n return { min: 0, max: 1 };\n }\n\n const values = data.map((d) => Number(d.value));\n let min = Math.min(...values);\n let max = Math.max(...values);\n\n if (min === max) {\n const value = min;\n return { min: Math.max(0, value - 1), max: value + 1 };\n }\n\n // Use a percentage-based padding (10% of the range)\n const padding = 0.02;\n\n // Add padding and ensure min is not negative\n min = Math.max(0, min - min * padding);\n max = max + max * padding;\n\n const range = max - min;\n\n // Determine the order of magnitude for rounding based on the range\n const rangeMagnitude = Math.floor(Math.log10(range));\n // Always round to at least 10s, but use larger steps for bigger ranges\n // const roundTo = Math.max(10, Math.pow(10, rangeMagnitude));\n const roundTo = Math.pow(10, rangeMagnitude);\n\n // Round min and max to the appropriate precision\n const roundedMax = Math.round(max / roundTo) * roundTo;\n max = roundedMax < max ? Math.ceil(max / roundTo) * roundTo : roundedMax;\n\n const roundedMin = Math.round(min / roundTo) * roundTo;\n min = roundedMin > min ? Math.floor(min / roundTo) * roundTo : roundedMin;\n min = Math.max(0, min);\n\n // Ensure we have a visible range even after rounding\n if (min === max) {\n const midPoint = (min + max) / 2;\n const smallRange = Math.max(Math.abs(midPoint) * padding, roundTo);\n min = Math.max(0, Math.floor(midPoint - smallRange));\n max = Math.ceil(midPoint + smallRange);\n }\n\n // Final safety check to ensure min is never negative\n min = Math.max(0, min);\n\n return { min, max };\n};\n\n// Calculates the width needed for the Y-axis based on the formatted tick values\nexport const calculateYAxisWidth = (\n ticks: number[],\n formatter: (value: number) => string,\n): number => {\n if (!ticks.length) {\n return 40;\n }\n\n // Get the longest formatted tick value\n const maxFormattedLength = Math.max(...ticks.map((tick) => formatter(tick).length));\n\n // Approximate width based on character count (assuming monospace font)\n // Add padding for safety\n const width = Math.max(20, maxFormattedLength * 8 + 20);\n return width;\n};\n"],"mappings":";;;AAOA,SAAgB,GAAG,GAAG,QAAsB;CAC1C,OAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;AAGA,SAAgB,SACd,MACA,MACA,YAAqB,OACC;CACtB,IAAI;CAEJ,OAAO,SAAyB,GAAG,MAAe;EAChD,MAAM,cAAc;GAClB,YAAY;GACZ,IAAI,CAAC,WACH,KAAK,MAAM,MAAM,IAAI;EAEzB;EAEA,MAAM,UAAU,aAAa,CAAC;EAE9B,IAAI,WACF,aAAa,SAAS;EAGxB,YAAY,WAAW,OAAO,IAAI;EAElC,IAAI,SACF,KAAK,MAAM,MAAM,IAAI;CAEzB;AACF;AAGA,SAAgB,gBAAgB,MAAuC;CACrE,IAAI,CAAC,MACH,OAAO;CAGT,IAAI,gBAAgB,aAAa;EAC/B,MAAM,YAAY,OAAO,iBAAiB,IAAI,CAAC,CAAC;EAGhD,IAFqB,cAAc,aAAa,cAAc,YAE1C,KAAK,gBAAgB,KAAK,cAC5C,OAAO;CAEX;CAEA,OAAO,gBAAgB,KAAK,UAAU,KAAK,SAAS;AACtD;AAMA,IAA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,KAAK,MAAM,MAAM,OAAO,IAAI;CAC/C,MAAM,aAAa,MAAM,KAAK,MAAM,MAAM,OAAO,IAAI,UAAU;CAC/D,MAAM,KAAK,IAAI,GAAG,GAAG;CAGrB,IAAI,QAAQ,KAAK;EACf,MAAM,YAAY,MAAM,OAAO;EAC/B,MAAM,aAAa,KAAK,IAAI,KAAK,IAAI,QAAQ,IAAI,SAAS,OAAO;EACjE,MAAM,KAAK,IAAI,GAAG,KAAK,MAAM,WAAW,UAAU,CAAC;EACnD,MAAM,KAAK,KAAK,WAAW,UAAU;CACvC;CAGA,MAAM,KAAK,IAAI,GAAG,GAAG;CAErB,OAAO;EAAE;EAAK;CAAI;AACpB;AAGA,IAAa,uBACX,OACA,cACW;CACX,IAAI,CAAC,MAAM,QACT,OAAO;CAIT,MAAM,qBAAqB,KAAK,IAAI,GAAG,MAAM,KAAK,SAAS,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC;CAKlF,OADc,KAAK,IAAI,IAAI,qBAAqB,IAAI,EAC7C;AACT"}
package/es/tokens.js CHANGED
@@ -2,6 +2,9 @@
2
2
  var SHADE_TOKEN_NAMES = [
3
3
  "accent",
4
4
  "accent-foreground",
5
+ "action-accent",
6
+ "action-accent-foreground",
7
+ "action-accent-hover",
5
8
  "animate-accordion-down",
6
9
  "animate-accordion-up",
7
10
  "animate-fade-in",
@@ -48,6 +51,9 @@ var SHADE_TOKEN_NAMES = [
48
51
  "chart-yellow",
49
52
  "color-accent",
50
53
  "color-accent-foreground",
54
+ "color-action-accent",
55
+ "color-action-accent-foreground",
56
+ "color-action-accent-hover",
51
57
  "color-background",
52
58
  "color-black",
53
59
  "color-blue",
@@ -176,6 +182,8 @@ var SHADE_TOKEN_NAMES = [
176
182
  "color-purple-700",
177
183
  "color-purple-800",
178
184
  "color-purple-900",
185
+ "color-reaction-foreground",
186
+ "color-reaction-liked",
179
187
  "color-red",
180
188
  "color-red-100",
181
189
  "color-red-200",
@@ -329,6 +337,8 @@ var SHADE_TOKEN_NAMES = [
329
337
  "radius-trend-badge",
330
338
  "radius-xl",
331
339
  "radius-xs",
340
+ "reaction-foreground",
341
+ "reaction-liked",
332
342
  "ring",
333
343
  "secondary",
334
344
  "secondary-foreground",
package/es/tokens.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","names":[],"sources":["../src/tokens.ts"],"sourcesContent":["// Token helpers generated from Tailwind + runtime CSS variable surfaces.\nexport const SHADE_TOKEN_NAMES = [\n 'accent',\n 'accent-foreground',\n 'animate-accordion-down',\n 'animate-accordion-up',\n 'animate-fade-in',\n 'animate-fade-out',\n 'animate-modal-backdrop-in',\n 'animate-modal-in',\n 'animate-modal-in-from-right',\n 'animate-modal-in-reverse',\n 'animate-spin',\n 'animate-toaster-in',\n 'animate-toaster-out',\n 'animate-toaster-top-in',\n 'background',\n 'border',\n 'border-default',\n 'border-strong',\n 'breakpoint-lg',\n 'breakpoint-md',\n 'breakpoint-sidebar',\n 'breakpoint-sidebarlg',\n 'breakpoint-sm',\n 'breakpoint-tablet',\n 'breakpoint-xl',\n 'breakpoint-xxl',\n 'breakpoint-xxxl',\n 'card',\n 'card-foreground',\n 'character-count',\n 'chart-1',\n 'chart-2',\n 'chart-3',\n 'chart-4',\n 'chart-5',\n 'chart-amber',\n 'chart-blue',\n 'chart-darkblue',\n 'chart-darkgray',\n 'chart-gray',\n 'chart-green',\n 'chart-orange',\n 'chart-purple',\n 'chart-rose',\n 'chart-teal',\n 'chart-yellow',\n 'color-accent',\n 'color-accent-foreground',\n 'color-background',\n 'color-black',\n 'color-blue',\n 'color-blue-100',\n 'color-blue-200',\n 'color-blue-300',\n 'color-blue-400',\n 'color-blue-50',\n 'color-blue-500',\n 'color-blue-600',\n 'color-blue-700',\n 'color-blue-800',\n 'color-blue-900',\n 'color-border',\n 'color-border-default',\n 'color-border-strong',\n 'color-card',\n 'color-card-foreground',\n 'color-character-count',\n 'color-chart-1',\n 'color-chart-2',\n 'color-chart-3',\n 'color-chart-4',\n 'color-chart-5',\n 'color-chart-amber',\n 'color-chart-blue',\n 'color-chart-darkgray',\n 'color-chart-gray',\n 'color-chart-green',\n 'color-chart-orange',\n 'color-chart-purple',\n 'color-chart-rose',\n 'color-chart-teal',\n 'color-chart-yellow',\n 'color-current',\n 'color-destructive',\n 'color-destructive-foreground',\n 'color-event-email-icon',\n 'color-event-email-surface',\n 'color-event-engagement-icon',\n 'color-event-engagement-surface',\n 'color-event-gain-icon',\n 'color-event-gain-surface',\n 'color-event-gift-icon',\n 'color-event-gift-surface',\n 'color-event-loss-icon',\n 'color-event-loss-surface',\n 'color-event-warning-icon',\n 'color-event-warning-surface',\n 'color-focus-ring',\n 'color-foreground',\n 'color-ghostaccent',\n 'color-gray',\n 'color-gray-100',\n 'color-gray-200',\n 'color-gray-300',\n 'color-gray-400',\n 'color-gray-50',\n 'color-gray-500',\n 'color-gray-600',\n 'color-gray-700',\n 'color-gray-800',\n 'color-gray-900',\n 'color-gray-950',\n 'color-green',\n 'color-green-100',\n 'color-green-200',\n 'color-green-300',\n 'color-green-400',\n 'color-green-50',\n 'color-green-500',\n 'color-green-600',\n 'color-green-700',\n 'color-green-800',\n 'color-green-900',\n 'color-input',\n 'color-lime',\n 'color-lime-100',\n 'color-lime-200',\n 'color-lime-300',\n 'color-lime-400',\n 'color-lime-50',\n 'color-lime-500',\n 'color-lime-600',\n 'color-lime-700',\n 'color-lime-800',\n 'color-lime-900',\n 'color-map-surface',\n 'color-muted',\n 'color-muted-foreground',\n 'color-orange',\n 'color-orange-100',\n 'color-orange-200',\n 'color-orange-300',\n 'color-orange-400',\n 'color-orange-50',\n 'color-orange-500',\n 'color-orange-600',\n 'color-orange-700',\n 'color-orange-800',\n 'color-orange-900',\n 'color-pink',\n 'color-pink-100',\n 'color-pink-200',\n 'color-pink-300',\n 'color-pink-400',\n 'color-pink-50',\n 'color-pink-500',\n 'color-pink-600',\n 'color-pink-700',\n 'color-pink-800',\n 'color-pink-900',\n 'color-popover',\n 'color-popover-foreground',\n 'color-primary',\n 'color-primary-foreground',\n 'color-publish-accent',\n 'color-purple',\n 'color-purple-100',\n 'color-purple-200',\n 'color-purple-300',\n 'color-purple-400',\n 'color-purple-50',\n 'color-purple-500',\n 'color-purple-600',\n 'color-purple-700',\n 'color-purple-800',\n 'color-purple-900',\n 'color-red',\n 'color-red-100',\n 'color-red-200',\n 'color-red-300',\n 'color-red-400',\n 'color-red-50',\n 'color-red-500',\n 'color-red-600',\n 'color-red-700',\n 'color-red-800',\n 'color-red-900',\n 'color-ring',\n 'color-secondary',\n 'color-secondary-foreground',\n 'color-sidebar',\n 'color-sidebar-accent',\n 'color-sidebar-accent-foreground',\n 'color-sidebar-border',\n 'color-sidebar-foreground',\n 'color-sidebar-primary',\n 'color-sidebar-primary-foreground',\n 'color-sidebar-ring',\n 'color-state-danger',\n 'color-state-danger-foreground',\n 'color-state-info',\n 'color-state-info-foreground',\n 'color-state-success',\n 'color-state-success-foreground',\n 'color-state-warning',\n 'color-state-warning-border',\n 'color-state-warning-fill',\n 'color-state-warning-foreground',\n 'color-state-warning-surface',\n 'color-surface-elevated',\n 'color-surface-page',\n 'color-surface-panel',\n 'color-text-primary',\n 'color-text-secondary',\n 'color-text-tertiary',\n 'color-transparent',\n 'color-white',\n 'color-yellow',\n 'color-yellow-100',\n 'color-yellow-200',\n 'color-yellow-300',\n 'color-yellow-400',\n 'color-yellow-50',\n 'color-yellow-500',\n 'color-yellow-600',\n 'color-yellow-700',\n 'color-yellow-800',\n 'color-yellow-900',\n 'container-0',\n 'container-2xl',\n 'container-3xl',\n 'container-4xl',\n 'container-5xl',\n 'container-6xl',\n 'container-7xl',\n 'container-8xl',\n 'container-9xl',\n 'container-lg',\n 'container-md',\n 'container-page',\n 'container-pageminsidebar',\n 'container-prose',\n 'container-sm',\n 'container-xl',\n 'container-xs',\n 'control-height',\n 'control-height-lg',\n 'control-outline-pressed-shadow',\n 'control-outline-shadow',\n 'control-pressed-shadow',\n 'destructive',\n 'destructive-foreground',\n 'duration-base',\n 'duration-fast',\n 'duration-slow',\n 'ease-emphasized',\n 'ease-standard',\n 'event-email-icon',\n 'event-email-surface',\n 'event-engagement-icon',\n 'event-engagement-surface',\n 'event-gain-icon',\n 'event-gain-surface',\n 'event-gift-icon',\n 'event-gift-surface',\n 'event-loss-icon',\n 'event-loss-surface',\n 'event-warning-icon',\n 'event-warning-surface',\n 'field-border',\n 'field-chip-internal-border',\n 'field-chip-internal-surface',\n 'field-chip-surface',\n 'field-disabled-surface',\n 'field-readonly-surface',\n 'field-shadow',\n 'field-surface',\n 'focus-ring',\n 'font-body',\n 'font-code',\n 'font-heading',\n 'font-inherit',\n 'font-mono',\n 'font-sans',\n 'font-serif',\n 'font-weight-settings-heading',\n 'font-weight-title',\n 'foreground',\n 'input',\n 'input-group-radius',\n 'leading-base',\n 'leading-body',\n 'leading-heading',\n 'leading-loose',\n 'leading-none',\n 'leading-normal',\n 'leading-relaxed',\n 'leading-snug',\n 'leading-supertight',\n 'leading-tight',\n 'leading-tighter',\n 'map-surface',\n 'mobile-navbar-height',\n 'muted',\n 'muted-foreground',\n 'popover',\n 'popover-foreground',\n 'primary',\n 'primary-foreground',\n 'publish-accent',\n 'radius',\n 'radius-2xl',\n 'radius-3xl',\n 'radius-badge',\n 'radius-card',\n 'radius-control',\n 'radius-control-sm',\n 'radius-field',\n 'radius-full',\n 'radius-lg',\n 'radius-md',\n 'radius-menu',\n 'radius-menu-item',\n 'radius-pill',\n 'radius-sm',\n 'radius-surface',\n 'radius-trend-badge',\n 'radius-xl',\n 'radius-xs',\n 'ring',\n 'secondary',\n 'secondary-foreground',\n 'shadow',\n 'shadow-control-outline',\n 'shadow-control-outline-pressed',\n 'shadow-control-pressed',\n 'shadow-field',\n 'shadow-inner',\n 'shadow-lg',\n 'shadow-md',\n 'shadow-md-heavy',\n 'shadow-none',\n 'shadow-sm',\n 'shadow-xl',\n 'shadow-xs',\n 'sidebar-accent',\n 'sidebar-accent-foreground',\n 'sidebar-background',\n 'sidebar-border',\n 'sidebar-foreground',\n 'sidebar-primary',\n 'sidebar-primary-foreground',\n 'sidebar-ring',\n 'spacing',\n 'state-danger',\n 'state-danger-foreground',\n 'state-info',\n 'state-info-foreground',\n 'state-success',\n 'state-success-foreground',\n 'state-warning',\n 'state-warning-border',\n 'state-warning-fill',\n 'state-warning-foreground',\n 'state-warning-surface',\n 'surface-elevated',\n 'surface-page',\n 'surface-panel',\n 'tab-inactive',\n 'tab-inactive-hover',\n 'text-2xl',\n 'text-2xs',\n 'text-3xl',\n 'text-4xl',\n 'text-5xl',\n 'text-5xl--line-height',\n 'text-6xl',\n 'text-6xl--line-height',\n 'text-7xl',\n 'text-7xl--line-height',\n 'text-8xl',\n 'text-8xl--line-height',\n 'text-9xl',\n 'text-9xl--line-height',\n 'text-base',\n 'text-body-lg',\n 'text-body-md',\n 'text-body-sm',\n 'text-control',\n 'text-control-lg',\n 'text-field',\n 'text-lg',\n 'text-md',\n 'text-primary',\n 'text-secondary',\n 'text-section-heading',\n 'text-section-heading-lg',\n 'text-sm',\n 'text-tertiary',\n 'text-xl',\n 'text-xs',\n 'tracking-normal',\n 'tracking-section-heading',\n 'tracking-settings-heading',\n 'tracking-tight',\n 'tracking-tighter',\n 'tracking-tightest',\n 'tracking-wide',\n 'tracking-wider',\n 'tracking-widest',\n] as const;\n\nexport type ShadeTokenName = (typeof SHADE_TOKEN_NAMES)[number];\n\nexport const shadeToken = (name: ShadeTokenName): string => `var(--${name})`;\n"],"mappings":";AACA,IAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAa,cAAc,SAAiC,SAAS,KAAK"}
1
+ {"version":3,"file":"tokens.js","names":[],"sources":["../src/tokens.ts"],"sourcesContent":["// Token helpers generated from Tailwind + runtime CSS variable surfaces.\nexport const SHADE_TOKEN_NAMES = [\n 'accent',\n 'accent-foreground',\n 'action-accent',\n 'action-accent-foreground',\n 'action-accent-hover',\n 'animate-accordion-down',\n 'animate-accordion-up',\n 'animate-fade-in',\n 'animate-fade-out',\n 'animate-modal-backdrop-in',\n 'animate-modal-in',\n 'animate-modal-in-from-right',\n 'animate-modal-in-reverse',\n 'animate-spin',\n 'animate-toaster-in',\n 'animate-toaster-out',\n 'animate-toaster-top-in',\n 'background',\n 'border',\n 'border-default',\n 'border-strong',\n 'breakpoint-lg',\n 'breakpoint-md',\n 'breakpoint-sidebar',\n 'breakpoint-sidebarlg',\n 'breakpoint-sm',\n 'breakpoint-tablet',\n 'breakpoint-xl',\n 'breakpoint-xxl',\n 'breakpoint-xxxl',\n 'card',\n 'card-foreground',\n 'character-count',\n 'chart-1',\n 'chart-2',\n 'chart-3',\n 'chart-4',\n 'chart-5',\n 'chart-amber',\n 'chart-blue',\n 'chart-darkblue',\n 'chart-darkgray',\n 'chart-gray',\n 'chart-green',\n 'chart-orange',\n 'chart-purple',\n 'chart-rose',\n 'chart-teal',\n 'chart-yellow',\n 'color-accent',\n 'color-accent-foreground',\n 'color-action-accent',\n 'color-action-accent-foreground',\n 'color-action-accent-hover',\n 'color-background',\n 'color-black',\n 'color-blue',\n 'color-blue-100',\n 'color-blue-200',\n 'color-blue-300',\n 'color-blue-400',\n 'color-blue-50',\n 'color-blue-500',\n 'color-blue-600',\n 'color-blue-700',\n 'color-blue-800',\n 'color-blue-900',\n 'color-border',\n 'color-border-default',\n 'color-border-strong',\n 'color-card',\n 'color-card-foreground',\n 'color-character-count',\n 'color-chart-1',\n 'color-chart-2',\n 'color-chart-3',\n 'color-chart-4',\n 'color-chart-5',\n 'color-chart-amber',\n 'color-chart-blue',\n 'color-chart-darkgray',\n 'color-chart-gray',\n 'color-chart-green',\n 'color-chart-orange',\n 'color-chart-purple',\n 'color-chart-rose',\n 'color-chart-teal',\n 'color-chart-yellow',\n 'color-current',\n 'color-destructive',\n 'color-destructive-foreground',\n 'color-event-email-icon',\n 'color-event-email-surface',\n 'color-event-engagement-icon',\n 'color-event-engagement-surface',\n 'color-event-gain-icon',\n 'color-event-gain-surface',\n 'color-event-gift-icon',\n 'color-event-gift-surface',\n 'color-event-loss-icon',\n 'color-event-loss-surface',\n 'color-event-warning-icon',\n 'color-event-warning-surface',\n 'color-focus-ring',\n 'color-foreground',\n 'color-ghostaccent',\n 'color-gray',\n 'color-gray-100',\n 'color-gray-200',\n 'color-gray-300',\n 'color-gray-400',\n 'color-gray-50',\n 'color-gray-500',\n 'color-gray-600',\n 'color-gray-700',\n 'color-gray-800',\n 'color-gray-900',\n 'color-gray-950',\n 'color-green',\n 'color-green-100',\n 'color-green-200',\n 'color-green-300',\n 'color-green-400',\n 'color-green-50',\n 'color-green-500',\n 'color-green-600',\n 'color-green-700',\n 'color-green-800',\n 'color-green-900',\n 'color-input',\n 'color-lime',\n 'color-lime-100',\n 'color-lime-200',\n 'color-lime-300',\n 'color-lime-400',\n 'color-lime-50',\n 'color-lime-500',\n 'color-lime-600',\n 'color-lime-700',\n 'color-lime-800',\n 'color-lime-900',\n 'color-map-surface',\n 'color-muted',\n 'color-muted-foreground',\n 'color-orange',\n 'color-orange-100',\n 'color-orange-200',\n 'color-orange-300',\n 'color-orange-400',\n 'color-orange-50',\n 'color-orange-500',\n 'color-orange-600',\n 'color-orange-700',\n 'color-orange-800',\n 'color-orange-900',\n 'color-pink',\n 'color-pink-100',\n 'color-pink-200',\n 'color-pink-300',\n 'color-pink-400',\n 'color-pink-50',\n 'color-pink-500',\n 'color-pink-600',\n 'color-pink-700',\n 'color-pink-800',\n 'color-pink-900',\n 'color-popover',\n 'color-popover-foreground',\n 'color-primary',\n 'color-primary-foreground',\n 'color-publish-accent',\n 'color-purple',\n 'color-purple-100',\n 'color-purple-200',\n 'color-purple-300',\n 'color-purple-400',\n 'color-purple-50',\n 'color-purple-500',\n 'color-purple-600',\n 'color-purple-700',\n 'color-purple-800',\n 'color-purple-900',\n 'color-reaction-foreground',\n 'color-reaction-liked',\n 'color-red',\n 'color-red-100',\n 'color-red-200',\n 'color-red-300',\n 'color-red-400',\n 'color-red-50',\n 'color-red-500',\n 'color-red-600',\n 'color-red-700',\n 'color-red-800',\n 'color-red-900',\n 'color-ring',\n 'color-secondary',\n 'color-secondary-foreground',\n 'color-sidebar',\n 'color-sidebar-accent',\n 'color-sidebar-accent-foreground',\n 'color-sidebar-border',\n 'color-sidebar-foreground',\n 'color-sidebar-primary',\n 'color-sidebar-primary-foreground',\n 'color-sidebar-ring',\n 'color-state-danger',\n 'color-state-danger-foreground',\n 'color-state-info',\n 'color-state-info-foreground',\n 'color-state-success',\n 'color-state-success-foreground',\n 'color-state-warning',\n 'color-state-warning-border',\n 'color-state-warning-fill',\n 'color-state-warning-foreground',\n 'color-state-warning-surface',\n 'color-surface-elevated',\n 'color-surface-page',\n 'color-surface-panel',\n 'color-text-primary',\n 'color-text-secondary',\n 'color-text-tertiary',\n 'color-transparent',\n 'color-white',\n 'color-yellow',\n 'color-yellow-100',\n 'color-yellow-200',\n 'color-yellow-300',\n 'color-yellow-400',\n 'color-yellow-50',\n 'color-yellow-500',\n 'color-yellow-600',\n 'color-yellow-700',\n 'color-yellow-800',\n 'color-yellow-900',\n 'container-0',\n 'container-2xl',\n 'container-3xl',\n 'container-4xl',\n 'container-5xl',\n 'container-6xl',\n 'container-7xl',\n 'container-8xl',\n 'container-9xl',\n 'container-lg',\n 'container-md',\n 'container-page',\n 'container-pageminsidebar',\n 'container-prose',\n 'container-sm',\n 'container-xl',\n 'container-xs',\n 'control-height',\n 'control-height-lg',\n 'control-outline-pressed-shadow',\n 'control-outline-shadow',\n 'control-pressed-shadow',\n 'destructive',\n 'destructive-foreground',\n 'duration-base',\n 'duration-fast',\n 'duration-slow',\n 'ease-emphasized',\n 'ease-standard',\n 'event-email-icon',\n 'event-email-surface',\n 'event-engagement-icon',\n 'event-engagement-surface',\n 'event-gain-icon',\n 'event-gain-surface',\n 'event-gift-icon',\n 'event-gift-surface',\n 'event-loss-icon',\n 'event-loss-surface',\n 'event-warning-icon',\n 'event-warning-surface',\n 'field-border',\n 'field-chip-internal-border',\n 'field-chip-internal-surface',\n 'field-chip-surface',\n 'field-disabled-surface',\n 'field-readonly-surface',\n 'field-shadow',\n 'field-surface',\n 'focus-ring',\n 'font-body',\n 'font-code',\n 'font-heading',\n 'font-inherit',\n 'font-mono',\n 'font-sans',\n 'font-serif',\n 'font-weight-settings-heading',\n 'font-weight-title',\n 'foreground',\n 'input',\n 'input-group-radius',\n 'leading-base',\n 'leading-body',\n 'leading-heading',\n 'leading-loose',\n 'leading-none',\n 'leading-normal',\n 'leading-relaxed',\n 'leading-snug',\n 'leading-supertight',\n 'leading-tight',\n 'leading-tighter',\n 'map-surface',\n 'mobile-navbar-height',\n 'muted',\n 'muted-foreground',\n 'popover',\n 'popover-foreground',\n 'primary',\n 'primary-foreground',\n 'publish-accent',\n 'radius',\n 'radius-2xl',\n 'radius-3xl',\n 'radius-badge',\n 'radius-card',\n 'radius-control',\n 'radius-control-sm',\n 'radius-field',\n 'radius-full',\n 'radius-lg',\n 'radius-md',\n 'radius-menu',\n 'radius-menu-item',\n 'radius-pill',\n 'radius-sm',\n 'radius-surface',\n 'radius-trend-badge',\n 'radius-xl',\n 'radius-xs',\n 'reaction-foreground',\n 'reaction-liked',\n 'ring',\n 'secondary',\n 'secondary-foreground',\n 'shadow',\n 'shadow-control-outline',\n 'shadow-control-outline-pressed',\n 'shadow-control-pressed',\n 'shadow-field',\n 'shadow-inner',\n 'shadow-lg',\n 'shadow-md',\n 'shadow-md-heavy',\n 'shadow-none',\n 'shadow-sm',\n 'shadow-xl',\n 'shadow-xs',\n 'sidebar-accent',\n 'sidebar-accent-foreground',\n 'sidebar-background',\n 'sidebar-border',\n 'sidebar-foreground',\n 'sidebar-primary',\n 'sidebar-primary-foreground',\n 'sidebar-ring',\n 'spacing',\n 'state-danger',\n 'state-danger-foreground',\n 'state-info',\n 'state-info-foreground',\n 'state-success',\n 'state-success-foreground',\n 'state-warning',\n 'state-warning-border',\n 'state-warning-fill',\n 'state-warning-foreground',\n 'state-warning-surface',\n 'surface-elevated',\n 'surface-page',\n 'surface-panel',\n 'tab-inactive',\n 'tab-inactive-hover',\n 'text-2xl',\n 'text-2xs',\n 'text-3xl',\n 'text-4xl',\n 'text-5xl',\n 'text-5xl--line-height',\n 'text-6xl',\n 'text-6xl--line-height',\n 'text-7xl',\n 'text-7xl--line-height',\n 'text-8xl',\n 'text-8xl--line-height',\n 'text-9xl',\n 'text-9xl--line-height',\n 'text-base',\n 'text-body-lg',\n 'text-body-md',\n 'text-body-sm',\n 'text-control',\n 'text-control-lg',\n 'text-field',\n 'text-lg',\n 'text-md',\n 'text-primary',\n 'text-secondary',\n 'text-section-heading',\n 'text-section-heading-lg',\n 'text-sm',\n 'text-tertiary',\n 'text-xl',\n 'text-xs',\n 'tracking-normal',\n 'tracking-section-heading',\n 'tracking-settings-heading',\n 'tracking-tight',\n 'tracking-tighter',\n 'tracking-tightest',\n 'tracking-wide',\n 'tracking-wider',\n 'tracking-widest',\n] as const;\n\nexport type ShadeTokenName = (typeof SHADE_TOKEN_NAMES)[number];\n\nexport const shadeToken = (name: ShadeTokenName): string => `var(--${name})`;\n"],"mappings":";AACA,IAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAa,cAAc,SAAiC,SAAS,KAAK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/shade",
3
- "version": "0.1.0-alpha.55",
3
+ "version": "0.1.0-alpha.57",
4
4
  "description": "Ghost design system for React apps",
5
5
  "license": "MIT",
6
6
  "author": "Ghost Foundation",
package/styles.css CHANGED
@@ -95,15 +95,14 @@
95
95
  text-transform: uppercase;
96
96
  }
97
97
 
98
- /* admin7Design: banners are a flat color with darker shades of it for text and no
98
+ /* Colored banners are a flat color with darker shades of it for text and no
99
99
  outline. Text inside takes those shades, whichever tone it asks for. */
100
- [data-admin7-design='true']
101
- [data-slot='banner']:is(
102
- [data-variant='info'],
103
- [data-variant='success'],
104
- [data-variant='warning'],
105
- [data-variant='destructive']
106
- ) {
100
+ [data-slot='banner']:is(
101
+ [data-variant='info'],
102
+ [data-variant='success'],
103
+ [data-variant='warning'],
104
+ [data-variant='destructive']
105
+ ) {
107
106
  --foreground: var(--banner-foreground);
108
107
  --text-primary: var(--banner-foreground);
109
108
  --text-secondary: var(--banner-secondary);
@@ -114,25 +113,25 @@
114
113
  color: var(--banner-foreground);
115
114
  }
116
115
 
117
- [data-admin7-design='true'] [data-slot='banner'][data-variant='info'] {
116
+ [data-slot='banner'][data-variant='info'] {
118
117
  --banner-surface: var(--banner-info-surface);
119
118
  --banner-foreground: var(--banner-info-foreground);
120
119
  --banner-secondary: var(--banner-info-secondary);
121
120
  }
122
121
 
123
- [data-admin7-design='true'] [data-slot='banner'][data-variant='success'] {
122
+ [data-slot='banner'][data-variant='success'] {
124
123
  --banner-surface: var(--banner-success-surface);
125
124
  --banner-foreground: var(--banner-success-foreground);
126
125
  --banner-secondary: var(--banner-success-secondary);
127
126
  }
128
127
 
129
- [data-admin7-design='true'] [data-slot='banner'][data-variant='warning'] {
128
+ [data-slot='banner'][data-variant='warning'] {
130
129
  --banner-surface: var(--banner-warning-surface);
131
130
  --banner-foreground: var(--banner-warning-foreground);
132
131
  --banner-secondary: var(--banner-warning-secondary);
133
132
  }
134
133
 
135
- [data-admin7-design='true'] [data-slot='banner'][data-variant='destructive'] {
134
+ [data-slot='banner'][data-variant='destructive'] {
136
135
  --banner-surface: var(--banner-destructive-surface);
137
136
  --banner-foreground: var(--banner-destructive-foreground);
138
137
  --banner-secondary: var(--banner-destructive-secondary);
@@ -22,15 +22,14 @@
22
22
  --color-transparent: transparent;
23
23
  --color-current: currentColor;
24
24
  --color-white: oklch(100% 0 0);
25
- /* Admin 7 palette (admin7Design). Gray keeps Shade's lightness at each step
25
+ /* Shared color palette. Gray keeps Shade's lightness at each step
26
26
  and is a slightly cool neutral (hue 255, chroma 0.0032 at most, about an
27
27
  eighth of the previous slate greys). It departs from Shapeshifter's warm
28
28
  sand on purpose, so Admin doesn't read brown or dated. The
29
29
  colour families are Shapeshifter's ramps (TryGhost/shapeshifter
30
30
  src/styles/tokens.css at 53cd116): red, orange = coral, yellow,
31
31
  green = emerald, blue = sky, purple = indigo, pink. Lime has no
32
- Shapeshifter family and is unchanged. The previous palette lives in
33
- theme-variables.css under [data-admin7-design='false']. */
32
+ Shapeshifter family and is unchanged. */
34
33
  --color-black: oklch(16% 0.002 255);
35
34
  --color-gray-50: oklch(99% 0.0004 255);
36
35
  --color-gray-100: oklch(97.83% 0.0006 255);
@@ -297,6 +296,11 @@
297
296
  --color-muted-foreground: var(--muted-foreground);
298
297
  --color-accent: var(--accent);
299
298
  --color-accent-foreground: var(--accent-foreground);
299
+ --color-action-accent: var(--action-accent);
300
+ --color-action-accent-hover: var(--action-accent-hover);
301
+ --color-action-accent-foreground: var(--action-accent-foreground);
302
+ --color-reaction-foreground: var(--reaction-foreground);
303
+ --color-reaction-liked: var(--reaction-liked);
300
304
  --color-destructive: var(--destructive);
301
305
  --color-destructive-foreground: var(--destructive-foreground);
302
306
  --color-border: var(--border);