-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
UnstyledWithTailwind.stories.tsx
139 lines (134 loc) · 4.45 KB
/
UnstyledWithTailwind.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import '../styles/tailwind.css';
import { ComponentMeta, ComponentStory } from '@storybook/react';
import classNames from 'classnames';
import * as React from 'react';
import Select from 'react-select';
import { Field } from '../components/field';
import { defaultArgs } from '../data';
export default {
title: 'Select/UnstyledWithTailwind',
component: Select,
argTypes: {},
} as ComponentMeta<typeof Select>;
const Template: ComponentStory<typeof Select> = ({
inputId = 'react-select',
...props
}) => {
return (
<Field htmlFor={inputId} label="Unstyled With Tailwind">
<Select
inputId={inputId}
{...props}
unstyled // Remove all non-essential styles
classNames={{
clearIndicator: ({ isFocused }) =>
classNames(
isFocused ? 'text-neutral-600' : 'text-neutral-200',
'p-2',
isFocused ? 'hover:text-neutral-800' : 'hover:text-neutral-400'
),
// container: () => classNames(),
control: ({ isDisabled, isFocused }) =>
classNames(
isDisabled ? 'bg-neutral-50' : 'bg-white',
isDisabled
? 'border-neutral-100'
: isFocused
? 'border-purple-800'
: 'border-neutral-200',
'rounded',
'border-solid',
'border',
isFocused && 'shadow-[0_0_0_1px] shadow-purple-800',
isFocused ? 'hover:border-purple-800' : 'hover:border-neutral-300'
),
dropdownIndicator: ({ isFocused }) =>
classNames(
isFocused ? 'text-neutral-600' : 'text-neutral-200',
'p-2',
isFocused ? 'hover:text-neutral-800' : 'hover:text-neutral-400'
),
group: () => classNames('py-2'),
groupHeading: () =>
classNames(
'text-neutral-400',
'text-xs',
'font-medium',
'mb-1',
'px-3',
'uppercase'
),
// indicatorsContainer: () => classNames(),
indicatorSeparator: ({ isDisabled }) =>
classNames(
isDisabled ? 'bg-neutral-100' : 'bg-neutral-200',
'my-2'
),
input: () => classNames('m-0.5', 'py-0.5', 'text-neutral-800'),
loadingIndicator: ({ isFocused }) =>
classNames(
isFocused ? 'text-neutral-600' : 'text-neutral-200',
'p-2'
),
loadingMessage: () => classNames('text-neutral-400', 'py-2', 'px-3'),
menu: () =>
classNames(
'bg-white',
'rounded',
'shadow-[0_0_0_1px_rgba(0,0,0,0.1)]',
'my-1'
),
menuList: () => classNames('py-1'),
// menuPortal: () => classNames(),
multiValue: () => classNames('bg-neutral-100', 'rounded-sm', 'm-0.5'),
multiValueLabel: () =>
classNames(
'rounded-sm',
'text-neutral-800',
'text-sm',
'p-[3]',
'pl-[6]'
),
multiValueRemove: ({ isFocused }) =>
classNames(
'rounded-sm',
isFocused && 'bg-red-500',
'px-1',
'hover:bg-red-500',
'hover:text-red-800'
),
noOptionsMessage: () =>
classNames('text-neutral-400', 'py-2', 'px-3'),
option: ({ isDisabled, isFocused, isSelected }) =>
classNames(
isSelected
? 'bg-purple-800'
: isFocused
? 'bg-purple-300'
: 'bg-transparent',
isDisabled
? 'text-neutral-200'
: isSelected
? 'text-white'
: 'text-inherit',
'py-2',
'px-3',
!isDisabled &&
(isSelected ? 'active:bg-purple-800' : 'active:bg-purple-500')
),
placeholder: () => classNames('text-neutral-500', 'mx-0.5'),
singleValue: ({ isDisabled }) =>
classNames(
isDisabled ? 'text-neutral-400' : 'text-neutral-800',
'mx-0.5'
),
valueContainer: () => classNames('py-0.5', 'px-2'),
}}
/>
</Field>
);
};
export const UnstyledWithTailwind = Template.bind({});
UnstyledWithTailwind.args = {
...defaultArgs,
};