Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Home page Epic #58

Merged
merged 58 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
6c6514b
Distinguish components
henrypalacios Apr 7, 2022
5347984
Adding statistics SummaryCards component (#50)
henrypalacios Apr 18, 2022
0e6f00f
fix uppercase on Fee
alongoni Apr 18, 2022
28ff856
add copybtn
alongoni Apr 18, 2022
000cf84
fix error
alongoni Apr 18, 2022
2b04e9e
fix copybtn position
alongoni Apr 18, 2022
6e90808
change address format
alongoni Apr 18, 2022
00c13b5
move the copybtn
alongoni Apr 19, 2022
8157105
add order link and styles on copybtn
alongoni Apr 19, 2022
ac8040f
add styles copybtn
alongoni Apr 19, 2022
3aad2ad
copybutton tooltip improvements
alongoni Apr 20, 2022
612652a
copy color delay and add fixed size wrapper
alongoni Apr 21, 2022
b502607
Merge pull request #67 from cowprotocol/65-fix-uppercase-typo-fees
alongoni Apr 21, 2022
71e4651
fix tooltip position
alongoni Apr 21, 2022
d406fba
Merge pull request #68 from cowprotocol/66-copy-btn-batch-id
alongoni Apr 22, 2022
1b8ea01
[Home Page] Volume chart (#62)
henrypalacios Apr 28, 2022
8d1e545
Add TokenTableComponent + hook
matextrem Apr 29, 2022
ace396e
Add flexSearch hook
matextrem Apr 29, 2022
406c10c
Merge remote-tracking branch 'origin/develop' into 35-epic-home-page
ramirotw Apr 30, 2022
cd1a932
Add tokens table with mocked data
matextrem May 2, 2022
17860c6
Remove invalid selector
matextrem May 2, 2022
4e2b5ae
Integrate the cow-sdk into the Home Page widgets (#77)
ramirotw May 5, 2022
78f95d3
Merge remote-tracking branch 'origin/develop' into 35-epic-home-page
ramirotw May 5, 2022
e6b1f25
Merge remote-tracking branch 'origin/35-epic-home-page' into 39/token…
ramirotw May 5, 2022
d4272ce
fix import
ramirotw May 5, 2022
550c7ba
styles improvements: chart, mobile, titles
alongoni May 5, 2022
59970a1
Update data types + improve styling
matextrem May 5, 2022
7a065b3
delete spinner beside Top token tittle
alongoni May 6, 2022
8e3164b
change Top tokens tittle position
alongoni May 6, 2022
7e03623
replace spinner -> CowLoading component
alongoni May 6, 2022
8aa4376
change breackpoints on token table to mobile
alongoni May 6, 2022
7953494
add another CowLoading component
alongoni May 6, 2022
8817f9e
Fix pagination
matextrem May 6, 2022
ce49c3f
Update pagination position
matextrem May 6, 2022
cf124c6
layout styles
alongoni May 6, 2022
0e7c1a2
styles fixes
alongoni May 6, 2022
fb54caa
table grid + message not found
alongoni May 6, 2022
ba98fae
Fix pagination results
matextrem May 6, 2022
72f16bb
fix height on search icon
alongoni May 9, 2022
5e013a3
table styles improvements
alongoni May 9, 2022
96f91c3
tabla columns numeration
alongoni May 9, 2022
74bec2e
change hover color on rows
alongoni May 10, 2022
1af44be
fix place holder on mobile
alongoni May 10, 2022
59342ef
add scrollbar styles
alongoni May 10, 2022
f23539c
fix table styles on medium screens
alongoni May 10, 2022
bcfbd23
fix placeholder mobile
alongoni May 10, 2022
5624c7a
fix placeholder mobile + tabs
alongoni May 11, 2022
838aeec
center not found text msg + move border bottom
alongoni May 11, 2022
387f823
add # column
alongoni May 11, 2022
8fede60
aligmnet on token table
alongoni May 12, 2022
e7523ad
Fix pagination when filtering
matextrem May 12, 2022
28b6fe5
Merge pull request #81 from cowprotocol/39/tokens-table
matextrem May 13, 2022
52c8add
Volume chart improvements (#89)
henrypalacios May 19, 2022
36030be
Volume chart and cards layout (#90)
alongoni May 19, 2022
e2c005c
Fetch orders and order detail from barn and prod apis (#105)
ramirotw Jun 1, 2022
27526e7
Update summary cards each 10 seconds (#107)
ramirotw Jun 8, 2022
68113df
Integrate Tokens table with data from the subgraph (#98)
ramirotw Jun 10, 2022
9ccbdd2
Merge remote-tracking branch 'origin/develop' into 35-epic-home-page
ramirotw Jun 16, 2022
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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 12
node-version: 16

- name: Set output of cache
id: yarn-cache
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 12
node-version: 16

- name: Load dependencies
id: cache-node-modules
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 12
node-version: 16

- name: Load dependencies
id: cache-node-modules
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 12
node-version: 16

- name: Load dependencies
id: cache-node-modules
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "src/index.js",
"sideEffects": false,
"engines": {
"node": "12"
"node": "16"
},
"scripts": {
"start": "npm run start:explorer",
Expand Down Expand Up @@ -52,7 +52,7 @@
"dependencies": {
"@amcharts/amcharts4": "^4.9.12",
"@apollo/client": "^3.1.5",
"@cowprotocol/cow-sdk": "^0.0.9",
"@cowprotocol/cow-sdk": "^0.0.12",
"@fortawesome/fontawesome-svg-core": "^1.2.26",
"@fortawesome/free-regular-svg-icons": "^5.12.0",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
Expand Down Expand Up @@ -83,11 +83,12 @@
"detect-browser": "^5.1.0",
"eth-json-rpc-middleware": "^4.4.1",
"ethers": "^5.0.26",
"graphql": "^15.3.0",
"flexsearch": "^0.7.21",
"graphql": "^16.5.0",
"inter-ui": "^3.15.0",
"joi": "^17.2.0",
"json-rpc-engine": "5.3.0",
"lightweight-charts": "^3.2.0",
"lightweight-charts": "^3.8.0",
"modali": "^1.2.0",
"node-cache": "^5.1.0",
"npm-run-all": "^4.1.5",
Expand Down Expand Up @@ -133,6 +134,7 @@
"@types/cytoscape-popper": "^2.0.0",
"@types/enzyme": "^3.10.4",
"@types/enzyme-adapter-react-16": "^1.0.5",
"@types/flexsearch": "^0.7.3",
"@types/hapi__joi": "^16.0.12",
"@types/jest": "^26.0.8",
"@types/node": "^14.0.14",
Expand Down Expand Up @@ -167,7 +169,7 @@
"eslint-plugin-react": "^7.21.2",
"eslint-plugin-react-hooks": "^4.1.2",
"eslint-utils": ">=2.1.0",
"favicons-webpack-plugin": "^3.0.1",
"favicons-webpack-plugin": "^4.0.0",
"file-loader": "^6.0.0",
"fork-ts-checker-webpack-plugin": "^4.0.3",
"frontmatter-markdown-loader": "^3.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import CowLoading from 'components/common/CowLoading'

export const OrdersTableWithData: React.FC = () => {
const {
orders,
data: orders,
addressAccountParams: { ownerAddress, networkId },
} = useContext(OrdersTableContext)
const isFirstRender = useFirstRender()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export type BlockchainNetwork = Network | undefined

type CommonState = {
addressAccountParams: { networkId: BlockchainNetwork; ownerAddress: string }
orders: Order[] | undefined
data: Order[] | undefined
error?: UiError
isOrdersLoading: boolean
isLoading: boolean
tableState: TableState
} & TableStateSetters

Expand Down
12 changes: 6 additions & 6 deletions src/apps/explorer/components/OrdersTableWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React from 'react'
import styled from 'styled-components'

import ExplorerTabs from 'apps/explorer/components/common/ExplorerTabs/ExplorerTabs'
import TablePagination from 'apps/explorer/components/common/TablePagination'
import { TabItemInterface } from 'components/common/Tabs/Tabs'
import { useTable } from './useTable'
import { OrdersTableWithData } from './OrdersTableWithData'
import { OrdersTableContext, BlockchainNetwork } from './context/OrdersTableContext'
import PaginationOrdersTable from './PaginationOrdersTable'
import { useGetAccountOrders } from 'hooks/useGetOrders'
import Spinner from 'components/common/Spinner'
import { ConnectionStatus } from 'components/ConnectionStatus'
Expand Down Expand Up @@ -44,7 +44,7 @@ const WrapperExtraComponents = styled.div`

const ExtraComponentNode: React.ReactNode = (
<WrapperExtraComponents>
<PaginationOrdersTable />
<TablePagination context={OrdersTableContext} />
</WrapperExtraComponents>
)
interface Props {
Expand All @@ -61,7 +61,7 @@ const OrdersTableWidget: React.FC<Props> = ({ ownerAddress, networkId }) => {
} = useTable({ initialState: { pageOffset: 0, pageSize: 20 } })
const {
orders,
isLoading: isOrdersLoading,
isLoading,
error,
isThereNext: isThereNextOrder,
} = useGetAccountOrders(ownerAddress, tableState.pageSize, tableState.pageOffset, tableState.pageIndex)
Expand All @@ -72,9 +72,9 @@ const OrdersTableWidget: React.FC<Props> = ({ ownerAddress, networkId }) => {
<OrdersTableContext.Provider
value={{
addressAccountParams,
orders,
data: orders,
error,
isOrdersLoading,
isLoading,
tableState,
setPageSize,
handleNextPage,
Expand All @@ -83,7 +83,7 @@ const OrdersTableWidget: React.FC<Props> = ({ ownerAddress, networkId }) => {
>
<ConnectionStatus />
{error && <Notification type={error.type} message={error.message} />}
<StyledExplorerTabs tabItems={tabItems(isOrdersLoading)} extra={ExtraComponentNode} />
<StyledExplorerTabs tabItems={tabItems(isLoading)} extra={ExtraComponentNode} />
</OrdersTableContext.Provider>
)
}
Expand Down
145 changes: 145 additions & 0 deletions src/apps/explorer/components/SummaryCardsWidget/SummaryCards.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import React from 'react'
import styled, { css } from 'styled-components'
import { media } from 'theme/styles/media'
import { formatDistanceToNowStrict } from 'date-fns'

import { Card, CardContent } from 'components/common/Card'
import { CardRow } from 'components/common/CardRow'
import { TotalSummaryResponse } from './useGetSummaryData'
import { abbreviateString } from 'utils'
import { useMediaBreakpoint } from 'hooks/useMediaBreakPoint'
import { calcDiff, getColorBySign } from 'components/common/Card/card.utils'
import { CopyButton } from 'components/common/CopyButton'
import { LinkWithPrefixNetwork } from 'components/common/LinkWithPrefixNetwork'
import { numberFormatter } from './utils'

const BatchInfoHeight = '21.6rem'
const DESKTOP_TEXT_SIZE = 1.8 // rem
const MOBILE_TEXT_SIZE = 1.65 // rem

const DoubleContentSize = css`
min-height: ${BatchInfoHeight};
`
const WrapperColumnChart = styled(Card)`
background: transparent;
& > div:first-child {
all: unset;
border: 1px solid ${({ theme }): string => theme.borderPrimary};
border-radius: 0.4rem;
overflow: hidden;
}
`

const DoubleCardStyle = css`
${DoubleContentSize}

${media.xSmallDown}, ${media.tinyDown} {
min-height: 15rem;
}
`
const WrappedDoubleCard = styled(Card)`
${DoubleCardStyle}
`

const WrapperDoubleContent = styled.div`
display: flex;
flex-direction: column;
gap: 3rem;

${media.mediumDownMd} {
gap: 2rem;
}
`

interface SummaryCardsProps {
summaryData: TotalSummaryResponse | undefined
children: React.ReactNode
}

export function SummaryCards({ summaryData, children }: SummaryCardsProps): JSX.Element {
const { batchInfo, dailyTransactions, totalTokens, volumeUsd, dailyFees, isLoading } = summaryData || {}
const isDesktop = useMediaBreakpoint(['xl', 'lg'])
const valueTextSize = isDesktop ? DESKTOP_TEXT_SIZE : MOBILE_TEXT_SIZE
const rowsByCard = isDesktop ? '2row' : '3row'
const diffTransactions = (dailyTransactions && calcDiff(dailyTransactions.now, dailyTransactions.before)) || 0
const diffFees = (dailyFees && calcDiff(dailyFees.now, dailyFees.before)) || 0

return (
<CardRow>
<WrapperColumnChart xs={12} sm={8} md={8} lg={5}>
{children}
</WrapperColumnChart>
<WrappedDoubleCard xs={12} sm={4} md={4} lg={3}>
<WrapperDoubleContent>
<CardContent
variant="3row"
label1="Last Batch"
value1={batchInfo && formatDistanceToNowStrict(batchInfo.lastBatchDate, { addSuffix: true })}
loading={isLoading}
valueSize={valueTextSize}
/>
<CardContent
variant={rowsByCard}
label1="Batch ID"
value1={
batchInfo && (
<>
<LinkWithPrefixNetwork to={`/tx/${batchInfo.batchId}`}>
{abbreviateString(batchInfo?.batchId, 6, 4)}
</LinkWithPrefixNetwork>
<CopyButton heightIcon={1.35} text={batchInfo?.batchId || ''} />
</>
)
}
loading={isLoading}
valueSize={valueTextSize}
/>
</WrapperDoubleContent>
</WrappedDoubleCard>
<Card emptyContent xs={12} sm={12} md={12} lg={4}>
<CardRow>
<Card xs={6} sm={3} md={3} lg={6}>
<CardContent
variant={rowsByCard}
label1="24h Transactions"
value1={dailyTransactions?.now.toLocaleString()}
caption1={`${diffTransactions.toFixed(2)}%`}
captionColor={getColorBySign(diffTransactions)}
loading={isLoading}
valueSize={valueTextSize}
/>
</Card>
<Card xs={6} sm={3} md={3} lg={6}>
<CardContent
variant="2row"
label1="Total Tokens"
value1={totalTokens?.toLocaleString()}
loading={isLoading}
valueSize={valueTextSize}
/>
</Card>
<Card xs={6} sm={3} md={3} lg={6}>
<CardContent
variant={rowsByCard}
label1="24h Fees"
value1={`$${numberFormatter(dailyFees?.now || 0)}`}
caption1={`${diffFees.toFixed(2)}%`}
captionColor={getColorBySign(diffFees)}
loading={isLoading}
valueSize={valueTextSize}
/>
</Card>
<Card xs={6} sm={3} md={3} lg={6}>
<CardContent
variant={rowsByCard}
label1="Total Volume"
value1={`$${numberFormatter(volumeUsd || 0)}`}
loading={isLoading}
valueSize={valueTextSize}
/>
</Card>
</CardRow>
</Card>
</CardRow>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react'
import { Story, Meta } from '@storybook/react'
import styled from 'styled-components'

import { GlobalStyles, ThemeToggler } from 'storybook/decorators'
import { VolumeChart, VolumeChartProps } from './VolumeChart'
import { VolumePeriod } from './VolumeChartWidget'
import volumeDataJson from './volumeData.json'
import { buildVolumeData } from './useGetVolumeData'

export default {
title: 'ExplorerApp/Chart',
component: VolumeChart,
decorators: [GlobalStyles, ThemeToggler],
argTypes: {
label: { control: 'text' },
variant: { control: 'default' },
size: { control: 'default' },
as: { control: null },
theme: { control: null },
forwardedAs: { control: null },
},
} as Meta

const WrapperVolumeChart = styled.div`
height: 19.6rem;
`

const Template: Story<VolumeChartProps> = (args) => (
<WrapperVolumeChart>
<VolumeChart {...args} />
</WrapperVolumeChart>
)

export const Default = Template.bind({})
Default.args = {
volumeData: {
...buildVolumeData(volumeDataJson, VolumePeriod.YEARLY),
isLoading: false,
},
}
Loading