Skip to content

Commit

Permalink
fix: updated UI according to design fixes (#492)
Browse files Browse the repository at this point in the history
Co-authored-by: Taras Oliynyk <taras.oliynyk@hapi.one>
  • Loading branch information
OliynykPro and tohapi authored Dec 28, 2023
1 parent 2e71910 commit ca30e5d
Show file tree
Hide file tree
Showing 31 changed files with 256 additions and 45 deletions.
9 changes: 8 additions & 1 deletion explorer/src/assets/locales/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@
"search": "Search by ID, name, description"
}
},
"theme": {
"switch": "Switch to {{mode}} Mode",
"dark": "Dark",
"light": "Light",
"system": "System"
},
"home": {
"title": "Verax is an open source, public registry for storing attestations",
"issuers": {
"title": "Explore the Verax Ecosystem"
"title": "Explore the ways of getting the attestation",
"description": "Find out how you can get attestations from the following providers that you can use across the ecosystem"
},
"info": {
"issueYourAttestation": "Want to issue your own attestation?",
Expand Down
36 changes: 36 additions & 0 deletions explorer/src/assets/networks/arbitrum-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions explorer/src/assets/networks/arbitrum-goerli.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions explorer/src/assets/networks/arbitrum.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const TdHandler: React.FC<ITdHandler> = ({ value, valueUrl, to, isTextLef
<a
href={valueUrl}
target="_blank"
onClick={(e) => e.stopPropagation()}
className={`hover:underline ${isTextLeft ? "translate-x-0" : "translate-x-5"} ${
isTextLeft ? "group-hover:translate-x-5" : "group-hover:translate-x-0"
} transition max-w-[300px] overflow-hidden text-ellipsis`}
Expand All @@ -26,7 +27,7 @@ export const TdHandler: React.FC<ITdHandler> = ({ value, valueUrl, to, isTextLef
{value}
</p>
)}
<Link to={to}>
<Link to={to} onClick={(e) => e.stopPropagation()}>
<ChevronRight className="w-5 opacity-0 group-hover:opacity-100 transition" />
</Link>
</div>
Expand Down
25 changes: 23 additions & 2 deletions explorer/src/components/DataTable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
import { flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table";
import { Attestation, Module, Schema } from "@verax-attestation-registry/verax-sdk";
import { t } from "i18next";
import { generatePath, useNavigate } from "react-router-dom";

import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { useNetworkContext } from "@/providers/network-provider/context";

import { DataTableProps } from "./interfaces";

export function DataTable<TData, TValue>({ columns, data }: DataTableProps<TData, TValue>) {
type TRowOriginal = Schema | Attestation | Module;

export function DataTable<TData, TValue>({ columns, data, link }: DataTableProps<TData, TValue>) {
const navigate = useNavigate();

const {
network: { network },
} = useNetworkContext();

const table = useReactTable({
data,
columns,
getCoreRowModel: getCoreRowModel(),
});

const trClickHandler = (original: TRowOriginal) => {
const id = original.id;
if (!link || !id) return;

navigate(generatePath(link, { chainId: network, id }), {
state: { from: location.pathname },
});
};

return (
<div className="rounded-3xl border border-border-table dark:border-blueDark">
<Table>
Expand All @@ -36,8 +56,9 @@ export function DataTable<TData, TValue>({ columns, data }: DataTableProps<TData
table.getRowModel().rows.map((row) => (
<TableRow
key={row.id}
onClick={() => trClickHandler(row.original as TRowOriginal)}
data-state={row.getIsSelected() && "selected"}
className="table-row-transition hover:bg-jumbotronLight dark:hover:bg-jumbotronDark"
className="table-row-transition hover:bg-jumbotronLight dark:hover:bg-jumbotronDark cursor-pointer"
>
{row.getVisibleCells().map((cell) => (
<TableCell key={cell.id} className="whitespace-nowrap text-text-secondary">
Expand Down
1 change: 1 addition & 0 deletions explorer/src/components/DataTable/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { ColumnDef } from "@tanstack/react-table";
export interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[];
data: TData[];
link?: string;
}
9 changes: 5 additions & 4 deletions explorer/src/components/LightDarkModeSwitcher/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { t } from "i18next";
import { Moon, Sun, SunMoon } from "lucide-react";
import { useEffect } from "react";
import { useTernaryDarkMode } from "usehooks-ts";
Expand Down Expand Up @@ -29,11 +30,11 @@ export const LightDarkModeSwitcher: React.FC<ILightDarkModeSwitcher> = ({ isMobi
const getPredictedThemeDetails = (mode: typeof ternaryDarkMode) => {
switch (mode) {
case "light":
return { label: "System", icon: <SunMoon width="1rem" height="auto" /> };
return { label: t("theme.system"), icon: <SunMoon width="1rem" height="auto" /> };
case "system":
return { label: "Dark", icon: <Moon width="1rem" height="auto" /> };
return { label: t("theme.dark"), icon: <Moon width="1rem" height="auto" /> };
case "dark":
return { label: "Light", icon: <Sun width="1rem" height="auto" /> };
return { label: t("theme.light"), icon: <Sun width="1rem" height="auto" /> };
}
};

Expand All @@ -49,7 +50,7 @@ export const LightDarkModeSwitcher: React.FC<ILightDarkModeSwitcher> = ({ isMobi
onClick={toggleTernaryDarkMode}
className="flex items-center gap-2 text-base font-semibold text-text-darkGrey cursor-pointer"
>
Switch to {label} Mode
{t("theme.switch", { mode: label })}
{icon}
</div>
);
Expand Down
20 changes: 19 additions & 1 deletion explorer/src/config/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { VeraxSdk } from "@verax-attestation-registry/verax-sdk";
import { createWeb3Modal, defaultWagmiConfig } from "@web3modal/wagmi/react";
import { linea, lineaTestnet } from "wagmi/chains";
import { arbitrum, arbitrumGoerli, linea, lineaTestnet } from "wagmi/chains";

import veraxColoredIcon from "@/assets/logo/verax-colored-icon.svg";
import ArbitrumIconDark from "@/assets/networks/arbitrum-dark.svg?react";
import ArbitrumGoerliIcon from "@/assets/networks/arbitrum-goerli.svg?react";
import ArbitrumIcon from "@/assets/networks/arbitrum.svg?react";
import LineaMainnetIconDark from "@/assets/networks/linea-mainnet-dark.svg?react";
import LineaMainnetIcon from "@/assets/networks/linea-mainnet.svg?react";
import LineaTestnetIcon from "@/assets/networks/linea-testnet.svg?react";
Expand All @@ -24,6 +27,21 @@ const chains: INetwork[] = [
img: <LineaTestnetIcon />,
network: "linea-testnet",
},
{
name: "Arbitrum",
chain: arbitrum,
veraxEnv: VeraxSdk.DEFAULT_ARBITRUM_FRONTEND,
img: <ArbitrumIcon />,
imgDark: <ArbitrumIconDark />,
network: "arbitrum",
},
{
name: "Arbitrum Goerli",
chain: arbitrumGoerli,
veraxEnv: VeraxSdk.DEFAULT_ARBITRUM_TESTNET_FRONTEND,
img: <ArbitrumGoerliIcon />,
network: "arbitrum-goerli",
},
];

const projectId = import.meta.env.VITE_WALLETCONNECT_PROJECT_ID;
Expand Down
14 changes: 11 additions & 3 deletions explorer/src/constants/columns/attestation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import { EMPTY_STRING, ITEMS_PER_PAGE_DEFAULT, links } from "../index";
interface ColumnsProps {
sortByDate: boolean;
sdk: VeraxSdk;
chainId: number;
}

export const columns = ({ sortByDate = true, sdk }: Partial<ColumnsProps> = {}): ColumnDef<Attestation>[] => [
export const columns = ({ sortByDate = true, sdk, chainId }: Partial<ColumnsProps> = {}): ColumnDef<Attestation>[] => [
{
accessorKey: "id",
header: () => (
Expand All @@ -35,7 +36,7 @@ export const columns = ({ sortByDate = true, sdk }: Partial<ColumnsProps> = {}):
cell: ({ row }) => {
const id = row.getValue("id");
return (
<Link to={toAttestationById(id as string)} className="hover:underline">
<Link to={toAttestationById(id as string)} className="hover:underline" onClick={(e) => e.stopPropagation()}>
{displayAmountWithComma(hexToNumber(id as Address))}
</Link>
);
Expand Down Expand Up @@ -84,8 +85,15 @@ export const columns = ({ sortByDate = true, sdk }: Partial<ColumnsProps> = {}):
header: () => <p className="text-left">{t("attestation.list.columns.subject")}</p>,
cell: ({ row }) => {
const subject = row.getValue("subject") as string;
if (!chainId) return cropString(subject);

return (
<a href={`${links.lineascan.address}/${subject}`} target="_blank" className="hover:underline">
<a
href={`${links[chainId].address}/${subject}`}
onClick={(e) => e.stopPropagation()}
target="_blank"
className="hover:underline"
>
{cropString(subject)}
</a>
);
Expand Down
10 changes: 7 additions & 3 deletions explorer/src/constants/columns/module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import { cropString } from "@/utils/stringUtils";

import { EMPTY_STRING, ITEMS_PER_PAGE_DEFAULT, links } from "../index";

export const columns = (): ColumnDef<Module>[] => [
interface ColumnsProps {
chainId: number;
}

export const columns = ({ chainId }: Partial<ColumnsProps> = {}): ColumnDef<Module>[] => [
{
accessorKey: "name",
header: () => (
Expand All @@ -23,7 +27,7 @@ export const columns = (): ColumnDef<Module>[] => [
cell: ({ row }) => {
const { name, id } = row.original;
return (
<Link to={toModuleById(id)} className="hover:underline">
<Link to={toModuleById(id)} className="hover:underline" onClick={(e) => e.stopPropagation()}>
{name}
</Link>
);
Expand All @@ -43,7 +47,7 @@ export const columns = (): ColumnDef<Module>[] => [

return (
<TdHandler
valueUrl={`${links.lineascan.address}/${address}`}
valueUrl={chainId ? `${links[chainId].address}/${address}` : "#"}
value={cropString(address)}
to={toModuleById(id)}
/>
Expand Down
2 changes: 1 addition & 1 deletion explorer/src/constants/columns/schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const columns = (): ColumnDef<Schema>[] => [
const id = row.original.id;

return (
<Link to={toSchemaById(id)} className="hover:underline">
<Link to={toSchemaById(id)} className="hover:underline" onClick={(e) => e.stopPropagation()}>
{name}
</Link>
);
Expand Down
15 changes: 13 additions & 2 deletions explorer/src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { arbitrum, arbitrumGoerli, linea, lineaTestnet } from "wagmi/chains";

export const EMPTY_STRING = "";
export const SPACE_STRING = " ";
export const COMMA_STRING = ",";
Expand All @@ -10,9 +12,18 @@ export const CURRENT_PAGE_DEFAULT = 1;
export const THOUSAND = 1e3;
export const BILLION = 1e9;

export const links = {
lineascan: {
export const links: { [key: number]: { trx?: string; address: string } } = {
[linea.id]: {
trx: "https://lineascan.build/trx",
address: "https://lineascan.build/address",
},
[lineaTestnet.id]: {
address: "https://goerli.lineascan.build/address",
},
[arbitrum.id]: {
address: "https://arbiscan.io/address",
},
[arbitrumGoerli.id]: {
address: "https://testnet.arbiscan.io/address",
},
};
Loading

0 comments on commit ca30e5d

Please sign in to comment.