-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Urban Vidovič <[email protected]> Co-authored-by: edis <[email protected]> Co-authored-by: Urban <[email protected]>
- Loading branch information
1 parent
c829624
commit 932f6aa
Showing
21 changed files
with
4,267 additions
and
837 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blockchain-lab-um/dapp": patch | ||
--- | ||
|
||
Improves dropdowns. |
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,17 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": true, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.js", | ||
"css": "src/styles/globals.css", | ||
"baseColor": "neutral", | ||
"cssVariables": false, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils" | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
99 changes: 68 additions & 31 deletions
99
packages/dapp/src/components/MethodDropdownMenu/MethodDropdownButton.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,49 +1,86 @@ | ||
import { Menu } from '@headlessui/react'; | ||
import { CheckIcon } from '@heroicons/react/24/solid'; | ||
import { DropdownMenuItem } from '@radix-ui/react-dropdown-menu'; | ||
import { clsx } from 'clsx'; | ||
import { useState } from 'react'; | ||
|
||
interface DropdownButtonProps { | ||
children: React.ReactNode; | ||
handleBtn: (text: string) => Promise<void>; | ||
selected: boolean; | ||
variant?: | ||
| 'primary' | ||
| 'secondary' | ||
| 'primary-active' | ||
| 'secondary-active' | ||
| 'gray' | ||
| 'method'; | ||
} | ||
|
||
export const DropdownButton = ({ | ||
const variants: Record<string, string> = { | ||
primary: | ||
'dark:bg-navy-blue-500 dark:text-orange-accent-dark/95 animated-transition cursor-pointer bg-pink-50 text-pink-600', | ||
secondary: 'bg-navy-blue-100 text-navy-blue-600 ', | ||
'primary-active': | ||
'dark:bg-navy-blue-500 dark:text-orange-accent-dark/95 animated-transition cursor-pointer bg-pink-50 text-pink-600', | ||
'secondary-active': 'bg-navy-blue-100 text-navy-blue-600', | ||
gray: 'bg-gray-100 text-gray-800 ', | ||
method: | ||
'dark:bg-navy-blue-500 dark:text-orange-accent-dark animated-transition cursor-pointer bg-pink-50 text-pink-600', | ||
}; | ||
|
||
const variantsSelected: Record<string, string> = { | ||
primary: | ||
'dark:text-orange-accent-dark dark:bg-navy-blue-600 bg-white text-pink-700', | ||
secondary: 'bg-navy-blue-100 text-navy-blue-600 font-semibold', | ||
'primary-active': | ||
'dark:text-orange-accent-dark dark:bg-navy-blue-600 bg-white text-pink-700', | ||
'secondary-active': 'bg-navy-blue-100 text-navy-blue-600 font-semibold', | ||
gray: 'bg-gray-100 font-semibold text-gray-900', | ||
method: | ||
'dark:text-orange-accent-dark dark:bg-navy-blue-600 bg-white text-pink-700', | ||
}; | ||
|
||
const variantsSelectedElse: Record<string, string> = { | ||
primary: 'dark:text-navy-blue-100 text-gray-600', | ||
secondary: 'bg-navy-blue-100 text-navy-blue-600 font-semibold', | ||
'primary-active': 'dark:text-navy-blue-100 text-gray-600 ', | ||
'secondary-active': 'bg-navy-blue-100 text-navy-blue-600 font-semibold', | ||
gray: 'bg-gray-100 font-semibold text-gray-900', | ||
method: '', | ||
}; | ||
|
||
export function DropdownButton({ | ||
children, | ||
handleBtn, | ||
selected, | ||
}: DropdownButtonProps) => ( | ||
<Menu.Item> | ||
{({ active }) => ( | ||
<span | ||
onClick={() => { | ||
handleBtn(children as string) | ||
.then(() => {}) | ||
.catch(() => {}); | ||
}} | ||
variant = 'primary', | ||
}: DropdownButtonProps) { | ||
const [isActive, setIsActive] = useState(false); | ||
const handleMouseEnter = () => setIsActive(true); | ||
const handleMouseLeave = () => setIsActive(false); | ||
|
||
return ( | ||
<DropdownMenuItem> | ||
<button | ||
type="button" | ||
className={clsx( | ||
active | ||
? 'dark:bg-navy-blue-500 dark:text-orange-accent-dark/95 animated-transition cursor-pointer bg-pink-50 text-pink-600 ' | ||
: '', | ||
selected | ||
? 'dark:text-orange-accent-dark dark:bg-navy-blue-600 bg-white text-pink-700' | ||
: 'dark:text-navy-blue-100 text-gray-600', | ||
'block rounded-full py-2 text-lg' | ||
'md:text-md block w-full rounded-full py-2 px-1 text-sm', | ||
isActive ? variants[variant] : null, | ||
selected ? variantsSelected[variant] : variantsSelectedElse[variant] | ||
)} | ||
onClick={() => handleBtn(children as string)} | ||
onMouseEnter={handleMouseEnter} | ||
onMouseLeave={handleMouseLeave} | ||
> | ||
<div className="grid grid-cols-6"> | ||
<span> | ||
{selected ? ( | ||
<CheckIcon className="ml-3 h-4 w-4 lg:h-5 lg:w-5" /> | ||
) : ( | ||
'' | ||
)} | ||
</span> | ||
<span className="col-span-4 col-start-2 text-center"> | ||
<div className="grid grid-cols-8 items-center px-1"> | ||
<span className="col-span-6 flex justify-start items-center"> | ||
{children === 'did:key:jwk_jcs-pub' ? 'did:key (EBSI)' : children} | ||
</span> | ||
<span className="col-span-2"> | ||
{selected && <CheckIcon className="ml-3 h-4 w-4 lg:h-5 lg:w-5" />} | ||
</span> | ||
</div> | ||
</span> | ||
)} | ||
</Menu.Item> | ||
); | ||
</button> | ||
</DropdownMenuItem> | ||
); | ||
} |
Oops, something went wrong.