From b95c622844b38558a3a244c22e279005b68ae34f Mon Sep 17 00:00:00 2001 From: goldsteinsveta Date: Mon, 16 Sep 2024 21:40:30 +0200 Subject: [PATCH] UI appearance nits (#137) Co-authored-by: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> Co-authored-by: Thibaut Sardan --- src/components/DelegateCard.tsx | 49 ++++++++++++---- src/components/MyDelegations.tsx | 4 +- src/components/ui/input.tsx | 2 +- src/components/ui/title.tsx | 8 ++- src/index.css | 12 ++-- src/pages/Delegate/index.tsx | 98 ++++++++++++++++++-------------- src/pages/Home/index.tsx | 8 ++- 7 files changed, 113 insertions(+), 68 deletions(-) diff --git a/src/components/DelegateCard.tsx b/src/components/DelegateCard.tsx index cc89f96..7635816 100644 --- a/src/components/DelegateCard.tsx +++ b/src/components/DelegateCard.tsx @@ -3,15 +3,25 @@ import { Card } from '@/components/ui/card' import { useLocation, useNavigate } from 'react-router-dom' import { Delegate } from '@/contexts/DelegatesContext' import { ContentReveal } from './ui/content-reveal' +import { cn } from '@/lib/utils' +import { toast } from 'sonner' +import { LinkIcon } from 'lucide-react' import Markdown from 'react-markdown' import { Title, TitleH2, TitleH3 } from './ui/title' import { AnchorLink } from './ui/anchorLink' interface Props { delegate: Delegate + className?: string + hasShareButton?: boolean + hasDelegateButton?: boolean } + export const DelegateCard = ({ delegate: { address, longDescription, shortDescription, image, name }, + className, + hasShareButton, + hasDelegateButton = true, }: Props) => { const navigate = useNavigate() const { search } = useLocation() @@ -21,17 +31,32 @@ export const DelegateCard = ({ const onDelegate = () => { navigate(`/delegate/${address}${search}`) } + const onCopy = () => { + navigator.clipboard.writeText( + window.location.origin + `/delegate/${address}${search}`, + ) + toast.success('Copied to clipboard', { + duration: 1000, + }) + } return ( - -
+ +
- +
-
-
{name}
-
-
{shortDescription}
+
+
+ {name} + {hasShareButton && ( + + )} +
+
+
{shortDescription}
- +
+ {hasDelegateButton && ( + + )} +
) diff --git a/src/components/MyDelegations.tsx b/src/components/MyDelegations.tsx index 25bc59c..293c9e7 100644 --- a/src/components/MyDelegations.tsx +++ b/src/components/MyDelegations.tsx @@ -81,8 +81,8 @@ export const MyDelegations = () => { return ( <> - My Delegations -
+ My Delegations +
{delegationsByDelegateConvictionAmount === undefined ? ( ) : noDelegations ? ( diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx index 762c2b3..dac092c 100644 --- a/src/components/ui/input.tsx +++ b/src/components/ui/input.tsx @@ -14,7 +14,7 @@ const Input = React.forwardRef( { const baseClass = - 'flex-1 shrink-0 whitespace-nowrap font-unbounded font-semibold tracking-tight text-slate-600 sm:grow-0' + 'flex-1 shrink-0 whitespace-nowrap font-unbounded font-semibold tracking-tight text-accent-foreground sm:grow-0' if (variant === 'h1') - return

{children}

+ return ( +

+ {children} +

+ ) if (variant === 'h2') return

{children}

if (variant === 'h3') diff --git a/src/index.css b/src/index.css index 0ca9b11..1d2137e 100644 --- a/src/index.css +++ b/src/index.css @@ -17,19 +17,19 @@ @layer base { :root { --background: 0 5% 98%; - --foreground: 240 10% 3.9%; + --foreground: 240 5% 20%; --card: 0 0% 100%; - --card-foreground: 240 10% 3.9%; + --card-foreground: 240 5% 20%; --popover: 0 0% 100%; - --popover-foreground: 240 10% 3.9%; + --popover-foreground: 240 5% 20%; --primary: 328 100% 45%; --primary-foreground: 355.7 100% 97.3%; --secondary: 240 4.8% 95.9%; --secondary-foreground: 240 5.9% 10%; --muted: 240 4.8% 95.9%; --muted-foreground: 240 3.8% 46.1%; - --accent: 240 4.8% 95.9%; - --accent-foreground: 240 5.9% 10%; + --accent: 228 12% 94%; + --accent-foreground: 215 20% 35%; --destructive: 0 84.2% 60.2%; --destructive-foreground: 0 0% 98%; --border: 240 5.9% 90%; @@ -57,7 +57,7 @@ --muted: 0 0% 15%; --muted-foreground: 240 5% 64.9%; --accent: 12 6.5% 15.1%; - --accent-foreground: 0 0% 98%; + --accent-foreground: 213 27% 84%; --destructive: 0 62.8% 30.6%; --destructive-foreground: 0 85.7% 97.3%; --border: 240 3.7% 15.9%; diff --git a/src/pages/Delegate/index.tsx b/src/pages/Delegate/index.tsx index b309282..f70e6bb 100644 --- a/src/pages/Delegate/index.tsx +++ b/src/pages/Delegate/index.tsx @@ -17,6 +17,8 @@ import { AlertNote } from '@/components/Alert' import { useTestTx } from '@/hooks/useTestTx' import { MultiTransactionDialog } from './MultiTransactionDialog' import { useGetSigningCallback } from '@/hooks/useGetSigningCallback' +import { Title } from '@/components/ui/title' +import { DelegateCard } from '@/components/DelegateCard' export const Delegate = () => { const { api, assetInfo } = useNetwork() @@ -176,7 +178,7 @@ export const Delegate = () => { } return ( -
+
{!api && ( { To all delegates -

- Delegate to {delegate.name} -

-
- - onChangeAmount(value, assetInfo.precision)} - value={amountVisible} - error={amountErrorDisplay} + Delegate to {delegate.name} +
+
+
+
+ + onChangeAmount(value, assetInfo.precision)} + value={amountVisible} + error={amountErrorDisplay} + /> +
- - []) => { - const value = v[0] === 0 ? '0.1' : `Locked${v[0]}x` - setConvictionNo(v[0]) - setConviction( - VotingConviction[value as keyof typeof VotingConviction], - ) - }} - /> - - + + []) => { + const value = v[0] === 0 ? '0.1' : `Locked${v[0]}x` + setConvictionNo(v[0]) + setConviction( + VotingConviction[value as keyof typeof VotingConviction], + ) + }} + /> + + +
{ const { delegates } = useDelegates() return ( -
+
- Delegates + Delegates
- {delegates?.map((d) => )} + {delegates?.map((d) => ( + + ))}
)