Skip to content

Commit 0624b56

Browse files
authored
Refactor Markdown component. (#51)
1 parent c436af2 commit 0624b56

File tree

7 files changed

+34
-421
lines changed

7 files changed

+34
-421
lines changed

components/Chat/Chat.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ const Chat = (props: ChatProps, ref: any) => {
274274
<FiSend className="size-4" />
275275
</IconButton>
276276
</Tooltip>
277-
<Tooltip content={'Clear Message'}>
277+
<Tooltip content={'Clear History'}>
278278
<IconButton
279279
variant="soft"
280280
color="gray"

components/Markdown.tsx renamed to components/Markdown/Markdown.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import remarkParse from 'remark-parse'
1616
import remarkRehype from 'remark-rehype'
1717
import { useCopyToClipboard } from '@/hooks/useCopyToClipboard'
1818

19+
import './index.scss'
20+
1921
export interface MarkdownProps {
2022
className?: string
2123
children: string

components/Markdown/index.scss

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.prose {
2+
img {
3+
@apply max-w-3xl max-lg:max-w-full;
4+
}
5+
6+
:where(pre):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
7+
position: relative;
8+
background-color: rgb(30, 30, 30) !important;
9+
}
10+
11+
:where(pre code):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
12+
@apply whitespace-pre-wrap #{!important};
13+
}
14+
15+
:where(code[class~='highlight']) {
16+
background-color: var(--accent-a5);
17+
}
18+
}

components/Markdown/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Markdown'

components/Themes/ThemeProvider.tsx

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { Fragment, useCallback, useContext, useEffect, useMemo, useState } from 'react'
4-
import { ThemeProviderProps } from './interface'
4+
import { ThemeProviderProps, UseThemeProps } from './interface'
55
import { ThemeContext } from './ThemeContext'
66
import ThemeScript from './ThemeScript'
77
import { ColorSchemes, disableAnimation, getSystemTheme, MEDIA } from './utils'
@@ -141,14 +141,15 @@ const Theme = ({
141141
}, [defaultTheme, storageKey])
142142

143143
const providerValue = useMemo(
144-
() => ({
145-
theme,
146-
setTheme,
147-
forcedTheme,
148-
resolvedTheme: theme === 'system' ? resolvedTheme : theme,
149-
themes: enableSystem ? [...themes, 'system'] : themes,
150-
systemTheme: (enableSystem ? resolvedTheme : undefined) as 'light' | 'dark' | undefined
151-
}),
144+
() =>
145+
({
146+
theme,
147+
setTheme,
148+
forcedTheme,
149+
resolvedTheme: theme === 'system' ? resolvedTheme : theme,
150+
themes: enableSystem ? [...themes, 'system'] : themes,
151+
systemTheme: (enableSystem ? resolvedTheme : undefined) as 'light' | 'dark' | undefined
152+
}) as UseThemeProps,
152153
[theme, setTheme, forcedTheme, resolvedTheme, enableSystem, themes]
153154
)
154155

components/Themes/interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface UseThemeProps {
2222
/**
2323
* If `enableSystem` is true and the active theme is "system", this returns whether the system preference resolved to "dark" or "light". Otherwise, identical to `theme`
2424
*/
25-
resolvedTheme?: string | undefined
25+
resolvedTheme?: 'dark' | 'light'
2626
/**
2727
* If enableSystem is true, returns the System theme preference ("dark" or "light"), regardless what the active theme is
2828
*/

0 commit comments

Comments
 (0)