mirror of
https://github.com/ershisan99/DevToysWeb.git
synced 2025-12-16 20:49:23 +00:00
refactor: make some variables grouped
This commit is contained in:
@@ -27,12 +27,14 @@ import { icons } from "@/components/icons";
|
|||||||
import { PageRootSection } from "@/components/page-root-section";
|
import { PageRootSection } from "@/components/page-root-section";
|
||||||
import { PageSection } from "@/components/page-section";
|
import { PageSection } from "@/components/page-section";
|
||||||
|
|
||||||
const two = " ";
|
const indentations = {
|
||||||
const four = " ";
|
two: " ",
|
||||||
|
four: " ",
|
||||||
|
};
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const [form, setForm] = useState({
|
const [form, setForm] = useState({
|
||||||
indentation: two,
|
indentation: indentations.two,
|
||||||
json: '{\n "foo": "bar"\n}',
|
json: '{\n "foo": "bar"\n}',
|
||||||
yaml: "foo: bar",
|
yaml: "foo: bar",
|
||||||
});
|
});
|
||||||
@@ -97,8 +99,8 @@ export default function Page() {
|
|||||||
<SelectValue placeholder={form.indentation} />
|
<SelectValue placeholder={form.indentation} />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value={two}>2 spaces</SelectItem>
|
<SelectItem value={indentations.two}>2 spaces</SelectItem>
|
||||||
<SelectItem value={four}>4 spaces</SelectItem>
|
<SelectItem value={indentations.four}>4 spaces</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,13 +24,15 @@ import { icons } from "@/components/icons";
|
|||||||
import { PageRootSection } from "@/components/page-root-section";
|
import { PageRootSection } from "@/components/page-root-section";
|
||||||
import { PageSection } from "@/components/page-section";
|
import { PageSection } from "@/components/page-section";
|
||||||
|
|
||||||
const two = " ";
|
const indentations = {
|
||||||
const four = " ";
|
two: " ",
|
||||||
const zero = "";
|
four: " ",
|
||||||
const tab = "\t";
|
zero: "",
|
||||||
|
tab: "\t",
|
||||||
|
};
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const [indentation, setIndentation] = useState(two);
|
const [indentation, setIndentation] = useState(indentations.two);
|
||||||
const [input, setInput] = useState('{\n"foo":"bar"\n}');
|
const [input, setInput] = useState('{\n"foo":"bar"\n}');
|
||||||
|
|
||||||
const parsed = safeJsonParse(input);
|
const parsed = safeJsonParse(input);
|
||||||
@@ -56,10 +58,10 @@ export default function Page() {
|
|||||||
<SelectValue placeholder={indentation} />
|
<SelectValue placeholder={indentation} />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value={two}>2 spaces</SelectItem>
|
<SelectItem value={indentations.two}>2 spaces</SelectItem>
|
||||||
<SelectItem value={four}>4 spaces</SelectItem>
|
<SelectItem value={indentations.four}>4 spaces</SelectItem>
|
||||||
<SelectItem value={tab}>1 tab</SelectItem>
|
<SelectItem value={indentations.tab}>1 tab</SelectItem>
|
||||||
<SelectItem value={zero}>minified</SelectItem>
|
<SelectItem value={indentations.zero}>minified</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,10 +28,12 @@ import { LabeledSwitch } from "@/components/labeled-switch";
|
|||||||
import { PageRootSection } from "@/components/page-root-section";
|
import { PageRootSection } from "@/components/page-root-section";
|
||||||
import { PageSection } from "@/components/page-section";
|
import { PageSection } from "@/components/page-section";
|
||||||
|
|
||||||
const v1 = "1";
|
const versions = {
|
||||||
const v4 = "4";
|
v1: "1",
|
||||||
|
v4: "4",
|
||||||
|
} as const;
|
||||||
|
|
||||||
const uuidVersions = t.keyof({ [v1]: null, [v4]: null });
|
const uuidVersions = t.keyof({ [versions.v1]: null, [versions.v4]: null });
|
||||||
type UuidVersion = t.TypeOf<typeof uuidVersions>;
|
type UuidVersion = t.TypeOf<typeof uuidVersions>;
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
@@ -118,8 +120,8 @@ export default function Page() {
|
|||||||
<SelectValue placeholder={uuidVersion} />
|
<SelectValue placeholder={uuidVersion} />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value={v1}>1</SelectItem>
|
<SelectItem value={versions.v1}>1</SelectItem>
|
||||||
<SelectItem value={v4}>4 (GUID)</SelectItem>
|
<SelectItem value={versions.v4}>4 (GUID)</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user