-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(SearchInput): add new custom shortcut and children now optional (#…
…3968) * fix(SearchInput): add new custom shortcut and children now optional * fix: feedback pantelis * fix: feedback
- Loading branch information
1 parent
e0eced0
commit fe71811
Showing
14 changed files
with
1,084 additions
and
1,185 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@ultraviolet/ui": minor | ||
--- | ||
|
||
Improve `<SearchInput />`: | ||
- prop `shortcut` now takes an array of string in addition to boolean. This way you can define multiple shortcuts for the same input: `shortcut={['/', 's']` for example. | ||
- prop `children` is now optional. If not provided the popup will not be displayed and the input will behave like a regular input. | ||
- new prop `className` |
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
16 changes: 16 additions & 0 deletions
16
packages/ui/src/components/SearchInput/__stories__/CustomShortcut.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,16 @@ | ||
import { Template } from './Template.stories' | ||
|
||
export const CustomShortcut = Template.bind({}) | ||
|
||
CustomShortcut.args = { | ||
shortcut: ['Control', 'Shift', 'A'], | ||
} | ||
|
||
CustomShortcut.parameters = { | ||
docs: { | ||
description: { | ||
story: | ||
'If the default shortcut is not suitable, you can customize it by passing a `shortcut` prop with an array of string representing the keys. For example, `["Ctrl", "Shift", "A"]` will display `Ctrl + Shift + A` as the shortcut.\n\nImportant: You need to set the correct key for it to work. To know the name of a key visit [https://www.toptal.com/developers/keycode](https://www.toptal.com/developers/keycode) type your key and check `event.key`.', | ||
}, | ||
}, | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/ui/src/components/SearchInput/__stories__/Standalone.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,41 @@ | ||
import type { StoryFn } from '@storybook/react' | ||
import { useState } from 'react' | ||
import { SearchInput } from '..' | ||
import { Button } from '../../Button' | ||
import { Stack } from '../../Stack' | ||
|
||
export const Standalone: StoryFn<typeof SearchInput> = ({ ...args }) => { | ||
const [value, setValue] = useState('') | ||
const [submit, setSubmit] = useState<string | undefined>() | ||
|
||
return ( | ||
<div style={{ height: '120px' }}> | ||
<Stack direction="row" gap={1}> | ||
<SearchInput | ||
{...args} | ||
placeholder="Type something" | ||
onSearch={setValue} | ||
onClose={() => {}} | ||
/> | ||
<Button onClick={() => setSubmit(value)}>Search</Button> | ||
</Stack> | ||
<div style={{ marginTop: '20px' }}> | ||
<p>Value: {value}</p> | ||
</div> | ||
{submit ? ( | ||
<div style={{ marginTop: '20px' }}> | ||
<p>Submitted with value: {submit}</p> | ||
</div> | ||
) : null} | ||
</div> | ||
) | ||
} | ||
|
||
Standalone.parameters = { | ||
docs: { | ||
description: { | ||
story: | ||
"The component can take a children or not. If not set the popup won't be displayed and the component will act as a simple input.", | ||
}, | ||
}, | ||
} |
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
Oops, something went wrong.