-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Jill wip/clearable button #617
Conversation
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.
When the input is focused, the X icon appears. When the X icon is focused, the X icon stays appeared. When neither the X icon or the input is focused, the X icon does not exist.
src/Components/Inputs/Input.tsx
Outdated
|
||
const clearElement = correctlyTypedValue && onClear && ( | ||
<DismissButton | ||
style={clearBtnStyle} |
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.
Do we need to expose this style prop? I think we could just use color = {ComponentColor.default}. I don't see where we would need to change the color or style of the dismiss button within the input but if you can think of concrete future usecases for it, would love to hear it
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.
As for styling, I think the default color set is the subtlety we are looking for rather than the primary color that comes out of box with the dismiss button component.
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.
are you saying that the color should. be changed from what it currently is?
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.
Two things:
- I think the Default Color Dismiss button might be more suitable than the Primary Color Dismiss Button.
- I'm trying to understand the rationale for style={clearBtnStyle}. It seems like its just passing in undefined.
In what scenarios would we want to pass in custom style to this dismiss button?
.cf-input-icon { | ||
transform: translate(-50%, -50%); | ||
.cf-input-icon, | ||
.cf-input-clear-btn { |
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.
This might be a .cf-input__clear-btn based on BEM methodology but I could be wrong
src/Components/Inputs/Input.scss
Outdated
} | ||
|
||
&.large { | ||
width: 32px; |
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.
Let's use variables instead of hard coding the width and heights if we can.
src/Components/Inputs/Input.scss
Outdated
right: 4px; | ||
} | ||
|
||
&.large { |
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.
I believe the possible sizes of inputs are :
- extra small
- small
- medium
- large
I think you've only accounted for small and large. Try a medium or extra small input on your storybook, I imagine the X won't scale for those.
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.
i only did small (default) and large since those are the only use cases we need for the ui; I can add the others but we aren't using them at this point
@@ -173,6 +182,19 @@ export const Input = forwardRef<InputRef, InputProps>( | |||
|
|||
const iconElement = icon && <Icon glyph={icon} className="cf-input-icon" /> | |||
|
|||
const clearClasses = classnames('cf-input-clear-btn', { | |||
large: size === ComponentSize.Large, |
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.
need to account for extra small, and medium as well
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.
done.
src/Components/Inputs/Input.tsx
Outdated
* */ | ||
onClear?: () => void | ||
/** optional extra styling for the clear button */ | ||
clearBtnStyle?: CSSProperties |
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.
Bit of a redundant feedback here but Not sure if we need to expose this. Im trying to think of a case where we would need a special css treatment of the dismiss button and can't think of it.
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.
i needed it previously, then after adjusting for component size don't need it; but it was already there so I left it in.
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.
...just removed it
src/Components/Inputs/Input.scss
Outdated
& .cf-dismiss-button--x { | ||
&:before, | ||
&:after { | ||
width: 20px; |
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.
Let's use variables instead of hard coding the width and heights if we can.
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.
Having the button disappear when you click it is a jarring experience. As long as the field or the button has focus then it should be visible.
You may need to prevent this from appearing when type="number"
.
Ensure that the button is vertically centered regardless of the input size. It may help here to use the extra small and medium button sizes along with those input sizes.
The text should stop before the clear button otherwise it becomes obscured. See the VisibilityInput
component for how this should be handled.
return ( | ||
<div className="story--example"> | ||
<Input | ||
min={number('min', 0)} |
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.
Did you mean minLength
& maxLength
? min
& max
are for type="number"
.
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.
the 'min' and such I just copied from another storybook story.
(for the default, plain text input).
in terms of the button disappearing, @daviddkkim specifically requested that the 'x' button only show when there is content. so after pressing it, there is no content so it disappears. easy to make it always appear tho.
src/Components/Inputs/Input.tsx
Outdated
@@ -12,18 +12,19 @@ import classnames from 'classnames' | |||
// Components | |||
import {Icon} from '../Icon/Base/Icon' | |||
import {StatusIndicator} from './StatusIndicator' | |||
|
|||
import {DismissButton} from '../Button/Composed/DismissButton' | |||
//import {Button} from '../Button/Composed/Button' |
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.
Remove if no longer used.
then how will the users discover this feature? what if they enter text, click away, then the 'x' disappears, then they want to clear it, so then they click in the field, and then it appears? that is non-intuitive. |
Good point. I think there is a middle ground here between my first suggestion of making the icon appear on text and Daniel's suggestion of making icon appear on focus for accessibility reasons. How about
|
having it appear sometimes/not others may make styling tricky. right now, the button always appears if the button is 'enabled' for the field.
|
it actually looks ok to have the button hide when there is no content. |
This looks almost ready @jrenee42. The styling is implemented slightly different than our input components with an icon. See This isn't a huge issue but I'd want to keep consistency. I'd want to see what other input's icon sizes are for each respective input size. I think for medium, we see 14 or 16 px. This one is 13.44px. It looks like the width of the strokes in the X is determined by the height, if that's the case I think 1px or 2px would work best. We use 2px border radius throughout our styles i believe. For hover state, active/focused state of the style, I'm happy to make these finishing touches/style changes but I am occupied with million other tasks at the moment and won't be able to get around to it until I get some breathing room! |
ok. my concerns are that the dismiss button is a part of clockface, so maybe that needs changing too for consistency, I will talk to Kristina and find out the priority on this (vs. other bugs/issues). thanks for the review! |
@jrenee42 As for the dismiss button, yeah the dismiss button wasn't designed to be used inside of an input. That's why you won't find it usable for the input out of the box. The hardcoded height,width you have seems to not align with the icon sizes we use for inputs. Thing to change:
|
I can make this change or you can. I think I might have some time later in the week to tackle some of these but since this is not a priority for me, my attention on it will be sparse for full transparency. |
0204e06
to
ee2a911
Compare
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.
lgtm
for ui #898
https://app.zenhub.com/workspaces/applicationui-5e3b05772922e316b3a210a4/issues/influxdata/ui/898
Changes
adds an 'x' that shows up in the right of the textfield if and only if:
the button is reachable by tabbing, so the user can type in data, then click 'tab' and the press 'return' to clear the field without ever having to use the mouse.
it uses the dismiss button, with some styling changes to get it to fit nicely in the field.
if the field is large, then the button is sized up, else it stays in its default, smaller size.
Added to storybook as well; so added to the documentation.
Screenshots
Screen.Recording.2021-05-03.at.4.28.31.PM.mov
Checklist
Check all that apply