design_system 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/assets/stylesheets/design_system/_hljs.scss +131 -0
- data/app/assets/stylesheets/design_system/govuk.scss +43 -0
- data/app/assets/stylesheets/design_system/nhsuk.scss +55 -0
- data/app/components/design_system/base_component.rb +21 -0
- data/app/components/design_system/generic/action_link_component.rb +17 -0
- data/app/components/design_system/generic/alert_component.rb +25 -0
- data/app/components/design_system/generic/breadcrumbs_component.rb +18 -0
- data/app/components/design_system/generic/button_component.rb +51 -0
- data/app/components/design_system/generic/callout_component.html.erb +8 -0
- data/app/components/design_system/generic/callout_component.rb +15 -0
- data/app/components/design_system/generic/details_component.html.erb +4 -0
- data/app/components/design_system/generic/details_component.rb +13 -0
- data/app/components/design_system/generic/grid_component.html.erb +5 -0
- data/app/components/design_system/generic/grid_component.rb +31 -0
- data/app/components/design_system/generic/heading_component.rb +41 -0
- data/app/components/design_system/generic/inset_text_component.html.erb +1 -0
- data/app/components/design_system/generic/inset_text_component.rb +24 -0
- data/app/components/design_system/generic/link_component.rb +51 -0
- data/app/components/design_system/generic/list_component.html.erb +7 -0
- data/app/components/design_system/generic/list_component.rb +26 -0
- data/app/components/design_system/generic/notification_component.html.erb +15 -0
- data/app/components/design_system/generic/notification_component.rb +39 -0
- data/app/components/design_system/generic/panel_component.html.erb +4 -0
- data/app/components/design_system/generic/panel_component.rb +18 -0
- data/app/components/design_system/generic/paragraph_component.rb +46 -0
- data/app/components/design_system/generic/start_button_component.html.erb +4 -0
- data/app/components/design_system/generic/start_button_component.rb +17 -0
- data/app/components/design_system/generic/summary_card_component.html.erb +15 -0
- data/app/components/design_system/generic/summary_card_component.rb +40 -0
- data/app/components/design_system/generic/summary_list_component.html.erb +21 -0
- data/app/components/design_system/generic/summary_list_component.rb +59 -0
- data/app/components/design_system/generic/tab_component.html.erb +21 -0
- data/app/components/design_system/generic/tab_component.rb +14 -0
- data/app/components/design_system/generic/table_component.rb +46 -0
- data/app/components/design_system/govuk/action_link_component.html.erb +1 -0
- data/app/components/design_system/govuk/action_link_component.rb +8 -0
- data/app/components/design_system/govuk/alert_component.rb +6 -0
- data/app/components/design_system/govuk/breadcrumbs_component.html.erb +11 -0
- data/app/components/design_system/govuk/breadcrumbs_component.rb +7 -0
- data/app/components/design_system/govuk/button_component.rb +6 -0
- data/app/components/design_system/govuk/callout_component.html.erb +6 -0
- data/app/components/design_system/govuk/callout_component.rb +6 -0
- data/app/components/design_system/govuk/details_component.rb +6 -0
- data/app/components/design_system/govuk/grid_component.rb +6 -0
- data/app/components/design_system/govuk/heading_component.rb +6 -0
- data/app/components/design_system/govuk/inset_text_component.rb +6 -0
- data/app/components/design_system/govuk/link_component.rb +17 -0
- data/app/components/design_system/govuk/list_component.rb +6 -0
- data/app/components/design_system/govuk/notification_component.rb +6 -0
- data/app/components/design_system/govuk/panel_component.rb +10 -0
- data/app/components/design_system/govuk/paragraph_component.rb +6 -0
- data/app/components/design_system/govuk/start_button_component.rb +6 -0
- data/app/components/design_system/govuk/summary_card_component.html.erb +15 -0
- data/app/components/design_system/govuk/summary_card_component.rb +13 -0
- data/app/components/design_system/govuk/summary_list_component.rb +6 -0
- data/app/components/design_system/govuk/tab_component.rb +6 -0
- data/app/components/design_system/govuk/table_component.html.erb +30 -0
- data/app/components/design_system/govuk/table_component.rb +6 -0
- data/app/components/design_system/nhsuk/action_link_component.html.erb +7 -0
- data/app/components/design_system/nhsuk/action_link_component.rb +7 -0
- data/app/components/design_system/nhsuk/alert_component.rb +6 -0
- data/app/components/design_system/nhsuk/breadcrumbs_component.html.erb +16 -0
- data/app/components/design_system/nhsuk/breadcrumbs_component.rb +7 -0
- data/app/components/design_system/nhsuk/button_component.rb +6 -0
- data/app/components/design_system/nhsuk/callout_component.rb +6 -0
- data/app/components/design_system/nhsuk/details_component.rb +6 -0
- data/app/components/design_system/nhsuk/grid_component.rb +6 -0
- data/app/components/design_system/nhsuk/heading_component.rb +6 -0
- data/app/components/design_system/nhsuk/inset_text_component.html.erb +4 -0
- data/app/components/design_system/nhsuk/inset_text_component.rb +6 -0
- data/app/components/design_system/nhsuk/link_component.rb +17 -0
- data/app/components/design_system/nhsuk/list_component.rb +6 -0
- data/app/components/design_system/nhsuk/notification_component.rb +6 -0
- data/app/components/design_system/nhsuk/panel_component.rb +6 -0
- data/app/components/design_system/nhsuk/paragraph_component.rb +6 -0
- data/app/components/design_system/nhsuk/start_button_component.rb +6 -0
- data/app/components/design_system/nhsuk/summary_card_component.rb +6 -0
- data/app/components/design_system/nhsuk/summary_list_component.rb +19 -0
- data/app/components/design_system/nhsuk/tab_component.rb +6 -0
- data/app/components/design_system/nhsuk/table_component.html.erb +43 -0
- data/app/components/design_system/nhsuk/table_component.rb +6 -0
- data/app/controllers/concerns/design_system/branded.rb +6 -0
- data/app/helpers/design_system_helper.rb +65 -27
- data/app/javascript/design_system/controllers/clipboard_controller.js +41 -0
- data/app/javascript/design_system/controllers/code_highlight_controller.js +9 -0
- data/app/javascript/design_system/controllers/hello_world_controller.js +6 -0
- data/app/javascript/design_system/index.js +4 -0
- data/app/views/layouts/govuk/application.html.erb +20 -7
- data/app/views/layouts/nhsuk/application.html.erb +10 -7
- data/lib/design_system/brand_derivable.rb +9 -0
- data/lib/design_system/engine.rb +1 -0
- data/lib/design_system/generic/builders/base.rb +1 -1
- data/lib/design_system/generic/builders/code.rb +23 -0
- data/lib/design_system/generic/builders/elements/breadcrumbs.rb +4 -24
- data/lib/design_system/generic/builders/elements/headings.rb +3 -2
- data/lib/design_system/generic/builders/pagination_renderer.rb +5 -4
- data/lib/design_system/generic.rb +1 -14
- data/lib/design_system/govuk/builders/code.rb +11 -0
- data/lib/design_system/govuk/builders/fixed_elements.rb +0 -1
- data/lib/design_system/govuk.rb +1 -12
- data/lib/design_system/nhsuk/builders/code.rb +11 -0
- data/lib/design_system/nhsuk/builders/fixed_elements.rb +0 -1
- data/lib/design_system/nhsuk.rb +1 -12
- data/lib/design_system/registry.rb +19 -1
- data/lib/design_system/version.rb +1 -1
- data/public/design_system/static/design_system-0.15.0/design_system.js +53150 -0
- metadata +101 -50
- data/lib/design_system/generic/builders/action_link.rb +0 -17
- data/lib/design_system/generic/builders/button.rb +0 -33
- data/lib/design_system/generic/builders/callout.rb +0 -28
- data/lib/design_system/generic/builders/concerns/brand_derivable.rb +0 -14
- data/lib/design_system/generic/builders/details.rb +0 -30
- data/lib/design_system/generic/builders/grid.rb +0 -44
- data/lib/design_system/generic/builders/heading.rb +0 -38
- data/lib/design_system/generic/builders/inset_text.rb +0 -18
- data/lib/design_system/generic/builders/link.rb +0 -44
- data/lib/design_system/generic/builders/list.rb +0 -41
- data/lib/design_system/generic/builders/notification.rb +0 -81
- data/lib/design_system/generic/builders/panel.rb +0 -18
- data/lib/design_system/generic/builders/paragraph.rb +0 -28
- data/lib/design_system/generic/builders/summary_list.rb +0 -89
- data/lib/design_system/generic/builders/tab.rb +0 -14
- data/lib/design_system/generic/builders/table.rb +0 -73
- data/lib/design_system/govuk/builders/action_link.rb +0 -17
- data/lib/design_system/govuk/builders/button.rb +0 -55
- data/lib/design_system/govuk/builders/callout.rb +0 -26
- data/lib/design_system/govuk/builders/details.rb +0 -10
- data/lib/design_system/govuk/builders/elements/breadcrumbs.rb +0 -33
- data/lib/design_system/govuk/builders/grid.rb +0 -12
- data/lib/design_system/govuk/builders/heading.rb +0 -11
- data/lib/design_system/govuk/builders/inset_text.rb +0 -11
- data/lib/design_system/govuk/builders/link.rb +0 -21
- data/lib/design_system/govuk/builders/list.rb +0 -11
- data/lib/design_system/govuk/builders/notification.rb +0 -11
- data/lib/design_system/govuk/builders/panel.rb +0 -18
- data/lib/design_system/govuk/builders/paragraph.rb +0 -11
- data/lib/design_system/govuk/builders/summary_list.rb +0 -32
- data/lib/design_system/govuk/builders/tab.rb +0 -54
- data/lib/design_system/govuk/builders/table.rb +0 -77
- data/lib/design_system/nhsuk/builders/action_link.rb +0 -30
- data/lib/design_system/nhsuk/builders/button.rb +0 -11
- data/lib/design_system/nhsuk/builders/callout.rb +0 -11
- data/lib/design_system/nhsuk/builders/details.rb +0 -10
- data/lib/design_system/nhsuk/builders/elements/breadcrumbs.rb +0 -43
- data/lib/design_system/nhsuk/builders/grid.rb +0 -12
- data/lib/design_system/nhsuk/builders/heading.rb +0 -11
- data/lib/design_system/nhsuk/builders/inset_text.rb +0 -23
- data/lib/design_system/nhsuk/builders/link.rb +0 -21
- data/lib/design_system/nhsuk/builders/list.rb +0 -11
- data/lib/design_system/nhsuk/builders/notification.rb +0 -11
- data/lib/design_system/nhsuk/builders/panel.rb +0 -11
- data/lib/design_system/nhsuk/builders/paragraph.rb +0 -11
- data/lib/design_system/nhsuk/builders/summary_list.rb +0 -18
- data/lib/design_system/nhsuk/builders/tab.rb +0 -11
- data/lib/design_system/nhsuk/builders/table.rb +0 -68
- data/public/design_system/static/design_system-0.14.0/design_system.js +0 -1309
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6ffd3715e56a0bdbf5169f22b8a92d447d81456eb17ee4adca169ea93bef15b
|
|
4
|
+
data.tar.gz: a9bb7ce82452b0f5234bd881b621a3725b6f63e001857e7488d023e3d4a8b738
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f76049549af4966a711a2f682cfb4a8c26e6b962b7464a3bd36c8d1c08e0ef7ed66fd4419c0f04803951b06899b358b2a2928564c80661cc3c34952a9ab3a981
|
|
7
|
+
data.tar.gz: 56dca56f40804c948db79fb49c66d5bc889317390b04c848a01efa9e368f00589b15e267eff2341cecbaaed65ea5d8a05826b65ee93bed421f1fac2be3958034
|
data/README.md
CHANGED
|
@@ -50,7 +50,7 @@ registerControllers(application)
|
|
|
50
50
|
|
|
51
51
|
## Updating Frontends
|
|
52
52
|
|
|
53
|
-
### GOVUK Frontend (currently v5.
|
|
53
|
+
### GOVUK Frontend (currently v5.11.1)
|
|
54
54
|
|
|
55
55
|
```bash
|
|
56
56
|
# Automatically fetch the latest
|
|
@@ -60,7 +60,7 @@ bundle exec rake app:make_govuk
|
|
|
60
60
|
bundle exec rake app:make_govuk\[5.9.0\]
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
### NHSUK Frontend (currently
|
|
63
|
+
### NHSUK Frontend (currently v10.3.1)
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
66
|
# Automatically fetch the latest
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
Theme: StackOverflow Light
|
|
3
|
+
Description: Light theme as used on stackoverflow.com
|
|
4
|
+
Author: stackoverflow.com
|
|
5
|
+
Maintainer: @Hirse
|
|
6
|
+
Website: https://github.com/StackExchange/Stacks
|
|
7
|
+
License: MIT
|
|
8
|
+
Updated: 2021-05-15
|
|
9
|
+
|
|
10
|
+
Updated for @stackoverflow/stacks v0.64.0
|
|
11
|
+
Code Blocks: /blob/v0.64.0/lib/css/components/_stacks-code-blocks.less
|
|
12
|
+
Colors: /blob/v0.64.0/lib/css/exports/_stacks-constants-colors.less
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
.hljs {
|
|
16
|
+
/* var(--highlight-color) */
|
|
17
|
+
color: #2f3337;
|
|
18
|
+
/* var(--highlight-bg) */
|
|
19
|
+
background: #f6f6f6;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.hljs-subst {
|
|
23
|
+
/* var(--highlight-color) */
|
|
24
|
+
color: #2f3337;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.hljs-comment {
|
|
28
|
+
/* var(--highlight-comment) */
|
|
29
|
+
color: #656e77;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.hljs-keyword,
|
|
33
|
+
.hljs-selector-tag,
|
|
34
|
+
.hljs-meta .hljs-keyword,
|
|
35
|
+
.hljs-doctag,
|
|
36
|
+
.hljs-section {
|
|
37
|
+
/* var(--highlight-keyword) */
|
|
38
|
+
color: #015692;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.hljs-attr {
|
|
42
|
+
/* var(--highlight-attribute); */
|
|
43
|
+
color: #015692;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.hljs-attribute {
|
|
47
|
+
/* var(--highlight-symbol) */
|
|
48
|
+
color: #803378;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.hljs-name,
|
|
52
|
+
.hljs-type,
|
|
53
|
+
.hljs-number,
|
|
54
|
+
.hljs-selector-id,
|
|
55
|
+
.hljs-quote,
|
|
56
|
+
.hljs-template-tag {
|
|
57
|
+
/* var(--highlight-namespace) */
|
|
58
|
+
color: #b25301;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.hljs-selector-class {
|
|
62
|
+
/* var(--highlight-keyword) */
|
|
63
|
+
color: #015692;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.hljs-string,
|
|
67
|
+
.hljs-regexp,
|
|
68
|
+
.hljs-symbol,
|
|
69
|
+
.hljs-variable,
|
|
70
|
+
.hljs-template-variable,
|
|
71
|
+
.hljs-link,
|
|
72
|
+
.hljs-selector-attr {
|
|
73
|
+
/* var(--highlight-variable) */
|
|
74
|
+
color: #54790d;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.hljs-meta,
|
|
78
|
+
.hljs-selector-pseudo {
|
|
79
|
+
/* var(--highlight-keyword) */
|
|
80
|
+
color: #015692;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.hljs-built_in,
|
|
84
|
+
.hljs-title,
|
|
85
|
+
.hljs-literal {
|
|
86
|
+
/* var(--highlight-literal) */
|
|
87
|
+
color: #b25301;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.hljs-bullet,
|
|
91
|
+
.hljs-code {
|
|
92
|
+
/* var(--highlight-punctuation) */
|
|
93
|
+
color: #535a60;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.hljs-meta .hljs-string {
|
|
97
|
+
/* var(--highlight-variable) */
|
|
98
|
+
color: #54790d;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.hljs-deletion {
|
|
102
|
+
/* var(--highlight-deletion) */
|
|
103
|
+
color: #c02d2e;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.hljs-addition {
|
|
107
|
+
/* var(--highlight-addition) */
|
|
108
|
+
color: #2f6f44;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.hljs-emphasis {
|
|
112
|
+
font-style: italic;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.hljs-strong {
|
|
116
|
+
font-weight: bold;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.hljs-formula,
|
|
120
|
+
.hljs-operator,
|
|
121
|
+
.hljs-params,
|
|
122
|
+
.hljs-property,
|
|
123
|
+
.hljs-punctuation,
|
|
124
|
+
.hljs-tag {
|
|
125
|
+
/* purposely ignored */
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
pre code.hljs {
|
|
129
|
+
display: block;
|
|
130
|
+
white-space: pre;
|
|
131
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
);
|
|
6
6
|
|
|
7
7
|
// Use extreme caution when making any design system level style changes or additions here.
|
|
8
|
+
@use 'hljs';
|
|
8
9
|
|
|
9
10
|
.app-header-layout {
|
|
10
11
|
display: flex;
|
|
@@ -67,3 +68,45 @@
|
|
|
67
68
|
border: none;
|
|
68
69
|
cursor: pointer;
|
|
69
70
|
}
|
|
71
|
+
|
|
72
|
+
.app-example__code {
|
|
73
|
+
background-color: #f6f6f6;
|
|
74
|
+
box-sizing: border-box;
|
|
75
|
+
max-width: 100%;
|
|
76
|
+
min-width: 0;
|
|
77
|
+
padding: 10px;
|
|
78
|
+
padding-top: 2.75rem;
|
|
79
|
+
position: relative;
|
|
80
|
+
width: 100%;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.app-example__scroll {
|
|
84
|
+
box-sizing: border-box;
|
|
85
|
+
width: 100%;
|
|
86
|
+
max-width: 100%;
|
|
87
|
+
min-width: 0;
|
|
88
|
+
overflow-x: auto;
|
|
89
|
+
overflow-y: auto;
|
|
90
|
+
padding: 0.5rem;
|
|
91
|
+
|
|
92
|
+
&:focus {
|
|
93
|
+
outline: 3px solid #fd0;
|
|
94
|
+
outline-offset: 2px;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.app-example__code pre {
|
|
99
|
+
margin: 0;
|
|
100
|
+
min-width: min-content;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.app-example__copy-button {
|
|
104
|
+
@extend .govuk-button;
|
|
105
|
+
@extend .govuk-button--inverse;
|
|
106
|
+
font-size: 0.875rem;
|
|
107
|
+
line-height: 1.25;
|
|
108
|
+
margin: 0;
|
|
109
|
+
position: absolute;
|
|
110
|
+
top: 0.5rem;
|
|
111
|
+
right: 0.5rem;
|
|
112
|
+
}
|
|
@@ -3,3 +3,58 @@
|
|
|
3
3
|
@use 'nhsuk-frontend-10.3.1/components';
|
|
4
4
|
|
|
5
5
|
// Use extreme caution when making any design system level style changes or additions here.
|
|
6
|
+
@use 'hljs';
|
|
7
|
+
|
|
8
|
+
// Code example block: fixed gray box, only __scroll + content scroll (like GOV.UK app-example).
|
|
9
|
+
.app-example__code {
|
|
10
|
+
background-color: #f0f4f5;
|
|
11
|
+
border: 4px solid transparent;
|
|
12
|
+
margin: -4px;
|
|
13
|
+
margin-bottom: 28px;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
max-width: 100%;
|
|
16
|
+
min-width: 0;
|
|
17
|
+
padding: 0;
|
|
18
|
+
padding-top: 2.75rem;
|
|
19
|
+
position: relative;
|
|
20
|
+
width: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.app-example__scroll {
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
width: 100%;
|
|
26
|
+
max-width: 100%;
|
|
27
|
+
min-width: 0;
|
|
28
|
+
overflow-x: auto;
|
|
29
|
+
overflow-y: auto;
|
|
30
|
+
padding: 0.5rem;
|
|
31
|
+
|
|
32
|
+
&:focus {
|
|
33
|
+
outline: 3px solid #fd0;
|
|
34
|
+
outline-offset: 2px;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.app-example__code pre {
|
|
39
|
+
margin: 0;
|
|
40
|
+
min-width: min-content;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.app-example__code pre code.hljs {
|
|
44
|
+
background: #f0f4f5;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.app-example__copy-button {
|
|
48
|
+
@extend .nhsuk-button;
|
|
49
|
+
@extend .nhsuk-button--secondary-solid;
|
|
50
|
+
@extend .nhsuk-button--small;
|
|
51
|
+
|
|
52
|
+
// Copy button positioning (based on NHS "code" button placement).
|
|
53
|
+
margin: 0;
|
|
54
|
+
margin-bottom: 4px;
|
|
55
|
+
position: absolute;
|
|
56
|
+
right: 16px;
|
|
57
|
+
top: 16px;
|
|
58
|
+
width: auto;
|
|
59
|
+
z-index: 1;
|
|
60
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module DesignSystem
|
|
2
|
+
# Base class for all design-system view components. Provides the brand
|
|
3
|
+
# derivation and shared CSS helpers.
|
|
4
|
+
#
|
|
5
|
+
# On the inheritance pattern (Brand::FooComponent < Generic::FooComponent):
|
|
6
|
+
# ViewComponent's docs recommend avoiding inheritance, but that guidance is
|
|
7
|
+
# aimed at typical application components, not multi-brand design systems.
|
|
8
|
+
# Here, Govuk::PanelComponent really is a specialization of the same
|
|
9
|
+
# conceptual panel as Nhsuk's, and ViewComponent's ancestor-walking template
|
|
10
|
+
# resolution lets Generic own the markup while brand classes override only
|
|
11
|
+
# what they need (e.g. an extra CSS modifier). The alternatives we weighed —
|
|
12
|
+
# one component with a `brand:` param, or sharing via a Concern — each trade
|
|
13
|
+
# more than they save: the param approach buries brand-specific behaviour in
|
|
14
|
+
# conditionals, and Concerns fight ViewComponent's sidecar-template model.
|
|
15
|
+
# We accept the occasional empty subclass in exchange for a uniform,
|
|
16
|
+
# predictable structure across the library.
|
|
17
|
+
class BaseComponent < ::ViewComponent::Base
|
|
18
|
+
include DesignSystem::BrandDerivable
|
|
19
|
+
include DesignSystem::Helpers::CssHelper
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module DesignSystem
|
|
2
|
+
module Generic
|
|
3
|
+
# Action links are calls-to-action signposting the start of a digital
|
|
4
|
+
# service. Implementation differs noticeably between brands so this is
|
|
5
|
+
# mostly a contract — both brand subclasses override `call`.
|
|
6
|
+
class ActionLinkComponent < DesignSystem::BaseComponent
|
|
7
|
+
def initialize(name = nil, options = nil, html_options = nil)
|
|
8
|
+
super()
|
|
9
|
+
@name = name
|
|
10
|
+
@options = options || {}
|
|
11
|
+
@html_options = html_options || {}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
attr_reader :name, :options, :html_options
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module DesignSystem
|
|
2
|
+
module Generic
|
|
3
|
+
# Error-summary alert rendered by ds_alert. Content comes from the message
|
|
4
|
+
# argument or a block.
|
|
5
|
+
class AlertComponent < DesignSystem::BaseComponent
|
|
6
|
+
def initialize(message = nil)
|
|
7
|
+
super()
|
|
8
|
+
@message = message
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call
|
|
12
|
+
content_tag(:div, class: "#{brand}-error-summary", 'aria-labelledby': 'error-summary-title',
|
|
13
|
+
role: 'alert', tabindex: '-1') do
|
|
14
|
+
content_tag(:h2, body, class: "#{brand}-error-summary__title", id: 'error-summary-title')
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def body
|
|
21
|
+
content.presence || @message
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module DesignSystem
|
|
2
|
+
module Generic
|
|
3
|
+
# Breadcrumb trail rendered into the :breadcrumbs content_for slot by the
|
|
4
|
+
# fixed-elements builder. Brands own the markup via their own templates.
|
|
5
|
+
class BreadcrumbsComponent < DesignSystem::BaseComponent
|
|
6
|
+
def initialize(breadcrumbs:)
|
|
7
|
+
super()
|
|
8
|
+
@breadcrumbs = breadcrumbs
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
attr_reader :breadcrumbs
|
|
12
|
+
|
|
13
|
+
def current_page_aria(breadcrumb)
|
|
14
|
+
helpers.current_page?(breadcrumb[:path]) ? 'page' : nil
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module DesignSystem
|
|
2
|
+
module Generic
|
|
3
|
+
# Submit button rendered by ds_button_tag. Brand subclasses add their
|
|
4
|
+
# button classes and style modifiers. Content can be supplied via the
|
|
5
|
+
# first argument or a block.
|
|
6
|
+
class ButtonComponent < DesignSystem::BaseComponent
|
|
7
|
+
def initialize(content_or_options = nil, options = nil)
|
|
8
|
+
super()
|
|
9
|
+
@content_or_options = content_or_options
|
|
10
|
+
@options = options
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
attr_reader :content_or_options, :options
|
|
14
|
+
|
|
15
|
+
def call
|
|
16
|
+
button_options = prep_button_options(content_or_options, options)
|
|
17
|
+
style = button_options.delete('style')
|
|
18
|
+
button_options['aria-disabled'] = true if button_options['disabled']
|
|
19
|
+
button_options = css_class_options_merge(button_options, ["#{brand}-button"]) do |classes|
|
|
20
|
+
style_class = style_class_hash[style]
|
|
21
|
+
classes << style_class if style_class
|
|
22
|
+
end
|
|
23
|
+
if content.present?
|
|
24
|
+
button_tag(button_options) { content }
|
|
25
|
+
else
|
|
26
|
+
button_tag(content_or_options, button_options)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def prep_button_options(content_or_options, options)
|
|
33
|
+
if content_or_options.is_a?(Hash)
|
|
34
|
+
options = content_or_options
|
|
35
|
+
else
|
|
36
|
+
options ||= {}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
{ 'data-module' => "#{brand}-button" }.merge!(options.stringify_keys)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def style_class_hash
|
|
43
|
+
{
|
|
44
|
+
'secondary' => "#{brand}-button--secondary",
|
|
45
|
+
'warning' => "#{brand}-button--warning",
|
|
46
|
+
'reverse' => "#{brand}-button--inverse"
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module DesignSystem
|
|
2
|
+
module Generic
|
|
3
|
+
# NHS-style warning callout: the GOV.UK brand renders a warning-text
|
|
4
|
+
# variant via its own subclass and template.
|
|
5
|
+
class CalloutComponent < DesignSystem::BaseComponent
|
|
6
|
+
def initialize(label:, body:)
|
|
7
|
+
super()
|
|
8
|
+
@label = label
|
|
9
|
+
@body = body
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
attr_reader :label, :body
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module DesignSystem
|
|
2
|
+
module Generic
|
|
3
|
+
# Disclosure widget rendered by ds_details.
|
|
4
|
+
class DetailsComponent < DesignSystem::BaseComponent
|
|
5
|
+
def initialize(summary_text)
|
|
6
|
+
super()
|
|
7
|
+
@summary_text = summary_text
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
attr_reader :summary_text
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module DesignSystem
|
|
2
|
+
module Generic
|
|
3
|
+
# Grid row rendered by ds_grid. Wraps columns whose widths map to the
|
|
4
|
+
# brand grid-column classes. The column widths are validated (total must
|
|
5
|
+
# not exceed 100%) when the component is built.
|
|
6
|
+
class GridComponent < DesignSystem::BaseComponent
|
|
7
|
+
def initialize(grid:, **options)
|
|
8
|
+
super()
|
|
9
|
+
@grid = grid
|
|
10
|
+
@options = options
|
|
11
|
+
@grid.validate_total_width!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
attr_reader :grid, :options
|
|
15
|
+
|
|
16
|
+
def row_options
|
|
17
|
+
css_class_options_merge(options, ["#{brand}-grid-row"])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def column_options(column)
|
|
21
|
+
css_class_options_merge(column[:options].dup, [grid_class(column[:width])])
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def grid_class(width)
|
|
27
|
+
"#{brand}-grid-column-#{::DesignSystem::Components::Grid::WIDTHS[width][:class]}"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module DesignSystem
|
|
2
|
+
module Generic
|
|
3
|
+
# Generic page heading. Brand subclasses inherit unchanged.
|
|
4
|
+
class HeadingComponent < DesignSystem::BaseComponent
|
|
5
|
+
SIZE_MAPPING = {
|
|
6
|
+
1 => 'xl',
|
|
7
|
+
2 => 'l',
|
|
8
|
+
3 => 'm',
|
|
9
|
+
4 => 's',
|
|
10
|
+
5 => 'xs',
|
|
11
|
+
6 => 'xs'
|
|
12
|
+
}.freeze
|
|
13
|
+
|
|
14
|
+
def initialize(text, level: 2, **options)
|
|
15
|
+
super()
|
|
16
|
+
@text = text
|
|
17
|
+
@level = level.to_i
|
|
18
|
+
@options = options
|
|
19
|
+
validate_level!
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
attr_reader :text, :level, :options
|
|
23
|
+
|
|
24
|
+
def call
|
|
25
|
+
content_tag("h#{level}", text, class: heading_class, **options)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def heading_class
|
|
31
|
+
"#{brand}-heading-#{SIZE_MAPPING[level]}"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def validate_level!
|
|
35
|
+
return if level.between?(1, 6)
|
|
36
|
+
|
|
37
|
+
raise ArgumentError, "Invalid heading level #{level}. Must be an integer between 1 and 6."
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= content_tag(:div, content || text, **inset_options) %>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module DesignSystem
|
|
2
|
+
module Generic
|
|
3
|
+
# Inset text used to differentiate a block of content from what surrounds
|
|
4
|
+
# it, rendered by ds_inset_text. Content comes from the `text` argument or
|
|
5
|
+
# a block (block wins if both are given). Renders nothing when blank.
|
|
6
|
+
class InsetTextComponent < DesignSystem::BaseComponent
|
|
7
|
+
def initialize(text: nil, **options)
|
|
8
|
+
super()
|
|
9
|
+
@text = text
|
|
10
|
+
@options = options
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
attr_reader :text, :options
|
|
14
|
+
|
|
15
|
+
def render?
|
|
16
|
+
text.present? || content.present?
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def inset_options
|
|
20
|
+
css_class_options_merge(options, ["#{brand}-inset-text"])
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module DesignSystem
|
|
2
|
+
module Generic
|
|
3
|
+
# Link (or button-styled link) rendered by ds_link_to. Mirrors the
|
|
4
|
+
# polymorphic Rails link_to signature: with a block the first argument is
|
|
5
|
+
# the URL, otherwise it is the link text. A :type option selects a
|
|
6
|
+
# button style (defined per brand). The link_context switches the default
|
|
7
|
+
# link class (e.g. inside a notification banner).
|
|
8
|
+
class LinkComponent < DesignSystem::BaseComponent
|
|
9
|
+
def initialize(name = nil, options = nil, html_options = nil, link_context: nil)
|
|
10
|
+
super()
|
|
11
|
+
@name = name
|
|
12
|
+
@options = options || {}
|
|
13
|
+
@html_options = html_options || {}
|
|
14
|
+
@link_context = link_context
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
attr_reader :name, :options, :html_options
|
|
18
|
+
|
|
19
|
+
def call
|
|
20
|
+
if content.present?
|
|
21
|
+
type = options.delete(:type)
|
|
22
|
+
options[:class] = prep_link_classes(type)
|
|
23
|
+
link_to(name, options, html_options) { content }
|
|
24
|
+
else
|
|
25
|
+
type = html_options.delete(:type)
|
|
26
|
+
html_options[:class] = prep_link_classes(type)
|
|
27
|
+
link_to(name, options, html_options)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def prep_link_classes(type)
|
|
34
|
+
if type && button_type_class_hash[type].present?
|
|
35
|
+
button_type_class_hash[type]
|
|
36
|
+
else
|
|
37
|
+
link_class
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def link_class
|
|
42
|
+
case @link_context
|
|
43
|
+
when :notification_banner
|
|
44
|
+
"#{brand}-notification-banner__link"
|
|
45
|
+
else
|
|
46
|
+
"#{brand}-link"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module DesignSystem
|
|
2
|
+
module Generic
|
|
3
|
+
# Plain, bullet, or numbered list rendered by ds_list.
|
|
4
|
+
class ListComponent < DesignSystem::BaseComponent
|
|
5
|
+
def initialize(list:, type: :default, **options)
|
|
6
|
+
super()
|
|
7
|
+
@list = list
|
|
8
|
+
@type = type.to_sym
|
|
9
|
+
@options = options
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
attr_reader :list, :type, :options
|
|
13
|
+
|
|
14
|
+
def tag_name
|
|
15
|
+
type == :number ? :ol : :ul
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def list_options
|
|
19
|
+
classes = ["#{brand}-list"]
|
|
20
|
+
classes << "#{brand}-list--bullet" if type == :bullet
|
|
21
|
+
classes << "#{brand}-list--number" if type == :number
|
|
22
|
+
css_class_options_merge(options, classes)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<% success = type == :success %>
|
|
2
|
+
<div class="<%= brand %>-notification-banner<%= " #{brand}-notification-banner--success" if success %>"
|
|
3
|
+
role="<%= success ? 'alert' : 'region' %>"
|
|
4
|
+
aria-labelledby="<%= brand %>-notification-banner-title"
|
|
5
|
+
data-module="<%= brand %>-notification-banner">
|
|
6
|
+
<div class="<%= brand %>-notification-banner__header">
|
|
7
|
+
<h2 class="<%= brand %>-notification-banner__title" id="<%= brand %>-notification-banner-title"><%= success ? 'Success' : 'Important' %></h2>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="<%= brand %>-notification-banner__content">
|
|
10
|
+
<% if heading_text.present? %>
|
|
11
|
+
<%= content_tag(heading_tag, heading_text, class: "#{brand}-notification-banner__heading") %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<%= body %>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|