Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions apps/website/screens/common/example/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ type ExamplePropTypes = {
actionsVisible?: boolean;
defaultIsVisible?: boolean;
example: {
scope: Record<string, unknown>;
scope?: Record<string, unknown>;
code: string;
};
onlyCode?: boolean;
};
//
const Example = ({ actionsVisible = true, defaultIsVisible = false, example }: ExamplePropTypes) => {

const Example = ({ actionsVisible = true, defaultIsVisible = false, example, onlyCode = false }: ExamplePropTypes) => {
const [isCodeVisible, changeIsCodeVisible] = useState(defaultIsVisible);
const [liveCode, setLiveCode] = useState(example.code);

Expand All @@ -61,12 +62,14 @@ const Example = ({ actionsVisible = true, defaultIsVisible = false, example }: E
return (
<DxcFlex direction="column" gap="var(--spacing-gap-m)">
<LiveProvider code={liveCode} scope={example.scope} theme={theme}>
<StyledPreview>
<LivePreview />
<StyledError>
<LiveError />
</StyledError>
</StyledPreview>
{!onlyCode && (
<StyledPreview>
<LivePreview />
<StyledError>
<LiveError />
</StyledError>
</StyledPreview>
)}
{actionsVisible && (
<DxcFlex gap="var(--spacing-gap-s)" justifyContent="flex-end">
{isCodeVisible && (
Expand All @@ -79,12 +82,14 @@ const Example = ({ actionsVisible = true, defaultIsVisible = false, example }: E
}}
/>
)}
<DxcButton
icon={isCodeVisible ? "code_off" : "code"}
label={isCodeVisible ? "Hide code" : "View code"}
mode="tertiary"
onClick={handleCodeOnClick}
/>
{!onlyCode && (
<DxcButton
icon={isCodeVisible ? "code_off" : "code"}
label={isCodeVisible ? "Hide code" : "View code"}
mode="tertiary"
onClick={handleCodeOnClick}
/>
)}
</DxcFlex>
)}
{isCodeVisible && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const sections = [
title: "Application layout with components",
content: (
<iframe
src="https://codesandbox.io/embed/default-app-layout-s65j9x?view=split&hidenavigation=1&editorsize=0&fontsize=12&runonclick=1"
src="https://codesandbox.io/embed/default-app-layout-s65j9x?view=split&hidenavigation=1&editorsize=0&fontsize=12"
style={{
width: "100%",
aspectRatio: "16/9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const sections = [
title: "Footer in application layout",
content: (
<iframe
src="https://codesandbox.io/embed/default-footer-pf6l2y?view=split&hidenavigation=1&editorsize=0&fontsize=12&runonclick=1"
src="https://codesandbox.io/embed/default-footer-pf6l2y?view=split&hidenavigation=1&editorsize=0&fontsize=12&"
style={{
width: "100%",
aspectRatio: "16/9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const sections = [
title: "Header in application layout",
content: (
<iframe
src="https://codesandbox.io/embed/default-header-qpz6dj?view=split&hidenavigation=1&editorsize=0&fontsize=12&runonclick=1"
src="https://codesandbox.io/embed/default-header-qpz6dj?view=split&hidenavigation=1&editorsize=0&fontsize=12"
style={{
width: "100%",
aspectRatio: "16/9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ const sections = [
title: "Application layout with sidenav",
content: (
<iframe
src="https://codesandbox.io/embed/default-sidenav-cvxr3m?view=split&hidenavigation=1&editorsize=0&fontsize=12&runonclick=1"
src="https://codesandbox.io/embed/default-sidenav-cvxr3m?view=split&hidenavigation=1&editorsize=0&fontsize=12"
style={{
width: "100%",
aspectRatio: "16/9",
Expand Down
Loading
Loading