Skip to content

Commit

Permalink
clean: clean up redundant code on website.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 21, 2023
1 parent 7c5585a commit 893a168
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions www/src/pages/theme/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const ButtonGroup = styled.div`
export const Preview: FC<PropsWithChildren<PreviewProps>> = (props) => {
const { themePkg, mode } = props;
const { mdData } = useMdData(props.path);
const childs = Children.toArray(props.children);
const [previewDoc, setPreviewDoc] = useState<PreviewProps['preview']>(props.preview || 'example');
const themePkgNmae = !!mode ? themePkg?.replace(/-(light|dark)$/, '') : themePkg;
const themeName = themePkgNmae?.replace('@uiw/codemirror-theme-', '').replace('-', ' ');
Expand Down Expand Up @@ -91,9 +90,6 @@ export const Preview: FC<PropsWithChildren<PreviewProps>> = (props) => {
<PreCode value={`npm install ${themePkg} --save`} />
</Header>
)}
{childs.map((child, key) => {
return cloneElement(child as any, { key, source: mdData?.source });
})}
{mdData && (previewDoc === 'document' || !themePkg) && <Markdown source={mdData.source} mdData={mdData} />}
{previewDoc === 'example' && themePkg && themeExtensionName && <Sample theme={extension} />}
</Content>
Expand Down
8 changes: 4 additions & 4 deletions www/src/pages/theme/themes/PreCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const Pre = styled.pre`
border-radius: 5px;
`;

const Span = styled.span<{ number: number }>`
const Span = styled.span<{ $number: number }>`
${(props) =>
props.number === 0 &&
props.$number === 0 &&
css`
color: var(--color-accent-emphasis);
`}
${(props) =>
props.number === 2 &&
props.$number === 2 &&
css`
color: var(--color-danger-fg);
`}
Expand All @@ -27,7 +27,7 @@ export const PreCode: FC<PropsWithoutRef<{ value?: string }>> = ({ value = '' })
<Pre>
{value.split(' ').map((str, idx) => {
return (
<Span key={idx} number={idx}>
<Span key={idx} $number={idx}>
{str}{' '}
</Span>
);
Expand Down

0 comments on commit 893a168

Please sign in to comment.