From a34d190cd4546fd725eef86db9846248c7e6cca6 Mon Sep 17 00:00:00 2001 From: Kenji Shiroma Date: Thu, 19 Oct 2023 12:06:50 +1000 Subject: [PATCH] fix --- .../live-code/live-code.component.tsx | 27 ++++------ .../components/live-code/live-code.styles.ts | 51 +++++++++++++++++++ .../accordion/accordion.stories.tsx | 2 +- 3 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 apps/site/src/components/code/components/live-code/live-code.styles.ts diff --git a/apps/site/src/components/code/components/live-code/live-code.component.tsx b/apps/site/src/components/code/components/live-code/live-code.component.tsx index baf912fd0..37b6f3898 100644 --- a/apps/site/src/components/code/components/live-code/live-code.component.tsx +++ b/apps/site/src/components/code/components/live-code/live-code.component.tsx @@ -1,12 +1,12 @@ import { AlertIcon } from '@westpac/ui/icon'; import copy from 'clipboard-copy'; -import { clsx } from 'clsx'; import { themes } from 'prism-react-renderer'; -import { ComponentType, Context, KeyboardEvent, useCallback, useContext, useId, useRef, useState } from 'react'; +import { KeyboardEvent, useCallback, useContext, useId, useRef, useState } from 'react'; import { LiveContext, LiveEditor, LivePreview } from 'react-live'; import { BracketIcon } from '../../../icons/bracket-icon'; +import { styles as liveCodeStyles } from './live-code.styles'; import { LiveCodeProps } from './live-code.types'; export function LiveCode({ showCode = false, className }: LiveCodeProps) { @@ -17,6 +17,8 @@ export function LiveCode({ showCode = false, className }: LiveCodeProps) { const [localCopy, setLocalCopy] = useState(live.code); const [isCodeVisible, toggleIsCodeVisible] = useState(showCode); + const styles = liveCodeStyles({ isCodeVisible, className }); + const copyLiveCode = useCallback(() => { copy(localCopy); }, [localCopy]); @@ -43,17 +45,17 @@ export function LiveCode({ showCode = false, className }: LiveCodeProps) { ); return ( -
-
+
+
{live.error ? ( -
+
{live.error}
) : ( )} -
+
-
- Controlled example */ -export const ControlledLook: Story = { +export const Controlled: Story = { args: { look: 'lego', rounded: false,