mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 02:42:26 -05:00
Add progressive enhancement to service switcher
- by default, the menu is open - if Javascript is enabled/loaded, the links are hidden, and visual cues (▶) to show that it can be opened are added - clicking it opens and closes it
This commit is contained in:
18
app/assets/javascripts/dropdown.js
Normal file
18
app/assets/javascripts/dropdown.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
(function(Modules) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Modules.Dropdown = function() {
|
||||||
|
|
||||||
|
this.start = function(component) {
|
||||||
|
|
||||||
|
$('.dropdown-toggle', component)
|
||||||
|
.on(
|
||||||
|
'click', () => $(component).toggleClass('js-closed')
|
||||||
|
)
|
||||||
|
.trigger('click');
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
})(window.GOVUK.Modules);
|
||||||
53
app/assets/stylesheets/components/dropdown.scss
Normal file
53
app/assets/stylesheets/components/dropdown.scss
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
%dropdown,
|
||||||
|
.dropdown {
|
||||||
|
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.js-enabled &-toggle {
|
||||||
|
|
||||||
|
color: $link-colour;
|
||||||
|
position: relative;
|
||||||
|
padding-left: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: $link-hover-colour;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '▼';
|
||||||
|
font-size: 12px;
|
||||||
|
position: absolute;
|
||||||
|
top: 1px;
|
||||||
|
left: -1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.js-closed &-toggle::before {
|
||||||
|
content: '▶';
|
||||||
|
left: -1px;
|
||||||
|
top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
.js-enabled & {
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
&.js-closed {
|
||||||
|
|
||||||
|
a {
|
||||||
|
left: -9999em;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
.management-navigation {
|
.management-navigation {
|
||||||
|
|
||||||
@extend %site-width-container;
|
@extend %site-width-container;
|
||||||
@include core-19();
|
@include core-16();
|
||||||
border-bottom: 1px solid $border-colour;
|
border-bottom: 1px solid $border-colour;
|
||||||
padding: 10px 0 8px;
|
padding: 10px 0 8px;
|
||||||
|
|
||||||
@@ -42,7 +42,8 @@
|
|||||||
@import 'components/banner';
|
@import 'components/banner';
|
||||||
@import 'components/textbox';
|
@import 'components/textbox';
|
||||||
@import 'components/browse-list';
|
@import 'components/browse-list';
|
||||||
@import 'components/switcher';
|
@import 'components/management-navigation';
|
||||||
|
@import 'components/dropdown';
|
||||||
|
|
||||||
@import 'views/job';
|
@import 'views/job';
|
||||||
|
|
||||||
|
|||||||
@@ -51,9 +51,13 @@
|
|||||||
<nav class="management-navigation">
|
<nav class="management-navigation">
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="column-half">
|
<div class="column-half">
|
||||||
Service name
|
<div class="dropdown" data-module="dropdown">
|
||||||
<a href="#">Switch to A N Other service</a>
|
<div class="dropdown-toggle">
|
||||||
<a href="#">Add a new service to Notify…</a>
|
Service name
|
||||||
|
</div>
|
||||||
|
<a href="#">Switch to A N Other service</a>
|
||||||
|
<a href="#">Add a new service to Notify…</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column-half management-navigation-account">
|
<div class="column-half management-navigation-account">
|
||||||
<a href="{{ url_for('.userprofile') }}">{{ current_user.name }}</a>
|
<a href="{{ url_for('.userprofile') }}">{{ current_user.name }}</a>
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ gulp.task('jquery', () => plugins.jquery.src({
|
|||||||
gulp.task('javascripts', ['jquery'], () => gulp.src([
|
gulp.task('javascripts', ['jquery'], () => gulp.src([
|
||||||
paths.src + 'govuk_frontend_toolkit/javascripts/govuk/modules.js',
|
paths.src + 'govuk_frontend_toolkit/javascripts/govuk/modules.js',
|
||||||
paths.src + 'javascripts/highlightTags.js',
|
paths.src + 'javascripts/highlightTags.js',
|
||||||
|
paths.src + 'javascripts/dropdown.js',
|
||||||
paths.src + 'javascripts/main.js'
|
paths.src + 'javascripts/main.js'
|
||||||
])
|
])
|
||||||
.pipe(plugins.babel({
|
.pipe(plugins.babel({
|
||||||
|
|||||||
Reference in New Issue
Block a user