Skip to content

Commit 3180abe

Browse files
feat: finesse iframe'd styling for dojo examples
1 parent 5e4e660 commit 3180abe

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

typescript-sdk/apps/dojo/src/app/[integrationId]/feature/layout.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import filesJSON from '../../../files.json'
66
import Readme from "@/components/readme/readme";
77
import CodeViewer from "@/components/code-viewer/code-viewer";
88
import { useURLParams } from "@/contexts/url-params-context";
9+
import { cn } from "@/lib/utils";
910

1011
type FileItem = {
1112
name: string;
@@ -24,6 +25,7 @@ interface Props {
2425
}
2526

2627
export default function FeatureLayout({ children, params }: Props) {
28+
const { sidebarHidden } = useURLParams();
2729
const { integrationId } = React.use(params);
2830
const pathname = usePathname();
2931
const { view } = useURLParams();
@@ -58,7 +60,11 @@ export default function FeatureLayout({ children, params }: Props) {
5860
}, [children, codeFiles, readme, view])
5961

6062
return (
61-
<div className="bg-(--copilot-kit-background-color) rounded-lg w-full h-full overflow-hidden">
63+
<div className={cn(
64+
"bg-white rounded-lg w-full h-full overflow-hidden",
65+
// if used in iframe, match background to chat background color, otherwise, use white
66+
sidebarHidden && "bg-(--copilot-kit-background-color)",
67+
)}>
6268
<div className="flex flex-col h-full overflow-auto">
6369
{content}
6470
</div>

typescript-sdk/apps/dojo/src/components/layout/viewer-layout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import { ViewerConfig } from "@/types/feature";
33
import { cn } from "@/lib/utils";
44
import { useMobileView } from "@/utils/use-mobile-view";
5+
import { useURLParams } from "@/contexts/url-params-context";
56

67
interface ViewerLayoutProps extends ViewerConfig {
78
className?: string;
@@ -15,11 +16,12 @@ export function ViewerLayout({
1516
className,
1617
children,
1718
}: ViewerLayoutProps) {
19+
const { sidebarHidden } = useURLParams();
1820
const { isMobile } = useMobileView();
1921

2022
return (
2123
<div className={cn("relative flex h-screen overflow-hidden bg-palette-surface-main", className, {
22-
"p-spacing-2": !isMobile,
24+
"p-spacing-2": !isMobile && !sidebarHidden,
2325
})}>
2426
<div className="flex flex-1 overflow-hidden z-1">
2527
<main className="flex-1 overflow-auto">

typescript-sdk/apps/dojo/src/components/theme-wrapper.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { ThemeProvider } from "@/components/theme-provider";
44
import { useURLParams } from "@/contexts/url-params-context";
55

66
export function ThemeWrapper({ children }: { children: React.ReactNode }) {
7-
const { theme } = useURLParams();
7+
const { sidebarHidden, theme } = useURLParams();
88

99
return (
1010
<ThemeProvider
1111
attribute="class"
12-
forcedTheme={theme}
12+
// if used in iframe, detect theme passed via url param, otherwise, use light
13+
forcedTheme={sidebarHidden ? theme : "light"}
1314
enableSystem={false}
1415
themes={["light", "dark"]}
1516
disableTransitionOnChange

0 commit comments

Comments
 (0)