mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-11 09:51:40 +00:00
fix: charts
This commit is contained in:
@@ -63,7 +63,6 @@ export default function ChartsLayout({
|
||||
</PageHeader>
|
||||
<PageNav id="charts">
|
||||
<ChartsNav />
|
||||
<ThemeSelector className="mr-4 hidden md:flex" />
|
||||
</PageNav>
|
||||
<div className="container-wrapper section-soft flex-1">
|
||||
<div className="container pb-6">
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
"use client"
|
||||
|
||||
import { useSearchParams } from "next/navigation"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
export function ComponentPreview({ children }: { children: React.ReactNode }) {
|
||||
const searchParams = useSearchParams()
|
||||
const theme = searchParams.get("theme") ?? "default"
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"bg-background *:data-[slot=card]:has-[[data-slot=chart]]:shadow-none",
|
||||
`theme-${theme}`,
|
||||
theme.endsWith("-scaled") && "theme-scaled"
|
||||
"bg-background *:data-[slot=card]:has-[[data-slot=chart]]:shadow-none"
|
||||
)}
|
||||
>
|
||||
<div className="theme-container">{children}</div>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { useThemeConfig } from "@/components/active-theme"
|
||||
|
||||
export function ChartIframe({
|
||||
src,
|
||||
@@ -15,14 +14,10 @@ export function ChartIframe({
|
||||
title: string
|
||||
}) {
|
||||
const [loaded, setLoaded] = React.useState(false)
|
||||
const { activeTheme } = useThemeConfig()
|
||||
|
||||
// Append theme as query param so iframe can apply it.
|
||||
const iframeSrc = `${src}?theme=${activeTheme}`
|
||||
|
||||
return (
|
||||
<iframe
|
||||
src={iframeSrc}
|
||||
src={src}
|
||||
className={cn(
|
||||
"w-full border-none transition-opacity duration-300",
|
||||
loaded ? "opacity-100" : "opacity-0"
|
||||
|
||||
@@ -46,7 +46,7 @@ export function ChartToolbar({
|
||||
}
|
||||
|
||||
function ChartTitle({ chart }: { chart: Chart }) {
|
||||
if (chart.name.includes("charts-line")) {
|
||||
if (chart.name.includes("chart-line")) {
|
||||
return (
|
||||
<>
|
||||
<LineChartIcon /> Line Chart
|
||||
|
||||
Reference in New Issue
Block a user