From 0c77e4f2238ca316d2e55a4e6c9228ce35326261 Mon Sep 17 00:00:00 2001 From: Volker E Date: Thu, 18 Apr 2019 12:54:17 -0700 Subject: [PATCH] SimpleSearch: Standardize input appearance Unifying Vector input appearance to follow Design Style Guide and OOUI, additionally: - Simplifying LESS code, reducing specificity to minimum needed - Providing fallbacks where necessary to a wide range of browsers including IE8 - Better positioning and larger click area of search button Bug: T225331 Change-Id: Iafeddf670a9c087e66acf5463c99351fc2d5d78c --- components/search.less | 156 ++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/components/search.less b/components/search.less index d86ef54..2afc974 100644 --- a/components/search.less +++ b/components/search.less @@ -11,101 +11,101 @@ .mixin-screen-reader-text; } - form, - input { - margin: 0.4em 0 0; + form { + margin: 0.5em 0 0; } } #simpleSearch { - background-color: #fff; - .background-image( 'images/search-fade.png' ); - background-position: top left; - background-repeat: repeat-x; - color: #000; display: block; - width: 12.6em; + width: 13.2em; width: 20vw; /* responsive width */ min-width: 5em; max-width: 20em; - padding-right: 1.4em; - height: 1.4em; - margin-top: 0.65em; + height: 100%; + margin-top: 0; position: relative; min-height: 1px; /* Gotta trigger hasLayout for IE7 */ - border: 1px solid @colorGray10; - border-radius: @borderRadius; - .transition( border-color 250ms ); - &:hover { + // Styles for both the search input and the button. + input { + // Support IE6-8:; Fallback for browsers, which don't support `rgba()`. + background-color: @background-color-base; + background-color: rgba( 0, 0, 0, 0 ); + color: #000; + margin: 0; + } +} + +// The search input. +#searchInput { + width: 100%; + .box-sizing( border-box ); + border: @border-width-base solid @colorGray10; + border-radius: @borderRadius; + // `padding-right` equals to `#searchbutton` width below. + padding: 0.4em 1.818em 0.4em 0.4em; + .box-shadow( @boxShadowWidget ); + font-size: 0.8125em; // Equals to `13px` at browser default of `16px`. + direction: ltr; + .transition( ~'border-color 250ms, box-shadow 250ms' ); + // Support: Webkit browsers. Undo the proprietary styles applied to `type=search` fields, + // we provide our own. + -webkit-appearance: textfield; + + #simpleSearch:hover & { border-color: @colorGray7; } - // Styles for both the search input and the button - input { - background-color: transparent; - color: #000; - margin: 0; - padding: 0; - border: 0; + &:focus, + #simpleSearch:hover &:focus { + outline: 0; + border-color: @colorProgressive; + .box-shadow( @boxShadowProgressiveFocus ); } - // The search input - #searchInput { - width: 100%; - padding: 0.2em 0 0.2em 0.2em; - font-size: 0.8125em; // equals `13px` at browser default of `16px` - direction: ltr; + .mixin-placeholder( { + color: @colorGray7; + opacity: 1; + } ); - &:focus { - outline: 0; - } - - /* stylelint-disable indentation */ - .mixin-placeholder( { - color: @colorGray7; - opacity: 1; - } ); - /* stylelint-enable indentation */ - - // Undo the styles Webkit browsers apply to type=search fields, - // we provide our own + &::-webkit-search-decoration, + &::-webkit-search-cancel-button, + &::-webkit-search-results-button, + &::-webkit-search-results-decoration { -webkit-appearance: textfield; - - &::-webkit-search-decoration, - &::-webkit-search-cancel-button, - &::-webkit-search-results-button, - &::-webkit-search-results-decoration { - -webkit-appearance: textfield; - } - } - - // The buttons. They are displayed in the same position, and if both are - // present the fulltext search one obscures the 'Go' one. - #searchButton, - #mw-searchButton { - position: absolute; - top: 0; - right: 0; - width: 1.65em; - height: 100%; - cursor: pointer; - /* Hide button text and replace it with the image. */ - text-indent: -99999px; - /* Opera 12 on RTL flips the text in a funny way without this. */ - /* @noflip */ - direction: ltr; - white-space: nowrap; - overflow: hidden; - } - - #searchButton { - .background-image-svg( 'images/search-ltr.svg', 'images/search-ltr.png' ); - background-position: center center; - background-repeat: no-repeat; - } - - #mw-searchButton { - z-index: 1; } } + +// The buttons. They are displayed in the same position, and if both are +// present the fulltext search one obscures the 'Go' one. +#searchButton, +#mw-searchButton { + position: absolute; + top: @border-width-base; + bottom: @border-width-base; + right: @border-width-base; + min-width: 20px; + width: 1.818em; // Equals to `20px` at `11px` base. + border: 0; + padding: 0; + cursor: pointer; + /* Opera 12 on RTL flips the text in a funny way without this. */ + /* @noflip */ + direction: ltr; + /* Hide button text and replace it with the image. */ + text-indent: -99999px; + white-space: nowrap; + overflow: hidden; + z-index: 1; +} + +#searchButton { + .background-image-svg( 'images/search-ltr.svg', 'images/search-ltr.png' ); + background-position: center center; + background-repeat: no-repeat; +} + +#mw-searchButton { + z-index: 1; +}