Skip to content

Commit

Permalink
chore(Input): increment/decrement reset buttons focus stylings (#3917)
Browse files Browse the repository at this point in the history
* feat(Intput): increment/decrement reset buttons focus stylings

* feat(Input): updating the changeset to include core patch

* feat(Input): lint fix

* feat(Input): destructure prop

* chore(Input): use box shaow instead of border
  • Loading branch information
krisantrobus authored May 28, 2024
1 parent b6146db commit 825dc39
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
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 => {
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

0 comments on commit 825dc39

Please sign in to comment.