GithubHelp home page GithubHelp logo

x-govuk / govuk-decorated-components Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 714 KB

Form components for the GOV.UK Design System that require less parameters to collect data.

Home Page: https://x-govuk.github.io/govuk-prototype-rig/using-data/form-components/

License: MIT License

JavaScript 83.76% Nunjucks 16.24%
components design-system govuk prototyping

govuk-decorated-components's Introduction

GOV.UK Decorated Components · test

Form components for the GOV.UK Design System that require less parameters to collect data. Replace the multiple parameters needed for saving data with a single decorate parameter.

Requirements

Node.js v16 or later.

Installation

Note These components are included by default with the GOV.UK Prototype Rig.

npm install govuk-decorated-components --save

Usage

To add them to the GOV.UK Prototype Kit, follow these steps:

  1. Add /node_modules/govuk-decorated-components to your application’s views (appViews) in server.js:

      // Set up App
      var appViews = extensions.getAppViews([
    +   path.join(projectDir, '/node_modules/govuk-decorated-components'),
        path.join(projectDir, '/app/views/'),
        path.join(projectDir, '/lib/')
      ])
  2. Add the decorate global function to your Nunjucks environment (nunjucksAppEnv) in server.js:

      var nunjucksAppEnv = nunjucks.configure(appViews, nunjucksConfig)
    
      // Add Nunjucks Globals
    + const { decorate } = require('govuk-decorated-components')
    + nunjucksAppEnv.addGlobal('decorate', decorate)
    
      // Add Nunjucks filters
      utils.addNunjucksFilters(nunjucksAppEnv)
  3. Replace imported GOV.UK Frontend macros with those provided by this package:

    - {% from "govuk/components/button/macro.njk" import govukButton %}
    + {% from "x-govuk/decorated/button/macro.njk" import govukButton with context %}
    - {% from "govuk/components/character-count/macro.njk" import govukCharacterCount %}
    + {% from "x-govuk/decorated/character-count/macro.njk" import govukCharacterCount with context %}
    - {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %}
    + {% from "x-govuk/decorated/checkboxes/macro.njk" import govukCheckboxes with context %}
    - {% from "govuk/components/date-input/macro.njk" import govukDateInput %}
    + {% from "x-govuk/decorated/date-input/macro.njk" import govukDateInput with context %}
    - {% from "govuk/components/file-upload/macro.njk" import govukFileUpload %}
    + {% from "x-govuk/decorated/file-upload/macro.njk" import govukFileUpload with context %}
    - {% from "govuk/components/input/macro.njk" import govukInput %}
    + {% from "x-govuk/decorated/input/macro.njk" import govukInput with context %}
    - {% from "govuk/components/radios/macro.njk" import govukRadios %}
    + {% from "x-govuk/decorated/radios/macro.njk" import govukRadios with context %}
    - {% from "govuk/components/select/macro.njk" import govukSelect %}
    + {% from "x-govuk/decorated/select/macro.njk" import govukSelect with context %}
    - {% from "govuk/components/textarea/macro.njk" import govukTextarea %}
    + {% from "x-govuk/decorated/textarea/macro.njk" import govukTextarea with context %}

govuk-decorated-components's People

Contributors

paulrobertlloyd avatar fofr avatar

Watchers

Silas Landricombe avatar

govuk-decorated-components's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.