-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add panel component #1012
Open
davidhunter08
wants to merge
11
commits into
main
Choose a base branch
from
confirmation-panel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add panel component #1012
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b723225
add panel component
davidhunter08 b886cbf
prettify
davidhunter08 a3f250e
add backstop screenshots
davidhunter08 32d2104
reduced panel body font size
davidhunter08 9ef9392
Merge branch 'main' into confirmation-panel
davidhunter08 7480422
Merge branch 'main' into confirmation-panel
davidhunter08 1e61c62
change desktop padding to 32px
davidhunter08 f7e16e4
Merge branch 'main' into confirmation-panel
anandamaryon1 b9b8f7a
Merge branch 'main' into confirmation-panel
frankieroberto 45ee813
Merge branch 'main' into confirmation-panel
anandamaryon1 020016d
update backstops
anandamaryon1 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
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,23 @@ | ||
{% set html_style = 'background-color: #f0f4f5;' %} | ||
{% set title = 'Panel' %} | ||
{% from 'components/panel/macro.njk' import panel %} | ||
{% extends 'layout.njk' %} | ||
|
||
{% block body %} | ||
|
||
<div class="nhsuk-width-container"> | ||
<main class="nhsuk-main-wrapper"> | ||
|
||
<div class="nhsuk-grid-row"> | ||
<div class="nhsuk-grid-column-two-thirds"> | ||
{{ panel({ | ||
titleText: "Application complete", | ||
html: "Your reference number<br><strong>HDJ2123F</strong>" | ||
}) }} | ||
</div> | ||
</div> | ||
|
||
</main> | ||
</div> | ||
|
||
{% endblock %} |
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,54 @@ | ||
# Panel | ||
|
||
## Guidance | ||
|
||
Find out more about the panel component and when to use it in the [NHS digital service manual](https://service-manual.nhs.uk/design-system/components/panel). | ||
|
||
## Quick start example | ||
|
||
[Preview the panel component](https://nhsuk.github.io/nhsuk-frontend/components/panel/index.html) | ||
|
||
### HTML markup | ||
|
||
```html | ||
<div class="nhsuk-panel"> | ||
<h1 class="nhsuk-panel__title"> | ||
Application complete | ||
</h1> | ||
<div class="nhsuk-panel__body"> | ||
Your reference number<br><strong>HDJ2123F</strong> | ||
</div> | ||
</div> | ||
``` | ||
|
||
### Nunjucks macro | ||
|
||
``` | ||
{% from 'components/panel/macro.njk' import panel %} | ||
|
||
{{ panel({ | ||
titleText: "Application complete", | ||
html: "Your reference number<br><strong>HDJ2123F</strong>" | ||
}) }} | ||
``` | ||
|
||
### Nunjucks arguments | ||
|
||
The panel Nunjucks macro takes the following arguments: | ||
|
||
| Name | Type | Required | Description | | ||
| ---------------- | -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| **titleText** | string | Yes | If `titleHtml` is set, this is not required. Text to use within the panel. If `titleHtml` is provided, the `titleText` option will be ignored. | | ||
| **titleHtml** | string | Yes | If `titleText` is set, this is not required. HTML to use within the panel. If `titleHtml` is provided, the `titleText` option will be ignored. | | ||
| **headingLevel** | integer | No | Heading level, from `1` to `6`. Default is `1`. | | ||
| **text** | string | No | If `html` is set, this is not required. Text to use within the panel content. If `html` is provided, the `text` option will be ignored. | | ||
| **html** | string | No | If `text` is set, this is not required. Text to use within the panel content. If `text` is provided, the `html` option will be ignored. | | ||
| **caller** | nunjucks-block | No | Not strictly a parameter but [Nunjucks code convention](https://mozilla.github.io/nunjucks/templating.html#call). Using a `call` block enables you to call a macro with all the text inside the tag. This is helpful if you want to pass a lot of content into a macro. To use it, you will need to wrap the entire panel component in a `call` block. | | ||
| **classes** | string | No | Optional additional classes to add to the hint div tag. Separate each class with a space. | | ||
| **attributes** | object | No | Any extra HTML attributes (for example data attributes) to add to the input component. | | ||
|
||
If you are using Nunjucks macros in production be aware that using `html` arguments, or ones ending with `html` can be a [security risk](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Read more about this in the [Nunjucks documentation](https://mozilla.github.io/nunjucks/api.html#user-defined-templates-warning). | ||
|
||
## Thanks to the Government Digital Service (GDS) | ||
|
||
This component and documentation has been taken from [GOV.UK Frontend - Panel component](https://github.com/alphagov/govuk-frontend/tree/main/package/govuk/components/panel) with a few minor adaptations. |
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,55 @@ | ||
// ========================================================================== | ||
// COMPONENTS / #PANEL | ||
// ========================================================================== | ||
|
||
/** | ||
* Original code taken from GDS (Government Digital Service) | ||
* https://github.com/alphagov/govuk-frontend | ||
* | ||
* 1. This is an if-all-else-fails attempt to stop long words from overflowing the container | ||
on very narrow viewports by forcing them to break and wrap instead. This | ||
overflowing is more likely to happen when user increases text size on a mobile eg. using | ||
iOS Safari text resize controls. | ||
|
||
The overflowing is a particular problem with the panel component since it uses white | ||
text: when the text overflows the container, it is invisible on the white (page) | ||
background. When the text in our other components overflow, the user might have to scroll | ||
horizontally to view it but the the text remains legible. | ||
* 2. Support IE (autoprefixer doesn't add this as it's not a prefix) | ||
*/ | ||
|
||
$nhsuk-border-width-panel: nhsuk-spacing(1); | ||
|
||
.nhsuk-panel { | ||
@include nhsuk-typography-responsive(24); | ||
@include nhsuk-responsive-margin(4, "bottom"); | ||
|
||
background: $color_nhsuk-green; | ||
border: $nhsuk-border-width-panel solid transparent; | ||
box-sizing: border-box; | ||
color: $color_nhsuk-white; | ||
padding: nhsuk-spacing(5) - $nhsuk-border-width-panel; | ||
|
||
@include mq($until: tablet) { | ||
padding: nhsuk-spacing(4) - $nhsuk-border-width-panel; | ||
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. add comment for why this is differenet? |
||
overflow-wrap: break-word; /* [1] */ | ||
word-wrap: break-word; /* [2] */ | ||
} | ||
|
||
@include mq($media-type: print) { | ||
border-color: currentcolor; | ||
color: $nhsuk-print-text-color; | ||
background: none; | ||
} | ||
} | ||
|
||
.nhsuk-panel__title { | ||
@include nhsuk-typography-responsive(48); | ||
@include nhsuk-responsive-margin(5, "bottom"); | ||
|
||
margin-top: 0; | ||
} | ||
|
||
.nhsuk-panel__title:last-child { | ||
margin-bottom: 0; | ||
} |
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 @@ | ||
{% macro panel(params) %} | ||
{%- include './template.njk' -%} | ||
{% endmacro %} |
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,16 @@ | ||
{% from "../../macros/attributes.njk" import nhsukAttributes %} | ||
|
||
{% set headingLevel = params.headingLevel if params.headingLevel else 1 -%} | ||
|
||
<div class="nhsuk-panel | ||
{%- if params.classes %} {{ params.classes }}{% endif %}" | ||
{{- nhsukAttributes(params.attributes) }}> | ||
<h{{ headingLevel }} class="nhsuk-panel__title"> | ||
{{ params.titleHtml | safe if params.titleHtml else params.titleText }} | ||
</h{{ headingLevel }}> | ||
{% if caller or params.html or params.text %} | ||
<div class="nhsuk-panel__body"> | ||
{{ caller() if caller else (params.html | safe | trim | indent(4) if params.html else params.text) }} | ||
</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
Binary file added
BIN
+11.8 KB
tests/backstop/bitmaps_reference/nhsuk-frontend_Panel_0_document_0_iPhone_5_SE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.5 KB
tests/backstop/bitmaps_reference/nhsuk-frontend_Panel_0_document_1_iPhone_6-8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.3 KB
tests/backstop/bitmaps_reference/nhsuk-frontend_Panel_0_document_2_iPad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.7 KB
...ckstop/bitmaps_reference/nhsuk-frontend_Panel_0_document_3_Surface_iPad_Pro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
I presume this is similar to the GOV.UK panel - we should double check this looks ok with changed / forced colours.
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.
Yeah that's taken from GOV. I'll check what it looks like with changed / forced colours.