-
-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(linked-accounts): add support for linking/unlinking jellyfin acc…
…ounts
- Loading branch information
1 parent
2dc13ac
commit be5a2ec
Showing
9 changed files
with
625 additions
and
21 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
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,111 @@ | ||
import { withProperties } from '@app/utils/typeHelpers'; | ||
import { Menu, Transition } from '@headlessui/react'; | ||
import { ChevronDownIcon } from '@heroicons/react/24/solid'; | ||
import { | ||
Fragment, | ||
useRef, | ||
type AnchorHTMLAttributes, | ||
type ButtonHTMLAttributes, | ||
} from 'react'; | ||
|
||
interface DropdownItemProps extends AnchorHTMLAttributes<HTMLAnchorElement> { | ||
buttonType?: 'primary' | 'ghost'; | ||
} | ||
|
||
const DropdownItem = ({ | ||
children, | ||
buttonType = 'primary', | ||
...props | ||
}: DropdownItemProps) => { | ||
let styleClass = 'button-md text-white'; | ||
|
||
switch (buttonType) { | ||
case 'ghost': | ||
styleClass += | ||
' bg-transparent rounded hover:bg-gradient-to-br from-indigo-600 to-purple-600 text-white focus:border-gray-500 focus:text-white'; | ||
break; | ||
default: | ||
styleClass += | ||
' bg-indigo-600 rounded hover:bg-indigo-500 focus:border-indigo-700 focus:text-white'; | ||
} | ||
return ( | ||
<Menu.Item> | ||
<a | ||
className={`flex cursor-pointer items-center px-4 py-2 text-sm leading-5 focus:outline-none ${styleClass}`} | ||
{...props} | ||
> | ||
{children} | ||
</a> | ||
</Menu.Item> | ||
); | ||
}; | ||
|
||
interface DropdownProps extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
text: React.ReactNode; | ||
dropdownIcon?: React.ReactNode; | ||
buttonType?: 'primary' | 'ghost'; | ||
} | ||
|
||
const Dropdown = ({ | ||
text, | ||
children, | ||
dropdownIcon, | ||
className, | ||
buttonType = 'primary', | ||
...props | ||
}: DropdownProps) => { | ||
const buttonRef = useRef<HTMLButtonElement>(null); | ||
|
||
const styleClasses = { | ||
mainButtonClasses: 'button-md text-white border', | ||
dropdownSideButtonClasses: 'button-md border', | ||
dropdownClasses: 'button-md', | ||
}; | ||
|
||
switch (buttonType) { | ||
case 'ghost': | ||
styleClasses.mainButtonClasses += | ||
' bg-transparent border-gray-600 hover:border-gray-200 focus:border-gray-100 active:border-gray-100'; | ||
styleClasses.dropdownSideButtonClasses = styleClasses.mainButtonClasses; | ||
styleClasses.dropdownClasses += | ||
' bg-gray-800 border border-gray-700 bg-opacity-80 p-1 backdrop-blur'; | ||
break; | ||
default: | ||
styleClasses.mainButtonClasses += | ||
' bg-indigo-600 border-indigo-500 bg-opacity-80 hover:bg-opacity-100 hover:border-indigo-500 active:bg-indigo-700 active:border-indigo-700 focus:ring-blue'; | ||
styleClasses.dropdownSideButtonClasses += | ||
' bg-indigo-600 bg-opacity-80 border-indigo-500 hover:bg-opacity-100 active:bg-opacity-100 focus:ring-blue'; | ||
styleClasses.dropdownClasses += ' bg-indigo-600 p-1'; | ||
} | ||
|
||
return ( | ||
<Menu as="div" className="relative z-10"> | ||
<Menu.Button | ||
type="button" | ||
className={` inline-flex h-full items-center space-x-2 rounded-md px-4 py-2 text-sm font-medium leading-5 transition duration-150 ease-in-out hover:z-20 focus:z-20 focus:outline-none ${styleClasses.mainButtonClasses} ${className}`} | ||
ref={buttonRef} | ||
disabled={!children} | ||
{...props} | ||
> | ||
<span>{text}</span> | ||
{children && (dropdownIcon ? dropdownIcon : <ChevronDownIcon />)} | ||
</Menu.Button> | ||
{children && ( | ||
<Transition | ||
as={Fragment} | ||
enter="transition ease-out duration-100" | ||
enterFrom="opacity-0 scale-95" | ||
enterTo="opacity-100 scale-100" | ||
leave="transition ease-in duration-75" | ||
leaveFrom="opacity-100 scale-100" | ||
leaveTo="opacity-0 scale-95" | ||
> | ||
<Menu.Items className="absolute right-0 z-40 mt-2 -mr-1 w-56 origin-top-right rounded-md shadow-lg"> | ||
{children} | ||
</Menu.Items> | ||
</Transition> | ||
)} | ||
</Menu> | ||
); | ||
}; | ||
export default withProperties(Dropdown, { Item: DropdownItem }); |
Oops, something went wrong.