Skip to content

Commit

Permalink
fix(frontend): focus search input on initial load (#472)
Browse files Browse the repository at this point in the history
* fix(frontend): update search input

* fix(frontend): remove placeholder

fix #462

* fix: tests
  • Loading branch information
lionelB authored Jan 29, 2019
1 parent 2cc50b9 commit d001b4e
Show file tree
Hide file tree
Showing 11 changed files with 369 additions and 306 deletions.
9 changes: 7 additions & 2 deletions packages/code-du-travail-css/docs/css/components/_buttons.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

/* Specific to <a> elements. */
text-decoration: none;

transition: background 250ms ease;
&:active {
position: relative;
top: 1px;
Expand All @@ -46,8 +46,13 @@
}

&:focus {
outline: none;
}
&:focus:not(:focus-visible) {
border: 1px solid var(--color-focus);
}
&:focus:not(:-moz-focusring) {
border: 1px solid var(--color-focus);
box-shadow: 0 0 2px 2px var(--color-focus-shadow);
}

&.btn__primary {
Expand Down
56 changes: 18 additions & 38 deletions packages/code-du-travail-css/docs/css/components/_search.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,26 @@
height: 5rem;
& button {
margin-left: 5px;
width: 4rem;
}
}

.search__fields {
flex: 1 1 auto;
display: flex;
border: 1px solid var(--color-element-border);
border-radius: var(--border-radius-base);
&:focus {
border: 1px solid var(--color-focus);
box-shadow: 0 0 2px 2px var(--color-focus-shadow);
}
}
.search__facets {
flex: 1 1 10%;
position: absolute;
display: flex;
align-items: center;
margin: 0.8rem;
margin: 0.575rem;
border: none;
max-width: 200px;
max-width: 10rem;
border-radius: var(--border-radius-base);
background-color: var(--color-lighter-grey);
}
.facet-icon {
position: absolute;
width: 1.25rem;
height: 1.25rem;
margin: 0 calc(var(--spacing-small) / 2);
Expand All @@ -43,51 +39,35 @@
font-size: var(--font-size-small);
border: 1px solid transparent;
background-color: transparent;
background-position: top 0.75rem right 0.75em;
background-position: top 1rem right 0.75em;
width: auto;
padding: 0.2em 2em 0.2em 0.2em;
flex: 1 1 auto;
padding: 0.6em 2.1em 0.6em 2em;
font-style: italic;
&:focus {
border: none;
box-shadow: none;
}
&:-moz-focusring {
border: 1px solid var(--color-focus);
box-shadow: 0 0 2px 2px var(--color-focus-shadow);
}
&:focus-visible {
border: 1px solid var(--color-focus);
box-shadow: 0 0 2px 2px var(--color-focus-shadow);
}
&:focus:not(:focus-visible) {
outline: none;
box-shadow: 0 0 2px 2px var(--color-focus-shadow);
}
}

input[type="search"].search__input {
flex: 1 0 90%;
.search__input[type="search"] {
appearance: none;
border: none;
border: 1px solid var(--color-element-border);
border-radius: var(--border-radius-base);
font-size: inherit;
font-family: inherit;
line-height: inherit;
color: inherit;

background: var(--color-white);

height: 100%;
margin: 0;
max-width: 100%;
width: 100%;
padding: 0;
padding-left: var(--spacing-small);
line-height: 3.625rem;
&:focus {
border: none;
box-shadow: 0 0 2px 2px var(--color-focus-shadow);
}
padding-right: 0.5rem;
padding-left: 11.5rem;
line-height: calc(3.625rem - 1px);
transition: border 250ms ease;
}
.search__input[type="search"]:focus {
outline: none;
border-color: var(--color-blue-light);
}

.search__loading {
Expand Down
14 changes: 4 additions & 10 deletions packages/code-du-travail-css/docs/css/elements/_forms.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,15 @@ select {
padding-right: 45px;
border-radius: 3px;
width: auto;
}

select:focus {
border-color: var(--color-blue);
transition: border-color 0.2s ease-out;
box-shadow: 0 0 0.15em 0.15em var(--color-focus-shadow);
transition: border-color 250ms ease;
}

select:disabled {
background-color: var(--color-dark-background);
}

select:focus:not(:focus-visible) {
outline: none;
}
select:focus:not(:-moz-focusring) {
select:focus {
outline: none;
border-color: var(--color-blue-light);
box-shadow: 0 0 0.15rem 0.15rem var(--color-focus-shadow);
}
4 changes: 2 additions & 2 deletions packages/code-du-travail-css/docs/css/global/_conf.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ https://fontlibrary.org/fr/font/source-sans-pro
--------------------------------------------------------------------------- */

:focus {
border: 1px solid var(--color-focus);
box-shadow: 0 0 2px 2px var(--color-focus-shadow);
outline: 1px solid var(--color-outline);
box-shadow: 0 0 0.15rem 0.15rem var(--color-focus-shadow);
}

/* WebKit gets its native focus styles. */
Expand Down
1 change: 0 additions & 1 deletion packages/code-du-travail-frontend/pages/_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default class MyDocument extends Document {
/>
<link rel="shortcut icon" href="/static/favicon.ico" />
{this.props.styleTags}
<link rel="shortcut icon" href="/static/favicon.ico" />
<link
rel="stylesheet"
type="text/css"
Expand Down
Loading

0 comments on commit d001b4e

Please sign in to comment.