-
Notifications
You must be signed in to change notification settings - Fork 119
chore(Input): increment/decrement reset buttons focus stylings #3917
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 1 commit
76cd29a
39ba2a7
520967f
9cf682c
6b817ed
75f75db
be939a0
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,5 @@ | ||
--- | ||
"@twilio-paste/input": patch | ||
--- | ||
|
||
[Input] updated focus stylings on increment/decrement buttons for number input type on both default and inverse variants | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,15 @@ | |
import { Button, type ButtonProps } from "@twilio-paste/button"; | ||
import { ChevronDownIcon } from "@twilio-paste/icons/esm/ChevronDownIcon"; | ||
import type { HTMLPasteProps } from "@twilio-paste/types"; | ||
import * as React from "react"; | ||
import { InputVariants } from "./Input"; | ||
|
||
export interface DecrementButtonProps extends HTMLPasteProps<"button"> { | ||
i18nStepDownLabel?: string; | ||
element?: BoxProps["element"]; | ||
// Button component restricts tabIndex values | ||
tabIndex?: ButtonProps["tabIndex"]; | ||
variant?: InputVariants; | ||
} | ||
|
||
export const DecrementButton = React.forwardRef<HTMLButtonElement, DecrementButtonProps>( | ||
|
@@ -22,8 +24,17 @@ | |
size="reset" | ||
type="button" | ||
borderRadius="borderRadius20" | ||
backgroundColor="colorBackground" | ||
backgroundColor={props.variant === "inverse" ? "colorBackgroundInverseStrong" : "colorBackground"} | ||
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. nitpick: very much non-blocking but when using another prop, in most cases we add it to the list of destructured props on line 17 so that we can use 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. Great suggestion 🙏 I'll make a change and push it up before we merge |
||
marginRight="space30" | ||
_focus={{ | ||
borderRadius: "borderRadius20", | ||
borderWidth: "borderWidth10", | ||
borderStyle: "solid", | ||
borderColor: props.variant === "inverse" ? "colorBorderInverseStrong" : "colorBorderPrimary", | ||
}} | ||
borderWidth="borderWidth10" | ||
borderStyle="solid" | ||
borderColor="transparent" | ||
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 had to add a border to the buttons and make it transparent. After changing the _focus style I saw the icons would move slightly due to the border changing for one and not the other. Issue shown in the video: 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. ooh ok yeah i was wondering about the use of border colors here & how you got it to work. This solution works just as well, but you could also use shadows instead. We have shadow border tokens ( I have no like...eng perspective on which solution is better, so I'll rely on @nkrantz here for that. 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. ok nvm I do have an opinion. Just realized it adds an extra 1px gray border all around the buttons. todo: Let's use the shadow border tokens instead. 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. Added boxShadow instead of border and that resolved all the spacing issues. Thank you! 🙇 |
||
> | ||
<ChevronDownIcon | ||
decorative={false} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -713,6 +713,32 @@ export const DefaultNumberInput = (): React.ReactNode => { | |
|
||
DefaultNumberInput.storyName = "Number Input - Controlled"; | ||
|
||
export const DefaultNumberInverseInput = (): React.ReactNode => { | ||
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. praise: new story for this missed use case 👏 |
||
const uid = useUID(); | ||
const [value, setValue] = React.useState("0"); | ||
return ( | ||
<Box backgroundColor="colorBackgroundBodyInverse" padding="space60"> | ||
<Label htmlFor={uid} variant="inverse"> | ||
Label | ||
</Label> | ||
<Input | ||
id={uid} | ||
type="number" | ||
max="50" | ||
min="-50" | ||
step={5} | ||
value={value} | ||
onChange={(event) => { | ||
setValue(event.target.value); | ||
}} | ||
variant="inverse" | ||
/> | ||
</Box> | ||
); | ||
}; | ||
|
||
DefaultNumberInverseInput.storyName = "Number Input - Inverse Controlled"; | ||
|
||
export const TestNumberInput = (): React.ReactNode => { | ||
const uid = useUID(); | ||
const [value, setValue] = React.useState("5"); | ||
|
Uh oh!
There was an error while loading. Please reload this page.