mirror of
https://github.com/ershisan99/md-preview-desktop.git
synced 2025-12-17 05:09:28 +00:00
feat: layout and dark mode switch
chore: move to npm
This commit is contained in:
19451
package-lock.json
generated
Normal file
19451
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,10 @@
|
|||||||
import { useState } from 'react'
|
|
||||||
|
|
||||||
import { View } from './components/view/view'
|
import { View } from './components/view/view'
|
||||||
import { Layout } from './layout'
|
import { Layout } from './layout'
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [fileName, setFileName] = useState<string>('')
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout fileName={fileName}>
|
<Layout>
|
||||||
<View setFileName={setFileName} />
|
<View />
|
||||||
</Layout>
|
</Layout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
1
src/renderer/src/components/file-selector/index.ts
Normal file
1
src/renderer/src/components/file-selector/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './file-selector'
|
||||||
@@ -6,10 +6,10 @@ import { ImagePreview } from '@it-incubator/ui-kit'
|
|||||||
|
|
||||||
import s from './view.module.scss'
|
import s from './view.module.scss'
|
||||||
|
|
||||||
import { FileOrDirectory, MdxFileSelector } from '../file-selector/file-selector'
|
import { FileOrDirectory, MdxFileSelector } from '../file-selector'
|
||||||
import { TableOfContents } from '../toc'
|
import { TableOfContents } from '../toc'
|
||||||
|
|
||||||
export const View = ({ setFileName }) => {
|
export const View = () => {
|
||||||
const [selectedFile, setSelectedFile] = useState<string>('')
|
const [selectedFile, setSelectedFile] = useState<string>('')
|
||||||
const [code, setCode] = useState<string>('')
|
const [code, setCode] = useState<string>('')
|
||||||
const [toc, setToc] = useState<any>({})
|
const [toc, setToc] = useState<any>({})
|
||||||
@@ -29,9 +29,10 @@ export const View = ({ setFileName }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const contentListener: IpcRendererListener = (_event, content) => {
|
const contentListener: IpcRendererListener = (_event, content) => {
|
||||||
if (!content) return
|
if (!content) {
|
||||||
|
return
|
||||||
|
}
|
||||||
setCode(content?.code)
|
setCode(content?.code)
|
||||||
setFileName(content?.fileName)
|
|
||||||
setSelectedFile(content?.fileName)
|
setSelectedFile(content?.fileName)
|
||||||
setToc(content?.toc)
|
setToc(content?.toc)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,3 +34,16 @@
|
|||||||
padding: 0 16px;
|
padding: 0 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
padding-inline: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import { ReactNode, useState } from 'react'
|
import { ReactNode, useState } from 'react'
|
||||||
|
|
||||||
import { Button, Header, Scrollbar, Typography } from '@it-incubator/ui-kit'
|
import { Header, Scrollbar, Toggle } from '@it-incubator/ui-kit'
|
||||||
|
|
||||||
import s from './layout.module.scss'
|
import s from './layout.module.scss'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
fileName: string
|
|
||||||
}
|
}
|
||||||
export const Layout = ({ children, fileName }: Props) => {
|
export const Layout = ({ children }: Props) => {
|
||||||
const [isDark, setIsDark] = useState<boolean>(false)
|
const [isDark, setIsDark] = useState<boolean>(false)
|
||||||
|
|
||||||
const handleThemeChanged = () => {
|
const handleThemeChanged = () => {
|
||||||
@@ -18,9 +17,11 @@ export const Layout = ({ children, fileName }: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header>
|
<Header className={s.header}>
|
||||||
<Typography.H1>{fileName}</Typography.H1>
|
<div className={s.toggle}>
|
||||||
<Button onClick={() => handleThemeChanged()}>Toggle theme</Button>
|
Темная тема
|
||||||
|
<Toggle checked={isDark} onCheckedChange={handleThemeChanged} />
|
||||||
|
</div>
|
||||||
</Header>
|
</Header>
|
||||||
<Scrollbar className={s.scrollbar}>
|
<Scrollbar className={s.scrollbar}>
|
||||||
<main className={s.main}>{children}</main>
|
<main className={s.main}>{children}</main>
|
||||||
|
|||||||
Reference in New Issue
Block a user