Skip to content

Commit

Permalink
code splitting highlight js
Browse files Browse the repository at this point in the history
  • Loading branch information
aarol committed Oct 15, 2023
1 parent 08dcd9d commit 1eb53f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/src/components/Highlight.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodeHighlight } from "@mantine/code-highlight"
import '@mantine/code-highlight/styles.css';
// Export Highlight as default to use code splitting
export { CodeHighlight as default }
export { CodeHighlight as default }
10 changes: 6 additions & 4 deletions client/src/components/Output.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Anchor, Button, Divider, Group, List, TextInput, Title } from '@mantine/core'
import { useState } from 'react'
import { Anchor, Button, Group, List, Text, TextInput, Title } from '@mantine/core'
import React, { Suspense, useState } from 'react'
import { downloadAllFiles, fontFaceIdentifier, Stylesheet } from '../api'
import Highlight from './Highlight'
const Highlight = React.lazy(() => import('./Highlight'))
import '@mantine/code-highlight/styles.css'

const renderStylesheets = (styles: Stylesheet[], url: string, fontName: string) => {
Expand Down Expand Up @@ -43,7 +43,9 @@ export const Output = ({ styles, fontName }: { styles: Stylesheet[], fontName: s
<Button onClick={downloadFonts}>Download All</Button>
</Group>
<TextInput value={url} label="CSS import url" onChange={(e) => setUrl(e.target.value)} />
<Highlight my="sm" key={css} language="css" code={css} />
<Suspense fallback={<Text>Loading...</Text>}>
<Highlight my="sm" key={css} language="css" code={css} />
</Suspense>
</>
)
}

0 comments on commit 1eb53f9

Please sign in to comment.