Skip to content

Commit 7fcf518

Browse files
committed
styling: update colors, use css vars
this will allow better customization later
1 parent 8e8d457 commit 7fcf518

File tree

1 file changed

+75
-23
lines changed

1 file changed

+75
-23
lines changed

src/autocomplete/autocomplete.css

Lines changed: 75 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,58 @@
1-
.autocomplete {
2-
position: relative;
3-
font-family: sans-serif;
1+
* { box-sizing: border-box }
2+
3+
:host {
4+
--gray-100: #F3F4F6;
5+
--gray-300: #D1D5DB;
6+
--gray-500: #6B7280;
7+
--gray-900: #111827;
8+
--blue-600: #3182CE;
9+
10+
--border-radius: 5px;
11+
12+
--font-family:
13+
ui-sans-serif,
14+
system-ui,
15+
-apple-system,
16+
BlinkMacSystemFont,
17+
"Segoe UI",
18+
Roboto,
19+
"Helvetica Neue",
20+
Arial,
21+
"Noto Sans",
22+
sans-serif;
23+
24+
--input-color: var(--gray-900);
25+
--input-bg: #fff;
26+
--input-border-color: var(--gray-300);
27+
--input-shadow:
28+
rgba(0, 0, 0, 0) 0px 0px 0px 0px,
29+
rgba(0, 0, 0, 0) 0px 0px 0px 0px,
30+
rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
31+
32+
--results-bg: #fff;
33+
--results-z-index: 10;
34+
--results-shadow:
35+
rgb(255, 255, 255) 0px 0px 0px 0px,
36+
rgba(0, 0, 0, 0.05) 0px 0px 0px 1px,
37+
rgba(0, 0, 0, 0.1) 0px 10px 15px -3px,
38+
rgba(0, 0, 0, 0.05) 0px 4px 6px -2px;
39+
40+
--result-item-color: var(--gray-900);
41+
--result-item-border-color: var(--gray-100);
42+
--result-item-active-color: var(--gray-900);
43+
--result-item-active-bg: var(--gray-100);
44+
--result-item-icon-color: var(--gray-500);
45+
46+
--attribution-color: var(--gray-500);
47+
--attribution-color-hover: var(--blue-600);
48+
49+
display: block;
450
}
551

6-
.autocomplete * {
7-
box-sizing: border-box;
52+
.autocomplete {
53+
position: relative;
54+
font-size: 16px;
55+
font-family: var(--font-family);
856
}
957

1058
.label {
@@ -21,34 +69,35 @@
2169

2270
.input {
2371
font-size: 16px;
72+
font-family: var(--font-family);
73+
color: var(--input-color);
74+
background: var(--input-bg);
2475
display: block;
2576
width: 100%;
26-
height: 45px;
27-
border: solid 1px rgba(255,255,255,.5);
28-
padding: 8px 12px;
29-
border-radius: 5px;
77+
border: 1px solid var(--input-border-color);
78+
padding: 13px 12px;
79+
border-radius: var(--border-radius);
3080
appearance: none;
3181
-webkit-appearance: none;
3282
-moz-ppearance: none;
3383
outline: none;
34-
box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 10px 0px, rgba(0, 0, 0, 0.1) 0px 2px 4px 0px;
84+
box-shadow: var(--input-shadow);
3585
}
3686

3787
.results {
3888
font-size: 16px;
3989
position: absolute;
40-
top: calc(45px + 10px); /* height of input plus 10px spacing */
90+
top: calc(46px + 10px); /* height of input plus 10px spacing */
4191
left: 0;
4292
margin: 0;
4393
padding: 0 0 35px 0; /* padding bottom equal to attribution height */
4494
width: 100%;
4595
list-style: none;
46-
border: solid 1px rgba(255,255,255,.5);
47-
border-radius: 5px;
48-
background-color: #fff;
96+
border-radius: var(--border-radius);
97+
background: var(--results-bg);
4998
overflow: hidden;
50-
box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 10px 0px, rgba(0, 0, 0, 0.1) 0px 2px 4px 0px;
51-
z-index: 10;
99+
box-shadow: var(--results-shadow);
100+
z-index: var(--results-z-index);
52101
}
53102

54103
.results-empty {
@@ -58,19 +107,22 @@
58107
.result-item {
59108
display: flex;
60109
align-items: center;
61-
padding: 12px;
62-
cursor: pointer;
110+
padding: 13px 12px;
111+
cursor: default;
112+
color: var(--result-item-color);
113+
border-bottom: 1px solid var(--result-item-border-color);
63114
}
64115

65116
.result-item-icon {
117+
color: var(--result-item-icon-color);
66118
margin-right: 10px;
67-
color: #707f8e;
68119
width: 20px;
69120
height: 20px;
70121
}
71122

72123
.result-item-active {
73-
background-color: #eee;
124+
color: var(--result-item-active-color);
125+
background-color: var(--result-item-active-bg);
74126
}
75127

76128
.attribution {
@@ -79,17 +131,17 @@
79131
width: 100%;
80132
padding: 0 12px;
81133
height: 35px;
82-
color: #707f8e;
134+
color: var(--attribution-color);
83135
line-height: 35px;
84136
font-size: 12px;
85137
text-align: right;
86138
}
87139

88140
.attribution a {
89-
color: #707f8e;
141+
color: var(--attribution-color);
90142
text-decoration: underline;
91143
}
92144

93145
.attribution a:hover {
94-
color: #3273dc;
146+
color: var(--attribution-color-hover);
95147
}

0 commit comments

Comments
 (0)