Skip to content

Commit

Permalink
Added the more options to the GuideSectionTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
cchaos committed Sep 29, 2021
1 parent 963e589 commit f3eccfb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,29 @@ export const GuideSectionExampleCode: FunctionComponent<GuideSectionExampleCode>
const [codeToRender, setCodeToRender] = useState();

useEffect(() => {
setCodeToRender(renderJsSourceCode(code));
if (type === GuideSectionTypes.JS) {
setCodeToRender(renderJsSourceCode(code));
} else {
setCodeToRender(code);
}

return () => {
setCodeToRender(undefined);
};
}, [code]);
}, [code, type]);

const codeSandboxLink = (
<CodeSandboxLink
className="guideSectionExampleCode__link"
content={code.default}
type={type.toLowerCase()}
>
<EuiButtonEmpty size="xs" iconType="logoCodesandbox">
Try out this demo on Code Sandbox
</EuiButtonEmpty>
</CodeSandboxLink>
);
const codeSandboxLink =
type === GuideSectionTypes.JS ? (
<CodeSandboxLink
className="guideSectionExampleCode__link"
content={code.default}
type={type.toLowerCase()}
>
<EuiButtonEmpty size="xs" iconType="logoCodesandbox">
Try out this demo on Code Sandbox
</EuiButtonEmpty>
</CodeSandboxLink>
) : undefined;

return (
<>
Expand Down
2 changes: 2 additions & 0 deletions src-docs/src/components/guide_section/guide_section_types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ export const GuideSectionTypes = {
JS: 'JS',
TSX: 'TSX',
HTML: 'HTML',
SNIPPET: 'SNIPPET',
SASS: 'SASS',
};

0 comments on commit f3eccfb

Please sign in to comment.