govuk-components 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -27
- data/app/components/govuk_component/base.rb +2 -2
- data/lib/govuk/components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca6bbedcd46abb76a978275beaf7952aa821078902f8c431dd3feebceeb48de2
|
4
|
+
data.tar.gz: f6e16eadbada45dcd58e87b7b299aeafcef1466dddadff36ce966b410dc708c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83f92b4bc426ed547e001d0b014e6b43742336f3ec8cd9f5feccf9b88b9bdf38718dcc10046727aab3f1b8e2c435615a22eb76baef1cccb5b4a53bf088ec2aaf
|
7
|
+
data.tar.gz: 874f9ad8b165be4816e53b03a1e0f513a1c8672635fcdc81c44c7e9cc71095caa1090b9550b74fa995276eaf2faeeb567137808640cdb9475938c7afb90af446
|
data/README.md
CHANGED
@@ -1,45 +1,63 @@
|
|
1
|
-
|
1
|
+
**This gem is under heavy development and the API is likely to change.**
|
2
2
|
|
3
3
|
# GOV.UK Components
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.com/DFE-Digital/govuk-components.svg?branch=master)](https://travis-ci.com/DFE-Digital/govuk-components)
|
6
6
|
|
7
|
-
This gem provides a suite of reusable components for the [GOV.UK Design System](https://design-system.service.gov.uk/). It is intended to provide a lightweight alternative to the [GOV.UK Publishing Components](https://github.com/alphagov/govuk_publishing_components) library and is built with Github's [ViewComponent](https://github.com/github/view_component) framework. ViewComponent
|
7
|
+
This gem provides a suite of reusable components for the [GOV.UK Design System](https://design-system.service.gov.uk/). It is intended to provide a lightweight alternative to the [GOV.UK Publishing Components](https://github.com/alphagov/govuk_publishing_components) library and is built with Github's [ViewComponent](https://github.com/github/view_component) framework. ViewComponent will be [supported natively in Rails 6.1](https://edgeguides.rubyonrails.org/layouts_and_rendering.html#rendering-objects).
|
8
8
|
|
9
9
|
## What's included
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
* Tag ✔️
|
28
|
-
* Warning text ✔️
|
11
|
+
| Component name | Helper |
|
12
|
+
| -------------- | ------ |
|
13
|
+
| [Accordion](app/components/govuk_component/accordion.rb) | `govuk_accordion` |
|
14
|
+
| [Back link](app/components/govuk_component/back_link.rb) | `govuk_back_link` |
|
15
|
+
| [Breadcrumbs](app/components/govuk_component/breadcrumbs.rb) | `govuk_breadcrumbs` |
|
16
|
+
| [Details](app/components/govuk_component/details.rb) | `govuk_details` |
|
17
|
+
| [Footer](app/components/govuk_component/footer.rb) | `govuk_footer` |
|
18
|
+
| [Header](app/components/govuk_component/header.rb) | `govuk_header` |
|
19
|
+
| [Inset text](app/components/govuk_component/inset_text.rb) | `govuk_inset_text` |
|
20
|
+
| [Panel](app/components/govuk_component/panel.rb) | `govuk_panel` |
|
21
|
+
| [Phase banner](app/components/govuk_component/phase_banner.rb) | `govuk_phase_banner` |
|
22
|
+
| [Start now button](app/components/govuk_component/start_now_button.rb) | `govuk_start_now_button` |
|
23
|
+
| [Summary list](app/components/govuk_component/summary_list.rb) | `govuk_summary_list` |
|
24
|
+
| [Tabs](app/components/govuk_component/tabs.rb) | `govuk_tabs` |
|
25
|
+
| [Tag](app/components/govuk_component/tag.rb) | `govuk_tag` |
|
26
|
+
| [Warning text](app/components/govuk_component/warning.rb) | `govuk_warning` |
|
29
27
|
|
30
28
|
### Helpers
|
31
29
|
|
32
|
-
* `#govuk_link_to`
|
33
|
-
* `#govuk_mail_to`
|
34
|
-
* `#govuk_button_to`
|
35
|
-
* `#govuk_back_to_top_link`
|
36
|
-
*
|
30
|
+
* `#govuk_link_to`
|
31
|
+
* `#govuk_mail_to`
|
32
|
+
* `#govuk_button_to`
|
33
|
+
* `#govuk_back_to_top_link`
|
34
|
+
* `#govuk_skip_link`
|
35
|
+
|
36
|
+
## Example use
|
37
|
+
|
38
|
+
This library allows components to be rendered with Rails' `render` method or via the provided helpers. Here we'll use the `govuk_accordion` to render an accordion.
|
39
|
+
|
40
|
+
```erb
|
41
|
+
<%= govuk_accordion(id: 'def234') do |accordion| %>
|
42
|
+
<%= accordion.add_section(title: 'Section 1') do %>
|
43
|
+
<p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
44
|
+
<% end %>
|
45
|
+
<%= accordion.add_section(title: 'Section 2') do %>
|
46
|
+
<p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
47
|
+
<% end %>
|
48
|
+
<%= accordion.add_section(title: 'Section 3') do %>
|
49
|
+
<p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
50
|
+
<% end %>
|
51
|
+
<% end %>
|
52
|
+
```
|
53
|
+
|
54
|
+
Here is the rendered accordion.
|
37
55
|
|
38
|
-
|
56
|
+
![Accordion preview](docs/images/accordion.png)
|
39
57
|
|
40
58
|
For examples on usage see the [guide page](https://dfe-digital.github.io/govuk-components/).
|
41
59
|
|
42
|
-
##
|
60
|
+
## Setup
|
43
61
|
|
44
62
|
Add this line to your `config/application.rb`:
|
45
63
|
|
@@ -7,10 +7,10 @@ class GovukComponent::Base < ViewComponent::Base
|
|
7
7
|
@html_attributes = html_attributes
|
8
8
|
end
|
9
9
|
|
10
|
-
# Redirect #
|
10
|
+
# Redirect #add_name to #slot(:name) to make building components
|
11
11
|
# with slots feel more DSL-like
|
12
12
|
def self.wrap_slot(name)
|
13
|
-
define_method(name) do |*args, **kwargs, &block|
|
13
|
+
define_method(%(add_#{name})) do |*args, **kwargs, &block|
|
14
14
|
self.slot(name, *args, **kwargs, &block)
|
15
15
|
end
|
16
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk-components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DfE developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|