Skip to content

Commit

Permalink
fix(input-number): button styling for hover and focus states
Browse files Browse the repository at this point in the history
  • Loading branch information
stafyniaksacha committed Nov 28, 2023
1 parent a700fef commit dfb241a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
24 changes: 16 additions & 8 deletions src/plugins/components/input-number/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ export default plugin.withOptions(
{},
},
[`.${prefix}input-number-buttons button`]: {
[`@apply hover:bg-muted-100 dark:hover:bg-muted-800`]: {},
[`@apply focus:bg-muted-100 dark:focus:bg-muted-800`]: {},
[`@apply enabled:hover:bg-muted-100 dark:enabled:hover:bg-muted-800`]:
{},
[`@apply enabled:focus:bg-muted-100 dark:enabled:focus:bg-muted-800`]:
{},
},
},
[`&.${prefix}input-number-default-contrast`]: {
Expand All @@ -213,8 +215,10 @@ export default plugin.withOptions(
{},
},
[`.${prefix}input-number-buttons button`]: {
[`@apply hover:bg-muted-100 dark:hover:bg-muted-900`]: {},
[`@apply focus:bg-muted-100 dark:focus:bg-muted-900`]: {},
[`@apply enabled:hover:bg-muted-100 dark:enabled:hover:bg-muted-900`]:
{},
[`@apply enabled:focus:bg-muted-100 dark:enabled:focus:bg-muted-900`]:
{},
},
},
[`&.${prefix}input-number-muted`]: {
Expand All @@ -223,8 +227,10 @@ export default plugin.withOptions(
{},
},
[`.${prefix}input-number-buttons button`]: {
[`@apply hover:bg-white dark:hover:bg-muted-800`]: {},
[`@apply focus:bg-white dark:focus:bg-muted-800`]: {},
[`@apply enabled:hover:bg-white dark:enabled:hover:bg-muted-800`]:
{},
[`@apply enabled:focus:bg-white dark:enabled:focus:bg-muted-800`]:
{},
},
},
[`&.${prefix}input-number-muted-contrast`]: {
Expand All @@ -233,8 +239,10 @@ export default plugin.withOptions(
{},
},
[`.${prefix}input-number-buttons button`]: {
[`@apply hover:bg-white dark:hover:bg-muted-900`]: {},
[`@apply focus:bg-white dark:focus:bg-muted-900`]: {},
[`@apply enabled:hover:bg-white dark:enabled:hover:bg-muted-900`]:
{},
[`@apply enabled:focus:bg-white dark:enabled:focus:bg-muted-900`]:
{},
},
},
[`&:not(.${prefix}input-number-loading)`]: {
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/components/input-number/input-number.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const InputNumber = ({
error: '',
},
icon,
disabled,
actionSlot,
...attrs
}: InputAttrs) => {
Expand Down Expand Up @@ -64,6 +65,7 @@ export const InputNumber = ({
class="${['nui-input-number', classes?.input]
.filter(Boolean)
.join(' ')}"
?disabled="${disabled}"
${spread(attrs)}
/>
${label && labelFloat
Expand Down Expand Up @@ -95,7 +97,7 @@ export const InputNumber = ({
</div>
`}
<div class="nui-input-number-buttons">
<button aria-label="Increment">
<button aria-label="Increment" ?disabled="${disabled}">
<svg
class=${['nui-chevron', 'rotate-180'].filter(Boolean).join(' ')}
aria-hidden="true"
Expand All @@ -111,7 +113,7 @@ export const InputNumber = ({
/>
</svg>
</button>
<button aria-label="Decrement">
<button aria-label="Decrement" ?disabled="${disabled}">
<svg
class=${['nui-chevron'].filter(Boolean).join(' ')}
aria-hidden="true"
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/components/input-number/input-number.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const meta = {
control: { type: 'boolean' },
defaultValue: false,
},
'?disabled': {
disabled: {
name: 'disabled',
control: { type: 'boolean' },
defaultValue: false,
Expand Down Expand Up @@ -383,7 +383,7 @@ export const DisabledSm: Story = {
size: 'sm',
contrast: 'default',
shape: 'rounded',
'?disabled': true,
disabled: true,
type: 'text',
inputmode: 'numeric',
placeholder: 'Enter a number',
Expand All @@ -401,7 +401,7 @@ export const DisabledMd: Story = {
size: 'md',
contrast: 'default',
shape: 'rounded',
'?disabled': true,
disabled: true,
type: 'text',
inputmode: 'numeric',
placeholder: 'Enter a number',
Expand All @@ -419,7 +419,7 @@ export const DisabledLg: Story = {
size: 'lg',
contrast: 'default',
shape: 'rounded',
'?disabled': true,
disabled: true,
type: 'text',
inputmode: 'numeric',
placeholder: 'Enter a number',
Expand Down

0 comments on commit dfb241a

Please sign in to comment.