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

[NO-TICKET] Add missing inversed attribute to ds-dropdown #3044

Merged
merged 1 commit into from
Apr 15, 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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export default {
description: 'Hint text or HTML',
control: 'text',
},
inversed: {
description: 'Set to "true" to apply the "inverse" theme',
control: 'boolean',
},
label: {
description: 'Label text or HTML.',
control: 'text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ describe('Button', () => {
expect(error).toContainHTML('Uh-oh!');
});

it('applies inverse class', () => {
const { container } = renderDropdown({
inversed: 'true',
hint: 'Hello',
'error-message': 'Ahh!!',
});
const inversedLabel = container.querySelector('.ds-c-label--inverse');
const inversedHint = container.querySelector('.ds-c-hint--inverse');
const inversedError = container.querySelector('.ds-c-inline-error--inverse');
expect(inversedLabel).toBeInTheDocument();
expect(inversedHint).toBeInTheDocument();
expect(inversedError).toBeInTheDocument();
});

it('applies size classes', () => {
renderDropdown({ size: 'small' });
const button = screen.getByRole('button');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const attributes = [
'label-id',
'hint',
'hint-id',
'inversed',
'name',
'requirement-label',
'root-id',
Expand All @@ -43,10 +44,11 @@ declare global {
/* eslint-enable */

interface WrapperProps
extends Omit<DropdownProps, 'options' | 'autoFocus' | 'disabled' | 'ariaDisabled'> {
extends Omit<DropdownProps, 'options' | 'autoFocus' | 'disabled' | 'ariaDisabled' | 'inversed'> {
autofocus?: string;
ariaDisabled?: string;
disabled?: string;
inversed?: string;
options?: string | DropdownProps['options'];
rootId?: string;
}
Expand All @@ -59,6 +61,7 @@ const Wrapper = ({ children, options, rootId, ...otherProps }: WrapperProps) =>
aria-disabled={parseBooleanAttr(otherProps.ariaDisabled)}
options={typeof options === 'string' ? JSON.parse(options) : options}
id={rootId}
inversed={parseBooleanAttr(otherProps.inversed)}
>
{options ? undefined : children}
</Dropdown>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
"Hint text or HTML",
"string"
],
[
"inversed",
"Set to \"true\" to apply the \"inverse\" theme",
"\"true\"\"false\""
],
[
"label",
"Label text or HTML.",
Expand Down