feat: hide transform when click title
All checks were successful
/ deploy_site (push) Successful in 3m16s

This commit is contained in:
Minhyeok Park 2024-10-29 21:04:49 +09:00
parent 76fe3e8083
commit 2f6b56d55b
Signed by: pmh_only
SSH Key Fingerprint: SHA256:g/OyGvi2pcd8ub9mqge/ohmDP0fZX/xOPWPIcM+9XpI
4 changed files with 41 additions and 7 deletions

View File

@ -12,6 +12,7 @@
"dependencies": { "dependencies": {
"@fontsource-variable/jetbrains-mono": "^5.1.1", "@fontsource-variable/jetbrains-mono": "^5.1.1",
"@monaco-editor/react": "^4.6.0", "@monaco-editor/react": "^4.6.0",
"@uidotdev/usehooks": "^2.4.1",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"framer-motion": "^11.11.10", "framer-motion": "^11.11.10",
"json5": "^2.2.3", "json5": "^2.2.3",

View File

@ -14,6 +14,9 @@ importers:
'@monaco-editor/react': '@monaco-editor/react':
specifier: ^4.6.0 specifier: ^4.6.0
version: 4.6.0(monaco-editor@0.52.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) version: 4.6.0(monaco-editor@0.52.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
'@uidotdev/usehooks':
specifier: ^2.4.1
version: 2.4.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
clsx: clsx:
specifier: ^2.1.1 specifier: ^2.1.1
version: 2.1.1 version: 2.1.1
@ -661,6 +664,13 @@ packages:
resolution: {integrity: sha512-EaewX6lxSjRJnc+99+dqzTeoDZUfyrA52d2/HRrkI830kgovWsmIiTfmr0NZorzqic7ga+1bS60lRBUgR3n/Bw==} resolution: {integrity: sha512-EaewX6lxSjRJnc+99+dqzTeoDZUfyrA52d2/HRrkI830kgovWsmIiTfmr0NZorzqic7ga+1bS60lRBUgR3n/Bw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@uidotdev/usehooks@2.4.1':
resolution: {integrity: sha512-1I+RwWyS+kdv3Mv0Vmc+p0dPYH0DTRAo04HLyXReYBL9AeseDWUJyi4THuksBJcu9F0Pih69Ak150VDnqbVnXg==}
engines: {node: '>=16'}
peerDependencies:
react: '>=18.0.0'
react-dom: '>=18.0.0'
'@vitejs/plugin-react-swc@3.7.1': '@vitejs/plugin-react-swc@3.7.1':
resolution: {integrity: sha512-vgWOY0i1EROUK0Ctg1hwhtC3SdcDjZcdit4Ups4aPkDcB1jYhmo+RMYWY87cmXMhvtD5uf8lV89j2w16vkdSVg==} resolution: {integrity: sha512-vgWOY0i1EROUK0Ctg1hwhtC3SdcDjZcdit4Ups4aPkDcB1jYhmo+RMYWY87cmXMhvtD5uf8lV89j2w16vkdSVg==}
peerDependencies: peerDependencies:
@ -1840,6 +1850,11 @@ snapshots:
'@typescript-eslint/types': 8.11.0 '@typescript-eslint/types': 8.11.0
eslint-visitor-keys: 3.4.3 eslint-visitor-keys: 3.4.3
'@uidotdev/usehooks@2.4.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
dependencies:
react: 18.3.1
react-dom: 18.3.1(react@18.3.1)
'@vitejs/plugin-react-swc@3.7.1(vite@5.4.10(@types/node@22.8.1)(sass-embedded@1.80.4))': '@vitejs/plugin-react-swc@3.7.1(vite@5.4.10(@types/node@22.8.1)(sass-embedded@1.80.4))':
dependencies: dependencies:
'@swc/core': 1.7.39 '@swc/core': 1.7.39

View File

@ -14,6 +14,7 @@ import {
WrappedTransform, WrappedTransform,
WrappedTransformResult WrappedTransformResult
} from "../Transforms/Transform"; } from "../Transforms/Transform";
import { useLocalStorage } from "@uidotdev/usehooks";
interface TransformGridItemProp { interface TransformGridItemProp {
transform: WrappedTransform transform: WrappedTransform
@ -22,6 +23,7 @@ interface TransformGridItemProp {
export const TransformGridItem: FC<TransformGridItemProp> = ({ transform }) => { export const TransformGridItem: FC<TransformGridItemProp> = ({ transform }) => {
const [value, setValue] = useRecoilState(EditorValueState) const [value, setValue] = useRecoilState(EditorValueState)
const [options, setOptions] = useState(transform.options) const [options, setOptions] = useState(transform.options)
const [closed, setClosed] = useLocalStorage(`transform_closed__${transform.name}`, false)
const [result, setResult] = useState<WrappedTransformResult>({ const [result, setResult] = useState<WrappedTransformResult>({
error: false, error: false,
value: '' value: ''
@ -90,13 +92,18 @@ export const TransformGridItem: FC<TransformGridItemProp> = ({ transform }) => {
} }
return ( return (
<div className={style.item}> <div className={clsx(style.item, closed && style.closed)}>
<div className={style.toolbar}> <div className={style.toolbar}>
<Button disabled={result.error} onClick={onForwardButtonPressed}> <Button disabled={result.error} onClick={onForwardButtonPressed}>
&lt;&lt;&lt; &lt;&lt;&lt;
</Button> </Button>
<h2 className={style.name}>{transform.name}</h2> <h2
onClick={() => setClosed(!closed)}
className={style.name}>
{transform.name}
</h2>
<div className={style.options}> <div className={style.options}>
{[...options.values()] {[...options.values()]
@ -162,11 +169,13 @@ export const TransformGridItem: FC<TransformGridItemProp> = ({ transform }) => {
</div> </div>
</div> </div>
{!closed &&
<TextArea <TextArea
readOnly readOnly
value={result.value} value={result.value}
placeholder="(empty)" placeholder="(empty)"
className={clsx(result.error && style.error)} /> className={clsx(result.error && style.error)} />
}
</div> </div>
) )
} }

View File

@ -6,6 +6,10 @@
flex-direction: column; flex-direction: column;
min-height: 250px; min-height: 250px;
&.closed {
min-height: inherit;
}
.toolbar { .toolbar {
display: flex; display: flex;
gap: 10px; gap: 10px;
@ -17,6 +21,11 @@
.name { .name {
font-size: inherit; font-size: inherit;
padding: 14px 6px; padding: 14px 6px;
cursor: pointer;
&:hover {
text-decoration: underline dotted;
}
} }
.options { .options {