-
-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add custom links dropdown, closes #520
- Loading branch information
Showing
8 changed files
with
106 additions
and
48 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
33 changes: 33 additions & 0 deletions
33
packages/ui/src/components/CustomLinksDropdown/CustomLinksDropdown.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { UIConfig } from '@bull-board/api/dist/typings/app'; | ||
import { Item, Portal, Root, Trigger } from '@radix-ui/react-dropdown-menu'; | ||
import React from 'react'; | ||
import { DropdownContent } from '../DropdownContent/DropdownContent'; | ||
import { UserIcon } from '../Icons/User'; | ||
import { Button } from '../JobCard/Button/Button'; | ||
|
||
type CustomLinksDropdownProps = { | ||
options: UIConfig['miscLinks']; | ||
className: string; | ||
}; | ||
|
||
export const CustomLinksDropdown = ({ options = [], className }: CustomLinksDropdownProps) => { | ||
return ( | ||
<Root> | ||
<Trigger asChild> | ||
<Button className={className}> | ||
<UserIcon /> | ||
</Button> | ||
</Trigger> | ||
|
||
<Portal> | ||
<DropdownContent align="end"> | ||
{options.map((option) => ( | ||
<Item key={option.url} asChild> | ||
<a href={option.url}>{option.text}</a> | ||
</Item> | ||
))} | ||
</DropdownContent> | ||
</Portal> | ||
</Root> | ||
); | ||
}; |
37 changes: 37 additions & 0 deletions
37
packages/ui/src/components/DropdownContent/DropdownContent.module.css
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.content { | ||
background: #fff; | ||
box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); | ||
border: 1px solid rgba(34, 36, 38, 0.15); | ||
border-radius: 0.28571429rem; | ||
padding-top: 0.25rem; | ||
padding-bottom: 0.25rem; | ||
font-size: 0.875rem; | ||
line-height: 1.25rem; | ||
font-weight: 400; | ||
min-width: 150px; | ||
z-index: 100; | ||
} | ||
|
||
.content > [role='menuitem'] { | ||
display: block; | ||
color: rgba(0, 0, 0, 0.87); | ||
padding: 0.5rem 1rem; | ||
font-weight: 400; | ||
white-space: nowrap; | ||
cursor: pointer; | ||
text-decoration: none; | ||
} | ||
|
||
.content > [role='menuitem'] > svg { | ||
float: none; | ||
margin-right: 0.5rem; | ||
width: 1.18em; | ||
height: 1em; | ||
vertical-align: middle; | ||
fill: #718096; | ||
} | ||
|
||
.content > [role='menuitem']:hover { | ||
color: rgba(0, 0, 0, 0.95); | ||
background: #e2e8f0; | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/ui/src/components/DropdownContent/DropdownContent.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Content, DropdownMenuContentProps } from '@radix-ui/react-dropdown-menu'; | ||
import React from 'react'; | ||
import s from './DropdownContent.module.css'; | ||
|
||
export const DropdownContent = React.forwardRef((props: DropdownMenuContentProps, ref: any) => ( | ||
<Content {...props} ref={ref} className={s.content} /> | ||
)); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
export const UserIcon = () => ( | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> | ||
<path fill="none" d="M0 0h48v48H0z" /> | ||
<path d="M24 10a8 8 0 1 0 8 8 8 8 0 0 0-8-8Zm0 12a4 4 0 1 1 4-4 4 4 0 0 1-4 4Z" /> | ||
<path d="M24 2a22 22 0 1 0 22 22A21.9 21.9 0 0 0 24 2ZM11.8 37.2A26.4 26.4 0 0 1 24 34a26.4 26.4 0 0 1 12.2 3.2 17.9 17.9 0 0 1-24.4 0Zm27.1-3.1A30.7 30.7 0 0 0 24 30a30.7 30.7 0 0 0-14.9 4.1A17.7 17.7 0 0 1 6 24a18 18 0 0 1 36 0 17.7 17.7 0 0 1-3.1 10.1Z" /> | ||
</svg> | ||
); |
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