Compare commits
No commits in common. "ba76193d333735cc1bccd272e2438435d094a5ac" and "145aa060958e32e41a611fa528248c574b15d121" have entirely different histories.
ba76193d33
...
145aa06095
@ -24,8 +24,6 @@ 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,
|
||||||
@ -33,28 +31,10 @@ 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, closed])
|
}, [value, options])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (value.length > 30000) {
|
|
||||||
setClosed(true)
|
|
||||||
setPreviewDisabled(true)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setClosed(alreadyClosed)
|
|
||||||
setPreviewDisabled(false)
|
|
||||||
}, [value])
|
|
||||||
|
|
||||||
const onCheckboxOptionChanged =
|
const onCheckboxOptionChanged =
|
||||||
(option: TransformCheckboxOption) =>
|
(option: TransformCheckboxOption) =>
|
||||||
@ -112,14 +92,6 @@ 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}>
|
||||||
@ -128,8 +100,8 @@ export const TransformGridItem: FC<TransformGridItemProp> = ({ transform }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<h2
|
<h2
|
||||||
onClick={onLabelClicked}
|
onClick={() => setClosed(!closed)}
|
||||||
className={clsx(style.name, previewDisabled && style.previewDisabled)}>
|
className={style.name}>
|
||||||
|
|
||||||
{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:not(.previewDisabled) {
|
&:hover {
|
||||||
cursor: pointer;
|
|
||||||
text-decoration: underline dotted;
|
text-decoration: underline dotted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,4 @@ 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