-
Notifications
You must be signed in to change notification settings - Fork 2.9k
TextField: Convert to JS Styling #5639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4f4176b
db1b1e5
5cbb1ad
0aa285a
02ba7c7
c4d2a81
de36bc5
bdf4197
275d476
1d7cd5d
d2fffc5
8b9a4cc
bf03d88
3909760
93b7982
ce9ac44
83652e2
115dd4e
75143d4
14f8901
aa7f1fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@uifabric/experiments", | ||
| "comment": "Comment out unused test.", | ||
| "type": "none" | ||
| } | ||
| ], | ||
| "packageName": "@uifabric/experiments", | ||
| "email": "[email protected]" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@uifabric/merge-styles", | ||
| "comment": "Add resize rule to IRawStyleBase.", | ||
| "type": "minor" | ||
| } | ||
| ], | ||
| "packageName": "@uifabric/merge-styles", | ||
| "email": "[email protected]" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "TextField: Convert to JS styling.", | ||
| "type": "minor" | ||
| } | ||
| ], | ||
| "packageName": "office-ui-fabric-react", | ||
| "email": "[email protected]" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import * as React from 'react'; | ||
| import { BaseComponent, classNamesFunction } from '../../Utilities'; | ||
| import { BaseComponent, classNamesFunction, createRef } from '../../Utilities'; | ||
| import { IColorPickerProps, IColorPickerStyleProps, IColorPickerStyles } from './ColorPicker.types'; | ||
| import { TextField } from '../../TextField'; | ||
| import { ITextField, TextField } from '../../TextField'; | ||
| import { ColorRectangle } from './ColorRectangle/ColorRectangle'; | ||
| import { ColorSlider } from './ColorSlider/ColorSlider'; | ||
| import { | ||
|
|
@@ -30,11 +30,11 @@ export class ColorPickerBase extends BaseComponent<IColorPickerProps, IColorPick | |
| alphaLabel: 'Alpha' | ||
| }; | ||
|
|
||
| private hexText: TextField; | ||
| private rText: TextField; | ||
| private gText: TextField; | ||
| private bText: TextField; | ||
| private aText: TextField; | ||
| private _hexText = createRef<ITextField>(); | ||
| private _rText = createRef<ITextField>(); | ||
| private _gText = createRef<ITextField>(); | ||
| private _bText = createRef<ITextField>(); | ||
| private _aText = createRef<ITextField>(); | ||
|
|
||
| constructor(props: IColorPickerProps) { | ||
| super(props); | ||
|
|
@@ -97,7 +97,7 @@ export class ColorPickerBase extends BaseComponent<IColorPickerProps, IColorPick | |
| <TextField | ||
| className={classNames.input} | ||
| value={color.hex} | ||
| ref={ref => (this.hexText = ref!)} | ||
| componentRef={this._hexText} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yay thank you! |
||
| onBlur={this._onHexChanged} | ||
| spellCheck={false} | ||
| ariaLabel={this.props.hexLabel} | ||
|
|
@@ -108,7 +108,7 @@ export class ColorPickerBase extends BaseComponent<IColorPickerProps, IColorPick | |
| className={classNames.input} | ||
| onBlur={this._onRGBAChanged} | ||
| value={String(color.r)} | ||
| ref={ref => (this.rText = ref!)} | ||
| componentRef={this._rText} | ||
| spellCheck={false} | ||
| ariaLabel={this.props.redLabel} | ||
| /> | ||
|
|
@@ -118,7 +118,7 @@ export class ColorPickerBase extends BaseComponent<IColorPickerProps, IColorPick | |
| className={classNames.input} | ||
| onBlur={this._onRGBAChanged} | ||
| value={String(color.g)} | ||
| ref={ref => (this.gText = ref!)} | ||
| componentRef={this._gText} | ||
| spellCheck={false} | ||
| ariaLabel={this.props.greenLabel} | ||
| /> | ||
|
|
@@ -128,7 +128,7 @@ export class ColorPickerBase extends BaseComponent<IColorPickerProps, IColorPick | |
| className={classNames.input} | ||
| onBlur={this._onRGBAChanged} | ||
| value={String(color.b)} | ||
| ref={ref => (this.bText = ref!)} | ||
| componentRef={this._bText} | ||
| spellCheck={false} | ||
| ariaLabel={this.props.blueLabel} | ||
| /> | ||
|
|
@@ -139,7 +139,7 @@ export class ColorPickerBase extends BaseComponent<IColorPickerProps, IColorPick | |
| className={classNames.input} | ||
| onBlur={this._onRGBAChanged} | ||
| value={String(color.a)} | ||
| ref={ref => (this.aText = ref!)} | ||
| componentRef={this._aText} | ||
| spellCheck={false} | ||
| ariaLabel={this.props.alphaLabel} | ||
| /> | ||
|
|
@@ -166,16 +166,16 @@ export class ColorPickerBase extends BaseComponent<IColorPickerProps, IColorPick | |
| }; | ||
|
|
||
| private _onHexChanged = (): void => { | ||
| this._updateColor(getColorFromString('#' + this.hexText.value)); | ||
| this._updateColor(getColorFromString('#' + this._hexText.value)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe (We REALLY need to enable the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is all pre-existing code. The only reason this changed at all is because TextField is now in an HOC wrapper. I'd rather not make ref-related or deprecation changes to this PR as it's already pretty wide in scope. |
||
| }; | ||
|
|
||
| private _onRGBAChanged = (): void => { | ||
| this._updateColor( | ||
| getColorFromRGBA({ | ||
| r: Number(this.rText.value), | ||
| g: Number(this.gText.value), | ||
| b: Number(this.bText.value), | ||
| a: Number((this.aText && this.aText.value) || 100) | ||
| r: Number(this._rText.value), | ||
| g: Number(this._gText.value), | ||
| b: Number(this._bText.value), | ||
| a: Number((this._aText && this._aText.value) || 100) | ||
| }) | ||
| ); | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ive seen these tests in form tests randomly fail. We will need to evaluate what the right pattern is here once we gain traction.