-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: oeth app uses shared components library, APY components, Histor…
…y tab
- Loading branch information
Showing
25 changed files
with
860 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { HistoryView, SwapView, WrapView } from '@origin/defi/oeth'; | ||
import { Route, Routes } from 'react-router-dom'; | ||
|
||
import { Layout } from './Layout'; | ||
|
||
export function App() { | ||
return ( | ||
<Routes> | ||
<Route path="/" element={<Layout />}> | ||
<Route index element={<SwapView />} /> | ||
<Route path="wrap" element={<WrapView />} /> | ||
<Route path="history" element={<HistoryView />} /> | ||
<Route path="swap" element={<SwapView />} /> | ||
</Route> | ||
</Routes> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Container } from '@mui/material'; | ||
import { TopNav } from '@origin/shared/components'; | ||
import { useIntl } from 'react-intl'; | ||
import { Outlet } from 'react-router-dom'; | ||
|
||
export function Layout() { | ||
const intl = useIntl(); | ||
|
||
return ( | ||
<> | ||
<TopNav | ||
logo="https://app.oeth.com/images/origin-ether-logo.svg" | ||
tabs={[ | ||
intl.formatMessage({ defaultMessage: 'Swap' }), | ||
intl.formatMessage({ defaultMessage: 'Wrap' }), | ||
intl.formatMessage({ defaultMessage: 'History' }), | ||
]} | ||
selected={0} | ||
connected={false} | ||
ipfsLink={'https://oeth.on.fleek.co/'} | ||
/> | ||
<Container | ||
sx={{ | ||
mt: { | ||
xs: 3, | ||
md: 5, | ||
paddingInline: { | ||
xs: 2, | ||
md: 0, | ||
}, | ||
}, | ||
}} | ||
maxWidth="sm" | ||
> | ||
<Outlet /> | ||
</Container> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './App'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
libs/defi/oeth/src/components/History/HistoryButton.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { HistoryFilterButton } from './HistoryButton'; | ||
|
||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
const meta: Meta<typeof HistoryFilterButton> = { | ||
component: HistoryFilterButton, | ||
title: 'History/History filter button', | ||
args: { | ||
circle: false, | ||
children: 'Test', | ||
}, | ||
render: (args) => <HistoryFilterButton {...args} />, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Primary: StoryObj<typeof HistoryFilterButton> = {}; | ||
|
||
export const WithCircle: StoryObj<typeof HistoryFilterButton> = { | ||
args: { | ||
circle: true, | ||
}, | ||
}; | ||
|
||
export const Selected: StoryObj<typeof HistoryFilterButton> = { | ||
args: { | ||
circle: true, | ||
selected: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { alpha, Box, Button } from '@mui/material'; | ||
|
||
import type { ButtonProps, SxProps } from '@mui/material'; | ||
import type { Theme } from '@origin/shared/theme'; | ||
|
||
interface Props extends ButtonProps { | ||
circle?: boolean; | ||
selected?: boolean; | ||
} | ||
|
||
export function HistoryFilterButton({ | ||
children, | ||
circle = false, | ||
onClick, | ||
selected = false, | ||
sx, | ||
...rest | ||
}: Props) { | ||
return ( | ||
<Button | ||
variant="contained" | ||
onClick={onClick} | ||
sx={{ | ||
background: (theme) => alpha(theme.palette.common.white, 0.1), | ||
color: selected ? 'primary.contrastText' : 'text.primary', | ||
display: 'flex', | ||
alignItems: 'center', | ||
backgroundImage: 'none', | ||
gap: 1.5, | ||
borderRadius: 14, | ||
paddingInline: 2, | ||
paddingBlock: 0.5, | ||
fontSize: (theme) => theme.typography.pxToRem(12), | ||
'&:hover': { | ||
background: (theme) => alpha(theme.palette.common.white, 0.1), | ||
}, | ||
...sx, | ||
}} | ||
{...rest} | ||
> | ||
{children} | ||
{circle ? ( | ||
<Circle | ||
// @ts-expect-error theme types | ||
sx={{ | ||
background: (theme: Theme) => | ||
selected | ||
? theme.palette.background.gradient3 | ||
: theme.palette.background.paper, | ||
}} | ||
/> | ||
) : undefined} | ||
</Button> | ||
); | ||
} | ||
|
||
function Circle({ sx }: { sx: SxProps }) { | ||
return ( | ||
<Box | ||
sx={{ | ||
backgroundColor: (theme) => theme.palette.background.default, | ||
height: '0.5rem', | ||
width: '0.5rem', | ||
borderRadius: '100%', | ||
...sx, | ||
}} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { useState } from 'react'; | ||
|
||
import { Box, Button, Stack, Typography } from '@mui/material'; | ||
import { Card } from '@origin/shared/components'; | ||
import { useIntl } from 'react-intl'; | ||
|
||
import { HistoryFilterButton } from './HistoryButton'; | ||
import { HistoryTable } from './HistoryTable'; | ||
|
||
import type { ColumnFilter } from '@tanstack/react-table'; | ||
|
||
export function HistoryCard() { | ||
const [isConnected, setConnectionState] = useState(false); | ||
const intl = useIntl(); | ||
const [filter, setFilter] = useState<ColumnFilter>({ | ||
id: 'type', | ||
value: [], | ||
}); | ||
|
||
function filterRows(value: string) { | ||
setFilter((prev) => { | ||
if ((prev.value as string[]).includes(value)) { | ||
return { | ||
...prev, | ||
value: [...(prev.value as string[]).filter((val) => val !== value)], | ||
}; | ||
} else { | ||
return { | ||
...prev, | ||
value: [...(prev.value as string[]), value], | ||
}; | ||
} | ||
}); | ||
} | ||
return ( | ||
<Card | ||
sx={{ mt: 3 }} | ||
title={ | ||
<Stack | ||
direction="row" | ||
sx={{ alignItems: 'center', justifyContent: 'space-between' }} | ||
> | ||
<Typography color="primary.contrastText">History</Typography> | ||
<Stack direction="row" gap={2} sx={{ marginInline: 'auto' }}> | ||
{[ | ||
intl.formatMessage({ defaultMessage: 'Received' }), | ||
intl.formatMessage({ defaultMessage: 'Sent' }), | ||
intl.formatMessage({ defaultMessage: 'Swap' }), | ||
intl.formatMessage({ defaultMessage: 'Yield' }), | ||
].map((label) => ( | ||
<HistoryFilterButton | ||
key={label} | ||
circle | ||
selected={(filter.value as string[]).includes( | ||
label.toLowerCase(), | ||
)} | ||
onClick={() => filterRows(label.toLowerCase())} | ||
> | ||
{label} | ||
</HistoryFilterButton> | ||
))} | ||
</Stack> | ||
<HistoryFilterButton> | ||
{intl.formatMessage({ defaultMessage: 'Export CSV' })} | ||
</HistoryFilterButton> | ||
</Stack> | ||
} | ||
> | ||
{isConnected ? ( | ||
<HistoryTable rows={[]} isLoading={false} filter={filter} /> | ||
) : ( | ||
<Box sx={{ height: '15rem', display: 'grid', placeContent: 'center' }}> | ||
<Typography> | ||
{intl.formatMessage({ | ||
defaultMessage: 'Connect your wallet to see your history', | ||
})} | ||
</Typography> | ||
<Button onClick={() => setConnectionState(true)}>Connect</Button> | ||
</Box> | ||
)} | ||
</Card> | ||
); | ||
} |
Oops, something went wrong.