GOV.UK Publishing Components is a Ruby gem to document and distribute components for GOV.UK applications.
It provides:
- a shared library of components
- helpers to generate component payloads
- an application to preview components and provide guidance
Components should be added to this gem if they are required in more than one application, otherwise they should be added to that application.
How to
- Install and use this gem
- Use a component in your application
- Generate a new component
- Develop a component
- Run the component guide
- Move a component from an application to the gem
- Publish/release a new version of the gem
- Keep this gem in sync with the Design System
Architecture / structure
There are 2 types of helper classes in this app:
- AppHelpers. Are exposed to the applications using this gem. They should be documented using RDoc.
- Component Presenters. Anything in these classes is only for use within the components. They should be marked
@private
.
Relationship with GOV.UK Design System
GOV.UK Publishing Components also makes GOV.UK Design System styles and components available to GOV.UK's frontend applications. This gem consumes GOV.UK Frontend via Yarn.
Browser and assistive technology support
GOV.UK Publishing Components shares the same standards in terms of browser and assistive technology support with GOV.UK Frontend.
Documentation
See the rubydoc.info documentation
Working locally
Install dependencies
As well as the Ruby, you will also need the Yarn package manager to allow installing npm dependencies.
Install the application's dependencies with:
bundle install
yarn install
Running a local app with a local gem
The GDS Developer Docs has a guide on local frontend development that covers setting up a local app to use the local version of the components gem in Docker and using the ./startup.sh
script.
Running tests
The default rake task runs all the linting and test tasks:
bin/rake
Javascript is tested using Jasmine and the Jasmine gem. Tests can be run either in the browser or on the command line via the dummy app’s tasks:
# browser
bin/rake app:jasmine
# command line
bin/rake app:jasmine:ci
Viewing the component guide
View the component guide in your browser with:
./startup.sh
The guide should be available at http://localhost:3212
View documentation
Preview documentation in your browser with:
bundle exec yard server --reload