Add group details gen & recode input with text field component #22

Merged
MrKBear merged 8 commits from dev-mrkbear into master 2022-03-16 12:50:40 +08:00
4 changed files with 81 additions and 222 deletions
Showing only changes of commit 0e79c09691 - Show all commits

View File

@ -1,32 +1,6 @@
@import "../Theme/Theme.scss";
$line-min-height: 24px;
$line-min-height: 26px;
div.color-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%;
height: 100%;
max-width: 180px;
min-height: $line-min-height;
border-radius: 3px;
overflow: hidden;
display: flex;
div.color-input {
div.color-view {
width: $line-min-height;
@ -53,37 +27,6 @@ div.color-input-root {
padding-left: 1px;
}
}
div.error-box {
display: flex;
align-items: center;
padding-left: 8px;
}
}
}
div.dark.color-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.color-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.color-picker-root {

View File

@ -1,16 +1,11 @@
import { Component, createRef, ReactNode } from "react";
import { FontLevel, Theme } from "@Component/Theme/Theme";
import { TextField, ITextFieldProps } from "@Component/TextField/TextField";
import { Callout, ColorPicker, DirectionalHint } from "@fluentui/react";
import { AllI18nKeys, Localization } from "@Component/Localization/Localization";
import "./ColorInput.scss";
interface IColorInputProps {
keyI18n: AllI18nKeys;
infoI18n?: AllI18nKeys;
interface IColorInputProps extends ITextFieldProps {
value?: number[];
normal?: boolean;
disable?: boolean;
disableI18n?: AllI18nKeys;
valueChange?: (color: number[]) => any;
}
@ -65,16 +60,6 @@ class ColorInput extends Component<IColorInputProps, IColorInputState> {
</Callout>
}
private renderErrorInput() {
return <div className="error-box">
{
this.props.disableI18n ?
<Localization i18nKey={this.props.disableI18n}/> :
<span>{this.props.value}</span>
}
</div>;
}
private renderColorInput() {
return <>
<div className="color-view">
@ -104,29 +89,21 @@ class ColorInput extends Component<IColorInputProps, IColorInputState> {
public render(): ReactNode {
return <>
<Theme className="color-input-root" fontLevel={FontLevel.normal}>
<div className="input-intro">
<Localization i18nKey={this.props.keyI18n}/>
</div>
<div
className="root-content"
ref={this.pickerTarget}
style={{
cursor: this.props.disable ? "not-allowed" : "pointer"
}}
<TextField
{...this.props}
className="color-input"
keyI18n={this.props.keyI18n}
targetRef={this.pickerTarget}
onClick={() => {
this.setState({
isPickerVisible: !this.props.disable
isPickerVisible: !this.props.disableI18n
})
}}
>
{ this.props.disable ? null : this.renderColorInput() }
{ this.props.disable ? this.renderErrorInput() : null }
</div>
</Theme>
{ this.renderColorInput() }
</TextField>
{this.state.isPickerVisible ? this.renderPicker(): null}
</>
</>;
}
}

View File

@ -1,33 +1,8 @@
@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%;
height: 100%;
max-width: 180px;
min-height: $line-min-height;
border-radius: 3px;
overflow: hidden;
display: flex;
cursor: pointer;
div.combo-input {
div.value-view {
width: 100%;
@ -55,33 +30,3 @@ div.combo-input-root {
align-items: center;
}
}
}
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;
}

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,13 +50,11 @@ 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}/>
</div>
<div
className="root-content"
ref={this.pickerTarget}
<TextField
{...this.props}
targetRef={this.pickerTarget}
className="combo-input"
keyI18n={this.props.keyI18n}
onClick={() => {
this.setState({
isPickerVisible: true
@ -76,8 +71,7 @@ class ComboInput extends Component<IComboInputProps, IComboInputState> {
<div className="list-button">
<Icon iconName="ChevronDownMed"/>
</div>
</div>
</Theme>
</TextField>
{this.state.isPickerVisible ? this.renderPicker(): null}
</>