diff --git a/microsite-canon/app/playground/page.tsx b/microsite-canon/app/playground/page.tsx index 4bb59426ce..99ade9b774 100644 --- a/microsite-canon/app/playground/page.tsx +++ b/microsite-canon/app/playground/page.tsx @@ -1,3 +1,50 @@ +'use client'; + +import styles from './styles.module.css'; +import { Text } from '@backstage/canon'; +import { screenSizes } from '@/utils/data'; +import { Frame } from '@/components/Frame'; +import { Stack, Inline, Button } from '@backstage/canon'; + export default function PlaygroundPage() { - return
; + return ( +
+ {screenSizes.map(screenSize => ( +
+ + {screenSize.title} - {screenSize.width}px + +
+ + + + Button - Primary - Small + + + + + + + + + + + +
+
+ ))} +
+ ); } diff --git a/microsite-canon/app/playground/styles.module.css b/microsite-canon/app/playground/styles.module.css index e69de29bb2..13b896a879 100644 --- a/microsite-canon/app/playground/styles.module.css +++ b/microsite-canon/app/playground/styles.module.css @@ -0,0 +1,32 @@ +.container { + height: 100vh; + display: flex; + flex-direction: row; + gap: 24px; + overflow-x: scroll; +} + +.breakpointContainer { + flex-shrink: 0; + margin-top: 40px; + height: calc(100vh - 86px); + display: flex; + flex-direction: column; + gap: 8px; + + &:first-child { + margin-left: 48px; + } + + &:last-child { + margin-right: 48px; + } +} + +.breakpointContent { + height: 100%; + border-radius: 4px; + border: 1px solid var(--canon-border-base); + background-color: var(--canon-background-base); + padding: 16px; +} diff --git a/microsite-canon/components/Frame/index.tsx b/microsite-canon/components/Frame/index.tsx new file mode 100644 index 0000000000..40b6641dfb --- /dev/null +++ b/microsite-canon/components/Frame/index.tsx @@ -0,0 +1,29 @@ +import { useEffect, useState } from 'react'; +import ReactFrame from 'react-frame-component'; +import '@backstage/canon/src/css/core.css'; +import '@backstage/canon/src/css/components.css'; + +export const Frame = ({ children }: { children: React.ReactNode }) => { + const [show, setShow] = useState(false); + + useEffect(() => { + setShow(true); + }, []); + + if (!show) return null; + + return ( + + + + + } + > + {children} + + ); +}; diff --git a/microsite-canon/components/Sidebar/index.tsx b/microsite-canon/components/Sidebar/index.tsx index f4136886ae..641f0d73ad 100644 --- a/microsite-canon/components/Sidebar/index.tsx +++ b/microsite-canon/components/Sidebar/index.tsx @@ -1,16 +1,9 @@ -'use client'; - import styles from './Sidebar.module.css'; import { TabsVersion, TabsTheme, TabsPages } from '../Tabs'; -import { usePathname } from 'next/navigation'; -import { AnimatePresence } from 'framer-motion'; import { Docs } from './docs'; import { Playground } from './playground'; export const Sidebar = () => { - const pathname = usePathname(); - const isPlayground = pathname.includes('/playground'); - return (
diff --git a/microsite-canon/components/Sidebar/playground.tsx b/microsite-canon/components/Sidebar/playground.tsx index ce4ffabcb2..8a6eaef4f8 100644 --- a/microsite-canon/components/Sidebar/playground.tsx +++ b/microsite-canon/components/Sidebar/playground.tsx @@ -1,18 +1,11 @@ -import Link from 'next/link'; +'use client'; + import { components } from '@/utils/data'; import { Box, Checkbox, Text } from '@backstage/canon'; import { motion } from 'framer-motion'; import styles from './Sidebar.module.css'; import { usePathname } from 'next/navigation'; - -const breakpoints = [ - { title: 'XSmall', slug: 'xs' }, - { title: 'Small', slug: 'sm' }, - { title: 'Medium', slug: 'md' }, - { title: 'Large', slug: 'lg' }, - { title: 'XLarge', slug: 'xl' }, - { title: 'XXLarge', slug: '2xl' }, -]; +import { screenSizes } from '@/utils/data'; export const Playground = () => { const pathname = usePathname(); @@ -40,18 +33,18 @@ export const Playground = () => { {components.map(({ slug, title }) => ( -
+
{title}
))} - Breakpoints + Screen sizes - {breakpoints.map(({ title }) => ( -
+ {screenSizes.map(({ slug, title }) => ( +
{title}
diff --git a/microsite-canon/components/Story/index.tsx b/microsite-canon/components/Story/index.tsx index f7be11592b..3b7a9430f8 100644 --- a/microsite-canon/components/Story/index.tsx +++ b/microsite-canon/components/Story/index.tsx @@ -2,7 +2,14 @@ import { useTheme } from 'next-themes'; import styles from './styles.module.css'; -export const Story = ({ id, height }: { id: string; height?: number }) => { +import IframeResizer from '@iframe-resizer/react'; + +interface StoryProps { + id: string; + border?: boolean; +} + +export const Story = ({ id, border = true }: StoryProps) => { const { theme } = useTheme(); const localTheme = theme === 'dark' ? 'Dark' : 'Light'; @@ -13,11 +20,14 @@ export const Story = ({ id, height }: { id: string; height?: number }) => { const iframeUrl = `${url}?globals=theme%3A${localTheme}&args=&id=${id}`; return ( -
-