-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
124 additions
and
100 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
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
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
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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
24 changes: 24 additions & 0 deletions
24
docs/app/components/shared/exampleSection/HeaderSection.tsx
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,24 @@ | ||
import { GenericLink } from '@heathmont/moon-icons-tw'; | ||
|
||
type Props = { | ||
title?: string; | ||
description?: string | JSX.Element; | ||
}; | ||
const HeaderSection = ({ title, description }: Props) => ( | ||
<> | ||
<h2 id={title} className="text-moon-20 font-medium "> | ||
<a | ||
href={`#${title}`} | ||
className="flex items-center gap-3 [&:hover_svg]:opacity-100 cursor-pointer" | ||
> | ||
{title} | ||
<GenericLink className="text-piccolo text-moon-16 opacity-0 transition-opacity" /> | ||
</a> | ||
</h2> | ||
{description && ( | ||
<div className="text-moon-16 text-bulma">{description}</div> | ||
)} | ||
</> | ||
); | ||
|
||
export default HeaderSection; |
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
2 changes: 1 addition & 1 deletion
2
docs/app/components/shared/CodePreview.tsx → ...xampleSection/codePreview/CodePreview.tsx
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
49 changes: 49 additions & 0 deletions
49
docs/app/components/shared/exampleSection/codePreview/wrapper/CodePreviewWrapper.tsx
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,49 @@ | ||
'use client'; | ||
|
||
import { useState, useEffect, useRef } from 'react'; | ||
import { mergeClassnames } from '@heathmont/moon-base-tw'; | ||
import ToggleCodeBtn from './ToggleCodeBtn'; | ||
import CodeCopy from '../CodeCopy'; | ||
|
||
const CodePreviewWrapper = ({ | ||
children, | ||
code, | ||
}: { | ||
children?: React.ReactNode; | ||
code: string; | ||
}) => { | ||
const [expand, setExpand] = useState(false); | ||
const [height, setHeight] = useState(0); | ||
const wrapperRef = useRef<HTMLDivElement>(null); | ||
const clickHandler = () => { | ||
setExpand(!expand); | ||
}; | ||
useEffect(() => { | ||
if (wrapperRef) { | ||
setHeight(wrapperRef?.current?.querySelector('#code')?.clientHeight || 0); | ||
} | ||
}, []); | ||
return ( | ||
<div | ||
ref={wrapperRef} | ||
className={mergeClassnames( | ||
'relative text-bulma p-4 pb-0 md:pr-12 overflow-hidden border border-t-0 border-beerus rounded-b-moon-s-sm' | ||
)} | ||
> | ||
<div | ||
className={mergeClassnames( | ||
'max-h-32 transition-[max-height] duration-150 ease-in-out overflow-hidden overflow-x-scroll pb-10 pt-10 md:pt-0', | ||
expand && 'max-h-96 overflow-scroll' | ||
)} | ||
> | ||
{children} | ||
</div> | ||
<CodeCopy code={code} /> | ||
{height > 72 && ( | ||
<ToggleCodeBtn expand={expand} clickHandler={clickHandler} /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default CodePreviewWrapper; |
36 changes: 36 additions & 0 deletions
36
docs/app/components/shared/exampleSection/codePreview/wrapper/ToggleCodeBtn.tsx
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,36 @@ | ||
import { mergeClassnames } from '@heathmont/moon-base-tw'; | ||
import { ControlsChevronDownSmall } from '@heathmont/moon-icons-tw'; | ||
|
||
type Props = { | ||
expand?: boolean; | ||
clickHandler?: () => void; | ||
}; | ||
|
||
const ToggleCodeBtn = ({ expand, clickHandler }: Props) => { | ||
return ( | ||
<div | ||
className={mergeClassnames( | ||
'absolute bottom-0 inset-x-0 h-32 flex items-end z-0 bg-[linear-gradient(180deg,_rgba(249,_250,_251,_0.00)_0%,_#F9FAFB_100%)]', | ||
expand && 'h-10' | ||
)} | ||
> | ||
<button | ||
onClick={clickHandler} | ||
className={mergeClassnames( | ||
'px-4 h-10 py-2 gap-2 text-moon-14 rounded-b-moon-s-sm relative z-0 flex justify-center items-center font-medium', | ||
'no-underline overflow-hidden whitespace-nowrap select-none transition duration-200 hover:bg-heles text-bulma hover:text-bulma w-full', | ||
expand ? 'bg-transperent' : 'bg-[rgba(249,_250,_251,_0.6)]' | ||
)} | ||
> | ||
<span className="flex items-center justify-center gap-2"> | ||
{expand ? 'Collapsed code' : 'Expand code '} | ||
<ControlsChevronDownSmall | ||
className={mergeClassnames('text-moon-24', expand && 'rotate-180')} | ||
/> | ||
</span> | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ToggleCodeBtn; |