From 49bb4c5a353ced196e1eae1be8fd7b4980d2eea0 Mon Sep 17 00:00:00 2001 From: Frankie Roberto Date: Mon, 11 Nov 2024 00:40:35 +0000 Subject: [PATCH] Makes the code example an exported component Also changed the design to match the one used by the GOV.UK Design System website, so no longer dependent upon the Tabs component. --- docs/_components/example/_example.scss | 33 ---- docs/_components/example/template.njk | 38 ----- docs/_layouts/sub-navigation.njk | 6 +- docs/assets/application.scss | 1 - docs/autocomplete.md | 26 +++- docs/code-example.md | 72 +++++++++ docs/examples/code-example-output.njk | 6 + docs/examples/code-example.njk | 37 +++++ docs/masthead.md | 73 ++++++++- docs/primary-navigation.md | 71 ++++++++- docs/related-navigation.md | 26 +++- docs/secondary-navigation.md | 51 ++++++- docs/sub-navigation.md | 26 +++- eleventy.config.mjs | 2 +- govuk-prototype-kit.config.json | 4 + x-govuk/all.js | 142 +++++++++++++++--- x-govuk/all.mjs | 9 +- x-govuk/components/_all.scss | 1 + x-govuk/components/example/_example.scss | 86 +++++++++++ x-govuk/components/example/example.js | 60 ++++++++ .../components}/example/macro.njk | 2 +- x-govuk/components/example/template.njk | 23 +++ 22 files changed, 661 insertions(+), 134 deletions(-) delete mode 100644 docs/_components/example/_example.scss delete mode 100644 docs/_components/example/template.njk create mode 100644 docs/code-example.md create mode 100644 docs/examples/code-example-output.njk create mode 100644 docs/examples/code-example.njk create mode 100644 x-govuk/components/example/_example.scss create mode 100644 x-govuk/components/example/example.js rename {docs/_components => x-govuk/components}/example/macro.njk (59%) create mode 100644 x-govuk/components/example/template.njk diff --git a/docs/_components/example/_example.scss b/docs/_components/example/_example.scss deleted file mode 100644 index 954bebe..0000000 --- a/docs/_components/example/_example.scss +++ /dev/null @@ -1,33 +0,0 @@ -.app-example__frame { - background: govuk-colour("white"); - border: 0; - border-right: 1px solid $govuk-border-colour; - display: block; - max-width: calc(100% - govuk-spacing(4) * 2); - padding: govuk-spacing(4); - resize: both; - width: 100%; -} - -.app-example__new-window { - @include govuk-font($size: 16); -} - -.app-example__tabs { - .govuk-tabs__panel[id$="-preview"] { - background: govuk-colour("light-grey"); - padding: 0; - } - - .x-govuk-code { - margin: 0; - } -} - -// stylelint-disable declaration-no-important -.app-example__toolbar { - background: $govuk-body-background-colour; - border-top: 1px solid $govuk-border-colour; - max-width: initial !important; - padding: govuk-spacing(2); -} diff --git a/docs/_components/example/template.njk b/docs/_components/example/template.njk deleted file mode 100644 index 7881e64..0000000 --- a/docs/_components/example/template.njk +++ /dev/null @@ -1,38 +0,0 @@ -{%- from "govuk/components/tabs/macro.njk" import govukTabs -%} - -{%- set examplePath = "/examples/" + params.example -%} - -
-

- Contents -

- - -
- {{ getHtmlCode(params.example) }} -
-
- {{ getNunjucksCode(params.example) }} -
-
\ No newline at end of file diff --git a/docs/_layouts/sub-navigation.njk b/docs/_layouts/sub-navigation.njk index c693411..169dccc 100644 --- a/docs/_layouts/sub-navigation.njk +++ b/docs/_layouts/sub-navigation.njk @@ -3,6 +3,10 @@ {% block scripts %} + + {% endblock %} diff --git a/docs/assets/application.scss b/docs/assets/application.scss index ea5026b..c665484 100644 --- a/docs/assets/application.scss +++ b/docs/assets/application.scss @@ -1,5 +1,4 @@ @import "govuk-frontend/dist/govuk/base"; -@import "../_components/example/example"; @media screen and (min-width: 800px) { .app-prose-scope .govuk-table:not([tabindex]) { diff --git a/docs/autocomplete.md b/docs/autocomplete.md index 48faadc..9f76ff4 100644 --- a/docs/autocomplete.md +++ b/docs/autocomplete.md @@ -4,11 +4,29 @@ order: 3 title: Autocomplete description: Help users find and select from a number of options. --- +{% from "example/macro.njk" import xGovukExample %} -{% from "example/macro.njk" import appExample %} - -{{ appExample({ - example: "autocomplete" +{{ xGovukExample({ + idPrefix: "autocomplete", + previewPath: "/examples/autocomplete", + codeSamples: [ + { + label: { + text: "HTML" + }, + content: { + html: getHtmlCode("autocomplete") + } + }, + { + label: { + text: "Nunjucks" + }, + content: { + html: getNunjucksCode("autocomplete") + } + } + ] }) }} This component implements the [Accessible autocomplete pattern](https://github.com/alphagov/accessible-autocomplete) to enhance a fixed list of options provided by a `