-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example demonstrating the SupportError in the browser
- Loading branch information
1 parent
dc1d5c9
commit 7f4defd
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/govuk-frontend-review/src/views/examples/javascript-errors/index.njk
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,40 @@ | ||
{% extends "layouts/layout.njk" %} | ||
|
||
{% from "govuk/components/back-link/macro.njk" import govukBackLink %} | ||
{% from "govuk/components/character-count/macro.njk" import govukCharacterCount %} | ||
|
||
{% block beforeContent %} | ||
{{ govukBackLink({ | ||
href: "/" | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h1 class="govuk-heading-l">JavaScript errors</h1> | ||
<p class="govuk-body-lead"> | ||
Open your <a class="govuk-link" href="https://developer.mozilla.org/en-US/docs/Web/API/console#see_also">brower's console</a> | ||
to witness the error thrown in browsers where GOV.UK Frontend is not supported. | ||
</p> | ||
{{ govukCharacterCount({ | ||
label: { | ||
text: "Any other comment" | ||
}, | ||
id: "some-content", | ||
name: "some-content" | ||
})}} | ||
{% endblock %} | ||
|
||
{% block bodyEnd %} | ||
|
||
<script type="module" src="/javascripts/govuk-frontend.min.js"></script> | ||
|
||
<script type="module"> | ||
import { Accordion } from '/javascripts/govuk-frontend.min.js' | ||
// Simulate GOV.UK Frontend not being supported | ||
document.body.classList.remove('govuk-frontend-supported') | ||
// We don't want to use `initAll` as it returns early if govuk-frontend is not supported | ||
const $element = document.querySelector('[data-module="govuk-character-count"]') | ||
new Accordion($element) | ||
</script> | ||
{% endblock %} |