-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from omnifed/60-feature-create-show-component
60 feature create show component
- Loading branch information
Showing
28 changed files
with
685 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
'use client' | ||
|
||
import { useState, type PropsWithChildren, type ReactNode } from 'react' | ||
import { Show } from '@cerberus-design/react' | ||
import { Code, CodeHide } from '@cerberus-design/icons' | ||
import { css } from '@/styled-system/css' | ||
import { hstack, vstack } from '@/styled-system/patterns' | ||
|
||
// TODO: Replace with Badge component | ||
// TODO: Replace with Button component | ||
|
||
const tempBtnStyles = css({ | ||
alignItems: 'center', | ||
display: 'inline-flex', | ||
gap: '2', | ||
}) | ||
|
||
interface CodePreviewProps { | ||
preview: ReactNode | ||
} | ||
|
||
export default function CodePreview( | ||
props: PropsWithChildren<CodePreviewProps>, | ||
) { | ||
const [viewCode, setViewCode] = useState<boolean>(false) | ||
|
||
function handleShowCode() { | ||
setViewCode(true) | ||
} | ||
|
||
function handleHideCode() { | ||
setViewCode(false) | ||
} | ||
|
||
return ( | ||
<Show | ||
when={viewCode} | ||
fallback={ | ||
<PreviewLayout onShowCode={handleShowCode}> | ||
{props.preview} | ||
</PreviewLayout> | ||
} | ||
> | ||
<header | ||
className={hstack({ | ||
bgColor: 'neutral.surface.100', | ||
justifyContent: 'flex-end', | ||
p: '4', | ||
})} | ||
> | ||
<button | ||
className={tempBtnStyles} | ||
onClick={handleHideCode} | ||
type="button" | ||
> | ||
Hide code | ||
<CodeHide aria-hidden size="1.5rem" /> | ||
</button> | ||
</header> | ||
{props.children} | ||
</Show> | ||
) | ||
} | ||
|
||
interface PreviewLayoutProps { | ||
onShowCode: () => void | ||
} | ||
|
||
export function PreviewLayout(props: PropsWithChildren<PreviewLayoutProps>) { | ||
return ( | ||
<div> | ||
<header | ||
className={hstack({ | ||
justifyContent: 'flex-end', | ||
p: '4', | ||
})} | ||
> | ||
<button | ||
className={tempBtnStyles} | ||
onClick={props.onShowCode} | ||
type="button" | ||
> | ||
Show code | ||
<Code aria-hidden size="1.5rem" /> | ||
</button> | ||
</header> | ||
<section | ||
className={vstack({ | ||
bgColor: 'info.surface.initial', | ||
border: '3px solid', | ||
borderColor: 'info.border.initial', | ||
borderRadius: 'xl', | ||
justify: 'center', | ||
mb: '4', | ||
minH: '18.75rem', | ||
overflow: 'hidden', | ||
position: 'relative', | ||
py: '8', | ||
})} | ||
> | ||
<span | ||
className={css({ | ||
bgColor: 'neutral.surface.initial', | ||
pxi: '2', | ||
rounded: 'md', | ||
position: 'absolute', | ||
top: '4', | ||
left: '4', | ||
textStyle: 'body-xs', | ||
textTransform: 'uppercase', | ||
zIndex: 'banner', | ||
})} | ||
> | ||
preview mode | ||
</span> | ||
|
||
{props.children} | ||
</section> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
import type { PropsWithChildren } from 'react' | ||
import { cx } from '@/styled-system/css' | ||
import { container } from '@/styled-system/patterns' | ||
import { markdown } from '../styles/markdown' | ||
import { PageLayout, PageSideNav } from '../components/PageLayout' | ||
import SideNav, { type NavList } from '../components/SideNav' | ||
import sideNavData from './side-nav.json' | ||
|
||
interface IconsProps {} | ||
|
||
export default function IconsLayout(props: PropsWithChildren<IconsProps>) { | ||
return ( | ||
<div | ||
className={cx( | ||
container({ | ||
pt: '12', | ||
}), | ||
markdown, | ||
)} | ||
> | ||
<PageLayout> | ||
<PageSideNav> | ||
<SideNav navList={sideNavData as NavList} /> | ||
</PageSideNav> | ||
|
||
{props.children} | ||
</div> | ||
</PageLayout> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import { css } from '@/styled-system/css' | ||
import OnThisPage from '../components/OnThisPage' | ||
import { PageMainContent, PageSections } from '../components/PageLayout' | ||
import Overview from './overview.mdx' | ||
|
||
export default function IconsPage() { | ||
return ( | ||
<main | ||
className={css({ | ||
py: '6', | ||
})} | ||
> | ||
<Overview /> | ||
</main> | ||
<> | ||
<PageMainContent> | ||
<main> | ||
<Overview /> | ||
</main> | ||
</PageMainContent> | ||
|
||
<PageSections> | ||
<OnThisPage /> | ||
</PageSections> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[ | ||
{ | ||
"id": "1", | ||
"label": "Overview", | ||
"type": "heading" | ||
}, | ||
{ | ||
"id": "1:a", | ||
"label": "Installation", | ||
"route": "/icons", | ||
"type": "route" | ||
}, | ||
{ | ||
"id": "1:b", | ||
"label": "Icons", | ||
"route": "/icons/all", | ||
"type": "route" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
import OnThisPage from '../../components/OnThisPage' | ||
import { PageMainContent, PageSections } from '../../components/PageLayout' | ||
import Colors from './colors.mdx' | ||
|
||
export default function ColorsPage() { | ||
return ( | ||
<main> | ||
<Colors /> | ||
</main> | ||
<> | ||
<PageMainContent> | ||
<main> | ||
<Colors /> | ||
</main> | ||
</PageMainContent> | ||
|
||
<PageSections> | ||
<OnThisPage /> | ||
</PageSections> | ||
</> | ||
) | ||
} |
Oops, something went wrong.