From de011db656cf36c30c0ac9c2403412b20bef90e4 Mon Sep 17 00:00:00 2001 From: Jeremy <297323986@qq.com> Date: Tue, 28 Jan 2025 18:06:11 +0800 Subject: [PATCH] Set border page --- .../top-bar/content/border-setting.tsx | 317 ++++++++++++++++++ src/components/top-bar/content/index.tsx | 26 ++ .../top-bar/content/start.module.scss | 2 +- 3 files changed, 344 insertions(+), 1 deletion(-) create mode 100644 src/components/top-bar/content/border-setting.tsx diff --git a/src/components/top-bar/content/border-setting.tsx b/src/components/top-bar/content/border-setting.tsx new file mode 100644 index 00000000..fcdd27bd --- /dev/null +++ b/src/components/top-bar/content/border-setting.tsx @@ -0,0 +1,317 @@ +import {SelectedData} from '@/components/canvas' +import {DataService} from '@/core/data' +import {useInjection} from '@/core/ioc/provider' +import {TYPES} from '@/core/ioc/types' +import {useState} from 'react' +import { + Box, + Button, + Typography, + FormControl, + FormLabel, + RadioGroup, + FormControlLabel, + Radio, + Select, + MenuItem, + ToggleButtonGroup, + ToggleButton, +} from '@mui/material' +import BorderAllIcon from '@mui/icons-material/BorderAll' +import BorderBottomIcon from '@mui/icons-material/BorderBottom' +import BorderClearIcon from '@mui/icons-material/BorderClear' +import BorderHorizontalIcon from '@mui/icons-material/BorderHorizontal' +import BorderInnerIcon from '@mui/icons-material/BorderInner' +import BorderOuterIcon from '@mui/icons-material/BorderOuter' +import BorderRightIcon from '@mui/icons-material/BorderRight' +import BorderTopIcon from '@mui/icons-material/BorderTop' +import BorderVerticalIcon from '@mui/icons-material/BorderVertical' +import BorderLeftIcon from '@mui/icons-material/BorderLeft' +import {ColorResult, SketchPicker} from 'react-color' + +export interface BorderSettingProps { + readonly selectedData?: SelectedData + readonly close: () => void +} + +export const BorderSettingComponent = ({ + selectedData, + close, +}: BorderSettingProps) => { + const DATA_SERVICE = useInjection(TYPES.Data) + + const [color, setColor] = useState('#000000') + const [lineWidth, setLineWidth] = useState(1) + const [borderStyle, setBorderStyle] = useState('solid') + const [showColorPicker, setShowColorPicker] = useState(false) + const [selectedRange, setSelectedRange] = useState('all') + + const applySettings = () => { + if (!selectedData) return + + // DATA_SERVICE.setBorder({ + // range: selectedData.range, + // color, + // lineWidth, + // style: borderStyle, + // }) + + close() + } + + return ( + + + Border Settings + + + + + Color + setShowColorPicker(!showColorPicker)} + /> + {showColorPicker && ( + + + setColor(colorResult.hex) + } + /> + + )} + + + + Line Width + + + + + + + Style + setBorderStyle(e.target.value)} + > + } + label="Solid" + /> + } + label="Dashed" + /> + } + label="Dotted" + /> + + + + + + + Border Range + { + if (newRange !== null) setSelectedRange(newRange) + }} + sx={{flexWrap: 'wrap'}} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/* Preview Section */} + + + + + + + + + + + + + + ) +} diff --git a/src/components/top-bar/content/index.tsx b/src/components/top-bar/content/index.tsx index 8ab045a0..1a163c93 100644 --- a/src/components/top-bar/content/index.tsx +++ b/src/components/top-bar/content/index.tsx @@ -22,6 +22,7 @@ import FormatAlignLeftIcon from '@mui/icons-material/FormatAlignLeft' import FormatAlignCenterIcon from '@mui/icons-material/FormatAlignCenter' import FormatAlignRightIcon from '@mui/icons-material/FormatAlignRight' import FormatAlignJustifyIcon from '@mui/icons-material/FormatAlignJustify' +import BorderClearIcon from '@mui/icons-material/BorderClear' import MergeTypeIcon from '@mui/icons-material/MergeType' import UndoIcon from '@mui/icons-material/Undo' import RedoIcon from '@mui/icons-material/Redo' @@ -42,6 +43,7 @@ import { Payload, } from 'logisheets-web' import {SplitMergedCellsBuilder} from 'packages/web' +import {BorderSettingComponent} from './border-setting' export * from './font-size' export * from './start-item' @@ -65,6 +67,8 @@ export const StartComponent = ({selectedData}: StartProps) => { const [mergedOn, setMergedOn] = useState(null) + const [borderSettingOn, setBorderSettingOn] = useState(false) + let mergedCells: readonly MergeCell[] = [] useEffect(() => { @@ -429,6 +433,14 @@ export const StartComponent = ({selectedData}: StartProps) => { */} + setBorderSettingOn(!borderSettingOn)} + > + + { className={styles['color-picker']} /> + + setBorderSettingOn(false)} + /> + ) } diff --git a/src/components/top-bar/content/start.module.scss b/src/components/top-bar/content/start.module.scss index 000eb74f..d8232368 100644 --- a/src/components/top-bar/content/start.module.scss +++ b/src/components/top-bar/content/start.module.scss @@ -37,7 +37,7 @@ .modal-content { position: absolute; - background-color: rgba(255, 255, 255, 0); // 透明背景 + background-color: rgba(255, 255, 255, 0); border: none; margin: 0; padding: 0;