Skip to content
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

fix: correctly apply styles to <Select> icon #4026

Merged
merged 4 commits into from
Jul 19, 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
5 changes: 5 additions & 0 deletions .changeset/lucky-plums-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marigold/components": patch
---

fix: correctly apply styles to `<Select>` icon
19 changes: 18 additions & 1 deletion packages/components/src/Select/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const theme: Theme = {
size: { small: 'text-sm' },
},
}),
icon: cva(),
icon: cva('text-zinc-600'),
},
Underlay: cva(),
ListBox: {
Expand Down Expand Up @@ -407,6 +407,23 @@ test('supports styling classnames with variants and sizes from theme', () => {
expect(button.className).toContain('text-sm');
});

test('supports applying styles to the caret icon', () => {
render(
<Select label="Label" data-testid="select">
<Select.Section>
<Select.Option id="one">one</Select.Option>
<Select.Option id="two">two</Select.Option>
</Select.Section>
</Select>
);

const button = screen.getByRole('button');
// eslint-disable-next-line testing-library/no-node-access
const icon = button.querySelector('svg');

expect(icon).toHaveClass('text-zinc-600');
});

test('set width via props', () => {
render(
<Select label="Label" data-testid="select" width="1/2">
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const _Select = forwardRef<any, SelectProps<object>>(
)}
>
<SelectValue />
<ChevronDown className="size-4" />
<ChevronDown className={cn('size-4', classNames.icon)} />
</Button>
<Popover>
<ListBox items={items}>{props.children}</ListBox>
Expand Down
Loading