-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6dc85d0
commit 4deadfd
Showing
7 changed files
with
36 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/libs/react-ui/src/components/NavHeader/NavHeaderButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/libs/react-ui/src/components/NavHeader/NavHeaderButtonLink.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 11 additions & 51 deletions
62
packages/libs/react-ui/src/components/NavHeader/NavHeaderSelect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,23 @@ | ||
import classNames from 'classnames'; | ||
import type { FC } from 'react'; | ||
import React, { forwardRef } from 'react'; | ||
import { SystemIcon } from '../Icon'; | ||
import { | ||
chevronIconClass, | ||
selectClass, | ||
selectContainerClass, | ||
selectContainerClassDisabled, | ||
selectIconClass, | ||
} from './NavHeader.css'; | ||
import type { ISelectProps } from '../Form'; | ||
import { Select as BaseSelect } from '../Form'; | ||
import { selectContainerClass } from './NavHeader.css'; | ||
|
||
export interface INavHeaderSelectProps | ||
extends Omit< | ||
React.HTMLAttributes<HTMLSelectElement>, | ||
'aria-label' | 'as' | 'className' | 'children' | 'id' | ||
> { | ||
ariaLabel: string; | ||
children: React.ReactNode; | ||
disabled?: boolean; | ||
icon?: keyof typeof SystemIcon; | ||
ref?: React.ForwardedRef<HTMLSelectElement>; | ||
onChange?: React.ChangeEventHandler<HTMLSelectElement>; | ||
id: string; | ||
value?: string; | ||
} | ||
export interface INavHeaderSelectProps<T extends object = any> | ||
extends ISelectProps<T> {} | ||
|
||
export const NavHeaderSelect: FC<INavHeaderSelectProps> = forwardRef< | ||
HTMLSelectElement, | ||
INavHeaderSelectProps | ||
>(function Select( | ||
{ ariaLabel, children, disabled = false, icon, ...rest }, | ||
ref, | ||
) { | ||
const Icon = icon && SystemIcon[icon]; | ||
const ChevronDown = SystemIcon.ChevronDown; | ||
|
||
>(function Select({ children, className, ...props }, ref) { | ||
return ( | ||
<div | ||
className={classNames(selectContainerClass, { | ||
[selectContainerClassDisabled]: disabled, | ||
})} | ||
<BaseSelect | ||
{...props} | ||
className={classNames(className, selectContainerClass)} | ||
> | ||
{Icon && ( | ||
<span className={selectIconClass}> | ||
<Icon size="md" /> | ||
</span> | ||
)} | ||
<select | ||
aria-label={ariaLabel} | ||
className={selectClass} | ||
disabled={Boolean(disabled)} | ||
ref={ref} | ||
{...rest} | ||
> | ||
{children} | ||
</select> | ||
<span className={chevronIconClass}> | ||
<ChevronDown size="md" /> | ||
</span> | ||
</div> | ||
{children} | ||
</BaseSelect> | ||
); | ||
}); |