-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31b80c0
commit 9d8c7bf
Showing
18 changed files
with
491 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<div class="app-example"> | ||
<span class="app-example__new-window"> | ||
<a href="{{ href | url }}" target="_blank">Open this example <span class="nhsuk-u-visually-hidden">({{ title }})</span> in a new window</a> | ||
</span> | ||
<iframe | ||
onload="this.style.height = this.contentWindow.document.documentElement.scrollHeight + 'px';" | ||
class="app-example__frame" | ||
scrolling="auto" | ||
frameborder="0" | ||
height="{{ height }}" | ||
src="{{ href | url }}" | ||
title="{{ title }}" | ||
></iframe> | ||
</div> | ||
|
||
<div class="app-tabs" data-module="app-tabs"> | ||
<ul class="app-tabs__list" role="tablist"> | ||
<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab" href="#html-default-{{ id }}" role="tab" id="tab_html-default-{{ id }}" aria-controls="html-default-{{ id }}">HTML</a></li> | ||
<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab" href="#nunjucks-default-{{ id }}" role="tab" id="tab_nunjucks-default-{{ id }}" aria-controls="nunjucks-default-{{ id }}">Nunjucks</a></li> | ||
{%- if jsCode %}<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab" href="#js-default-{{ id }}" role="tab" id="tab_js-default-{{ id }}" aria-controls="js-default-{{ id }}">JavaScript</a></li>{% endif -%} | ||
{%- if figmaLink %}<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab" href="#figma-default-{{ id }}" role="tab" id="tab_figma-default-{{ id }}" aria-controls="figma-default-{{ id }}">Figma</a></li>{% endif -%} | ||
{%- if vueLink %}<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab" href="#vue-default-{{ id }}" role="tab" id="tab_vue-default-{{ id }}" aria-controls="vue-default-{{ id }}">Vue</a></li>{% endif -%} | ||
</ul> | ||
|
||
<div class="app-tabs__panel app-tabs__panel--hidden" id="html-default-{{ id }}" role="tabpanel" aria-labelledby="tab_html-default-{{ id }}"> | ||
<button class="app-copy__button app-u-hidden" data-module="app-copy" data-clipboard-target="#html-default-{{ id }}-code">Copy code</button> | ||
<div id="html-default-{{ id }}-code"> | ||
{%- highlight "html" -%} | ||
{{ htmlCode | safe }} | ||
{%- endhighlight -%} | ||
</div> | ||
</div> | ||
|
||
<div class="app-tabs__panel app-tabs__panel--hidden" id="nunjucks-default-{{ id }}" role="tabpanel" aria-labelledby="tab_nunjucks-default-{{ id }}"> | ||
<button class="app-copy__button app-u-hidden" data-module="app-copy" data-clipboard-target="#nunjucks-default-{{ id }}-code">Copy code</button> | ||
|
||
{%- if arguments -%} | ||
<details class="nhsuk-details nhsuk-u-padding-3" data-module="nhsuk-details"> | ||
<summary class="nhsuk-details__summary"> | ||
<span class="nhsuk-details__summary-text"> | ||
Nunjucks macro options | ||
</span> | ||
</summary> | ||
<div class="nhsuk-details__text"> | ||
|
||
{% include "./arguments/" + arguments + ".md" %} | ||
|
||
</div> | ||
</details> | ||
{%- endif -%} | ||
|
||
<div id="nunjucks-default-{{ id }}-code"> | ||
|
||
```jinja2 | ||
{{ nunjucksCode | safe }} | ||
``` | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
{% if figmaLink -%} | ||
<div class="app-tabs__panel nhsuk-u-padding-2 app-tabs__panel--hidden" id="figma-default-{{ id }}" role="tabpanel" aria-labelledby="tab_figma-default-{{ id }}"> | ||
|
||
To use the component in your design, add the NHS App Figma Kit to your Figma libraries and find the component using the Assets tab. | ||
|
||
[View component in Figma]({{ figmaLink }}) | ||
</div> | ||
{% endif -%} | ||
|
||
{% if vueLink -%} | ||
<div class="app-tabs__panel nhsuk-u-padding-2 app-tabs__panel--hidden" id="vue-default-{{ id }}" role="tabpanel" aria-labelledby="tab_vue-default-{{ id }}"> | ||
|
||
To use the component in your Vue application, install the NHS App Vue Component Library and import the component. | ||
|
||
[View component in Vue]({{ vueLink }}) | ||
</div> | ||
{% endif -%} | ||
</div> |
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,8 @@ | ||
{% extends "./base.njk" %} | ||
|
||
{% block header %}{% endblock %} | ||
{% block footer %}{% endblock %} | ||
|
||
{% block content %} | ||
{{ content | safe }} | ||
{% endblock %} |
This file was deleted.
Oops, something went wrong.
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,50 @@ | ||
/* ========================================================================== | ||
#EXAMPLE | ||
========================================================================== */ | ||
|
||
.app-example { | ||
background-color: $color_nhsuk-white; | ||
border: 1px solid $nhsuk-border-color; | ||
position: relative; | ||
} | ||
|
||
.app-example__frame { | ||
background-color: $color_nhsuk-white; | ||
border: 0; | ||
display: block; | ||
width: 100%; | ||
} | ||
|
||
.app-example-page { | ||
margin-bottom: -1px; | ||
padding: 30px; | ||
padding-top: 60px; | ||
position: relative; | ||
} | ||
|
||
.app-example__new-window { | ||
@include nhsuk-font($size: 14); | ||
border: 1px solid $nhsuk-border-color; | ||
position: absolute; | ||
top: -1px; | ||
left: -1px; | ||
|
||
a, | ||
a:link, | ||
a:visited { | ||
background-color: white; | ||
color: $color_nhsuk-blue; | ||
display: block; | ||
padding: 5px 10px; | ||
text-decoration: none; | ||
} | ||
|
||
a:hover { | ||
color: $nhsuk-link-hover-color; | ||
} | ||
|
||
a:focus { | ||
color: $nhsuk-focus-text-color; | ||
background-color: $nhsuk-focus-color; | ||
} | ||
} |
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,67 @@ | ||
/* ========================================================================== | ||
#TABS | ||
========================================================================== */ | ||
|
||
.app-tabs { | ||
margin-bottom: nhsuk-spacing(6); | ||
} | ||
|
||
.app-tabs__list { | ||
background: $color_nhsuk-white; | ||
border: 1px solid $nhsuk-border-color; | ||
border-top: 0; | ||
list-style: none; | ||
margin: 0; | ||
padding: 0; | ||
|
||
display: flex; | ||
} | ||
|
||
.app-tabs__list-item { | ||
border-right: 1px solid $nhsuk-border-color; | ||
margin: 0; | ||
|
||
z-index: 2; | ||
} | ||
|
||
.app-tabs__tab { | ||
@include nhsuk-font($size: 19, $weight: bold); | ||
background-color: $color_nhsuk-white; | ||
color: $color_nhsuk-blue; | ||
display: block; | ||
padding: 20px; | ||
position: relative; | ||
text-decoration: none; | ||
|
||
&[aria-selected="true"] { | ||
background-color: $color_nhsuk-grey-5; | ||
color: $color_nhsuk-black; | ||
margin-bottom: -1px; | ||
padding-bottom: 21px; | ||
|
||
&:focus { | ||
background-color: $nhsuk-focus-color; | ||
} | ||
} | ||
} | ||
|
||
.app-tabs__panel { | ||
@include nhsuk-font($size: 16); | ||
background-color: $color_nhsuk-grey-5; | ||
border: 1px solid $nhsuk-border-color; | ||
border-top: 0; | ||
position: relative; | ||
|
||
&--hidden { | ||
display: none; | ||
} | ||
|
||
*:last-of-type { | ||
margin-bottom: 0; // Remove margin bottom from any last element | ||
} | ||
|
||
p { | ||
max-width: 100% !important; | ||
padding: nhsuk-spacing(2); | ||
} | ||
} |
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,3 @@ | ||
.app-u-hidden { | ||
display: none; | ||
} |
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,5 @@ | ||
--- | ||
permalink: assets/js/app.js | ||
--- | ||
{% include "js/tabs.js" %} | ||
{% include "js/copy.js" %} |
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,30 @@ | ||
const Copy = function (button) { | ||
this.button = button | ||
|
||
// If the browser supports the Clipboard API, show the copy button | ||
if (navigator.clipboard) { | ||
this.button.classList.remove('app-u-hidden') | ||
} | ||
|
||
button.addEventListener('click', (e) => this.handleCopyClick(e)) | ||
} | ||
|
||
Copy.prototype.handleCopyClick = function (e) { | ||
e.preventDefault() | ||
const copyFrom = this.button.getAttribute('data-clipboard-target') | ||
const str = document.querySelector(copyFrom).innerText | ||
navigator.clipboard.writeText(str) | ||
|
||
// Change the button text to "Copied" for 5 seconds | ||
const originalText = this.button.innerText | ||
this.button.innerText = 'Copied' | ||
setTimeout(() => { | ||
this.button.innerText = originalText | ||
}, 5000) | ||
} | ||
|
||
document | ||
.querySelectorAll('[data-module="app-copy"]') | ||
.forEach(function (element) { | ||
new Copy(element) | ||
}) |
Oops, something went wrong.