feat: layout and dark mode switch

chore: move to npm
This commit is contained in:
andres
2023-10-19 11:46:39 +02:00
parent a110ca33ce
commit ef9ed77552
7 changed files with 19479 additions and 8679 deletions

19451
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,10 @@
import { useState } from 'react'
import { View } from './components/view/view'
import { Layout } from './layout'
function App() {
const [fileName, setFileName] = useState<string>('')
return (
<Layout fileName={fileName}>
<View setFileName={setFileName} />
<Layout>
<View />
</Layout>
)
}

View File

@@ -0,0 +1 @@
export * from './file-selector'

View File

@@ -6,10 +6,10 @@ import { ImagePreview } from '@it-incubator/ui-kit'
import s from './view.module.scss'
import { FileOrDirectory, MdxFileSelector } from '../file-selector/file-selector'
import { FileOrDirectory, MdxFileSelector } from '../file-selector'
import { TableOfContents } from '../toc'
export const View = ({ setFileName }) => {
export const View = () => {
const [selectedFile, setSelectedFile] = useState<string>('')
const [code, setCode] = useState<string>('')
const [toc, setToc] = useState<any>({})
@@ -29,9 +29,10 @@ export const View = ({ setFileName }) => {
useEffect(() => {
const contentListener: IpcRendererListener = (_event, content) => {
if (!content) return
if (!content) {
return
}
setCode(content?.code)
setFileName(content?.fileName)
setSelectedFile(content?.fileName)
setToc(content?.toc)
}

View File

@@ -34,3 +34,16 @@
padding: 0 16px;
}
}
.header {
display: flex;
align-items: center;
justify-content: flex-end;
padding-inline: 20px;
}
.toggle {
display: flex;
align-items: center;
gap: 12px;
}

View File

@@ -1,14 +1,13 @@
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'
type Props = {
children: ReactNode
fileName: string
}
export const Layout = ({ children, fileName }: Props) => {
export const Layout = ({ children }: Props) => {
const [isDark, setIsDark] = useState<boolean>(false)
const handleThemeChanged = () => {
@@ -18,9 +17,11 @@ export const Layout = ({ children, fileName }: Props) => {
return (
<>
<Header>
<Typography.H1>{fileName}</Typography.H1>
<Button onClick={() => handleThemeChanged()}>Toggle theme</Button>
<Header className={s.header}>
<div className={s.toggle}>
Темная тема
<Toggle checked={isDark} onCheckedChange={handleThemeChanged} />
</div>
</Header>
<Scrollbar className={s.scrollbar}>
<main className={s.main}>{children}</main>

8663
yarn.lock

File diff suppressed because it is too large Load Diff