-
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.
Merge pull request #67 from nhsuk/code-examples
Code examples
- Loading branch information
Showing
23 changed files
with
577 additions
and
51 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 library to your working files, and navigate using the components 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
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 @@ | ||
{% extends "./base.njk" %} | ||
|
||
{% block skiplink %}{% endblock %} | ||
{% 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
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,89 @@ | ||
/* ========================================================================== | ||
#EXAMPLE | ||
========================================================================== */ | ||
|
||
.app-example { | ||
border: 1px solid $nhsuk-border-color; | ||
padding-top: 37px; //matches height of new window link | ||
margin-top: 24px; | ||
position: relative; | ||
|
||
@include mq($from: desktop) { | ||
padding-top: 41px; //matches height of new window link | ||
} | ||
} | ||
|
||
.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-bottom: 1px solid $nhsuk-border-color; | ||
left: 0; | ||
position: absolute; | ||
padding: 8px 16px; | ||
top: 0; | ||
width: 100%; | ||
|
||
a, | ||
a:link, | ||
a:visited { | ||
color: $color_nhsuk-blue; | ||
display: inline-block; | ||
text-decoration: underline; | ||
} | ||
|
||
a:hover { | ||
color: $nhsuk-link-hover-color; | ||
} | ||
|
||
a:focus { | ||
color: $nhsuk-focus-text-color; | ||
background-color: $nhsuk-focus-color; | ||
text-decoration: none; | ||
} | ||
} | ||
|
||
:not(pre) > code[class*="language-"], | ||
pre[class*="language-"] { | ||
background: $color_nhsuk-white; | ||
margin: 0; | ||
} | ||
|
||
.app-copy__button { | ||
background-color: $color_nhsuk-white; | ||
border: 1px solid $color_nhsuk-green; | ||
box-shadow: 0 2px 0 $color_nhsuk-green; | ||
color: $color_nhsuk-green; | ||
cursor: pointer; | ||
font-size: 14px; | ||
padding: 2px 8px; | ||
position: absolute; | ||
right: 16px; | ||
top: 16px; | ||
|
||
&:hover { | ||
background-color: $color_nhsuk-green; | ||
color: $color_nhsuk-white; | ||
} | ||
|
||
&:focus { | ||
background-color: $nhsuk-focus-color; | ||
border-color: $nhsuk-focus-color; | ||
box-shadow: | ||
0 -2px $nhsuk-focus-color, | ||
0 4px $nhsuk-focus-text-color; | ||
color: $nhsuk-focus-text-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,72 @@ | ||
/* ========================================================================== | ||
#TABS | ||
========================================================================== */ | ||
|
||
.app-tabs { | ||
margin-bottom: nhsuk-spacing(6); | ||
} | ||
|
||
.app-tabs__list { | ||
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); | ||
color: $color_nhsuk-blue; | ||
display: block; | ||
padding: 16px; | ||
position: relative; | ||
text-decoration: underline; | ||
|
||
@include mq($from: desktop) { | ||
padding: 16px 20px; | ||
} | ||
|
||
&[aria-selected="true"] { | ||
background-color: $color_nhsuk-white; | ||
color: $color_nhsuk-black; | ||
margin-bottom: -1px; | ||
padding-bottom: 21px; | ||
|
||
&:focus { | ||
background-color: $nhsuk-focus-color; | ||
box-shadow: | ||
0 -2px $nhsuk-focus-color, | ||
inset 0 -4px $nhsuk-focus-text-color; | ||
} | ||
} | ||
} | ||
|
||
.app-tabs__panel { | ||
@include nhsuk-font($size: 16); | ||
background-color: $color_nhsuk-white; | ||
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" %} |
Oops, something went wrong.