Chart
weekendsuperhero-io-sistine/chartUnverifiedComponent
Chart components built with Recharts with optional glass material.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/Weekendsuperhero-io/sistine/main/chart.jsonSource
1"use client";23import * as React from "react";4import * as RechartsPrimitive from "recharts";56import { type MaterialAxisProps, materialSurface, splitAxisProps } from "@/lib/material";7import { cn } from "@/lib/utils";89// Format: { THEME_NAME: CSS_SELECTOR }10const THEMES = {11 light: "",12 dark: ".dark",13} as const;1415/* Roles: the container and legend are bordered adaptive glass;16 the tooltip is bordered + veiled. */17const SURFACE_ROLE = {18 border: true,19};20const TOOLTIP_ROLE = {21 border: true,22 veil: true,23};2425export type ChartConfig = {26 [key in string]: {27 label?: React.ReactNode;28 icon?: React.ComponentType;29 } & (30 | {31 color?: string;32 theme?: never;33 }34 | {35 color?: never;36 theme: {37 light?: string;38 dark?: string;39 };40 }41 );42};4344type ChartContextProps = {45 config: ChartConfig;46};4748const ChartContext = React.createContext<ChartContextProps | null>(null);4950function useChart() {51 const context = React.useContext(ChartContext);5253 if (!context) {54 throw new Error("useChart must be used within a <ChartContainer />");55 }5657 return context;58}5960const ChartContainer = React.forwardRef<61 HTMLDivElement,62 React.ComponentProps<"div"> & {63 config: ChartConfig;64 children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];65 } & MaterialAxisProps & {66 variant?: "default" | "glass";67 }68>(({ id, className, children, config, variant = "glass", ...props }, ref) => {69 const [axes, rest] = splitAxisProps(props);70 const uniqueId = React.useId();71 const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;7273 /* Variant classes carry BEHAVIOR only; the surface comes from materialSurface. */74 const variants = {75 default: "",76 glass: "rounded-lg p-4",77 };7879 const m = materialSurface(variant === "default" ? null : SURFACE_ROLE, axes);8081 return (82 <ChartContext.Provider83 value={{84 config,85 }}86 >87 <div88 data-chart={chartId}89 data-material={m?.["data-material"]}90 ref={ref}91 className={cn(92 m?.className,93// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from weekendsuperhero-io/sistine
All 71 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | weekendsuperhero-io/sistine | Components | Unverified | 5 deps · 4 files | |
| Alertalert | weekendsuperhero-io/sistine | Components | Unverified | 3 deps · 4 files | |
| Alert Dialogalert-dialog | weekendsuperhero-io/sistine | Components | Unverified | 4 deps · 4 files | |
| Auto Foregroundauto-foreground | weekendsuperhero-io/sistine | Components | Unverified | no deps | |
| Avataravatar | weekendsuperhero-io/sistine | Components | Unverified | 4 deps · 4 files | |
| Badgebadge | weekendsuperhero-io/sistine | Components | Unverified | 4 deps · 4 files | |
| Breadcrumbbreadcrumb | weekendsuperhero-io/sistine | Components | Unverified | 5 deps · 4 files | |
| Buttonbutton | weekendsuperhero-io/sistine | Components | Unverified | 4 deps · 4 files |
