Skip to content

Commit ec1eaf7

Browse files
committed
hide phrase dialog action buttons via props
1 parent ff20dcb commit ec1eaf7

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import type { Meta, StoryFn } from '@storybook/react-vite'
2+
import React from 'react'
3+
4+
import { SeedPhraseProvider } from '../../../../../contexts/index.ts'
5+
import { PhraseDialogActions } from './PhraseDialogActions.tsx'
6+
7+
export default {
8+
title: 'Wallet/PhraseDialogActions',
9+
component: PhraseDialogActions,
10+
} as Meta
11+
12+
const Template: StoryFn<typeof PhraseDialogActions> = args => (
13+
<SeedPhraseProvider>
14+
<PhraseDialogActions {...args} />
15+
</SeedPhraseProvider>
16+
)
17+
18+
const Default = Template.bind({})
19+
Default.args = {}
20+
21+
const WithHideGenerate = Template.bind({})
22+
WithHideGenerate.args = { hideGenerate: true }
23+
24+
const WithHideClear = Template.bind({})
25+
WithHideClear.args = { hideClear: true }
26+
27+
export {
28+
Default, WithHideClear, WithHideGenerate,
29+
}
Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
1+
import type { DialogActionsProps } from '@mui/material'
12
import { Button, DialogActions } from '@mui/material'
23
import React from 'react'
34

45
import { useSeedPhrase } from '../../../../../contexts/index.ts'
56

7+
export interface PhraseDialogActionsProps extends DialogActionsProps {
8+
hideClear?: boolean
9+
hideGenerate?: boolean
10+
}
11+
612
/** @public */
7-
export const PhraseDialogActions = () => {
13+
export const PhraseDialogActions: React.FC<PhraseDialogActionsProps> = ({
14+
hideClear, hideGenerate, ...props
15+
}) => {
816
const {
917
handleClear, handleGenerate, overwriteWarning,
1018
} = useSeedPhrase()
1119
return (
12-
<DialogActions sx={{ justifyContent: 'center' }}>
13-
<Button disabled={overwriteWarning} variant="contained" onClick={handleGenerate}>
14-
Generate
15-
</Button>
16-
<Button variant="outlined" onClick={handleClear}>
17-
Clear
18-
</Button>
20+
<DialogActions sx={{ justifyContent: 'center' }} {...props}>
21+
{hideGenerate
22+
? null
23+
: (
24+
<Button disabled={overwriteWarning} variant="contained" onClick={handleGenerate}>
25+
Generate
26+
</Button>
27+
)}
28+
{hideClear
29+
? null
30+
: (
31+
<Button variant="outlined" onClick={handleClear}>
32+
Clear
33+
</Button>
34+
35+
)}
1936
</DialogActions>
2037
)
2138
}

0 commit comments

Comments
 (0)