-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vlad Afonin
committed
Sep 11, 2022
1 parent
0eae3ba
commit e147702
Showing
18 changed files
with
255 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
* { | ||
*, ::before, ::after { | ||
box-sizing: border-box | ||
-webkit-tap-highlight-color: transparent | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
.surface { | ||
background: var(--theme-bg-fill) | ||
border-radius: 12px | ||
padding: 16px | ||
display: flex | ||
flex-direction: column | ||
gap: 16px | ||
border: 2px solid var(--theme-bg-text) | ||
} | ||
|
||
.title { | ||
display: flex | ||
justify-content: center | ||
} | ||
|
||
.content { | ||
display: flex | ||
flex-direction: column | ||
gap: 12px | ||
} | ||
|
||
.controls { | ||
display: flex | ||
justify-content: flex-end | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useSelector } from 'lib/sotore' | ||
import { suite } from 'model/suite' | ||
import { FC } from 'react' | ||
import { Button } from 'ui/Button' | ||
import { Form, TextField } from 'ui/Form' | ||
import { Modal } from 'ui/Modal' | ||
import { Title } from 'ui/Text' | ||
|
||
import { | ||
$title, | ||
$surface, | ||
$content, | ||
$controls, | ||
} from './SettingsModal.module.styl' | ||
|
||
type Props = { | ||
visible: boolean | ||
onDismiss(value: boolean): void | ||
} | ||
|
||
export const SettingsModal: FC<Props> = (props) => { | ||
const { visible, onDismiss } = props | ||
|
||
const config = useSelector(suite, ({ title, author }) => ({ title, author })) | ||
|
||
const handleApply = (values: Record<string, any>) => { | ||
suite.lay(values) | ||
onDismiss(false) | ||
} | ||
|
||
return ( | ||
<Modal name="suite_config" visible={visible} onDismiss={onDismiss}> | ||
<Form onSubmit={handleApply} values={config} className={$surface}> | ||
<header className={$title}> | ||
<Title size="small">Suite config</Title> | ||
</header> | ||
|
||
<main className={$content}> | ||
<TextField name="title" placeholder="Title" /> | ||
<TextField name="author" placeholder="Author" /> | ||
</main> | ||
|
||
<nav className={$controls}> | ||
<Button size="small" type="primary"> | ||
Apply | ||
</Button> | ||
</nav> | ||
</Form> | ||
</Modal> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Sotore } from 'lib/sotore' | ||
import { createContext } from 'react' | ||
|
||
export const Context = createContext<Sotore<Record<string, any>>>(null!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { sotore } from 'lib/sotore' | ||
import { FC, FormEventHandler, ReactNode, useMemo } from 'react' | ||
import { Context } from './Context' | ||
|
||
type Props = { | ||
className?: string | ||
children: ReactNode | ||
values?: Record<string, any> | ||
onSubmit(values: Record<string, any>): void | ||
} | ||
|
||
export const Form: FC<Props> = (props) => { | ||
const { className, children, values, onSubmit } = props | ||
|
||
const store = useMemo(() => sotore(values ?? {}), [values]) | ||
|
||
const handleSubmit: FormEventHandler = (e) => { | ||
e.preventDefault() | ||
onSubmit(store.get()) | ||
} | ||
|
||
return ( | ||
<form onSubmit={handleSubmit} className={className}> | ||
<Context.Provider value={store}>{children}</Context.Provider> | ||
</form> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
.text-field { | ||
display: flex | ||
flex-direction: column | ||
gap: 8px | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useFilter } from 'lib/sotore' | ||
import { FC, useCallback, useContext } from 'react' | ||
import { Text } from 'ui/Text' | ||
import { TextField } from 'ui/TextField' | ||
import { Context } from './Context' | ||
|
||
import { $text_field } from './FormTextField.module.styl' | ||
|
||
type Props = { | ||
name: string | ||
placeholder: string | ||
} | ||
|
||
export const FormTextField: FC<Props> = (props) => { | ||
const { name, placeholder } = props | ||
|
||
const store = useContext(Context) | ||
const [value] = useFilter(store, name) | ||
|
||
const handleChange = useCallback( | ||
(value: string) => { | ||
store.lay({ [name]: value }) | ||
}, | ||
[store], | ||
) | ||
|
||
return ( | ||
<div className={$text_field}> | ||
<Text>{placeholder}</Text> | ||
<TextField onChange={handleChange} placeholder={placeholder}> | ||
{value} | ||
</TextField> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { Form } from './Form' | ||
export { FormTextField as TextField } from './FormTextField' |
Oops, something went wrong.