Skip to content

Commit

Permalink
initial open on the code preview
Browse files Browse the repository at this point in the history
  • Loading branch information
linkb15 committed Aug 8, 2024
1 parent 2c1f13e commit 153c04b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion apps/astro-docs/src/components/code-block-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ import {

interface CodeBlockProps extends React.HTMLAttributes<HTMLDivElement> {
expandButtonTitle?: string;
initialOpen?: boolean;
}

export function CodeBlockWrapper({
expandButtonTitle = 'View Code',
className = 'my-6 overflow-hidden rounded-md',
children,
initialOpen = false,
...props
}: CodeBlockProps) {
const [isOpened, setIsOpened] = React.useState(false);
const [isOpened, setIsOpened] = React.useState(initialOpen);

return (
<Collapsible open={isOpened} onOpenChange={({ open }) => setIsOpened(open)}>
Expand Down
2 changes: 1 addition & 1 deletion apps/astro-docs/src/content/docs/components/accordion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A vertically stacked set of interactive headings that each reveal a section of c
</div>
</TabItem>
<TabItem label="Code">
<CodeBlockWrapper client:load>
<CodeBlockWrapper client:load initialOpen>
<Code
class="mb-4 mt-4 max-h-[650px] min-h-32 overflow-x-auto rounded-lg relative text-sm"
code={previewCode}
Expand Down

0 comments on commit 153c04b

Please sign in to comment.