Skip to content

Commit d8ee46b

Browse files
authored
Merge pull request #197 from ynput/search-filter
Component: Search filter
2 parents dd29c6f + a5b9f16 commit d8ee46b

15 files changed

+1497
-0
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,8 @@
125125
},
126126
"resolutions": {
127127
"jackspeak": "2.1.1"
128+
},
129+
"dependencies": {
130+
"short-uuid": "^5.2.0"
128131
}
129132
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Meta, StoryObj } from '@storybook/react'
2+
import { SearchFilter } from './SearchFilter'
3+
import { useState } from 'react'
4+
import { Filter, Option } from './types'
5+
6+
const meta: Meta<typeof SearchFilter> = {
7+
component: SearchFilter,
8+
tags: ['autodocs'],
9+
}
10+
11+
export default meta
12+
type Story = StoryObj<typeof SearchFilter>
13+
14+
const options: Option[] = [
15+
{
16+
id: 'status',
17+
label: 'Status',
18+
operator: 'OR',
19+
allowExcludes: true,
20+
allowHasValue: true,
21+
allowNoValue: true,
22+
allowsCustomValues: true,
23+
operatorChangeable: true,
24+
25+
values: [
26+
{ id: 'waiting', label: 'Waiting', color: '#FFA500', icon: 'hourglass_empty' },
27+
{ id: 'inProgress', label: 'In Progress', color: '#4CAF50', icon: 'play_circle' },
28+
{ id: 'completed', label: 'Completed', color: '#2196F3', icon: 'check_circle' },
29+
{ id: 'error', label: 'Error', color: '#F44336', icon: 'error' },
30+
{ id: 'paused', label: 'Paused', color: '#9C27B0', icon: 'pause_circle' },
31+
{ id: 'cancelled', label: 'Cancelled', color: '#757575', icon: 'cancel' },
32+
],
33+
},
34+
]
35+
36+
const Template = (args: Story['args']) => {
37+
const [filters, setFilters] = useState<Filter[]>([])
38+
39+
return <SearchFilter {...args} options={options} filters={filters} onChange={setFilters} />
40+
}
41+
42+
export const Default: Story = {
43+
args: {},
44+
render: Template,
45+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import styled from 'styled-components'
2+
import { Button } from '../Button'
3+
4+
export const Container = styled.div`
5+
position: relative;
6+
width: 100%;
7+
`
8+
9+
export const SearchBar = styled.div`
10+
display: flex;
11+
12+
padding: 3px 8px;
13+
height: 32px;
14+
align-items: center;
15+
gap: var(--base-gap-small);
16+
17+
border-radius: var(--border-radius-m);
18+
border: 1px solid var(--md-sys-color-outline-variant);
19+
background-color: var(--md-sys-color-surface-container-low);
20+
21+
position: relative;
22+
z-index: 301;
23+
overflow: hidden;
24+
25+
cursor: pointer;
26+
27+
&:hover {
28+
background-color: var(--md-sys-color-surface-container-low-hover);
29+
}
30+
31+
&:has(.search-filter-item:hover) {
32+
background-color: var(--md-sys-color-surface-container-low);
33+
}
34+
`
35+
36+
export const SearchBarFilters = styled.div`
37+
display: flex;
38+
gap: var(--base-gap-small);
39+
white-space: nowrap;
40+
`
41+
42+
export const FilterButton = styled(Button)`
43+
&.hasIcon {
44+
padding: 2px;
45+
}
46+
`
47+
48+
export const Backdrop = styled.div`
49+
position: fixed;
50+
top: 0;
51+
left: 0;
52+
right: 0;
53+
bottom: 0;
54+
55+
z-index: 300;
56+
`

0 commit comments

Comments
 (0)