@open-mercato/ui 0.6.6-develop.6229.1.ebe6706732 → 0.6.6-develop.6245.1.2be3b151f8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ /** @jest-environment jsdom */
2
+
3
+ import * as React from 'react'
4
+ import { render } from '@testing-library/react'
5
+ import { IconButton, iconButtonVariants } from '../icon-button'
6
+
7
+ describe('IconButton solid variants', () => {
8
+ // Regression for issue #3507 (BUG-003): the timesheets TimerBar Start/Stop
9
+ // icon buttons used `variant="outline"` and forced their fill via a
10
+ // `bg-primary`/`bg-destructive` className. The outline variant ships a
11
+ // `dark:bg-input/30` override that tailwind-merge cannot reconcile with a
12
+ // base `bg-*` class, so in dark mode the intended solid fill was replaced by
13
+ // the muted input surface and the dark `text-primary-foreground` play icon
14
+ // became near-invisible. The fix is a proper solid `primary`/`destructive`
15
+ // variant with NO `dark:` background override.
16
+
17
+ it('primary variant applies the solid primary surface without a dark override', () => {
18
+ const classes = iconButtonVariants({ variant: 'primary' })
19
+ expect(classes).toContain('bg-primary')
20
+ expect(classes).toContain('text-primary-foreground')
21
+ expect(classes).not.toContain('dark:bg-input')
22
+ })
23
+
24
+ it('destructive variant applies the solid destructive surface without a dark override', () => {
25
+ const classes = iconButtonVariants({ variant: 'destructive' })
26
+ expect(classes).toContain('bg-destructive')
27
+ expect(classes).not.toContain('dark:bg-input')
28
+ })
29
+
30
+ it('renders the primary fill on the element so the icon keeps contrast in both themes', () => {
31
+ const { getByRole } = render(
32
+ <IconButton variant="primary" aria-label="Start timer">
33
+ <svg />
34
+ </IconButton>,
35
+ )
36
+ const className = getByRole('button').className
37
+ expect(className).toContain('bg-primary')
38
+ expect(className).not.toContain('dark:bg-input')
39
+ })
40
+ })
@@ -8,6 +8,10 @@ const iconButtonVariants = cva(
8
8
  {
9
9
  variants: {
10
10
  variant: {
11
+ primary:
12
+ 'bg-primary text-primary-foreground shadow-xs hover:bg-primary-hover',
13
+ destructive:
14
+ 'bg-destructive text-white shadow-xs hover:bg-destructive/90',
11
15
  outline:
12
16
  'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
13
17
  ghost: 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',