Skip to content

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

Merged
merged 7 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/wise-suns-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@twilio-paste/input": patch
"@twilio-paste/core": patch
---

[Input] updated focus stylings on increment/decrement buttons for number input type on both default and inverse variants
10 changes: 8 additions & 2 deletions packages/paste-core/components/input/src/DecrementButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ 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>(
({ i18nStepDownLabel = "step value down", element, ...props }, ref) => {
({ i18nStepDownLabel = "step value down", element, variant, ...props }, ref) => {
return (
<Button
{...props}
Expand All @@ -22,8 +25,11 @@ export const DecrementButton = React.forwardRef<HTMLButtonElement, DecrementButt
size="reset"
type="button"
borderRadius="borderRadius20"
backgroundColor="colorBackground"
backgroundColor={variant === "inverse" ? "colorBackgroundInverseStrong" : "colorBackground"}
marginRight="space30"
_focus={{
boxShadow: variant === "inverse" ? "shadowBorderInverseStrong" : "shadowBorderPrimary",
}}
>
<ChevronDownIcon
decorative={false}
Expand Down
10 changes: 8 additions & 2 deletions packages/paste-core/components/input/src/IncrementButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import { ChevronUpIcon } from "@twilio-paste/icons/esm/ChevronUpIcon";
import type { HTMLPasteProps } from "@twilio-paste/types";
import * as React from "react";

import { InputVariants } from "./Input";

export interface IncrementButtonProps extends HTMLPasteProps<"button"> {
i18nStepUpLabel?: string;
element?: BoxProps["element"];
// Button component restricts tabIndex values
tabIndex?: ButtonProps["tabIndex"];
variant?: InputVariants;
}

export const IncrementButton = React.forwardRef<HTMLButtonElement, IncrementButtonProps>(
({ i18nStepUpLabel = "step value up", element, ...props }, ref) => {
({ i18nStepUpLabel = "step value up", element, variant, ...props }, ref) => {
return (
<Button
{...props}
Expand All @@ -22,8 +25,11 @@ export const IncrementButton = React.forwardRef<HTMLButtonElement, IncrementButt
size="reset"
type="button"
borderRadius="borderRadius20"
backgroundColor="colorBackground"
backgroundColor={variant === "inverse" ? "colorBackgroundInverseStrong" : "colorBackground"}
marginRight="space30"
_focus={{
boxShadow: variant === "inverse" ? "shadowBorderInverseStrong" : "shadowBorderPrimary",
}}
>
<ChevronUpIcon
decorative={false}
Expand Down
2 changes: 2 additions & 0 deletions packages/paste-core/components/input/src/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
internalRef.current?.focus();
}}
i18nStepUpLabel={i18nStepUpLabel}
variant={variant}
/>
) : (
<Box height="12px" width="12px" element={`${element}_INCREMENT_PLACEHOLDER`} />
Expand All @@ -347,6 +348,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
internalRef.current?.focus();
}}
i18nStepDownLabel={i18nStepDownLabel}
variant={variant}
/>
) : (
<Box height="12px" width="12px" element={`${element}_DECREMENT_PLACEHOLDER`} />
Expand Down
26 changes: 26 additions & 0 deletions packages/paste-core/components/input/stories/input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,32 @@ export const DefaultNumberInput = (): React.ReactNode => {

DefaultNumberInput.storyName = "Number Input - Controlled";

export const DefaultNumberInverseInput = (): React.ReactNode => {
Copy link
Collaborator

Choose a reason for hiding this comment

The 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");
Expand Down
Loading