Skip to content

Commit 655ee66

Browse files
authored
feat(SearchInput): make whole input interactive (#4868)
* feat(SearchInput): make whole input interactive * fix: add changeset and add more unit tests
1 parent 52d584a commit 655ee66

File tree

6 files changed

+433
-160
lines changed

6 files changed

+433
-160
lines changed

.changeset/plain-suits-wait.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ultraviolet/ui": patch
3+
---
4+
5+
`<SearchInput />` is now fully interactive

packages/ui/src/components/SearchInput/Key.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useMemo } from 'react'
33
import { Text } from '../Text'
44

55
const Container = styled.div`
6+
cursor: text;
67
background: ${({ theme }) => theme.colors.neutral.backgroundWeak};
78
border-radius: ${({ theme }) => theme.radii.default};
89
border: 0.5px solid ${({ theme }) => theme.colors.neutral.border};
@@ -54,6 +55,7 @@ export const Key = ({ children, disabled }: KeyProps) => {
5455
<Container
5556
data-disabled={disabled}
5657
data-children-length={children.length > 1}
58+
data-testid={`key-${children}`}
5759
>
5860
<Text as="span" variant="caption" sentiment="neutral" disabled={disabled}>
5961
{isSpecialKey
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1+
import styled from '@emotion/styled'
12
import type { ComponentProps } from 'react'
23
import { Stack } from '../Stack'
34
import { Key } from './Key'
45

6+
const ClickableStack = styled(Stack)`
7+
cursor: text;
8+
`
9+
510
type KeyGroupProps = {
611
keys: ComponentProps<typeof Key>['children'][]
712
disabled: ComponentProps<typeof Key>['disabled']
13+
onClick?: () => void
814
}
915

10-
export const KeyGroup = ({ keys, disabled }: KeyGroupProps) => (
11-
<Stack gap={0.5} direction="row">
16+
export const KeyGroup = ({ keys, disabled, onClick }: KeyGroupProps) => (
17+
<ClickableStack gap={0.5} direction="row" onClick={onClick}>
1218
{keys.map(key => (
1319
<Key key={key} disabled={disabled}>
1420
{key}
1521
</Key>
1622
))}
17-
</Stack>
23+
</ClickableStack>
1824
)

0 commit comments

Comments
 (0)