feat: add Json <> Yaml converter

This commit is contained in:
rusconn
2022-03-26 03:18:44 +00:00
parent 55fd4a6473
commit 20df0b8c19
16 changed files with 398 additions and 6 deletions

View File

@@ -0,0 +1,50 @@
import { SpaceBar } from "@mui/icons-material";
import { FormControl, MenuItem, Select } from "@mui/material";
import { SelectInputProps } from "@mui/material/Select/SelectInput";
import { css } from "@mui/material/styles";
import { memo } from "react";
import { Configurations } from "@/components/common";
const spacesArray = [2, 4] as const;
export type Spaces = typeof spacesArray[number];
export const isSpaces = (x: number): x is Spaces => spacesArray.includes(x as Spaces);
type OnSelectChange<T> = NonNullable<SelectInputProps<T>["onChange"]>;
type Props = {
spaces: Spaces;
onSpacesChange: OnSelectChange<Spaces>;
};
const select = css`
& .MuiSelect-select:focus {
background-color: transparent;
}
`;
const StyledComponent = ({ spaces, onSpacesChange }: Props) => (
<Configurations
configurations={[
{
icon: <SpaceBar />,
title: "Indentation",
input: (
<FormControl variant="standard">
<Select value={spaces} onChange={onSpacesChange} css={select}>
{spacesArray.map(value => (
<MenuItem key={value} {...{ value }}>
{value} spaces
</MenuItem>
))}
</Select>
</FormControl>
),
},
]}
/>
);
export const Component = memo(StyledComponent);
export default Component;