This repository has been archived by the owner on Mar 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Feature/site search #432
Closed
Closed
Feature/site search #432
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
83859cb
Start of a site-search component
TrebBrennan 3bc5e47
better browser support
TrebBrennan 0c991bd
Fix to examples
TrebBrennan 71b5ece
but fix for build
TrebBrennan 379f4e6
Add KSS comments to the Site search components
ea4dd1e
Refactor Site search JS to remove JQuery
6f5e51c
Reorder Components @imports so they're alphabetical
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
require('classlist-polyfill'); | ||
|
||
function init(siteSearchInputSelector) { | ||
var siteSearchInput = document.querySelectorAll(siteSearchInputSelector).item(0); | ||
var formChangeEvents = 'propertychange input'; | ||
_addEventListener(siteSearchInput, formChangeEvents, _onFormChange); | ||
} | ||
|
||
function _onFormChange(event) { | ||
let element = event.target; | ||
element.classList.toggle(); | ||
} | ||
|
||
function _addEventListener(elem, triggers, callback) { | ||
if (typeof window.addEventListener === undefined) { | ||
elem.addEventListener(triggers, callback); | ||
} else { | ||
elem.attachEvent(triggers, callback); | ||
} | ||
} | ||
|
||
module.exports = { | ||
init: init | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
@import 'components/navigation'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @petronbot Just saw this: are we sure we won’t run into any cascading issues wrt. vars or other things that are introduced in a partial that now is imported after a partial that might rely or call it?] |
||
@import 'components/page-footer'; | ||
@import 'components/page-header'; | ||
@import 'components/site-search'; | ||
@import 'components/tables'; | ||
@import 'components/accordions'; | ||
@import 'components/typography'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
|
||
/* | ||
Site search | ||
|
||
Search helps people find things on your site. | ||
|
||
Style guide: Site search | ||
*/ | ||
|
||
/* | ||
Site search input | ||
|
||
JavaScript is required for pseudo placeholder label, but no-js will fall back gracefully | ||
|
||
Markup: templates/site-search.html | ||
|
||
Style guide: Site search.1 Input | ||
*/ | ||
|
||
|
||
// Responsive site-search box | ||
//============================ | ||
|
||
// Tested: | ||
//----------------- | ||
// Browser Pass: Chrome, FF.49, Opera.36, ie.E-8, iPhone.6-5 | ||
// Browser Semi-pass: ie7 (functions but layout is broken) | ||
// HTML validated: W3C & WCAG | ||
// WCAG: Approved by A11y SME | ||
|
||
//Notes: | ||
//----------------- | ||
// - JS required for psudo placeholder label, but no-js will fall back gracefully | ||
// - JS written jQuery, rewrite if required | ||
|
||
// Expected HTML: | ||
//----------------- | ||
// <div class="site-search"> | ||
// <form id="search" class="" action="/search" role="search"> | ||
// <label for="site-search-text">Search GOV.AU</label> | ||
// <div class="site-search-border"> | ||
// <input type="search" name="q" id="site-search-text" title="Search" class="search-input" /> | ||
// <input class="submit" type="submit" value="Search" /> | ||
// </div> | ||
// </form> | ||
// </div><!--site-search--> | ||
|
||
// Expected JS (jQuery): | ||
//----------------- | ||
// $( document ).ready(function() { | ||
// //If search-input has value add class that moves it in front of label | ||
// $('#site-search-text').on("propertychange input", function(){ // input = ie9+, propertychange < ie9 | ||
// element = $(this); | ||
// if( element.val() ) { | ||
// element.addClass('has-value'); | ||
// } else { | ||
// element.removeClass('has-value'); | ||
// } | ||
// }); | ||
// }); | ||
|
||
|
||
//VARS | ||
//================= | ||
$site-search-border: solid 1px; //none; | ||
$site-search-font-colour: $navy; | ||
$site-search-label-colour: $non-white; //Only seen with no JS | ||
$site-search-background-colour: $non-white; | ||
$site-search-background-colour--hover: darken($non-white, 5%); | ||
$site-search-button-background-colour: $non-white; | ||
$site-search-button-background-colour--hover: darken($non-white, 5%); | ||
$site-search-outline--focus: $light-aqua; | ||
|
||
.site-search { | ||
color: $site-search-font-colour; | ||
|
||
form { | ||
position: relative; // for psudo placeholder label | ||
// height: 3em; //No height ie7. position:relative ? | ||
} | ||
|
||
input { | ||
//both text-input and button | ||
transition-timing-function: $transition-easing; | ||
transition-duration: $transition-timing-fast; | ||
transition-property: background-color; | ||
} | ||
|
||
label { | ||
// Acts as a psudo placeholder with JS, or normal label if no JS | ||
// see JS related styles below nested parent | ||
height: 3em; | ||
line-height: 3em; | ||
margin: 0; | ||
cursor: text; | ||
} | ||
|
||
.site-search-border { | ||
// Provides an option for a border around the search-box and a place to put the clearfix that doesn't interfere with other elements. | ||
// This CSS is not on the form or .site-search parent because the label should not be included | ||
@include clearfix; | ||
|
||
border: $site-search-border; | ||
border-radius: $base-border-radius; | ||
//width: 100%; | ||
padding-right: 3em; | ||
} | ||
|
||
.search-input { | ||
-webkit-appearance: none; //Cause iPhone | ||
position: relative; //For z-index on focus if JS | ||
z-index: 1; //For z-index on focus if JS | ||
display: block; | ||
width: 100%; | ||
float: left; | ||
border: none; | ||
padding: 0; | ||
text-indent: 1em; | ||
line-height: 3em; | ||
height: 3em; | ||
background-color: $site-search-background-colour; | ||
border-radius: $base-border-radius 0 0 $base-border-radius; | ||
|
||
&:hover { | ||
background-color: $site-search-background-colour--hover; | ||
} | ||
|
||
&:focus { | ||
outline: solid 3px $site-search-outline--focus; | ||
} | ||
|
||
&:focus, | ||
&.has-value { // Class is added with JS | ||
z-index: 3; //For z-index on focus | ||
} | ||
|
||
&:hover:focus { | ||
background-color: $site-search-background-colour; | ||
} | ||
} //.search-input | ||
|
||
|
||
.submit { | ||
position: relative; //For z-index on focus if JS | ||
z-index: 1; //For z-index on focus if JS | ||
border: none; | ||
float: right; | ||
margin: 0; | ||
margin-right: -3em; | ||
padding: 0; | ||
width: 3em; | ||
height: 3em; | ||
text-indent: -99em; | ||
background-color: $site-search-button-background-colour; | ||
border-radius: 0 $base-border-radius $base-border-radius 0; | ||
|
||
@include inline-background-image('search--navy'); | ||
background-size: 20px auto; //Resize the SVG img as it has no height (could be set in SVG meta but this is safer) | ||
background-repeat: no-repeat; | ||
background-position: center center; | ||
|
||
&:hover { | ||
background-color: $site-search-button-background-colour--hover; | ||
} | ||
|
||
&:focus { | ||
outline: solid 3px $site-search-outline--focus; | ||
z-index: 3; | ||
} | ||
|
||
} //.submit | ||
} //.site-search | ||
|
||
|
||
.no-js .site-search label { | ||
color: $site-search-label-colour; | ||
} | ||
|
||
.js .site-search label { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
z-index: 2; //For z-index on focus if JS | ||
text-indent: 1em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="site-search"> | ||
<form id="search" class="" action="#" role="search"> | ||
<label for="site-search-text">Search GOV.AU</label> | ||
<div class="site-search-border"> | ||
<input type="search" name="q" title="Search" class="search-input js-search-input" /> | ||
<input class="submit" type="submit" value="Search" /> | ||
</div> | ||
</form> | ||
</div><!--site-search--> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined
here should be a string? And shouldn't thisif
be inverse?