diff --git a/src/components/common/CodeEditor.tsx b/src/components/common/CodeEditor.tsx index 575e742..4b5c184 100644 --- a/src/components/common/CodeEditor.tsx +++ b/src/components/common/CodeEditor.tsx @@ -1,4 +1,4 @@ -import { Paper } from "@mui/material"; +import { css, Theme } from "@mui/material/styles"; import { config } from "ace-builds"; import { ComponentPropsWithoutRef, memo } from "react"; import AceEditor from "react-ace"; @@ -12,19 +12,24 @@ config.setModuleUrl( type Props = ComponentPropsWithoutRef; +const editor = (theme: Theme) => css` + box-shadow: ${theme.shadows[1]}; +`; + const StyledComponent = (props: Props) => ( - - - + ); export const Component = memo(StyledComponent); diff --git a/src/components/common/CodeEditorHalf.tsx b/src/components/common/CodeEditorHalf.tsx deleted file mode 100644 index 9ff9911..0000000 --- a/src/components/common/CodeEditorHalf.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { useTheme } from "@mui/material/styles"; -import { ComponentPropsWithoutRef, memo } from "react"; - -import { drawerWidth } from "@/components/layout/Drawer"; -import { headerHeight } from "@/components/layout/Header"; - -import CodeEditor from "./CodeEditor"; - -type Props = Omit, "width">; - -const StyledComponent = (props: Props) => { - const theme = useTheme(); - - return ( - - ); -}; - -export const Component = memo(StyledComponent); - -export default Component; diff --git a/src/components/common/CodeEditorHalfLoading.tsx b/src/components/common/CodeEditorHalfLoading.tsx deleted file mode 100644 index ca78dd5..0000000 --- a/src/components/common/CodeEditorHalfLoading.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { Skeleton } from "@mui/material"; -import { useTheme } from "@mui/material/styles"; -import { ComponentPropsWithoutRef, memo } from "react"; - -import { drawerWidth } from "@/components/layout/Drawer"; -import { headerHeight } from "@/components/layout/Header"; - -type Props = Omit, "width">; - -const StyledComponent = (props: Props) => { - const theme = useTheme(); - - return ( - - ); -}; - -export const Component = memo(StyledComponent); - -export default Component; diff --git a/src/components/common/Main.tsx b/src/components/common/Main.tsx index 7b743b4..eecfce8 100644 --- a/src/components/common/Main.tsx +++ b/src/components/common/Main.tsx @@ -1,24 +1,28 @@ -import { Box, Stack, Typography } from "@mui/material"; +import { Stack, Typography } from "@mui/material"; import { css, Theme } from "@mui/material/styles"; -import { memo, PropsWithChildren } from "react"; +import { ComponentPropsWithoutRef, memo, PropsWithChildren } from "react"; -type Props = PropsWithChildren<{ - title: string; -}>; +type Props = PropsWithChildren< + { + title: string; + } & ComponentPropsWithoutRef +>; const mainTitle = (theme: Theme) => css` font-size: ${theme.typography.fontSize * 3}px; font-weight: 400; - margin-bottom: ${theme.spacing(2)}; `; -const StyledComponent = ({ children, title }: Props) => ( - +const StyledComponent = ({ children, title, ...stackProps }: Props) => ( + // eslint-disable-next-line react/jsx-props-no-spreading + {title} - {children} - + + {children} + + ); export const Component = memo(StyledComponent); diff --git a/src/components/common/MainItem.tsx b/src/components/common/MainItem.tsx index 501958c..90f89c8 100644 --- a/src/components/common/MainItem.tsx +++ b/src/components/common/MainItem.tsx @@ -1,17 +1,20 @@ -import { Box, Typography } from "@mui/material"; -import { memo, PropsWithChildren } from "react"; +import { Box, Stack, Typography } from "@mui/material"; +import { ComponentPropsWithoutRef, memo, PropsWithChildren } from "react"; -type Props = PropsWithChildren<{ - title: string; -}>; +type Props = PropsWithChildren< + { + title: string; + } & ComponentPropsWithoutRef +>; -const StyledComponent = ({ children, title }: Props) => ( - +const StyledComponent = ({ children, title, ...stackProps }: Props) => ( + // eslint-disable-next-line react/jsx-props-no-spreading + {title} - {children} - + {children} + ); export const Component = memo(StyledComponent); diff --git a/src/components/common/index.ts b/src/components/common/index.ts index eeaaa34..e775486 100644 --- a/src/components/common/index.ts +++ b/src/components/common/index.ts @@ -1,8 +1,7 @@ -import CodeEditorHalfLoading from "./CodeEditorHalfLoading"; import Configurations from "./Configurations"; import Main from "./Main"; import MainItem from "./MainItem"; import TextField from "./TextField"; import ToolCardGrid from "./ToolCardGrid"; -export { CodeEditorHalfLoading, Configurations, Main, MainItem, TextField, ToolCardGrid }; +export { Configurations, Main, MainItem, TextField, ToolCardGrid }; diff --git a/src/components/pages/converters/json-yaml/Content.tsx b/src/components/pages/converters/json-yaml/Content.tsx index cd019ce..83daab7 100644 --- a/src/components/pages/converters/json-yaml/Content.tsx +++ b/src/components/pages/converters/json-yaml/Content.tsx @@ -1,27 +1,27 @@ -import { Stack } from "@mui/material"; +import { Skeleton, Stack } from "@mui/material"; import dynamic from "next/dynamic"; import { ComponentPropsWithoutRef, memo, useCallback, useState } from "react"; import YAML from "yaml"; -import { CodeEditorHalfLoading, Main, MainItem } from "@/components/common"; +import { Main, MainItem } from "@/components/common"; import Configuration, { isSpaces, Spaces } from "./Configuration"; // https://github.com/securingsincity/react-ace/issues/27 -const CodeEditorHalf = dynamic( +const CodeEditor = dynamic( async () => { - const ace = await import("@/components/common/CodeEditorHalf"); + const ace = await import("@/components/common/CodeEditor"); await Promise.all([ import("ace-builds/src-noconflict/mode-json"), import("ace-builds/src-noconflict/mode-yaml"), ]); return ace; }, - { ssr: false, loading: () => } + { ssr: false, loading: () => } ); -type CodeValue = NonNullable["value"]>; -type OnCodeChange = NonNullable["onChange"]>; +type CodeValue = NonNullable["value"]>; +type OnCodeChange = NonNullable["onChange"]>; type Props = { json: CodeValue; @@ -42,24 +42,12 @@ const StyledComponent = ({ - - - + + + - - + + diff --git a/src/components/pages/encoders-decoders/jwt/CodeEditor.tsx b/src/components/pages/encoders-decoders/jwt/CodeEditor.tsx deleted file mode 100644 index 2081d54..0000000 --- a/src/components/pages/encoders-decoders/jwt/CodeEditor.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { ComponentPropsWithoutRef, memo } from "react"; - -import CodeEditor from "@/components/common/CodeEditor"; - -type Props = Omit, "height" | "width">; - -const StyledComponent = (props: Props) => ( - -); - -export const Component = memo(StyledComponent); - -export default Component; diff --git a/src/components/pages/encoders-decoders/jwt/CodeEditorLoading.tsx b/src/components/pages/encoders-decoders/jwt/CodeEditorLoading.tsx deleted file mode 100644 index 2d630d3..0000000 --- a/src/components/pages/encoders-decoders/jwt/CodeEditorLoading.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { Skeleton } from "@mui/material"; -import { memo } from "react"; - -const StyledComponent = () => ; - -export const Component = memo(StyledComponent); - -export default Component; diff --git a/src/components/pages/encoders-decoders/jwt/Content.tsx b/src/components/pages/encoders-decoders/jwt/Content.tsx index c6020f1..e1e45fe 100644 --- a/src/components/pages/encoders-decoders/jwt/Content.tsx +++ b/src/components/pages/encoders-decoders/jwt/Content.tsx @@ -1,19 +1,18 @@ +import { Skeleton } from "@mui/material"; import dynamic from "next/dynamic"; import { ComponentPropsWithoutRef, memo, useCallback, useState } from "react"; import { Main, MainItem, TextField } from "@/components/common"; import { decode } from "@/libs/jwt"; -import CodeEditorLoading from "./CodeEditorLoading"; - // https://github.com/securingsincity/react-ace/issues/27 const CodeEditor = dynamic( async () => { - const ace = await import("./CodeEditor"); + const ace = await import("@/components/common/CodeEditor"); await import("ace-builds/src-noconflict/mode-json"); return ace; }, - { ssr: false, loading: CodeEditorLoading } + { ssr: false, loading: () => } ); type TextFieldValue = ComponentPropsWithoutRef["value"]; @@ -33,10 +32,10 @@ const StyledComponent = ({ jwt, header, payload, onJwtChange }: Props) => ( - + - + ); diff --git a/src/components/pages/formatters/json/Content.tsx b/src/components/pages/formatters/json/Content.tsx index 146f876..c3d7680 100644 --- a/src/components/pages/formatters/json/Content.tsx +++ b/src/components/pages/formatters/json/Content.tsx @@ -1,23 +1,23 @@ -import { Stack } from "@mui/material"; +import { Skeleton, Stack } from "@mui/material"; import dynamic from "next/dynamic"; import { ComponentPropsWithoutRef, memo, useCallback, useState } from "react"; -import { CodeEditorHalfLoading, Main, MainItem } from "@/components/common"; +import { Main, MainItem } from "@/components/common"; import Configuration, { isSpaces, Spaces } from "./Configuration"; // https://github.com/securingsincity/react-ace/issues/27 -const CodeEditorHalf = dynamic( +const CodeEditor = dynamic( async () => { - const ace = await import("@/components/common/CodeEditorHalf"); + const ace = await import("@/components/common/CodeEditor"); await import("ace-builds/src-noconflict/mode-json"); return ace; }, - { ssr: false, loading: () => } + { ssr: false, loading: () => } ); -type CodeValue = NonNullable["value"]>; -type OnCodeChange = NonNullable["onChange"]>; +type CodeValue = NonNullable["value"]>; +type OnCodeChange = NonNullable["onChange"]>; type Props = { json: CodeValue; @@ -30,12 +30,12 @@ const StyledComponent = ({ json, formatted, spaces, onJsonChange, onSpacesChange - - - + + + - - + + diff --git a/src/components/pages/home/Content.tsx b/src/components/pages/home/Content.tsx index 1da48ff..3d6142b 100644 --- a/src/components/pages/home/Content.tsx +++ b/src/components/pages/home/Content.tsx @@ -6,7 +6,7 @@ import { homeTools } from "@/data/tools"; type Props = ComponentPropsWithoutRef; const StyledComponent = ({ tools }: Props) => ( -
+
);