Recode color input & combo input with text field component
This commit is contained in:
		
							parent
							
								
									469ebd2ac9
								
							
						
					
					
						commit
						0e79c09691
					
				| @ -1,89 +1,32 @@ | |||||||
| @import "../Theme/Theme.scss"; | $line-min-height: 24px; | ||||||
| 
 | 
 | ||||||
| $line-min-height: 26px; | div.color-input { | ||||||
| 
 | 
 | ||||||
| div.color-input-root { |     div.color-view { | ||||||
| 	width: 100%; |         width: $line-min-height; | ||||||
| 	display: flex; |         max-width: $line-min-height; | ||||||
| 	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; |         display: flex; | ||||||
|  |         justify-content: center; | ||||||
|  |         align-items: center; | ||||||
| 
 | 
 | ||||||
|         div.color-view { |         div.color-box { | ||||||
|             width: $line-min-height; |             width: 12px; | ||||||
|             max-width: $line-min-height; |             height: 12px; | ||||||
|             display: flex; |             border-radius: 3px; | ||||||
|             justify-content: center; |  | ||||||
|             align-items: center; |  | ||||||
| 
 |  | ||||||
|             div.color-box { |  | ||||||
|                 width: 12px; |  | ||||||
|                 height: 12px; |  | ||||||
|                 border-radius: 3px; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         div.value-view { |  | ||||||
|             width: 100%; |  | ||||||
|             height: 100%; |  | ||||||
|             min-height: $line-min-height; |  | ||||||
|             display: flex; |  | ||||||
|             align-items: center; |  | ||||||
| 
 |  | ||||||
|             div.text-box { |  | ||||||
|                 padding-left: 1px; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         div.error-box { |  | ||||||
|             display: flex; |  | ||||||
|             align-items: center; |  | ||||||
|             padding-left: 8px; |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| div.dark.color-input-root { |     div.value-view { | ||||||
|  |         width: 100%; | ||||||
|  |         height: 100%; | ||||||
|  |         min-height: $line-min-height; | ||||||
|  |         display: flex; | ||||||
|  |         align-items: center; | ||||||
| 
 | 
 | ||||||
| 	div.root-content { |         div.text-box { | ||||||
| 		background-color: $lt-bg-color-lvl3-dark; |             padding-left: 1px; | ||||||
| 		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 { | div.color-picker-root { | ||||||
|  | |||||||
| @ -1,16 +1,11 @@ | |||||||
| import { Component, createRef, ReactNode } from "react"; | 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 { Callout, ColorPicker, DirectionalHint } from "@fluentui/react"; | ||||||
| import { AllI18nKeys, Localization } from "@Component/Localization/Localization"; |  | ||||||
| import "./ColorInput.scss"; | import "./ColorInput.scss"; | ||||||
| 
 | 
 | ||||||
| interface IColorInputProps { | interface IColorInputProps extends ITextFieldProps { | ||||||
|     keyI18n: AllI18nKeys; |  | ||||||
|     infoI18n?: AllI18nKeys; |  | ||||||
|     value?: number[]; |     value?: number[]; | ||||||
|     normal?: boolean; |     normal?: boolean; | ||||||
|     disable?: boolean; |  | ||||||
|     disableI18n?: AllI18nKeys; |  | ||||||
|     valueChange?: (color: number[]) => any; |     valueChange?: (color: number[]) => any; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -65,16 +60,6 @@ class ColorInput extends Component<IColorInputProps, IColorInputState> { | |||||||
|         </Callout> |         </Callout> | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private renderErrorInput() { |  | ||||||
|         return <div className="error-box"> |  | ||||||
|             { |  | ||||||
|                 this.props.disableI18n ?  |  | ||||||
|                 <Localization i18nKey={this.props.disableI18n}/> : |  | ||||||
|                 <span>{this.props.value}</span> |  | ||||||
|             } |  | ||||||
|         </div>; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     private renderColorInput() { |     private renderColorInput() { | ||||||
|         return <> |         return <> | ||||||
|             <div className="color-view"> |             <div className="color-view"> | ||||||
| @ -104,29 +89,21 @@ class ColorInput extends Component<IColorInputProps, IColorInputState> { | |||||||
| 
 | 
 | ||||||
|     public render(): ReactNode { |     public render(): ReactNode { | ||||||
|         return <> |         return <> | ||||||
|             <Theme className="color-input-root" fontLevel={FontLevel.normal}> |             <TextField | ||||||
|                 <div className="input-intro"> |                 {...this.props} | ||||||
|                     <Localization i18nKey={this.props.keyI18n}/> |                 className="color-input" | ||||||
|                 </div> |                 keyI18n={this.props.keyI18n} | ||||||
|                 <div |                 targetRef={this.pickerTarget} | ||||||
|                     className="root-content" |                 onClick={() => { | ||||||
|                     ref={this.pickerTarget} |                     this.setState({ | ||||||
|                     style={{ |                         isPickerVisible: !this.props.disableI18n | ||||||
|                         cursor: this.props.disable ? "not-allowed" : "pointer" |                     }) | ||||||
|                     }} |                 }} | ||||||
|                     onClick={() => { |             > | ||||||
|                         this.setState({ |                 { this.renderColorInput() } | ||||||
|                             isPickerVisible: !this.props.disable |             </TextField> | ||||||
|                         }) |  | ||||||
|                     }} |  | ||||||
|                 > |  | ||||||
|                     { this.props.disable ? null : this.renderColorInput() } |  | ||||||
|                     { this.props.disable ? this.renderErrorInput() : null } |  | ||||||
|                 </div> |  | ||||||
|             </Theme> |  | ||||||
| 
 |  | ||||||
|             {this.state.isPickerVisible ?  this.renderPicker(): null} |             {this.state.isPickerVisible ?  this.renderPicker(): null} | ||||||
|         </> |         </>; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,87 +1,32 @@ | |||||||
| @import "../Theme/Theme.scss"; | @import "../Theme/Theme.scss"; | ||||||
| 
 | 
 | ||||||
| $line-min-height: 26px; | $line-min-height: 24px; | ||||||
| 
 | 
 | ||||||
| div.combo-input-root { | div.combo-input { | ||||||
| 	width: 100%; |  | ||||||
| 	display: flex; |  | ||||||
| 	min-height: $line-min-height; |  | ||||||
| 	padding: 5px 0; |  | ||||||
| 	 | 	 | ||||||
|     div.input-intro { |     div.value-view { | ||||||
| 		width: 50%; |         width: 100%; | ||||||
| 		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%; |         height: 100%; | ||||||
|         max-width: 180px; |  | ||||||
|         min-height: $line-min-height; |         min-height: $line-min-height; | ||||||
|         border-radius: 3px; |  | ||||||
|         overflow: hidden; |  | ||||||
|         display: flex; |         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 { |         span { | ||||||
|             width: 100%; |             display: block; | ||||||
|             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; |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | 
 | ||||||
| 
 |     div.list-button { | ||||||
| div.dark.combo-input-root { |         width: $line-min-height; | ||||||
| 
 |         height: $line-min-height; | ||||||
| 	div.root-content { |         flex-shrink: 0; | ||||||
| 		background-color: $lt-bg-color-lvl3-dark; |         display: flex; | ||||||
| 		color: $lt-font-color-normal-dark; |         justify-content: center; | ||||||
| 	} |         align-items: center; | ||||||
| 
 |     } | ||||||
| 	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; |  | ||||||
| } | } | ||||||
| @ -1,13 +1,10 @@ | |||||||
| import { Component, createRef, ReactNode } from "react"; | import { Component, createRef, ReactNode } from "react"; | ||||||
| import { FontLevel, Theme } from "@Component/Theme/Theme"; |  | ||||||
| import { PickerList, IDisplayItem } from "../PickerList/PickerList"; | 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 { Icon } from "@fluentui/react"; | ||||||
|  | import { Localization } from "@Component/Localization/Localization"; | ||||||
| import "./ComboInput.scss"; | import "./ComboInput.scss"; | ||||||
| 
 | interface IComboInputProps extends ITextFieldProps { | ||||||
| interface IComboInputProps { |  | ||||||
|     keyI18n: AllI18nKeys; |  | ||||||
|     infoI18n?: AllI18nKeys; |  | ||||||
|     allOption?: IDisplayItem[]; |     allOption?: IDisplayItem[]; | ||||||
|     value?: IDisplayItem; |     value?: IDisplayItem; | ||||||
|     valueChange?: (value: IDisplayItem) => any; |     valueChange?: (value: IDisplayItem) => any; | ||||||
| @ -53,31 +50,28 @@ class ComboInput extends Component<IComboInputProps, IComboInputState> { | |||||||
| 
 | 
 | ||||||
|     public render(): ReactNode { |     public render(): ReactNode { | ||||||
|         return <> |         return <> | ||||||
|             <Theme className="combo-input-root" fontLevel={FontLevel.normal}> |             <TextField | ||||||
|                 <div className="input-intro"> |                 {...this.props} | ||||||
|                     <Localization i18nKey={this.props.keyI18n}/> |                 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> | ||||||
|                 <div |                 <div className="list-button"> | ||||||
|                     className="root-content" |                     <Icon iconName="ChevronDownMed"/> | ||||||
|                     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> |                 </div> | ||||||
|             </Theme> |             </TextField> | ||||||
| 
 | 
 | ||||||
|             {this.state.isPickerVisible ?  this.renderPicker(): null} |             {this.state.isPickerVisible ?  this.renderPicker(): null} | ||||||
|         </> |         </> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user