@import "govuk_publishing_components/individual_component_support"; $input-size: 40px; $large-input-size: 50px; @mixin large-mode { .gem-c-search__label { @include govuk-font($size: 19, $line-height: $large-input-size); } .gem-c-search__input[type="search"] { height: $large-input-size; } .gem-c-search__submit { width: $large-input-size; height: $large-input-size; .gem-c-search__icon { @include icon-positioning($large-input-size); } } } .gem-c-search { position: relative; margin-bottom: 30px; } .gem-c-search__label { @include govuk-font($size: 19, $line-height: $input-size); display: block; color: $govuk-text-colour; h1 { @include govuk-font($size: 19, $line-height: $input-size); margin: 0; } .js-enabled & { position: absolute; left: 2px; top: 2px; bottom: 2px; padding-left: govuk-spacing(3); z-index: 1; color: $govuk-secondary-text-colour; background: govuk-colour("white"); } // match label colour with the label component colour // when javascript is enabled and inline_label option is set to false .js-enabled .gem-c-search--separate-label & { color: $govuk-text-colour; } } %gem-c-search-input-focus { outline: $govuk-focus-width solid $govuk-focus-colour; // Ensure outline appears outside of the element outline-offset: 0; // Double the border by adding its width again. Use `box-shadow` for this // instead of changing `border-width` // Also, `outline` cannot be utilised here as it is already used for the yellow focus state. box-shadow: inset 0 0 0 $govuk-border-width-form-element; @include govuk-if-ie8 { // IE8 doesn't support `box-shadow` so double the border with // `border-width`. border-width: $govuk-border-width-form-element * 2; } } .gem-c-search__input[type="search"] { // overly specific to prevent some overrides from outside @include govuk-font($size: 19, $line-height: (28 / 19)); margin: 0; width: 100%; height: govuk-em(40, 16); padding: govuk-em(6, 16); border: $govuk-border-width-form-element solid $govuk-input-border-colour; background: govuk-colour("white"); border-radius: 0; // otherwise iphones apply an automatic border radius box-sizing: border-box; -webkit-appearance: none; -moz-appearance: none; appearance: none; @include govuk-media-query($from: tablet) { height: govuk-em(40, 19); padding: govuk-em(6, 19); } // the .focus class is added by JS and ensures that the input remains above the label once clicked/filled in &:focus, &.focus { z-index: 2; } &:focus { @extend %gem-c-search-input-focus; } } @mixin icon-positioning($container-size) { $icon-dimension: 20px; $icon-position: ($container-size - $icon-dimension) / 2; display: block; pointer-events: none; position: absolute; height: $icon-dimension; width: $icon-dimension; top: $icon-position; left: $icon-position; } .gem-c-search__submit { border: 0; cursor: pointer; border-radius: 0; position: relative; padding: 0; width: $input-size; height: $input-size; text-indent: -5000px; overflow: hidden; .gem-c-search__icon { @include icon-positioning($input-size); } &:focus { z-index: 2; outline: $govuk-focus-width solid $govuk-focus-colour; // Ensure outline appears outside of the element outline-offset: 0; // Double the border by adding its width again. Use `box-shadow` for this // instead of changing `border-width` - this is for consistency with // Also, `outline` cannot be utilised // here as it is already used for the yellow focus state. box-shadow: inset 0 0 0 $govuk-border-width-form-element * 2 govuk-colour("black"); @include govuk-if-ie8 { // IE8 doesn't support `box-shadow` so double the border with // `border-width`. border-width: $govuk-border-width-form-element * 2; } } &::-moz-focus-inner { border: 0; } } .gem-c-search__item-wrapper { display: table; width: 100%; background: govuk-colour("white"); } // general class applied to search input and button wrapper .gem-c-search__item { position: relative; display: table-cell; vertical-align: top; } .gem-c-search__submit-wrapper { width: 1%; } .gem-c-search--on-govuk-blue { .gem-c-search__label { color: govuk-colour("white"); } .gem-c-search__input { border-width: 0; // no need for black outline as there is enough contrast // with the blue background &:focus { box-shadow: none; } } .gem-c-search__submit { background-color: govuk-colour("black"); color: govuk-colour("white"); &:hover { background-color: lighten(govuk-colour("black"), 5%); } } .js-enabled & { .gem-c-search__label { color: $govuk-secondary-text-colour; } } } .gem-c-search--on-white { .gem-c-search__submit { background-color: govuk-colour("blue"); color: govuk-colour("white"); &:hover { background-color: lighten(govuk-colour("blue"), 5%); } } .gem-c-search__input[type="search"] { border-right-width: 0; // add the border once focused &:focus { border-right-width: 2px; } } } .gem-c-search--no-border { .gem-c-search__label { color: govuk-colour("white"); } .gem-c-search__input[type="search"] { border: 0; } .js-enabled & { .gem-c-search__label { color: $govuk-secondary-text-colour; } } } .gem-c-search--large { @include large-mode; } .gem-c-search--large-on-mobile { @include govuk-media-query($until: "tablet") { @include large-mode; } } .gem-c-search--separate-label { .gem-c-search__label { position: relative; top: auto; left: auto; padding-left: 0; } } .search-toggle { display: none; background-color: govuk-colour("blue"); background-image: image-url("govuk_publishing_components/search-button.png"); background-position: 0 50%; background-repeat: no-repeat; float: right; height: 30px; margin: -46px 0; overflow: hidden; padding: 0; text-indent: -5000px; width: 36px; border: 0; &:focus { border-width: 0; box-shadow: inset 0 0 0 4px $govuk-input-border-colour; outline: $govuk-focus-width solid $govuk-focus-colour; outline-offset: 0; } &:focus, &:hover { background-color: lighten(govuk-colour("blue"), 5%); } &.js-hidden { display: none; } @include govuk-device-pixel-ratio { background-size: 52.5px 35px; background-position: 100% 50%; } @include govuk-media-query($from: tablet) { display: none; } @include govuk-media-query($until: tablet) { .js-enabled & { display: block; } } }