-
Notifications
You must be signed in to change notification settings - Fork 366
Add Feedback component #7232
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
Open
owenatgov
wants to merge
4
commits into
main
Choose a base branch
from
feedback-component
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 Feedback component #7232
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
15 changes: 15 additions & 0 deletions
15
packages/govuk-frontend/src/govuk/components/feedback/README.md
This file contains hidden or 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,15 @@ | ||
| # Feedback | ||
|
|
||
| ## Installation | ||
|
|
||
| See the [main README quick start guide](https://github.com/alphagov/govuk-frontend#quick-start) for how to install this component. | ||
|
|
||
| ## Guidance and Examples | ||
|
|
||
| Find out when to use the Feedback component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/feedback). | ||
|
|
||
| ## Component options | ||
|
|
||
| Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text. | ||
|
|
||
| See [options table](https://design-system.service.gov.uk/components/feedback/#options-feedback-example) for details. |
5 changes: 5 additions & 0 deletions
5
packages/govuk-frontend/src/govuk/components/feedback/_feedback.import.scss
This file contains hidden or 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 @@ | ||
| @use "../../settings/warnings--internal"; | ||
|
|
||
| @include warnings--internal.component-scss-file-warning("feedback"); | ||
|
|
||
| @import "index"; |
7 changes: 7 additions & 0 deletions
7
packages/govuk-frontend/src/govuk/components/feedback/_index.import.scss
This file contains hidden or 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,7 @@ | ||
| @use "mixin"; | ||
|
|
||
| @import "../../base"; | ||
|
|
||
| @include govuk-exports("govuk/component/feedback") { | ||
| @include mixin.styles; | ||
| } |
4 changes: 4 additions & 0 deletions
4
packages/govuk-frontend/src/govuk/components/feedback/_index.scss
This file contains hidden or 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,4 @@ | ||
| @use "../../custom-properties"; | ||
| @use "mixin"; | ||
|
|
||
| @include mixin.styles; |
42 changes: 42 additions & 0 deletions
42
packages/govuk-frontend/src/govuk/components/feedback/_mixin.scss
This file contains hidden or 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,42 @@ | ||
| @use "../../base"; | ||
|
|
||
| /// @access private | ||
| @mixin styles { | ||
| .govuk-feedback { | ||
| box-sizing: border-box; | ||
| // Tie left/right padding to page gutter as it stretches across the whole | ||
| // screen on smaller screens | ||
| padding: base.govuk-spacing(4) base.$govuk-gutter-half base.govuk-spacing(5); | ||
| border-top: 1px solid; | ||
| border-color: base.govuk-functional-colour("brand"); | ||
| background-color: base.govuk-functional-colour("surface-background"); | ||
|
|
||
| @media #{base.govuk-from-breakpoint(tablet)} { | ||
| padding-right: base.govuk-spacing(4); | ||
| padding-left: base.govuk-spacing(4); | ||
| } | ||
|
|
||
| // Override $govuk-width-container's left and right margin as we want Feedback | ||
| // to go across the whole screen on smaller screens | ||
| @media #{base.govuk-until-breakpoint(tablet)} { | ||
| margin-right: 0; | ||
| margin-left: 0; | ||
| } | ||
| } | ||
|
|
||
| .govuk-feedback__title { | ||
| @include base.govuk-font($size: 24, $weight: bold); | ||
| margin-top: 0; | ||
| color: base.govuk-functional-colour(text); | ||
| @include base.govuk-responsive-margin(1, "bottom"); | ||
| } | ||
|
|
||
| // Removes the bottom margin from the final child element eg: a paragraph | ||
| // | ||
| // Feedback body doesn't have any opinions about typography. Instead we defer | ||
| // to users to use typography classes in their input, or apply a `govuk-body` | ||
| // paragraph for if users pass `text`. | ||
| .govuk-feedback__body > :last-child { | ||
| margin-bottom: 0; | ||
| } | ||
| } | ||
28 changes: 28 additions & 0 deletions
28
packages/govuk-frontend/src/govuk/components/feedback/accessibility.puppeteer.test.mjs
This file contains hidden or 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,28 @@ | ||
| import { axe, render } from '@govuk-frontend/helpers/puppeteer' | ||
| import { getExamples } from '@govuk-frontend/lib/components' | ||
|
|
||
| describe('/components/feedback', () => { | ||
| let axeRules | ||
|
|
||
| beforeAll(() => { | ||
| axeRules = { | ||
| /** | ||
| * Ignore 'Element has insufficient color contrast' for WCAG Level AAA | ||
| * | ||
| * Affects links on 'surface background' functional colour | ||
| */ | ||
| 'color-contrast-enhanced': { enabled: false } | ||
| } | ||
| }) | ||
|
|
||
| describe('component examples', () => { | ||
| it('passes accessibility tests', async () => { | ||
| const examples = await getExamples('feedback') | ||
|
|
||
| for (const exampleName in examples) { | ||
| await render(page, 'feedback', examples[exampleName]) | ||
| await expect(axe(page, axeRules)).resolves.toHaveNoViolations() | ||
| } | ||
| }, 120000) | ||
| }) | ||
| }) |
95 changes: 95 additions & 0 deletions
95
packages/govuk-frontend/src/govuk/components/feedback/feedback.yaml
This file contains hidden or 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,95 @@ | ||
| params: | ||
| - name: titleText | ||
| type: string | ||
| required: true | ||
| description: Text to use within the title of the Feedback component. If `titleHtml` is provided, the `titleText` option will be ignored. | ||
| - name: titleHtml | ||
| type: string | ||
| required: true | ||
| description: HTML to use within the title of the Feedback component. If `titleHtml` is provided, the `titleText` option will be ignored. | ||
| - name: headingLevel | ||
| type: integer | ||
| required: false | ||
| description: Heading level, from `1` to `6`. Default is `2`. | ||
| - name: text | ||
| type: string | ||
| required: true | ||
| description: Text to use within the Feedback component content. If `html` is provided, the `text` option will be ignored. | ||
| - name: html | ||
| type: string | ||
| required: true | ||
| description: HTML to use within the Feedback component content. If `html` is provided, the `text` option will be ignored. | ||
| - name: caller | ||
| type: nunjucks-block | ||
| required: false | ||
| description: Not strictly a parameter but a [Nunjucks code convention](https://mozilla.github.io/nunjucks/templating.html#call). Using a `call` block lets you 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'll need to wrap the entire Feedback component in a `call` block. | ||
| - name: classes | ||
| type: string | ||
| required: false | ||
| description: Classes to add to the Feedback component container. | ||
| - name: attributes | ||
| type: object | ||
| required: false | ||
| description: HTML attributes (for example, data attributes) to add to the Feedback component container. | ||
|
|
||
| examples: | ||
| - name: default | ||
|
owenatgov marked this conversation as resolved.
|
||
| screenshot: true | ||
| options: | ||
| titleText: Help us improve this service | ||
| html: | | ||
| <p class="govuk-body">Tell us about your experience using this service. <a href="#" class="govuk-link">Give us your feedback</a></p> | ||
|
|
||
| - name: silly example | ||
| description: In reality we'd recommend users only use the default example but this is to illustrate if a service team decides they want to add a lot of content | ||
| options: | ||
| titleText: Help us improve this service | ||
| html: | | ||
| <p class="govuk-body">Tell us about your experience using this service.</p> | ||
| <p class="govuk-body">Click this cool link to <a href="#" class="govuk-link">give us your feedback</a>.</p> | ||
| <p class="govuk-body">There's another paragraph here.</p> | ||
| <ul class="govuk-list govuk-list--bullet"> | ||
| <li>There is also a list</li> | ||
| <li>With items in</li> | ||
| <li>How strange!</li> | ||
| </ul> | ||
|
|
||
| # Hidden examples are not shown in the review app, but are used for tests and HTML fixtures | ||
| - name: html in title | ||
| hidden: true | ||
| options: | ||
| titleHtml: Help us improve this <em>cool</em> service | ||
| html: | | ||
| <p class="govuk-body">Tell us about your experience using this service. <a href="#" class="govuk-link">Give us your feedback</a></p> | ||
|
|
||
| - name: custom heading level | ||
| hidden: true | ||
| options: | ||
| titleText: Help us improve this service | ||
| headingLevel: 3 | ||
| html: | | ||
| <p class="govuk-body">Tell us about your experience using this service. <a href="#" class="govuk-link">Give us your feedback</a></p> | ||
|
|
||
| - name: html in text options | ||
| hidden: true | ||
| options: | ||
| titleText: Help us improve this <em>cool</em> service | ||
| text: Tell us about your experience using this <em>cool</em> service | ||
|
|
||
| - name: classes | ||
| hidden: true | ||
| options: | ||
| titleText: Help us improve this service | ||
| html: | | ||
| <p class="govuk-body">Tell us about your experience using this service. <a href="#" class="govuk-link">Give us your feedback</a></p> | ||
| classes: my-first-class my-second-class | ||
|
|
||
| - name: attributes | ||
| hidden: true | ||
| options: | ||
| titleText: Help us improve this service | ||
| html: | | ||
| <p class="govuk-body">Tell us about your experience using this service. <a href="#" class="govuk-link">Give us your feedback</a></p> | ||
| attributes: | ||
| first-attribute: first | ||
| second-attribute: second | ||
3 changes: 3 additions & 0 deletions
3
packages/govuk-frontend/src/govuk/components/feedback/macro.njk
This file contains hidden or 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 govukFeedback(params) %} | ||
| {%- include "./template.njk" -%} | ||
| {% endmacro %} |
24 changes: 24 additions & 0 deletions
24
packages/govuk-frontend/src/govuk/components/feedback/template.njk
This file contains hidden or 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,24 @@ | ||
| {% from "../../macros/attributes.njk" import govukAttributes -%} | ||
|
|
||
| {% set headingLevel = params.headingLevel if params.headingLevel else 2 -%} | ||
|
|
||
| <div class="govuk-feedback govuk-width-container {%- if params.classes %} {{ params.classes }}{% endif %}" {{- govukAttributes(params.attributes) }}> | ||
| <div class="govuk-grid-row"> | ||
| <div class="govuk-grid-column-two-thirds"> | ||
| <h{{ headingLevel }} class="govuk-feedback__title"> | ||
| {{ params.titleHtml | safe if params.titleHtml else params.titleText }} | ||
| </h{{ headingLevel }}> | ||
| {% if caller or params.html or params.text %} | ||
| <div class="govuk-feedback__body"> | ||
| {% if caller or params.html %} | ||
| {{ caller() if caller else params.html | safe | trim | indent(4) }} | ||
| {% elif params.text %} | ||
| <p class="govuk-body"> | ||
| {{ params.text | trim | indent(6) }} | ||
| </p> | ||
| {% endif %} | ||
| </div> | ||
| {% endif %} | ||
| </div> | ||
| </div> | ||
| </div> |
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.
Uh oh!
There was an error while loading. Please reload this page.