From 851ca149b9ec9f2cbb0af5bee6fdc5a26f80e12b Mon Sep 17 00:00:00 2001 From: MrKBear Date: Thu, 17 Mar 2022 22:47:33 +0800 Subject: [PATCH] Optim object list checkout icon --- source/Component/DetailsList/DetailsList.scss | 2 +- source/Component/DetailsList/DetailsList.tsx | 50 ++++++++++++------- source/Panel/ObjectList/ObjectList.scss | 47 ++++++++++++++--- source/Panel/ObjectList/ObjectList.tsx | 17 +++++++ 4 files changed, 90 insertions(+), 26 deletions(-) diff --git a/source/Component/DetailsList/DetailsList.scss b/source/Component/DetailsList/DetailsList.scss index d98dcbb..adf1ad8 100644 --- a/source/Component/DetailsList/DetailsList.scss +++ b/source/Component/DetailsList/DetailsList.scss @@ -11,7 +11,7 @@ div.details-list { min-height: 30px; div.details-list-value { - padding: 5px 5px; + padding: 5px 0; display: flex; justify-content: center; align-items: center; diff --git a/source/Component/DetailsList/DetailsList.tsx b/source/Component/DetailsList/DetailsList.tsx index d50e2ca..74d2bad 100644 --- a/source/Component/DetailsList/DetailsList.tsx +++ b/source/Component/DetailsList/DetailsList.tsx @@ -23,10 +23,13 @@ interface IDetailsListProps { click?: () => void; clickLine?: (item: IItems) => any; checkBox?: (data: IItems) => any; + renderCheckbox?: (data: IItems, click: () => void) => ReactNode; } class DetailsList extends Component { + private propagationCount = 0; + private renderValue(item: IItems, column: IColumns) { const classList: string[] = []; if (!column.noDefaultStyle) { @@ -43,15 +46,36 @@ class DetailsList extends Component { } + private handelClickCheckbox(item: IItems) { + if (this.propagationCount <= 2 && this.props.checkBox) { + this.props.checkBox(item); + this.propagationCount = 2; + } + } + + private renderCheckbox(item: IItems) { + const { checkboxClassName } = this.props; + return
this.handelClickCheckbox(item)} + > + +
; + } + public render(): ReactNode { return { + if (this.propagationCount <= 0 && this.props.click) { + this.props.click(); + } + this.propagationCount = 0; + }} backgroundLevel={BackgroundLevel.Level4} fontLevel={FontLevel.normal} >{ this.props.items.map((item) => { - const { checkboxClassName } = this.props; const classList: string[] = ["details-list-item"]; if (item.select) { classList.push("active"); @@ -59,10 +83,10 @@ class DetailsList extends Component { return
{ - if (this.props.clickLine) { - e.stopPropagation(); + onClick={() => { + if (this.propagationCount <= 1 && this.props.clickLine) { this.props.clickLine(item); + this.propagationCount = 1; } }} > @@ -74,18 +98,10 @@ class DetailsList extends Component { }) } { - this.props.hideCheckBox ? null : -
{ - if (this.props.checkBox) { - e.stopPropagation(); - this.props.checkBox(item); - } - }} - > - -
+ this.props.hideCheckBox ? null : + this.props.renderCheckbox ? + this.props.renderCheckbox(item, () => this.handelClickCheckbox(item)) : + this.renderCheckbox(item) } { this.props.columns.map((column) => { diff --git a/source/Panel/ObjectList/ObjectList.scss b/source/Panel/ObjectList/ObjectList.scss index e66398b..b98f127 100644 --- a/source/Panel/ObjectList/ObjectList.scss +++ b/source/Panel/ObjectList/ObjectList.scss @@ -1,15 +1,46 @@ @import "../../Component/Theme/Theme.scss"; -div.object-list-color-value { - height: calc( 100% - 6px); - margin: 3px 0; - margin-left: 3px; - border-radius: 1000px; - width: 3px; -} - div.object-list { min-height: 100%; + + div.object-list-color-value { + height: calc( 100% - 6px); + margin: 3px 0; + margin-left: 3px; + border-radius: 1000px; + width: 3px; + } + + div.object-list-checkbox { + opacity: 1 !important; + padding-left: 2px; + + i.checkbox-icon { + display: none; + opacity: 0; + } + + i.type-icon { + display: inline-block; + opacity: 1; + } + } + + div.details-list-item:hover { + + div.object-list-checkbox { + + i.checkbox-icon { + display: inline-block; + opacity: 1; + } + + i.type-icon { + display: none; + opacity: 0; + } + } + } } div.object-list-command-bar { diff --git a/source/Panel/ObjectList/ObjectList.tsx b/source/Panel/ObjectList/ObjectList.tsx index 8e69711..6da3c46 100644 --- a/source/Panel/ObjectList/ObjectList.tsx +++ b/source/Panel/ObjectList/ObjectList.tsx @@ -4,6 +4,7 @@ import { useStatusWithEvent, IMixinStatusProps } from "@Context/Status"; import { useSetting, IMixinSettingProps } from "@Context/Setting"; import { Localization } from "@Component/Localization/Localization"; import { ObjectID } from "@Model/Renderer"; +import { Icon } from "@fluentui/react"; import "./ObjectList.scss"; @useSetting @@ -71,6 +72,22 @@ class ObjectList extends Component { this.props.status.setFocusObject(new Set()); } }} + renderCheckbox={(item, click) => { + let icon = "CheckMark"; + if (item.key.slice(0, 1) === "R") { + icon = "CubeShape"; + } + if (item.key.slice(0, 1) === "G") { + icon = "WebAppBuilderFragment"; + } + return
+ + +
; + }} columns={[ { key: "color",