Skip to content

Commit

Permalink
TSC
Browse files Browse the repository at this point in the history
  • Loading branch information
cohitre committed Feb 23, 2024
1 parent c8d1fbe commit 374b173
Show file tree
Hide file tree
Showing 32 changed files with 64 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import React, { useState } from 'react';

import { FormControlLabel, Switch } from '@mui/material';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { HexColorInput, HexColorPicker } from 'react-colorful';

import { Box, Stack, SxProps, Typography } from '@mui/material';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import React from 'react';

import { Box, Button, SxProps } from '@mui/material';

type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import React from 'react';

import BaseColorInput from './BaseColorInput';

type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState } from 'react';
import React, { useState } from 'react';

import { MenuItem, TextField } from '@mui/material';

import { FONT_FAMILIES } from '../../../../../../../documents/blocks/helpers/fontFamily';
import { FONT_FAMILIES } from '../../../../../../documents/blocks/helpers/fontFamily';

const OPTIONS = FONT_FAMILIES.map((option) => (
<MenuItem key={option.key} value={option.key} sx={{ fontFamily: option.value }}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import React, { useState } from 'react';

import { TextFieldsOutlined } from '@mui/icons-material';
import { InputLabel, Stack } from '@mui/material';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import React, { useState } from 'react';

import { ToggleButton } from '@mui/material';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import React, { useState } from 'react';

import {
AlignHorizontalLeftOutlined,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import React, { useState } from 'react';

import { InputLabel, Stack, ToggleButtonGroup } from '@mui/material';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import React, { useState } from 'react';

import { InputLabel, Stack } from '@mui/material';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import React, { useState } from 'react';

import { FormatAlignCenterOutlined, FormatAlignLeftOutlined, FormatAlignRightOutlined } from '@mui/icons-material';
import { ToggleButton } from '@mui/material';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import React, { useState } from 'react';

import { InputProps, TextField } from '@mui/material';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import React from 'react';

import { Box, Slider, Stack, Typography } from '@mui/material';

type SliderInputProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import SingleStylePropertyPanel, { TStyle } from './SingleStylePropertyPanel';
import React from 'react';

import { TStyle } from '../../../../../../documents/blocks/helpers/TStyle';

import SingleStylePropertyPanel from './SingleStylePropertyPanel';

type MultiStylePropertyPanelProps = {
names: (keyof TStyle)[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react';

import { RoundedCornerOutlined } from '@mui/icons-material';

import { TStyle } from '../../../../../../documents/blocks/helpers/TStyle';
import { NullableColorInput } from '../inputs/ColorInput';
import { NullableFontFamily } from '../inputs/FontFamily';
import FontSizeInput from '../inputs/FontSizeInput';
Expand All @@ -8,27 +11,14 @@ import PaddingInput from '../inputs/PaddingInput';
import SliderInput from '../inputs/SliderInput';
import TextAlignInput from '../inputs/TextAlignInput';

/* eslint-disable @typescript-eslint/no-explicit-any */

type TStyle = {
backgroundColor?: any;
borderColor?: any;
borderRadius?: any;
color?: any;
fontFamily?: any;
fontSize?: any;
fontWeight?: any;
padding?: any;
textAlign?: any;
};

type StylePropertyPanelProps = {
name: keyof TStyle;
value: TStyle;
onChange: (style: TStyle) => void;
};
export default function SingleStylePropertyPanel({ name, value, onChange }: StylePropertyPanelProps) {
const defaultValue = value[name] ?? null;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handleChange = (v: any) => {
onChange({ ...value, [name]: v });
};
Expand Down
1 change: 1 addition & 0 deletions packages/editor-sample/src/documents/blocks/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { z } from 'zod';

import { zColor, zPadding, zTextAlign } from './helpers/zod';
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-sample/src/documents/blocks/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CSSProperties } from 'react';
import React, { CSSProperties } from 'react';
import { z } from 'zod';

import { zColor, zFontFamily, zFontWeight, zPadding, zTextAlign } from './helpers/zod';
Expand Down
1 change: 1 addition & 0 deletions packages/editor-sample/src/documents/blocks/Divider.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { z } from 'zod';

import { zColor, zPadding } from './helpers/zod';
Expand Down
1 change: 1 addition & 0 deletions packages/editor-sample/src/documents/blocks/Heading.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { z } from 'zod';

import { zColor, zFontFamily, zFontWeight, zPadding, zTextAlign } from './helpers/zod';
Expand Down
1 change: 1 addition & 0 deletions packages/editor-sample/src/documents/blocks/Html.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { z } from 'zod';

import { zColor, zFontFamily, zPadding, zTextAlign } from './helpers/zod';
Expand Down
1 change: 1 addition & 0 deletions packages/editor-sample/src/documents/blocks/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { z } from 'zod';

import { zColor, zPadding, zTextAlign } from './helpers/zod';
Expand Down
1 change: 1 addition & 0 deletions packages/editor-sample/src/documents/blocks/Spacer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { z } from 'zod';

export const SpacerPropsSchema = z.object({
Expand Down
1 change: 1 addition & 0 deletions packages/editor-sample/src/documents/blocks/Text.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { z } from 'zod';

import { zColor, zFontFamily, zFontWeight, zPadding, zTextAlign } from './helpers/zod';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import React from 'react';

import { Box, Menu } from '@mui/material';

import { TBlockConfiguration } from '../../../../documents';
import { TEditorBlock } from '../../../../editor/core';

import BlockButton from './BlockButton';
import { BUTTONS } from './buttons';

type BlocksMenuProps = {
anchorEl: HTMLElement | null;
setAnchorEl: (v: HTMLElement | null) => void;
onSelect: (block: TBlockConfiguration) => void;
onSelect: (block: TEditorBlock) => void;
};
export default function BlocksMenu({ anchorEl, setAnchorEl, onSelect }: BlocksMenuProps) {
const onClose = () => {
setAnchorEl(null);
};

const onClick = (block: TBlockConfiguration) => {
const onClick = (block: TEditorBlock) => {
onSelect(block);
setAnchorEl(null);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import React, { useEffect, useState } from 'react';

import { AddOutlined } from '@mui/icons-material';
import { Fade, IconButton } from '@mui/material';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import React from 'react';

import { AddOutlined } from '@mui/icons-material';
import { ButtonBase } from '@mui/material';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useState } from 'react';
import React, { useState } from 'react';

import { TBlockConfiguration } from '../../../../documents';
import { TEditorBlock } from '../../../../editor/core';

import BlocksMenu from './BlocksMenu';
import DividerButton from './DividerButton';
import PlaceholderButton from './PlaceholderButton';

type Props = {
placeholder?: boolean;
onSelect: (block: TBlockConfiguration) => void;
onSelect: (block: TEditorBlock) => void;
};
export default function AddBlockButton({ onSelect, placeholder }: Props) {
const [menuAnchorEl, setMenuAnchorEl] = useState<HTMLElement | null>(null);
Expand Down
13 changes: 13 additions & 0 deletions packages/editor-sample/src/documents/blocks/helpers/TStyle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

export type TStyle = {
backgroundColor?: any;
borderColor?: any;
borderRadius?: any;
color?: any;
fontFamily?: any;
fontSize?: any;
fontWeight?: any;
padding?: any;
textAlign?: any;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,13 @@ import { Box } from '@mui/material';

import { useCurrentBlockId } from '../../../editor/EditorBlock';
import { useEditorState } from '../../../editor/EditorContext';
import { TStyle } from '../TStyle';

import ReaderBlockWrapper from './ReaderBlockWrapper';
import TuneMenu from './TuneMenu';

type TEditorBlockWrapperProps = {
style: {
/* eslint-disable @typescript-eslint/no-explicit-any */
backgroundColor?: any;
borderColor?: any;
borderRadius?: any;
color?: any;
fontFamily?: any;
fontSize?: any;
fontWeight?: any;
padding?: any;
textAlign?: any;
/* eslint-enable @typescript-eslint/no-explicit-any */
};
style: TStyle;
children: JSX.Element;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CSSProperties } from 'react';
import React, { CSSProperties } from 'react';

import { TStyle } from '../../../App/sidebar/ConfigurationPanel/input-panels/helpers/style-inputs/SingleStylePropertyPanel';
import { TStyle } from '../TStyle';

type TReaderBlockWrapperProps = {
style: TStyle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IconButton, Paper, Stack, Tooltip } from '@mui/material';

import { TEditorBlock } from '../../../editor/core';
import { useEditorState } from '../../../editor/EditorContext';
import { ColumnsContainerProps } from '../../ColumnsContainer';
import { ColumnsContainerProps } from '../../ColumnsContainer/ColumnsContainerPropsSchema';

const STYLE: CSSProperties = {
position: 'absolute',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { TStyle } from '../../../App/sidebar/ConfigurationPanel/input-panels/helpers/style-inputs/SingleStylePropertyPanel';
import { TStyle } from '../TStyle';

import EditorBlockWrapper from './EditorBlockWrapper';
import ReaderBlockWrapper from './ReaderBlockWrapper';
Expand Down

0 comments on commit 374b173

Please sign in to comment.