Skip to content

Commit 0e04bd2

Browse files
authored
Merge pull request #286 from invariant-labs/staging
Update Prod
2 parents 3b1cb5d + 7506bed commit 0e04bd2

28 files changed

+458
-341
lines changed

src/components/Header/Header.stories.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@ import Header from './Header'
44
import { MemoryRouter } from 'react-router-dom'
55
import { Network } from '@invariant-labs/a0-sdk'
66
import { Chain } from '@store/consts/types'
7+
import { Provider } from 'react-redux'
8+
import { store } from '@store/index'
79

810
const meta = {
911
title: 'Layout/Header',
1012
component: Header,
1113
args: {},
1214
decorators: [
1315
Story => (
14-
<MemoryRouter>
15-
<Story />
16-
</MemoryRouter>
16+
<Provider store={store}>
17+
<MemoryRouter>
18+
<Story />
19+
</MemoryRouter>
20+
</Provider>
1721
)
1822
]
1923
} satisfies Meta<typeof Header>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { Meta, StoryObj } from '@storybook/react'
2+
import ChangeWalletButton from './ChangeWalletButton'
3+
import { fn } from '@storybook/test'
4+
5+
const meta = {
6+
title: 'Buttons/ChangeWalletButton',
7+
component: ChangeWalletButton
8+
} satisfies Meta<typeof ChangeWalletButton>
9+
10+
export default meta
11+
type Story = StoryObj<typeof meta>
12+
13+
export const Primary: Story = {
14+
args: {
15+
name: 'Change Wallet',
16+
onConnect: fn(),
17+
connected: false,
18+
onDisconnect: fn()
19+
}
20+
}

src/components/Header/HeaderButton/HeaderButton.stories.tsx

Lines changed: 0 additions & 85 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { Meta, StoryObj } from '@storybook/react'
2+
import SelectChainButton from './SelectChainButton'
3+
import { fn } from '@storybook/test'
4+
import { Chain } from '@store/consts/types'
5+
6+
const meta = {
7+
title: 'Buttons/SelectChainButton',
8+
component: SelectChainButton
9+
} satisfies Meta<typeof SelectChainButton>
10+
11+
export default meta
12+
type Story = StoryObj<typeof meta>
13+
14+
export const Primary: Story = {
15+
args: {
16+
activeChain: {
17+
name: Chain.AlephZero,
18+
address: 'https://azero.invariant.app/swap'
19+
},
20+
chains: [
21+
{ name: Chain.AlephZero, address: 'https://azero.invariant.app/swap' },
22+
{ name: Chain.Eclipse, address: 'https://eclipse.invariant.app/swap' }
23+
],
24+
onSelect: fn(),
25+
disabled: false
26+
}
27+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { Meta, StoryObj } from '@storybook/react'
2+
import SelectNetworkButton from './SelectNetworkButton'
3+
import { Network } from '@invariant-labs/a0-sdk'
4+
import { RPC } from '@store/consts/static'
5+
import { action } from '@storybook/addon-actions'
6+
7+
const meta = {
8+
title: 'Buttons/SelectNetworkButton',
9+
component: SelectNetworkButton
10+
} satisfies Meta<typeof SelectNetworkButton>
11+
12+
export default meta
13+
type Story = StoryObj<typeof meta>
14+
15+
export const Primary: Story = {
16+
args: {
17+
name: Network.Testnet,
18+
networks: [{ networkType: Network.Testnet, rpc: RPC.TEST }],
19+
onSelect: (networkType, rpc) => action('chosen: ' + networkType + ' ' + rpc)()
20+
}
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { Meta, StoryObj } from '@storybook/react'
2+
import SelectRPCButton from './SelectRPCButton'
3+
import { Network } from '@invariant-labs/a0-sdk'
4+
import { RPC } from '@store/consts/static'
5+
import { action } from '@storybook/addon-actions'
6+
7+
const meta = {
8+
title: 'Buttons/SelectRPCButton',
9+
component: SelectRPCButton
10+
} satisfies Meta<typeof SelectRPCButton>
11+
12+
export default meta
13+
type Story = StoryObj<typeof meta>
14+
15+
export const Primary: Story = {
16+
args: {
17+
rpc: RPC.TEST,
18+
networks: [
19+
{
20+
networkType: Network.Testnet,
21+
rpc: RPC.TEST,
22+
rpcName: 'Testnet'
23+
}
24+
],
25+
onSelect: (networkType, rpc) => action('chosen: ' + networkType + ' ' + rpc)()
26+
}
27+
}
Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Meta, StoryObj } from '@storybook/react'
22
import { fn } from '@storybook/test'
3-
import RangeInput from './RangeInput'
3+
import RangeInput, { IRangeInput } from './RangeInput' // Assuming RangeInputProps is exported
44
import { useState } from 'react'
55

66
const meta = {
@@ -12,6 +12,37 @@ const meta = {
1212
export default meta
1313
type Story = StoryObj<typeof meta>
1414

15+
const RangeInputWrapper: React.FC<IRangeInput> = args => {
16+
const [val, setVal] = useState('100')
17+
18+
return (
19+
<div
20+
style={{
21+
backgroundColor: '#202946',
22+
width: 400,
23+
paddingBlock: 20
24+
}}>
25+
<RangeInput
26+
{...args}
27+
currentValue={val}
28+
decreaseValue={() => {
29+
setVal((+val - 0.01).toFixed(2).toString())
30+
}}
31+
increaseValue={() => {
32+
setVal((+val + 0.01).toFixed(2).toString())
33+
}}
34+
setValue={value => {
35+
setVal(value)
36+
}}
37+
onBlur={() => {
38+
setVal((+val).toFixed(2).toString())
39+
}}
40+
style={{ width: 200, maxHeight: 300, margin: 'auto' }}
41+
/>
42+
</div>
43+
)
44+
}
45+
1546
export const Primary: Story = {
1647
args: {
1748
currentValue: '10',
@@ -25,33 +56,5 @@ export const Primary: Story = {
2556
tokenFromSymbol: 'USDC',
2657
tokenToSymbol: 'USDT'
2758
},
28-
render: args => {
29-
const [val, setVal] = useState('100')
30-
return (
31-
<div
32-
style={{
33-
backgroundColor: '#202946',
34-
width: 400,
35-
paddingBlock: 20
36-
}}>
37-
<RangeInput
38-
{...args}
39-
currentValue={val}
40-
decreaseValue={() => {
41-
setVal((+val - 0.01).toFixed(2).toString())
42-
}}
43-
increaseValue={() => {
44-
setVal((+val + 0.01).toFixed(2).toString())
45-
}}
46-
setValue={value => {
47-
setVal(value)
48-
}}
49-
onBlur={() => {
50-
setVal((+val).toFixed(2).toString())
51-
}}
52-
style={{ width: 200, maxHeight: 300, margin: 'auto' }}
53-
/>
54-
</div>
55-
)
56-
}
59+
render: args => <RangeInputWrapper {...args} />
5760
}

src/components/Modals/RoutesModal/index.tsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import { Link } from 'react-router-dom'
33
import useStyles from './style'
44
import { Grid, Popover, Typography } from '@mui/material'
5+
import classNames from 'classnames'
56

67
export interface IRoutesModal {
78
routes: string[]
@@ -47,30 +48,34 @@ export const RoutesModal: React.FC<IRoutesModal> = ({
4748
horizontal: 'center'
4849
}}>
4950
<Grid className={classes.root} container alignContent='space-around' direction='column'>
51+
<Typography className={classes.subtitle}>Navigation</Typography>
5052
{routes.map(route => (
5153
<Grid
5254
item
5355
key={`routes-${route}`}
54-
className={classes.listItem}
56+
className={classNames(
57+
classes.listItem,
58+
current === route ||
59+
(typeof current !== 'undefined' &&
60+
!!otherRoutesToHighlight[route] &&
61+
otherRoutesToHighlight[route].some(pathRegex => pathRegex.test(current)))
62+
? classes.current
63+
: null
64+
)}
5565
onClick={() => {
5666
onSelect(route)
5767
handleClose()
5868
}}>
5969
<Link to={`/${route}`} className={classes.link}>
60-
<Typography
61-
className={
62-
current === route ||
63-
(typeof current !== 'undefined' &&
64-
!!otherRoutesToHighlight[route] &&
65-
otherRoutesToHighlight[route].some(pathRegex => pathRegex.test(current)))
66-
? classes.current
67-
: classes.name
68-
}>
69-
{route}
70-
</Typography>
70+
<Typography className={classes.name}>{route}</Typography>
7171
</Link>
7272
</Grid>
7373
))}
74+
{(typeof onFaucet !== 'undefined' ||
75+
typeof onRPC !== 'undefined' ||
76+
typeof onChainSelect !== 'undefined') && (
77+
<Typography className={classes.subtitle}>Wallet</Typography>
78+
)}
7479
{typeof onFaucet !== 'undefined' ? (
7580
<Grid
7681
item

0 commit comments

Comments
 (0)