Skip to content

Commit 9c4f956

Browse files
committed
Auto merge of #4359 - Turbo87:search-input, r=locks
Improve search bar styling This moves the search icon to the submit button, and makes that submit button visible and clickable to the user. It also replaces the search icon PNG with an SVG. ## Before <img width="993" alt="Bildschirmfoto 2021-12-24 um 11 34 12" src="https://user-images.githubusercontent.com/141300/147345385-ad511911-ab44-4758-a0db-ee9b91818ed9.png"> ## After <img width="994" alt="Bildschirmfoto 2021-12-24 um 11 33 55" src="https://user-images.githubusercontent.com/141300/147345391-908c9eb4-f81f-421b-951a-5d76701ce1b7.png">
2 parents 910ac64 + ed19976 commit 9c4f956

File tree

5 files changed

+56
-16
lines changed

5 files changed

+56
-16
lines changed

app/components/search-form.hbs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@
4343
aria-label="Search"
4444
>
4545

46-
{{! Hidden submit button to enable enter-to-submit behavior for form with multiple inputs }}
47-
<button type="submit" local-class="submit-button">Submit</button>
46+
<button type="submit" local-class="submit-button">
47+
<span local-class="submit-label">Submit</span>
48+
{{svg-jar "search" local-class="submit-icon"}}
49+
</button>
4850

4951
{{on-key 's' (focus '#cargo-desktop-search')}}
5052
{{on-key 'S' (focus '#cargo-desktop-search')}}

app/components/search-form.module.css

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
.form {
2-
display: flex;
2+
--border-radius: 15px;
3+
--submit-icon-size: 16px;
4+
--submit-button-padding-left: 8px;
5+
--submit-button-padding-right: 10px;
6+
--submit-button-width: calc(var(--submit-button-padding-left) + var(--submit-icon-size) + var(--submit-button-padding-right));
7+
--input-padding: 5px;
8+
--input-padding-left: 10px;
9+
--input-padding-right: calc(var(--submit-button-width) + var(--input-padding));
10+
11+
position: relative;
12+
13+
&.size-big {
14+
--border-radius: 30px;
15+
--input-padding: 8px;
16+
--input-padding-left: 16px;
17+
--submit-icon-size: 20px;
18+
--submit-button-padding-left: 12px;
19+
--submit-button-padding-right: 16px;
20+
}
321
}
422

523
.input {
@@ -9,21 +27,13 @@
927
border: none;
1028
color: black;
1129
width: 100%;
12-
padding: 5px 5px 5px 25px;
13-
background-color: white;
14-
background-image: url('/assets/search.png');
15-
background-repeat: no-repeat;
16-
background-position: 6px 6px;
17-
background-size: 14px 15px;
18-
border-radius: 15px;
30+
padding: var(--input-padding) var(--input-padding-right) var(--input-padding) var(--input-padding-left);
31+
border-radius: var(--border-radius);
1932
box-shadow: 1px 2px 4px 0 var(--green900);
2033
transition: box-shadow 150ms;
2134

2235
.size-big & {
2336
font-size: 125%;
24-
padding: 5px 5px 5px 35px;
25-
background-position: 10px 7px;
26-
background-size: 20px 21px;
2737
}
2838

2939
&:focus {
@@ -51,8 +61,32 @@
5161
}
5262

5363
.submit-button {
64+
composes: button-reset from '../styles/shared/buttons.module.css';
65+
5466
position: absolute;
55-
visibility: hidden;
56-
width: 0;
57-
height: 0;
67+
right: 0;
68+
top: 0;
69+
bottom: 0;
70+
display: inline-grid;
71+
place-items: center;
72+
padding-left: var(--submit-button-padding-left);
73+
padding-right: var(--submit-button-padding-right);
74+
color: white;
75+
background-color: var(--yellow500);
76+
border-top-right-radius: var(--border-radius);
77+
border-bottom-right-radius: var(--border-radius);
78+
cursor: pointer;
79+
80+
&:hover {
81+
background-color: var(--yellow700);
82+
}
83+
}
84+
85+
.submit-label {
86+
composes: sr-only from '../styles/shared/a11y.module.css';
87+
}
88+
89+
.submit-icon {
90+
width: var(--submit-icon-size);
91+
height: var(--submit-icon-size);
5892
}

app/styles/application.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
--green800: hsl(115, 31%, 31%);
88
--green900: hsl(115, 31%, 21%);
99
--yellow500: hsl(44, 100%, 60%);
10+
--yellow700: hsl(44, 67%, 50%);
1011

1112
--header-bg-color: var(--green800);
1213

public/assets/search.png

-803 Bytes
Binary file not shown.

public/assets/search.svg

Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)