Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TAS-177] Local icons, meta tags and Scott's PR feedback #19

Merged
merged 4 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions apps/oeth/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,51 @@
<head>
<meta charset="utf-8" />
<title>Oeth</title>
<meta
name="description"
content="An ETH-pegged token that earns yield from all forms of staking"
/>
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />

<!-- favicon -->
<link rel="shortcut icon" href="/images/favicon.svg" type="image/x-icon" />
<link rel="icon" href="/images/favicon.svg" type="image/x-icon" />

<!-- Inter font -->
<link rel="preconnect" href="https://rsms.me/" />
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
<!-- -->

<!-- Sailec font -->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/typeface-sailec@1.0.0/index.min.css"
/>

<!-- meta tags for social -->

<meta property="og:url" content="https://oeth.com" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Origin Ether (OETH)" />
<meta
property="og:description"
content="An ETH-pegged token that earns yield from all forms of staking"
/>
<meta name="og:image" content="/images/meta.png" />

<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@originprotocol" />
<meta name="twitter:title" content="Origin Ether (OETH)" />
<meta
name="twitter:description"
content="An ETH-pegged token that earns yield from all forms of staking"
/>
<meta
name="twitter:image"
content="https://cmsmediaproduction.s3.amazonaws.com/thumbnail_oeth_meta_ed53499f08.png"
/>
<!-- end meta tags -->
</head>
<body>
<div id="root"></div>
Expand Down
2 changes: 1 addition & 1 deletion apps/oeth/src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function Layout() {
return (
<>
<TopNav
logo="https://app.oeth.com/images/origin-ether-logo.svg"
logo="/images/origin-ether-logo.svg"
tabs={[
intl.formatMessage({ defaultMessage: 'Swap' }),
intl.formatMessage({ defaultMessage: 'Wrap' }),
Expand Down
2 changes: 1 addition & 1 deletion apps/oeth/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"src/**/*.spec.jsx",
"src/**/*.test.jsx"
],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx", "../../libs/defi/oeth/src/components/TopNav.tsx"]
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
}
21 changes: 3 additions & 18 deletions libs/defi/oeth/src/components/History/HistoryTable.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
import { useState } from 'react';

import { faker } from '@faker-js/faker';
import { Container, Stack, Typography } from '@mui/material';
import { within } from '@storybook/testing-library';

import { rows } from './fixtures';
import { HistoryFilterButton } from './HistoryButton';
import { HistoryTable } from './HistoryTable';

import type { Meta, StoryObj } from '@storybook/react';
import type { ColumnFilter } from '@tanstack/react-table';

import type { HistoryRow } from './HistoryTable';

const rows = faker.helpers.multiple<HistoryRow>(
() => ({
date: faker.date.recent({ days: 35 }),
balance: faker.number.float({
min: 10000,
max: 10000000000,
precision: 10,
}),
change: faker.number.float({ min: -10, max: 25 }),
type: faker.helpers.arrayElement(['swap', 'received', 'sent', 'yield']),
link: faker.internet.url(),
}),
{ count: 150 },
);

const WithFilters = () => {
const [filter, setFilter] = useState<ColumnFilter>({ id: 'type', value: [] });
return (
Expand Down Expand Up @@ -70,6 +53,7 @@ const WithFilters = () => {
))}
</Stack>
</Stack>
{/* @ts-expect-error type mismatch with fixtures */}
<HistoryTable rows={rows} isLoading={false} filter={filter} />
</Stack>
);
Expand All @@ -80,6 +64,7 @@ const meta: Meta<typeof HistoryTable> = {
title: 'History/History table',
args: {
isLoading: false,
// @ts-expect-error type mismatch
rows,
},
render: (args) => (
Expand Down
111 changes: 21 additions & 90 deletions libs/defi/oeth/src/components/History/HistoryTable.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
import { useEffect, useMemo, useState } from 'react';
import { useEffect, useMemo, useRef } from 'react';

import {
Box,
Pagination,
Stack,
Table,
TableBody,
TableCell,
TableHead,
TableRow,
} from '@mui/material';
import { LinkIcon, quantityFormat } from '@origin/shared/components';
import {
createColumnHelper,
flexRender,
getCoreRowModel,
getFilteredRowModel,
getPaginationRowModel,
useReactTable,
} from '@tanstack/react-table';
import { Box, Stack } from '@mui/material';
import { DataTable, LinkIcon, quantityFormat } from '@origin/shared/components';
import { createColumnHelper } from '@tanstack/react-table';
import { useIntl } from 'react-intl';

import type { ColumnFilter, ColumnFiltersState } from '@tanstack/react-table';
import type { DataTableRef } from '@origin/shared/components';
import type { ColumnFilter } from '@tanstack/react-table';

type Filter = 'swap' | 'yield' | 'received' | 'sent';

Expand All @@ -31,6 +16,7 @@ export interface HistoryRow {
change: number;
balance: number;
link: string;
[key: string]: unknown;
}

interface Props {
Expand All @@ -41,9 +27,10 @@ interface Props {

const columnHelper = createColumnHelper<HistoryRow>();

export function HistoryTable({ rows, filter }: Props) {
export function HistoryTable({ rows, filter, isLoading }: Props) {
const intl = useIntl();
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
const ref = useRef<DataTableRef>(null);

const columns = useMemo(
() => [
columnHelper.accessor('date', {
Expand Down Expand Up @@ -93,74 +80,18 @@ export function HistoryTable({ rows, filter }: Props) {
[intl],
);

const table = useReactTable({
data: rows,
columns,
state: {
pagination: {
pageSize: 20,
pageIndex: 0,
},
columnFilters,
},
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
getFilteredRowModel: getFilteredRowModel(),
onColumnFiltersChange: setColumnFilters,
// add when we do server side pagination
// manualPagination: true,
pageCount: rows.length / 3,
// add when we do server side pagination
// onPaginationChange: setPagination
});

useEffect(() => {
table.getColumn('type')?.setFilterValue(filter);
}, [filter, table]);
ref?.current?.setFilter(filter, 'type');
}, [filter]);

return (
<Stack gap={2}>
<Table>
<TableHead>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => (
<TableCell key={header.id}>
{flexRender(
header.column.columnDef.header,
header.getContext(),
)}
</TableCell>
))}
</TableRow>
))}
</TableHead>
<TableBody>
{table.getRowModel().rows.map((row) => (
<TableRow key={row.id}>
{row.getVisibleCells().map((cell) => (
<TableCell
key={cell.id}
sx={{
...(cell.column.columnDef.id === 'type'
? { '&:first-letter': { textTransform: 'uppercase' } }
: {}),
}}
>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
))}
</TableRow>
))}
</TableBody>
</Table>
<Pagination
count={table.getPageCount()}
shape="rounded"
variant="outlined"
hidePrevButton
hideNextButton
onChange={(_, page) => table.setPageIndex(page)}
/>
</Stack>
<DataTable
ref={ref}
rows={rows}
// @ts-expect-error typescript doesn't like my generic prop for whatever reason
columns={columns}
pageCount={rows.length / 3}
isLoading={isLoading}
/>
);
}
Loading
Loading