|
1 | 1 | import styled, { css } from "styled-components";
|
2 | 2 |
|
3 |
| -export const Container = styled.div<any>` |
| 3 | +export const Container = styled.div` |
4 | 4 | position: relative;
|
5 |
| - display: block; |
6 |
| - width: ${({ width }) => width || `calc(5rem * 4)`}; |
7 |
| - background-color: #fff; |
| 5 | + letter-spacing: 0.04rem; |
8 | 6 | `;
|
9 | 7 |
|
10 |
| -export const SelectedOption = styled.div.attrs(() => ({ |
11 |
| - tabIndex: 0, |
12 |
| - ariaHasPopup: "listbox", |
13 |
| -}))<any>` |
14 |
| - border: 1px solid; |
15 |
| - border-color: ${({ disabled, errorMessage }) => |
16 |
| - !disabled && errorMessage ? "#FDA29B" : "#D0D5DD"}; |
17 |
| - border-radius: 7px; |
18 |
| - width: ${({ width }) => width || `calc(5rem * 4 - 1.5rem)`}; |
19 |
| - padding: 0.5rem 0.75rem; |
20 |
| - color: ${({ selectedOption }) => (selectedOption ? "#101828" : "#667085")}; |
21 |
| - cursor: pointer; |
| 8 | +export const SelectedOption = styled.div<{ |
| 9 | + disabled: boolean; |
| 10 | + hasError: boolean; |
| 11 | + hasValue: boolean; |
| 12 | +}>` |
22 | 13 | display: flex;
|
23 |
| - justify-content: space-between; |
24 |
| - letter-spacing: 0.052rem; |
25 |
| - font-size: 1rem; |
26 |
| - line-height: 1.5rem; |
27 |
| - font-weight: 400; |
| 14 | + align-items: center; |
| 15 | + padding: 0.6875rem 0.875rem; |
| 16 | + border: 1px solid #d0d5dd; |
| 17 | + border-radius: 8px; |
| 18 | + cursor: pointer; |
| 19 | + color: #667085; |
| 20 | + box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05); |
28 | 21 | &:focus {
|
29 |
| - outline: 3px solid; |
30 |
| - outline-color: ${({ disabled, errorMessage }) => |
31 |
| - !disabled && errorMessage ? "#FEE4E2" : "#E9D7FE"}; |
| 22 | + outline: none; |
| 23 | + box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05), 0px 0px 0px 4px #f4ebff; |
32 | 24 | }
|
33 |
| - ${({ disabled }) => |
34 |
| - disabled && |
35 |
| - css` |
36 |
| - color: #667085; |
37 |
| - background-color: #f2f4f7; |
38 |
| - pointer-events: none; |
39 |
| - `} |
| 25 | + ${({ hasValue, hasError, disabled }) => { |
| 26 | + if (disabled) { |
| 27 | + return css` |
| 28 | + color: #667085; |
| 29 | + background-color: #f2f4f7; |
| 30 | + pointer-events: none; |
| 31 | + `; |
| 32 | + } |
| 33 | + if (hasError) { |
| 34 | + return css` |
| 35 | + border-color: #fda29b; |
| 36 | + &:focus { |
| 37 | + box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05), |
| 38 | + 0px 0px 0px 4px #fee4e2; |
| 39 | + } |
| 40 | + `; |
| 41 | + } |
| 42 | + if (hasValue) { |
| 43 | + return css` |
| 44 | + color: #101828; |
| 45 | + `; |
| 46 | + } |
| 47 | + }} |
40 | 48 | `;
|
41 | 49 |
|
42 | 50 | export const SelectArrowIcon = styled.img<{
|
43 | 51 | showDropdown: boolean;
|
44 | 52 | }>`
|
45 | 53 | transform: ${({ showDropdown }) =>
|
46 | 54 | showDropdown ? "rotate(180deg)" : "none"};
|
47 |
| - padding-inline: 0.25rem; |
48 | 55 | `;
|
49 | 56 |
|
50 | 57 | export const OptionalIcon = styled.img`
|
51 | 58 | width: 1.25rem;
|
52 | 59 | height: 1.25rem;
|
53 |
| - padding-inline: 0.25rem 0.5rem; |
54 | 60 | `;
|
55 | 61 |
|
56 |
| -export const LeftContainer = styled.div` |
57 |
| - display: flex; |
58 |
| - align-items: center; |
| 62 | +export const SelectedText = styled.span` |
| 63 | + flex: 1; |
| 64 | + padding: 0 0.5rem; |
59 | 65 | `;
|
60 | 66 |
|
61 |
| -export const Label = styled.p` |
62 |
| - margin: 0; |
| 67 | +export const Label = styled.div` |
63 | 68 | margin-bottom: 0.25rem;
|
64 | 69 | color: #344054;
|
65 |
| - font-size: 1rem; |
66 |
| - line-height: 1.5rem; |
67 |
| - font-weight: 400; |
| 70 | + font-size: 0.875rem; |
| 71 | + line-height: 1.25rem; |
| 72 | + letter-spacing: 0.025rem; |
68 | 73 | `;
|
69 | 74 |
|
70 | 75 | export const List = styled.ul<{ showDropdown: boolean }>`
|
71 |
| - display: block; |
| 76 | + display: none; |
| 77 | + position: absolute; |
72 | 78 | width: 100%;
|
73 | 79 | margin: 0.5rem 0 0;
|
74 | 80 | padding: 0;
|
75 |
| - position: absolute; |
| 81 | + z-index: 1; |
76 | 82 | background: white;
|
77 |
| - box-shadow: 0 7px 12px -6px #d0d5dd; |
78 | 83 | box-shadow: 0px 12px 16px -4px rgba(16, 24, 40, 0.1),
|
79 | 84 | 0px 4px 6px -2px rgba(16, 24, 40, 0.05);
|
80 | 85 | border-radius: 8px;
|
81 | 86 | overflow: hidden;
|
82 |
| -
|
83 | 87 | ${({ showDropdown }) =>
|
84 |
| - showDropdown |
85 |
| - ? css` |
86 |
| - opacity: 1; |
87 |
| - visibility: visible; |
88 |
| - position: absolute; |
89 |
| - height: auto; |
90 |
| - z-index: 200; |
91 |
| - ` |
92 |
| - : css` |
93 |
| - opacity: 0; |
94 |
| - visibility: hidden; |
95 |
| - `}; |
| 88 | + showDropdown && |
| 89 | + css` |
| 90 | + display: block; |
| 91 | + `} |
96 | 92 | `;
|
97 | 93 |
|
98 |
| -export const Hint = styled.p` |
99 |
| - margin: 0; |
| 94 | +export const Hint = styled.div` |
100 | 95 | margin-top: 0.25rem;
|
101 | 96 | color: #667085;
|
102 | 97 | font-size: 0.875rem;
|
103 | 98 | line-height: 1.25rem;
|
104 |
| - font-weight: 400; |
105 |
| - letter-spacing: 0.05rem; |
| 99 | + letter-spacing: 0.025rem; |
106 | 100 | `;
|
107 | 101 |
|
108 |
| -export const ErrorMessage = styled.p` |
109 |
| - margin: 0; |
110 |
| - margin-top: 0.25rem; |
| 102 | +export const ErrorMessage = styled(Hint)` |
111 | 103 | color: #f04438;
|
112 |
| - font-size: 0.875rem; |
113 |
| - line-height: 1.25rem; |
114 |
| - font-weight: 400; |
115 |
| - letter-spacing: 0.05rem; |
116 | 104 | `;
|
0 commit comments