Skip to content

Commit

Permalink
1248-feuiadd-disabled-property-to-button-to-pass-as-prop-in-dropdown-…
Browse files Browse the repository at this point in the history
…component (#1334)
  • Loading branch information
marmorrei authored Jun 10, 2024
1 parent 723541e commit 64d68c5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

All notable changes to this project will be documented in this file.

## [0.35.0] - 2024-06-10

### Added

- Added prop disabled to Dropdown

## [0.34.0] - 2024-06-03

### Added

- Create RadioGroup Molecule

## [0.33.1] - 2024-05-29

### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@itacademy/ui",
"version": "0.34.0",
"version": "0.35.0",
"description": "React FE components for ITAcademy projects.",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.es.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/ui/src/__tests__/atoms/Dropdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,10 @@ describe('Dropdown', () => {
expect(dropdownHeader).toHaveTextContent(/Test select/i)
})
})

it('disables dropdown when prop is passed', () => {
render(<Dropdown options={mockOptions} disabled />)

expect(screen.getByTestId('dropdown-header')).toBeDisabled()
})
})
3 changes: 3 additions & 0 deletions packages/ui/src/components/atoms/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export type TDropdown = HTMLAttributes<HTMLElement> & {
className?: string
$size?: 'small' | 'normal' | 'large'
resetSelectedValue?: boolean
disabled?: boolean
}

export const Dropdown = forwardRef<HTMLDivElement, TDropdown>(
Expand All @@ -168,6 +169,7 @@ export const Dropdown = forwardRef<HTMLDivElement, TDropdown>(
className = '',
$size = 'normal',
resetSelectedValue = undefined,
disabled = undefined,
...rest
},
ref
Expand Down Expand Up @@ -226,6 +228,7 @@ export const Dropdown = forwardRef<HTMLDivElement, TDropdown>(
data-testid="dropdown-header"
onClick={() => setIsDropdownOpen(!isDropdownOpen)}
$size={$size}
disabled={disabled}
>
{selectedOption ? (
<StyledFlexBox
Expand Down
19 changes: 19 additions & 0 deletions packages/ui/src/stories/atoms/Dropdown/Dropdown.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const meta: Meta<typeof Dropdown> = {
control: { type: 'select' },
options: ['small', 'normal', 'large'],
},
disabled: { control: 'boolean' },
},
}

Expand Down Expand Up @@ -238,3 +239,21 @@ export const WithSizeLarge: DropdownStory = {
},
render: (args) => <Dropdown {...args} />,
}

export const DisabledDropdown: DropdownStory = {
args: {
placeholder: 'Disabled dropdown',
options: [
{
id: '1',
name: 'Option 1',
},
{
id: '2',
name: 'Option 2',
},
],
disabled: true,
},
render: (args) => <Dropdown {...args} />,
}

0 comments on commit 64d68c5

Please sign in to comment.