Skip to content

Commit

Permalink
Tabs sync (#5)
Browse files Browse the repository at this point in the history
* tabs, capitalize, socials

* fix lint

* change links to terms & priuvacy

* lint

* move edit address to breadcrumbs

* user edit in component

* footer issue ok

* show bg-main color instead of banner outside of home and opportunities

* add link to protocol header

* implement zkSync colors/fonts as default

* commit hash

* lint

* remove comments

* lint
  • Loading branch information
indaviande authored Dec 6, 2024
1 parent f3c7aa1 commit 48bb14f
Show file tree
Hide file tree
Showing 43 changed files with 239 additions and 159 deletions.
29 changes: 17 additions & 12 deletions merkl.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default createConfig({
harm: createColoring(["#d22e14", "#d22e14", "#131620"], ["#FFFFFF", "#40B66B", "white"]),
},
merkl: {
base: createColoring(["#1F2333", "#B8AAFD", "#131620"], ["#FCF8F5", "#B8AAFD", "white"]),
base: createColoring(["#1755F4", "#FF7900", "#0D1530"], ["#1755F4", "#FF7900", "#FFFFFF"]),
info: createColoring(["#2ABDFF", "#2ABDFF", "#131620"], ["#FFFFFF", "#40B66B", "white"]),
good: createColoring(["#40B66B", "#40B66B", "#131620"], ["#FFFFFF", "#40B66B", "white"]),
warn: createColoring(["#ff9600", "#ff9600", "#131620"], ["#FFFFFF", "#40B66B", "white"]),
Expand Down Expand Up @@ -97,16 +97,16 @@ export default createConfig({
// route: "/protocols",
// key: crypto.randomUUID(),
// },
terms: {
icon: "RiCompassesLine",
route: "/terms",
key: crypto.randomUUID(),
},
privacy: {
icon: "RiInformationFill",
route: "/privacy",
key: crypto.randomUUID(),
},
// terms: {
// icon: "RiCompassesLine",
// route: "/terms",
// key: crypto.randomUUID(),
// },
// privacy: {
// icon: "RiInformationFill",
// route: "/privacy",
// key: crypto.randomUUID(),
// },
},
socials: {
discord: "",
Expand All @@ -116,6 +116,8 @@ export default createConfig({
},
links: {
merkl: "https://merkl.xyz/",
merklTermsConditions: "https://app.merkl.xyz/merklTerms.pdf",
merklPrivacy: "https://privacy.angle.money",
},
wagmi: {
chains: [
Expand Down Expand Up @@ -154,7 +156,10 @@ export default createConfig({
],
client({ chain }) {
if (chain.id === zksync.id)
return createClient({ chain, transport: custom(window.ethereum!) }).extend(eip712WalletActions());
return createClient({
chain,
transport: custom(window.ethereum!),
}).extend(eip712WalletActions());
return createClient({ chain, transport: http() });
},
ssr: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/dappkit
Submodule dappkit updated 43 files
+0 −25 .github/workflows/build.yml
+28 −0 .github/workflows/code_quality.yml
+76 −0 biome.json
+ bun.lockb
+6 −2 package.json
+2 −0 src/components.ts
+1 −1 src/components/dapp/Countdown.tsx
+3 −5 src/components/dapp/TransactionButton.tsx
+1 −1 src/components/dapp/TransactionHelper.tsx
+21 −46 src/components/dapp/WalletButton.tsx
+8 −16 src/components/dapp/WalletConnectors.tsx
+2 −2 src/components/extenders/Card.tsx
+1 −0 src/components/extenders/Dropdown.tsx
+1 −1 src/components/extenders/Group.tsx
+5 −13 src/components/extenders/Icons.tsx
+6 −36 src/components/extenders/Modal.tsx
+44 −79 src/components/extenders/Select.tsx
+2 −2 src/components/primitives/Accordion.tsx
+10 −23 src/components/primitives/Button.tsx
+1 −1 src/components/primitives/Checkbox.tsx
+2 −4 src/components/primitives/Hash.tsx
+16 −23 src/components/primitives/Icon.tsx
+20 −42 src/components/primitives/Input.tsx
+1 −1 src/components/primitives/Scroll.tsx
+1 −1 src/components/primitives/Slider.tsx
+2 −2 src/components/primitives/Space.tsx
+34 −77 src/components/primitives/Table.tsx
+128 −0 src/components/primitives/Tabs.tsx
+47 −44 src/components/primitives/Text.tsx
+2 −2 src/components/primitives/Time.tsx
+1 −1 src/components/primitives/Title.tsx
+3 −3 src/components/primitives/Value.tsx
+7 −6 src/context/Dapp.context.tsx
+4 −4 src/context/Theme.context.tsx
+8 −5 src/context/Wallet.context.tsx
+1 −1 src/hooks/events/useShortcut.tsx
+1 −1 src/hooks/theming/useThemedVariables.tsx
+6 −9 src/hooks/useClipboard.tsx
+6 −8 src/hooks/useWalletState.tsx
+1 −0 src/utils/event.ts
+0 −1 src/utils/format.ts
+3 −2 src/utils/tailwind.ts
+28 −0 tsconfig.json
99 changes: 43 additions & 56 deletions src/components/composite/Hero.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useLocation } from "@remix-run/react";
import { Box, Container, Divider, Group, Icon, type IconProps, Icons, Text, Title } from "dappkit";
import { Container, Divider, Group, Icon, type IconProps, Icons, Tabs, Text, Title } from "dappkit";
import { Button } from "dappkit";
import config from "merkl.config";
import type { PropsWithChildren, ReactNode } from "react";
Expand All @@ -8,28 +8,46 @@ import type { Opportunity } from "src/api/services/opportunity/opportunity.model
export type HeroProps = PropsWithChildren<{
icons?: IconProps[];
title: ReactNode;
breadcrumbs?: { name: string; link: string; component?: ReactNode }[];
breadcrumbs?: { name?: string; link: string; component?: ReactNode }[];
navigation?: { label: ReactNode; link: string };
description: ReactNode;
tags?: ReactNode[];
tabs?: { label: ReactNode; link: string }[];
sideDatas?: { data: ReactNode; label: string; key: string }[];
tabs?: { label: ReactNode; link: string; key: string }[];
opportunity?: Opportunity;
}>;

export default function Hero({ navigation, breadcrumbs, icons, title, description, tags, tabs, children }: HeroProps) {
export default function Hero({
navigation,
breadcrumbs,
icons,
title,
description,
tags,
sideDatas,
tabs,
children,
}: HeroProps) {
const location = useLocation();

return (
<>
{/* TODO: Align lines & descriptions on all pages */}
{/* TODO: On sub-pages (all pages except Opportunities): Replace the banner by a color */}
<Group
className="flex-row justify-between aspect-[1440/440] bg-cover bg-no-repeat xl:aspect-auto xl:min-h-[400px]"
style={{ backgroundImage: `url('${config.images.hero}')` }}>
className={`${
location?.pathname === "/" || location?.pathname.includes("opportunities") ? "bg-cover" : "bg-main-6"
} flex-row justify-between bg-no-repeat xl:aspect-auto xl:min-h-[350px] aspect-[1440/350]`}
style={{
backgroundImage:
location?.pathname === "/" || location?.pathname.includes("opportunities")
? `url('${config.images.hero}')`
: "none",
}}>
<Container>
<Group className="flex-col h-full py-xl gap-xl lg:gap-xs">
<Group className="items-center">
<Group className="items-center" size="sm">
{/* TODO: Build dynamic breadcrumbs */}
{/** Disabled and set invisible when undefined to preserve layout height */}
<Button to={navigation?.link} look="soft" size="xs">
<Button to={navigation?.link} look="soft" bold size="xs">
Home
</Button>
{breadcrumbs?.map(breadcrumb => {
Expand Down Expand Up @@ -69,68 +87,37 @@ export default function Hero({ navigation, breadcrumbs, icons, title, descriptio
{title}
</Title>
</Group>
{tags && (
<Text size="xl" bold>
{description}
</Text>
)}
</Group>
<Divider look="base" />
{tags && <Group className="mb-lg">{tags}</Group>}
{!tags && (
{!!description && (
<Text size="xl" bold>
{description}
</Text>
)}
{!!tags && <Group className="mb-lg">{tags}</Group>}
</Group>
{/* TODO: Move this outside the Hero component */}
{/* {!location?.pathname.includes("user") && (
{!!sideDatas && (
<Group className="w-full lg:w-auto lg:flex-col mr-xl*2" size="xl">
<Group className="flex-col">
<Text size={3}>
<Value look={totalRewards === "0" ? "soft" : "base"} format="$0,0" size={"md"}>
{totalRewards}
</Value>
</Text>
{sideDatas.map(data => (
<Group key={data.key} className="flex-col">
<Text size={3}>{data.data}</Text>

<Text size="xl" className="font-bold">
Daily rewards
</Text>
</Group>
<Group className="flex-col">
<Text size={3}>
<Value value format="0a%">
{(opportunity?.apr ?? 0) / 100}
</Value>
</Text>
<Text size={"xl"} className="font-bold">
APR
</Text>
</Group>
<Group className="flex-col">
<Text size={3}>{filteredCampaigns?.length}</Text>
<Text size={"xl"} className="font-bold">
Active campaigns
</Text>
</Group>
<Text size="xl" className="font-bold not-italic">
{data.label}
</Text>
</Group>
))}
</Group>
)} */}
)}
</Group>
</Group>
</Container>
</Group>
<Container>
{!!tabs && (
<Box size="sm" look="base" className="flex-row mt-md w-min">
{tabs?.map(tab => (
<Button
look={location.pathname === tab.link ? "hype" : "base"}
to={tab.link}
key={`${tab.label}-${tab.link}`}>
{tab.label}
</Button>
))}
</Box>
<Group size="xl" className="my-lg">
<Tabs tabs={tabs} look="base" size="lg" />
</Group>
)}
</Container>
<div>{children}</div>
Expand Down
22 changes: 22 additions & 0 deletions src/components/element/AddressEdit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useNavigate } from "@remix-run/react";
import { Button, Group, Icon, Input } from "packages/dappkit/src";
import { useState } from "react";

export default function AddressEdit() {
const navigate = useNavigate();
const [inputAddress, setInputAddress] = useState<string>();
const [_isEditingAddress, setIsEditingAddress] = useState(false);

return (
<Group size="sm">
<Input state={[inputAddress, setInputAddress]} look="bold" aria-label="Enter address" size="xs" />
<Button
onClick={() => (inputAddress ? navigate(`/users/${inputAddress}`) : setIsEditingAddress(false))}
size="sm"
look="soft"
aria-label="Submit address">
<Icon remix="RiCornerDownRightLine" />
</Button>
</Group>
);
}
5 changes: 5 additions & 0 deletions src/components/element/Socials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export default function Socials() {
<Icon remix="RiDiscordFill" />
</Button>
)}
{!!config.socials.medium && (
<Button look="base" size="lg" external to={config.socials.medium}>
<Icon remix="RiMediumFill" />
</Button>
)}
</Group>
);
}
2 changes: 1 addition & 1 deletion src/components/element/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export default function Tag<T extends keyof TagTypes>({ type, value, ...props }:
</Group>
</Group>
}>
<PrimitiveTag look="tint" key={value} {...props}>
<PrimitiveTag look="bold" key={value} {...props}>
<Icon src={protocol?.icon} />
{value?.name}
</PrimitiveTag>
Expand Down
2 changes: 1 addition & 1 deletion src/components/element/chain/ChainTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createTable } from "dappkit";

export const [ChainTable, ChainRow, chainColumns] = createTable({
chain: {
name: "CHAIN",
name: "Chain",
size: "minmax(350px,1fr)",
compact: "1fr",
className: "justify-start",
Expand Down
2 changes: 1 addition & 1 deletion src/components/element/opportunity/OpportunityTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const [OpportunityTable, OpportunityRow, opportunityColumns] = createTabl
className: "justify-center",
},
apy: {
name: "APR",
name: "APY",
size: "minmax(min-content,150px)",
compactSize: "minmax(min-content,1fr)",
className: "justify-center",
Expand Down
3 changes: 2 additions & 1 deletion src/components/element/opportunity/OpportunityTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export default function OpportunityTableRow({ hideTags, opportunity, className,
}
apyColumn={
<Group className="py-xl">
<Button look={(opportunity?.aprRecord?.cummulated ?? 0) > 0 ? "hype" : "soft"} className="font-mono">
{/* TODO: Transform in Button so we can show an APY modal */}
<Button look="tint" size="lg" className="font-mono">
<Value value format="0a%">
{opportunity.apr / 100}
</Value>
Expand Down
2 changes: 1 addition & 1 deletion src/components/element/protocol/ProtocolTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createTable } from "dappkit";

export const [ProtocolTable, ProtocolRow, protocolColumns] = createTable({
protocol: {
name: "PROTOCOL",
name: "Protocol",
size: "minmax(350px,1fr)",
compact: "1fr",
className: "justify-start",
Expand Down
6 changes: 3 additions & 3 deletions src/components/element/rewards/ClaimRewardsChainTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import { createTable } from "dappkit";

export const [ClaimRewardsChainTable, ClaimRewardsChainRow, claimRewardsChainColumns] = createTable({
chain: {
name: "CHAIN",
name: "Chain",
size: "minmax(180px,1fr)",
compact: "1fr",
className: "justify-start",
main: true,
},
unclaimed: {
name: "UNCLAIMED",
name: "Unclaimed",
size: "minmax(100px,150px)",
compactSize: "minmax(min-content,1fr)",
className: "justify-end",
},
claimed: {
name: "CLAIMED",
name: "Claimed",
size: "minmax(100px,150px)",
compactSize: "minmax(min-content,1fr)",
className: "justify-end",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default function ClaimRewardsChainTableRow({
<ClaimRewardsTokenTable
tokenHeader={
<Text size="xs" className="pl-md">
TOKEN
Token
</Text>
}
size="sm"
Expand Down
8 changes: 4 additions & 4 deletions src/components/element/rewards/ClaimRewardsTokenTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ import { createTable } from "dappkit";

export const [ClaimRewardsTokenTable, ClaimRewardsTokenRow, claimRewardsTokenColumns] = createTable({
token: {
name: "TOKEN",
name: "Token",
size: "minmax(100px,1fr)",
compact: "1fr",
className: "justify-start",
main: true,
},
pending: {
name: "PENDING",
name: "Pending",
size: "minmax(min-content,150px)",
compactSize: "minmax(min-content,200px)",
className: "justify-end",
},
amount: {
name: "UNCLAIMED",
name: "Unclaimed",
size: "minmax(min-content,150px)",
compactSize: "minmax(min-content,200px)",
className: "justify-end",
},
claimed: {
name: "CLAIMED",
name: "Claimed",
size: "minmax(min-content,150px)",
compactSize: "minmax(min-content,200px)",
className: "justify-end",
Expand Down
10 changes: 5 additions & 5 deletions src/components/element/rewards/ClaimRewardsTokenTablePrice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ export default function ClaimRewardsTokenTablePrice({ amount, price, decimals }:
const value = formatUnits(amount, decimals);

return (
<Group size="sm">
<Group size="xs" className="flex-col items-end">
<Value
fallback={v => (v as string).includes("0.000") && "<0.001"}
className="text-right"
fallback={v => (v as string).includes("0.000") && "< 0.001"}
className="text-right items-center flex"
look={"bold"}
format="0,0.###">
{value}
</Value>
<Value
fallback={v => {
if (price === 0) return "-";
return (v.toString() as string).includes("0.0") && "$<0.1";
return (v.toString() as string).includes("0.0") && "< $0.1";
}}
className="text-right"
className="text-right items-center flex"
look={"soft"}
format="$0,0.#">
{Number.parseFloat(value) * (price ?? 0)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/element/token/TokenTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { createTable } from "dappkit";

export const [TokenTable, TokenRow, tokenColumns] = createTable({
token: {
name: "TOKEN",
name: "Token",
size: "minmax(350px,1fr)",
compact: "1fr",
className: "justify-start",
main: true,
},
price: {
name: "PRICE",
name: "Price",
size: "minmax(min-content,150px)",
compactSize: "minmax(min-content,1fr)",
className: "justify-end",
Expand Down
Loading

0 comments on commit 48bb14f

Please sign in to comment.