-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from ZeroGachis/SORD-564-Update-banner
💄 Banner - update and refactoring
- Loading branch information
Showing
4 changed files
with
106 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,61 @@ | ||
import type { Meta, StoryObj } from '@storybook/react-native'; | ||
import type { ComponentMeta, ComponentStory } from '@storybook/react-native'; | ||
import React from 'react'; | ||
import { StyleSheet, View } from 'react-native'; | ||
import { View } from 'react-native'; | ||
import Banner from '../../../src/components/alert/Banner'; | ||
import { action } from '@storybook/addon-actions'; | ||
|
||
type ComponentProps = React.ComponentProps<typeof Banner>; | ||
type BannerType = typeof Banner; | ||
|
||
export default { | ||
title: 'components/Banner', | ||
component: Banner, | ||
argTypes: { | ||
onDismiss: { action: 'onDismiss' }, | ||
args: { | ||
status: 'info', | ||
title: 'This is a title', | ||
description: 'This is a description', | ||
buttonText: 'Click me', | ||
onButtonPress: () => action('onButtonPress')('Button pressed'), | ||
onDismiss: () => action('onDismiss')('Dismissed'), | ||
}, | ||
decorators: [ | ||
(Story) => { | ||
const styles = StyleSheet.create({ | ||
container: { flex: 1 }, | ||
}); | ||
return ( | ||
<View style={styles.container}> | ||
<View style={{ paddingTop: 16 }}> | ||
<Story /> | ||
</View> | ||
); | ||
}, | ||
], | ||
} as Meta<ComponentProps>; | ||
} as ComponentMeta<BannerType>; | ||
|
||
type Story = StoryObj<ComponentProps>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
title: 'This is a title', | ||
description: 'This is a description', | ||
export const Base: ComponentStory<BannerType> = (args) => { | ||
return <Banner {...args} />; | ||
}; | ||
Base.argTypes = { | ||
status: { | ||
control: { type: 'radio' }, | ||
options: ['info', 'success', 'warning', 'error'], | ||
}, | ||
title: { control: { type: 'text' } }, | ||
description: { control: { type: 'text' } }, | ||
buttonText: { control: { type: 'text' } }, | ||
onButtonPress: { | ||
control: { type: 'boolean' }, | ||
mapping: { true: action('Button pressed'), false: undefined }, | ||
}, | ||
render(args) { | ||
return ( | ||
<View style={{ gap: 8 }}> | ||
<Banner {...args} status='info' /> | ||
<Banner {...args} status='success' /> | ||
<Banner {...args} status='warning' /> | ||
<Banner {...args} status='error' /> | ||
</View> | ||
); | ||
onDismiss: { | ||
control: { type: 'boolean' }, | ||
mapping: { true: action('Dismissed'), false: undefined }, | ||
}, | ||
}; | ||
|
||
export const Catalog: ComponentStory<BannerType> = (args) => { | ||
return ( | ||
<View style={{ gap: 8 }}> | ||
<Banner {...args} status="info" /> | ||
<Banner {...args} status="success" /> | ||
<Banner {...args} status="warning" /> | ||
<Banner {...args} status="error" /> | ||
</View> | ||
); | ||
}; |
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