-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from nhsuk/develop
Release 1.7.0
- Loading branch information
Showing
27 changed files
with
3,592 additions
and
418 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import nhsukHeader from '../../node_modules/nhsuk-frontend/packages/components/header/header'; | ||
import autocomplete from '../../node_modules/nhsuk-frontend/packages/components/header/autocomplete'; | ||
|
||
function suggestionTemplate(data) { | ||
const result = data.title; | ||
const truncateLength = 36; | ||
const dots = result.length > truncateLength ? '...' : ''; | ||
const resultTruncated = result.substring(0, truncateLength) + dots; | ||
const svgIcon = '<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path></svg>'; | ||
const resultsHref = `<a href="${data.url}">${resultTruncated}</a>`; | ||
|
||
return svgIcon + resultsHref; | ||
} | ||
|
||
function searchSource(query, callback) { | ||
const url = `/service-manual/suggestions/?search=${encodeURIComponent(query)}`; | ||
const xhr = new XMLHttpRequest(); | ||
xhr.open('GET', url); | ||
xhr.onload = () => { | ||
if (xhr.status === 200) { | ||
const data = JSON.parse(xhr.responseText); | ||
callback(data); | ||
} | ||
}; | ||
xhr.send(); | ||
} | ||
|
||
function inputValueTemplate(selected) { | ||
if (selected) { | ||
return selected.title; | ||
} | ||
return ''; | ||
} | ||
|
||
const searchConfig = { | ||
onConfirm: (selected) => { | ||
window.location.href = selected.url; | ||
}, | ||
required: false, | ||
showNoOptionsFound: false, | ||
source: searchSource, | ||
templates: { | ||
inputValue: inputValueTemplate, | ||
suggestion: suggestionTemplate, | ||
}, | ||
}; | ||
|
||
nhsukHeader(); | ||
autocomplete(searchConfig); |
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 |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
@import 'homepage'; | ||
@import 'related-nav'; | ||
@import 'utilities'; | ||
@import 'search'; |
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,118 @@ | ||
.nhsuk-list--border li { | ||
border-bottom: 1px solid $color_nhsuk-grey-4; | ||
padding: 8px 0 16px; | ||
} | ||
|
||
.nhsuk-list--border li>:first-child { | ||
margin-top: 0; | ||
} | ||
|
||
.nhsuk-list--border li>:last-child { | ||
margin-bottom: 0; | ||
} | ||
|
||
.nhsuk-list--border li:first-of-type { | ||
border-top: 1px solid $color_nhsuk-grey-4; | ||
padding: 16px 0; | ||
} | ||
|
||
.nhsuk-header__search-form--search-results { | ||
@include nhsuk-responsive-margin(7, 'bottom'); | ||
|
||
background-color: transparent; | ||
display: -ms-flexbox; /* [14] */ | ||
display: flex; // sass-lint:disable-line no-duplicate-properties | ||
padding: 0; | ||
width: 100%; | ||
|
||
.autocomplete-container { | ||
width: 100%; | ||
} | ||
|
||
.autocomplete__menu--hidden { | ||
display: none; | ||
} | ||
|
||
.autocomplete__input, | ||
.nhsuk-search__input { | ||
-ms-flex-positive: 2; /* [14] */ | ||
-webkit-appearance: listbox; // sass-lint:disable-line prefixes /* [5] */ | ||
background-color: $color_nhsuk-white !important; // sass-lint:disable-line no-important /* [6] */ | ||
border-bottom: 1px solid $color_nhsuk-grey-3; | ||
border-bottom-left-radius: $nhsuk-border-radius; | ||
border-bottom-right-radius: 0; | ||
border-left: 1px solid $color_nhsuk-grey-3; | ||
border-right: 0; | ||
border-top: 1px solid $color_nhsuk-grey-3; | ||
border-top-left-radius: $nhsuk-border-radius; | ||
border-top-right-radius: 0; | ||
flex-grow: 2; | ||
font-size: inherit; | ||
height: 52px; /* [2] */ | ||
margin: 0; | ||
outline: none; | ||
padding: 0 nhsuk-spacing(3); | ||
width: 100%; /* [2] */ | ||
|
||
&:focus { | ||
box-shadow: inset 0 0 0 $nhsuk-box-shadow-spread $nhsuk-focus-color; | ||
} | ||
} | ||
|
||
.nhsuk-search__submit { | ||
background-color: $color_nhsuk-green; | ||
border: 0; | ||
border-bottom-left-radius: 0; | ||
border-bottom-right-radius: $nhsuk-border-radius; | ||
border-top-left-radius: 0; | ||
border-top-right-radius: $nhsuk-border-radius; | ||
float: right; | ||
font-size: inherit; | ||
height: 52px; /* [2] */ | ||
line-height: inherit; | ||
margin: 0; | ||
outline: none; | ||
padding: nhsuk-spacing(2) nhsuk-spacing(2) 0; | ||
width: 52px; | ||
|
||
.nhsuk-icon__search { | ||
fill: $color_nhsuk-white; | ||
height: 38px; /* [3] */ | ||
width: 38px; /* [3] */ | ||
} | ||
|
||
&::-moz-focus-inner { | ||
border: 0; /* [4] */ | ||
} | ||
|
||
&:hover { | ||
background-color: $nhsuk-button-hover-color; | ||
cursor: pointer; | ||
} | ||
|
||
&:focus { | ||
box-shadow: inset 0 0 0 $nhsuk-box-shadow-spread $nhsuk-focus-color; | ||
} | ||
|
||
&:active { | ||
background-color: $nhsuk-button-active-color; | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
.app-search-results-item { | ||
@include nhsuk-typography-responsive(22); | ||
|
||
font-weight: $nhsuk-font-bold; | ||
text-decoration: none; | ||
|
||
&:hover { | ||
text-decoration: underline; | ||
} | ||
} | ||
|
||
.app-search-results-item::first-letter { | ||
text-transform: uppercase; | ||
} |
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
Oops, something went wrong.