-
-
Notifications
You must be signed in to change notification settings - Fork 8
feat: [DSRN] Added HeaderSearch #1031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
brianacnguyen
wants to merge
16
commits into
main
Choose a base branch
from
dsrn/headersearch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ecc35dd
Added HeaderSearch to DSRN
brianacnguyen f1bd603
Updated HeaderSearch based on feedback
brianacnguyen b46e588
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen cf40a34
Fixed lint errors for headersearch
brianacnguyen 6965b60
Merge branch 'main' into dsrn/headersearch
brianacnguyen 9f98c2e
Aligned HeaderSearch with cursor rules
brianacnguyen 86e3c89
Merge branch 'dsrn/headersearch' of github.com:MetaMask/metamask-desi…
brianacnguyen 3acc755
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen 75d2a80
Fixed lint for stories
brianacnguyen abc4823
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen 98f4db3
Updated based on reviews
brianacnguyen f59de6a
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen 9601f2f
Merge branch 'main' into dsrn/headersearch
brianacnguyen fb8c61f
chore: update HeaderSearch stories to add Variant story and fix argTypes
georgewrmarshall e54a227
Removed unnecessary docs for stories
brianacnguyen 19d089a
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
140 changes: 140 additions & 0 deletions
140
packages/design-system-react-native/src/components/HeaderSearch/HeaderSearch.stories.tsx
This file contains hidden or 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,140 @@ | ||
| import type { Meta, StoryObj } from '@storybook/react-native'; | ||
| import React, { useState } from 'react'; | ||
|
|
||
| import { BoxFlexDirection, TextVariant } from '../../types'; | ||
| import { Box } from '../Box'; | ||
| import { Text } from '../Text'; | ||
|
|
||
| import type { HeaderSearchProps } from './HeaderSearch.types'; | ||
|
|
||
| import { HeaderSearch, HeaderSearchVariant } from '.'; | ||
|
|
||
| const noop = () => undefined; | ||
|
|
||
| const meta: Meta<HeaderSearchProps> = { | ||
| title: 'Components/HeaderSearch', | ||
| component: HeaderSearch, | ||
| argTypes: { | ||
| variant: { | ||
| control: 'select', | ||
| options: Object.values(HeaderSearchVariant), | ||
| description: | ||
| 'Screen shows a back icon; Inline shows a tertiary Cancel button.', | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<HeaderSearchProps>; | ||
|
|
||
| export const Default: Story = { | ||
| args: { | ||
| variant: HeaderSearchVariant.Screen, | ||
| }, | ||
| render: (args) => { | ||
| const [value, setValue] = useState(''); | ||
| const textFieldSearchProps = { | ||
| value, | ||
| onChangeText: setValue, | ||
| onPressClearButton: () => setValue(''), | ||
| placeholder: 'Search...', | ||
| }; | ||
|
|
||
| if (args.variant === HeaderSearchVariant.Screen) { | ||
| return ( | ||
| <HeaderSearch | ||
| variant={HeaderSearchVariant.Screen} | ||
| onPressBackButton={noop} | ||
| textFieldSearchProps={textFieldSearchProps} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <HeaderSearch | ||
| variant={HeaderSearchVariant.Inline} | ||
| onPressCancelButton={noop} | ||
| textFieldSearchProps={textFieldSearchProps} | ||
| /> | ||
| ); | ||
| }, | ||
| }; | ||
|
|
||
| export const Variant: Story = { | ||
| render: () => { | ||
| const [screenValue, setScreenValue] = useState(''); | ||
| const [inlineValue, setInlineValue] = useState(''); | ||
|
|
||
| return ( | ||
| <Box flexDirection={BoxFlexDirection.Column} gap={4}> | ||
| <Text twClassName="px-4" variant={TextVariant.HeadingSm}> | ||
| HeaderSearchVariant.Screen | ||
| </Text> | ||
| <HeaderSearch | ||
| variant={HeaderSearchVariant.Screen} | ||
| onPressBackButton={noop} | ||
| textFieldSearchProps={{ | ||
| value: screenValue, | ||
| onChangeText: setScreenValue, | ||
| onPressClearButton: () => setScreenValue(''), | ||
| placeholder: 'Search tokens, sites, URLs', | ||
| }} | ||
| /> | ||
| <Text twClassName="px-4" variant={TextVariant.HeadingSm}> | ||
| HeaderSearchVariant.Inline | ||
| </Text> | ||
| <HeaderSearch | ||
| variant={HeaderSearchVariant.Inline} | ||
| onPressCancelButton={noop} | ||
| textFieldSearchProps={{ | ||
| value: inlineValue, | ||
| onChangeText: setInlineValue, | ||
| onPressClearButton: () => setInlineValue(''), | ||
| placeholder: 'Search tokens, sites, URLs', | ||
| }} | ||
| /> | ||
| </Box> | ||
| ); | ||
| }, | ||
| }; | ||
|
|
||
| export const BackButtonProps: Story = { | ||
| render: () => { | ||
| const [value, setValue] = useState(''); | ||
|
|
||
| return ( | ||
| <HeaderSearch | ||
| variant={HeaderSearchVariant.Screen} | ||
| onPressBackButton={noop} | ||
| backButtonProps={{ accessibilityLabel: 'Go back' }} | ||
| textFieldSearchProps={{ | ||
| value, | ||
| onChangeText: setValue, | ||
| onPressClearButton: () => setValue(''), | ||
| placeholder: 'Search tokens, sites, URLs', | ||
| }} | ||
| /> | ||
| ); | ||
| }, | ||
| }; | ||
|
|
||
| export const CancelButtonProps: Story = { | ||
| render: () => { | ||
| const [value, setValue] = useState(''); | ||
|
|
||
| return ( | ||
| <HeaderSearch | ||
| variant={HeaderSearchVariant.Inline} | ||
| onPressCancelButton={noop} | ||
| cancelButtonProps={{ testID: 'header-search-cancel' }} | ||
| textFieldSearchProps={{ | ||
| value, | ||
| onChangeText: setValue, | ||
| onPressClearButton: () => setValue(''), | ||
| placeholder: 'Search tokens, sites, URLs', | ||
| }} | ||
| /> | ||
| ); | ||
| }, | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.