Recode color input & combo input with text field component

This commit is contained in:
2022-03-15 15:53:28 +08:00
parent 469ebd2ac9
commit 0e79c09691
4 changed files with 81 additions and 222 deletions
+21 -76
View File
@@ -1,87 +1,32 @@
@import "../Theme/Theme.scss";
$line-min-height: 26px;
$line-min-height: 24px;
div.combo-input-root {
width: 100%;
display: flex;
min-height: $line-min-height;
padding: 5px 0;
div.input-intro {
width: 50%;
height: 100%;
max-width: 220px;
min-height: $line-min-height;
display: flex;
align-items: center;
padding-right: 5px;
box-sizing: border-box;
}
div.root-content {
width: 50%;
div.combo-input {
div.value-view {
width: 100%;
height: 100%;
max-width: 180px;
min-height: $line-min-height;
border-radius: 3px;
overflow: hidden;
display: flex;
cursor: pointer;
align-items: center;
padding-left: 8px;
white-space: nowrap;
word-break: keep-all;
text-overflow: ellipsis;
overflow: hidden;
div.value-view {
width: 100%;
height: 100%;
min-height: $line-min-height;
display: flex;
align-items: center;
padding-left: 8px;
white-space: nowrap;
word-break: keep-all;
text-overflow: ellipsis;
overflow: hidden;
span {
display: block;
}
}
div.list-button {
width: $line-min-height;
height: $line-min-height;
flex-shrink: 0;
display: flex;
justify-content: center;
align-items: center;
span {
display: block;
}
}
}
div.dark.combo-input-root {
div.root-content {
background-color: $lt-bg-color-lvl3-dark;
color: $lt-font-color-normal-dark;
}
div.root-content:hover {
background-color: $lt-bg-color-lvl2-dark;
}
}
div.light.combo-input-root {
div.root-content {
background-color: $lt-bg-color-lvl3-light;
color: $lt-font-color-normal-light;
}
div.root-content:hover {
background-color: $lt-bg-color-lvl2-light;
}
}
div.combo-picker-root {
width: 300px;
height: 340px;
div.list-button {
width: $line-min-height;
height: $line-min-height;
flex-shrink: 0;
display: flex;
justify-content: center;
align-items: center;
}
}
+23 -29
View File
@@ -1,13 +1,10 @@
import { Component, createRef, ReactNode } from "react";
import { FontLevel, Theme } from "@Component/Theme/Theme";
import { PickerList, IDisplayItem } from "../PickerList/PickerList";
import { AllI18nKeys, Localization } from "@Component/Localization/Localization";
import { TextField, ITextFieldProps } from "../TextField/TextField";
import { Icon } from "@fluentui/react";
import { Localization } from "@Component/Localization/Localization";
import "./ComboInput.scss";
interface IComboInputProps {
keyI18n: AllI18nKeys;
infoI18n?: AllI18nKeys;
interface IComboInputProps extends ITextFieldProps {
allOption?: IDisplayItem[];
value?: IDisplayItem;
valueChange?: (value: IDisplayItem) => any;
@@ -53,31 +50,28 @@ class ComboInput extends Component<IComboInputProps, IComboInputState> {
public render(): ReactNode {
return <>
<Theme className="combo-input-root" fontLevel={FontLevel.normal}>
<div className="input-intro">
<Localization i18nKey={this.props.keyI18n}/>
<TextField
{...this.props}
targetRef={this.pickerTarget}
className="combo-input"
keyI18n={this.props.keyI18n}
onClick={() => {
this.setState({
isPickerVisible: true
})
}}
>
<div className="value-view">
{
this.props.value ?
<Localization i18nKey={this.props.value.nameKey}/> :
null
}
</div>
<div
className="root-content"
ref={this.pickerTarget}
onClick={() => {
this.setState({
isPickerVisible: true
})
}}
>
<div className="value-view">
{
this.props.value ?
<Localization i18nKey={this.props.value.nameKey}/> :
null
}
</div>
<div className="list-button">
<Icon iconName="ChevronDownMed"/>
</div>
<div className="list-button">
<Icon iconName="ChevronDownMed"/>
</div>
</Theme>
</TextField>
{this.state.isPickerVisible ? this.renderPicker(): null}
</>