Compare commits
2 Commits
145aa06095
...
ba76193d33
Author | SHA1 | Date | |
---|---|---|---|
ba76193d33 | |||
b843facac6 |
@ -24,6 +24,8 @@ 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 [previewDisabled, setPreviewDisabled] = useState(false)
|
||||||
|
const [alreadyClosed, setAlreadyClosed] = useState(false)
|
||||||
const [closed, setClosed] = useLocalStorage(`transform_closed__${transform.name}`, false)
|
const [closed, setClosed] = useLocalStorage(`transform_closed__${transform.name}`, false)
|
||||||
const [result, setResult] = useState<WrappedTransformResult>({
|
const [result, setResult] = useState<WrappedTransformResult>({
|
||||||
error: false,
|
error: false,
|
||||||
@ -31,10 +33,28 @@ export const TransformGridItem: FC<TransformGridItemProp> = ({ transform }) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
setAlreadyClosed(closed)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (closed)
|
||||||
|
return
|
||||||
|
|
||||||
transform
|
transform
|
||||||
.fn(value, options)
|
.fn(value, options)
|
||||||
.then(setResult.bind(this))
|
.then(setResult.bind(this))
|
||||||
}, [value, options])
|
}, [value, options, closed])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (value.length > 30000) {
|
||||||
|
setClosed(true)
|
||||||
|
setPreviewDisabled(true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setClosed(alreadyClosed)
|
||||||
|
setPreviewDisabled(false)
|
||||||
|
}, [value])
|
||||||
|
|
||||||
const onCheckboxOptionChanged =
|
const onCheckboxOptionChanged =
|
||||||
(option: TransformCheckboxOption) =>
|
(option: TransformCheckboxOption) =>
|
||||||
@ -92,6 +112,14 @@ export const TransformGridItem: FC<TransformGridItemProp> = ({ transform }) => {
|
|||||||
setValue(result.value)
|
setValue(result.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onLabelClicked = () => {
|
||||||
|
if (previewDisabled)
|
||||||
|
return
|
||||||
|
|
||||||
|
setClosed(!closed)
|
||||||
|
setAlreadyClosed(!closed)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx(style.item, closed && style.closed)}>
|
<div className={clsx(style.item, closed && style.closed)}>
|
||||||
<div className={style.toolbar}>
|
<div className={style.toolbar}>
|
||||||
@ -100,8 +128,8 @@ export const TransformGridItem: FC<TransformGridItemProp> = ({ transform }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<h2
|
<h2
|
||||||
onClick={() => setClosed(!closed)}
|
onClick={onLabelClicked}
|
||||||
className={style.name}>
|
className={clsx(style.name, previewDisabled && style.previewDisabled)}>
|
||||||
|
|
||||||
{transform.name}
|
{transform.name}
|
||||||
</h2>
|
</h2>
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
.name {
|
.name {
|
||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
padding: 14px 6px;
|
padding: 14px 6px;
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&:hover {
|
&:hover:not(.previewDisabled) {
|
||||||
|
cursor: pointer;
|
||||||
text-decoration: underline dotted;
|
text-decoration: underline dotted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,11 @@ import react from '@vitejs/plugin-react-swc'
|
|||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
|
css: {
|
||||||
|
preprocessorOptions: {
|
||||||
|
scss: {
|
||||||
|
api: 'modern-compiler' // or "modern"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user