design_system 0.7.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.
Files changed (411) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +91 -0
  4. data/Rakefile +47 -0
  5. data/app/assets/config/design_system_manifest.js +0 -0
  6. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/_base.scss +3 -0
  7. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/all.scss +7 -0
  8. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/_all.scss +8 -0
  9. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/_index.scss +38 -0
  10. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/accordion/_accordion.scss +2 -0
  11. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/accordion/_index.scss +368 -0
  12. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/back-link/_back-link.scss +2 -0
  13. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/back-link/_index.scss +81 -0
  14. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/breadcrumbs/_breadcrumbs.scss +2 -0
  15. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/breadcrumbs/_index.scss +132 -0
  16. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/button/_button.scss +2 -0
  17. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/button/_index.scss +260 -0
  18. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/character-count/_character-count.scss +2 -0
  19. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/character-count/_index.scss +42 -0
  20. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/checkboxes/_checkboxes.scss +2 -0
  21. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/checkboxes/_index.scss +309 -0
  22. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/cookie-banner/_cookie-banner.scss +2 -0
  23. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/cookie-banner/_index.scss +57 -0
  24. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/date-input/_date-input.scss +2 -0
  25. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/date-input/_index.scss +26 -0
  26. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/details/_details.scss +2 -0
  27. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/details/_index.scss +137 -0
  28. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/error-message/_error-message.scss +2 -0
  29. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/error-message/_index.scss +12 -0
  30. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/error-summary/_error-summary.scss +2 -0
  31. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/error-summary/_index.scss +54 -0
  32. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/exit-this-page/_exit-this-page.scss +2 -0
  33. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/exit-this-page/_index.scss +90 -0
  34. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/fieldset/_fieldset.scss +2 -0
  35. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/fieldset/_index.scss +67 -0
  36. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/file-upload/_file-upload.scss +2 -0
  37. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/file-upload/_index.scss +216 -0
  38. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/footer/_footer.scss +2 -0
  39. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/footer/_index.scss +192 -0
  40. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/header/_header.scss +2 -0
  41. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/header/_index.scss +546 -0
  42. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/hint/_hint.scss +2 -0
  43. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/hint/_index.scss +43 -0
  44. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/input/_index.scss +166 -0
  45. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/input/_input.scss +2 -0
  46. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/inset-text/_index.scss +24 -0
  47. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/inset-text/_inset-text.scss +2 -0
  48. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/label/_index.scss +44 -0
  49. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/label/_label.scss +2 -0
  50. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/notification-banner/_index.scss +91 -0
  51. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/notification-banner/_notification-banner.scss +2 -0
  52. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/pagination/_index.scss +226 -0
  53. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/pagination/_pagination.scss +2 -0
  54. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/panel/_index.scss +56 -0
  55. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/panel/_panel.scss +2 -0
  56. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/password-input/_index.scss +55 -0
  57. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/password-input/_password-input.scss +2 -0
  58. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/phase-banner/_index.scss +34 -0
  59. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/phase-banner/_phase-banner.scss +2 -0
  60. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/radios/_index.scss +326 -0
  61. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/radios/_radios.scss +2 -0
  62. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/select/_index.scss +57 -0
  63. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/select/_select.scss +2 -0
  64. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/service-navigation/_index.scss +252 -0
  65. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/service-navigation/_service-navigation.scss +2 -0
  66. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/skip-link/_index.scss +50 -0
  67. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/skip-link/_skip-link.scss +2 -0
  68. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/summary-list/_index.scss +267 -0
  69. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/summary-list/_summary-list.scss +2 -0
  70. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/table/_index.scss +73 -0
  71. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/table/_table.scss +2 -0
  72. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/tabs/_index.scss +132 -0
  73. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/tabs/_tabs.scss +2 -0
  74. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/tag/_index.scss +95 -0
  75. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/tag/_tag.scss +2 -0
  76. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/task-list/_index.scss +77 -0
  77. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/task-list/_task-list.scss +2 -0
  78. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/textarea/_index.scss +48 -0
  79. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/textarea/_textarea.scss +2 -0
  80. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/warning-text/_index.scss +64 -0
  81. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/components/warning-text/_warning-text.scss +2 -0
  82. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/core/_all.scss +8 -0
  83. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/core/_global-styles.scss +18 -0
  84. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/core/_govuk-frontend-properties.scss +13 -0
  85. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/core/_index.scss +6 -0
  86. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/core/_links.scss +40 -0
  87. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/core/_lists.scss +65 -0
  88. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/core/_section-break.scss +49 -0
  89. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/core/_typography.scss +187 -0
  90. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_all.scss +8 -0
  91. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_clearfix.scss +15 -0
  92. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_colour.scss +165 -0
  93. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_device-pixels.scss +36 -0
  94. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_focused.scss +57 -0
  95. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_font-faces.scss +39 -0
  96. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_grid.scss +61 -0
  97. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_index.scss +12 -0
  98. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_links.scss +389 -0
  99. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_media-queries.scss +80 -0
  100. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_shape-arrow.scss +80 -0
  101. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_spacing.scss +171 -0
  102. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_typography.scss +286 -0
  103. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/helpers/_visually-hidden.scss +86 -0
  104. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/index.scss +9 -0
  105. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/objects/_all.scss +8 -0
  106. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/objects/_button-group.scss +78 -0
  107. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/objects/_form-group.scss +23 -0
  108. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/objects/_grid.scss +24 -0
  109. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/objects/_index.scss +6 -0
  110. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/objects/_main-wrapper.scss +53 -0
  111. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/objects/_template.scss +55 -0
  112. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/objects/_width-container.scss +75 -0
  113. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/overrides/_all.scss +7 -0
  114. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/overrides/_display.scss +24 -0
  115. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/overrides/_index.scss +5 -0
  116. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/overrides/_spacing.scss +84 -0
  117. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/overrides/_text-align.scss +14 -0
  118. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/overrides/_typography.scss +40 -0
  119. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/overrides/_width.scss +46 -0
  120. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_all.scss +8 -0
  121. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_assets.scss +82 -0
  122. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_colours-applied.scss +193 -0
  123. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_colours-organisations.scss +380 -0
  124. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_colours-palette.scss +35 -0
  125. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_global-styles.scss +13 -0
  126. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_index.scss +34 -0
  127. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_links.scss +47 -0
  128. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_measurements.scss +105 -0
  129. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_media-queries.scss +23 -0
  130. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_spacing.scss +76 -0
  131. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_typography-font.scss +50 -0
  132. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_typography-responsive.scss +315 -0
  133. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/settings/_warnings.scss +76 -0
  134. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/tools/_all.scss +8 -0
  135. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/tools/_exports.scss +33 -0
  136. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/tools/_font-url.scss +26 -0
  137. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/tools/_image-url.scss +26 -0
  138. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/tools/_index.scss +6 -0
  139. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/tools/_px-to-em.scss +20 -0
  140. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/tools/_px-to-rem.scss +20 -0
  141. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/tools/_rebrand.scss +63 -0
  142. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/utilities/_all.scss +8 -0
  143. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/utilities/_clearfix.scss +5 -0
  144. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/utilities/_index.scss +2 -0
  145. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/utilities/_visually-hidden.scss +9 -0
  146. data/app/assets/stylesheets/design_system/govuk-frontend-5.11.1/vendor/_sass-mq.scss +347 -0
  147. data/app/assets/stylesheets/design_system/govuk.scss +7 -0
  148. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/_index.scss +38 -0
  149. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/action-link/_action-link.scss +1 -0
  150. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/action-link/_index.scss +73 -0
  151. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/back-link/_back-link.scss +1 -0
  152. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/back-link/_index.scss +66 -0
  153. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/breadcrumb/_breadcrumb.scss +1 -0
  154. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/breadcrumb/_index.scss +138 -0
  155. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/button/_button.scss +1 -0
  156. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/button/_index.scss +257 -0
  157. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/card/_card.scss +1 -0
  158. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/card/_index.scss +321 -0
  159. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/character-count/_character-count.scss +1 -0
  160. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/character-count/_index.scss +19 -0
  161. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/checkboxes/_checkboxes.scss +1 -0
  162. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/checkboxes/_index.scss +155 -0
  163. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/contents-list/_contents-list.scss +1 -0
  164. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/contents-list/_index.scss +40 -0
  165. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/date-input/_date-input.scss +1 -0
  166. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/date-input/_index.scss +29 -0
  167. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/details/_details.scss +1 -0
  168. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/details/_index.scss +211 -0
  169. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/do-dont-list/_do-dont-list.scss +1 -0
  170. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/do-dont-list/_index.scss +23 -0
  171. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/error-message/_error-message.scss +1 -0
  172. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/error-message/_index.scss +17 -0
  173. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/error-summary/_error-summary.scss +1 -0
  174. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/error-summary/_index.scss +72 -0
  175. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/fieldset/_fieldset.scss +1 -0
  176. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/fieldset/_index.scss +65 -0
  177. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/footer/_footer.scss +1 -0
  178. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/footer/_index.scss +87 -0
  179. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/header/_header-base.scss +495 -0
  180. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/header/_header-organisation.scss +126 -0
  181. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/header/_header-service.scss +60 -0
  182. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/header/_header-transactional.scss +61 -0
  183. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/header/_header-white.scss +117 -0
  184. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/header/_header.scss +1 -0
  185. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/header/_index.scss +5 -0
  186. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/hero/_hero.scss +1 -0
  187. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/hero/_index.scss +187 -0
  188. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/hint/_hint.scss +1 -0
  189. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/hint/_index.scss +51 -0
  190. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/images/_images.scss +1 -0
  191. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/images/_index.scss +48 -0
  192. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/input/_index.scss +149 -0
  193. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/input/_input.scss +1 -0
  194. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/inset-text/_index.scss +28 -0
  195. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/inset-text/_inset-text.scss +1 -0
  196. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/label/_index.scss +53 -0
  197. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/label/_label.scss +1 -0
  198. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/pagination/_index.scss +95 -0
  199. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/pagination/_pagination.scss +1 -0
  200. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/panel/_index.scss +57 -0
  201. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/panel/_panel.scss +1 -0
  202. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/radios/_index.scss +180 -0
  203. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/radios/_radios.scss +1 -0
  204. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/select/_index.scss +44 -0
  205. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/select/_select.scss +1 -0
  206. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/skip-link/_index.scss +34 -0
  207. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/skip-link/_skip-link.scss +1 -0
  208. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/summary-list/_index.scss +183 -0
  209. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/summary-list/_summary-list.scss +1 -0
  210. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/tables/_index.scss +181 -0
  211. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/tables/_tables.scss +1 -0
  212. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/tabs/_index.scss +120 -0
  213. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/tabs/_tabs.scss +1 -0
  214. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/tag/_index.scss +92 -0
  215. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/tag/_tag.scss +1 -0
  216. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/task-list/_index.scss +101 -0
  217. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/task-list/_task-list.scss +1 -0
  218. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/textarea/_index.scss +30 -0
  219. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/textarea/_textarea.scss +1 -0
  220. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/warning-callout/_index.scss +19 -0
  221. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/components/warning-callout/_warning-callout.scss +1 -0
  222. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/_index.scss +11 -0
  223. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/all.scss +8 -0
  224. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/elements/_forms.scss +16 -0
  225. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/elements/_index.scss +8 -0
  226. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/elements/_links.scss +42 -0
  227. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/elements/_page.scss +43 -0
  228. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/elements/_table.scss +62 -0
  229. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/generic/_box-sizing.scss +26 -0
  230. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/generic/_font-face.scss +47 -0
  231. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/generic/_index.scss +6 -0
  232. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/objects/_form-group.scss +25 -0
  233. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/objects/_grid.scss +23 -0
  234. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/objects/_index.scss +8 -0
  235. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/objects/_main-wrapper.scss +96 -0
  236. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/objects/_width-container.scss +63 -0
  237. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/settings/_all.scss +8 -0
  238. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/settings/_breakpoints.scss +18 -0
  239. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/settings/_colours.scss +188 -0
  240. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/settings/_globals.scss +82 -0
  241. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/settings/_index.scss +10 -0
  242. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/settings/_spacing.scss +79 -0
  243. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/settings/_typography.scss +176 -0
  244. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/settings/_warnings.scss +82 -0
  245. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/styles/_icons.scss +105 -0
  246. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/styles/_index.scss +4 -0
  247. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/styles/_lists.scss +115 -0
  248. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/styles/_section-break.scss +71 -0
  249. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/styles/_typography.scss +297 -0
  250. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_all.scss +8 -0
  251. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_exports.scss +47 -0
  252. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_focused.scss +86 -0
  253. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_functions.scss +45 -0
  254. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_grid.scss +138 -0
  255. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_ifff.scss +19 -0
  256. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_index.scss +15 -0
  257. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_links.scss +184 -0
  258. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_mixins.scss +520 -0
  259. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_sass-mq.scss +79 -0
  260. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_shape-arrow.scss +91 -0
  261. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_spacing.scss +192 -0
  262. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/tools/_typography.scss +259 -0
  263. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_clearfix.scss +15 -0
  264. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_display.scss +15 -0
  265. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_float.scss +15 -0
  266. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_grid-widths.scss +97 -0
  267. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_index.scss +16 -0
  268. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_link-nowrap.scss +19 -0
  269. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_list-border.scss +20 -0
  270. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_reading-width.scss +16 -0
  271. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_spacing.scss +88 -0
  272. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_text-align.scss +19 -0
  273. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_typography.scss +72 -0
  274. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_visually-hidden.scss +20 -0
  275. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/utilities/_widths.scss +62 -0
  276. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/core/vendor/sass-mq.scss +316 -0
  277. data/app/assets/stylesheets/design_system/nhsuk-frontend-9.6.4/nhsuk.scss +1 -0
  278. data/app/assets/stylesheets/design_system/nhsuk.scss +5 -0
  279. data/app/controllers/concerns/design_system/branded.rb +21 -0
  280. data/app/helpers/css_helper.rb +13 -0
  281. data/app/helpers/design_system_helper.rb +113 -0
  282. data/app/javascript/design_system/controllers/hello_world_controller.js +7 -0
  283. data/app/javascript/design_system/controllers/show_password_controller.js +40 -0
  284. data/app/javascript/design_system/index.js +11 -0
  285. data/app/views/govuk/_navigation.html.erb +14 -0
  286. data/app/views/layouts/_alert_and_notice.html.erb +7 -0
  287. data/app/views/layouts/govuk/application.html.erb +196 -0
  288. data/app/views/layouts/govuk/full_page.html.erb +2 -0
  289. data/app/views/layouts/govuk/left_panel.html.erb +2 -0
  290. data/app/views/layouts/nhsuk/application.html.erb +132 -0
  291. data/app/views/layouts/nhsuk/full_page.html.erb +2 -0
  292. data/app/views/layouts/nhsuk/left_panel.html.erb +2 -0
  293. data/app/views/nhsuk/_navigation.html.erb +25 -0
  294. data/config/importmap.rb +4 -0
  295. data/config/initializers/govuk_form_builder_overrides.rb +128 -0
  296. data/config/routes.rb +3 -0
  297. data/lib/design_system/all.rb +3 -0
  298. data/lib/design_system/components/summary_list.rb +53 -0
  299. data/lib/design_system/components/tab.rb +20 -0
  300. data/lib/design_system/components/table.rb +68 -0
  301. data/lib/design_system/engine.rb +30 -0
  302. data/lib/design_system/generic/builders/base.rb +18 -0
  303. data/lib/design_system/generic/builders/button.rb +35 -0
  304. data/lib/design_system/generic/builders/callout.rb +28 -0
  305. data/lib/design_system/generic/builders/concerns/brand_derivable.rb +14 -0
  306. data/lib/design_system/generic/builders/elements/breadcrumbs.rb +45 -0
  307. data/lib/design_system/generic/builders/elements/form.rb +23 -0
  308. data/lib/design_system/generic/builders/elements/headings.rb +31 -0
  309. data/lib/design_system/generic/builders/fixed_elements.rb +38 -0
  310. data/lib/design_system/generic/builders/heading.rb +38 -0
  311. data/lib/design_system/generic/builders/link.rb +37 -0
  312. data/lib/design_system/generic/builders/notification.rb +43 -0
  313. data/lib/design_system/generic/builders/pagination_renderer.rb +85 -0
  314. data/lib/design_system/generic/builders/panel.rb +18 -0
  315. data/lib/design_system/generic/builders/summary_list.rb +84 -0
  316. data/lib/design_system/generic/builders/tab.rb +17 -0
  317. data/lib/design_system/generic/builders/table.rb +76 -0
  318. data/lib/design_system/generic/form_builder.rb +54 -0
  319. data/lib/design_system/generic.rb +15 -0
  320. data/lib/design_system/govuk/builders/button.rb +57 -0
  321. data/lib/design_system/govuk/builders/callout.rb +26 -0
  322. data/lib/design_system/govuk/builders/elements/breadcrumbs.rb +33 -0
  323. data/lib/design_system/govuk/builders/elements/headings.rb +18 -0
  324. data/lib/design_system/govuk/builders/fixed_elements.rb +17 -0
  325. data/lib/design_system/govuk/builders/heading.rb +11 -0
  326. data/lib/design_system/govuk/builders/link.rb +23 -0
  327. data/lib/design_system/govuk/builders/notification.rb +11 -0
  328. data/lib/design_system/govuk/builders/pagination_renderer.rb +80 -0
  329. data/lib/design_system/govuk/builders/panel.rb +18 -0
  330. data/lib/design_system/govuk/builders/summary_list.rb +44 -0
  331. data/lib/design_system/govuk/builders/tab.rb +56 -0
  332. data/lib/design_system/govuk/builders/table.rb +79 -0
  333. data/lib/design_system/govuk/form_builder.rb +430 -0
  334. data/lib/design_system/govuk.rb +19 -0
  335. data/lib/design_system/nhsuk/builders/button.rb +11 -0
  336. data/lib/design_system/nhsuk/builders/callout.rb +11 -0
  337. data/lib/design_system/nhsuk/builders/elements/breadcrumbs.rb +47 -0
  338. data/lib/design_system/nhsuk/builders/fixed_elements.rb +15 -0
  339. data/lib/design_system/nhsuk/builders/heading.rb +11 -0
  340. data/lib/design_system/nhsuk/builders/link.rb +21 -0
  341. data/lib/design_system/nhsuk/builders/notification.rb +17 -0
  342. data/lib/design_system/nhsuk/builders/pagination_renderer.rb +16 -0
  343. data/lib/design_system/nhsuk/builders/panel.rb +11 -0
  344. data/lib/design_system/nhsuk/builders/summary_list.rb +34 -0
  345. data/lib/design_system/nhsuk/builders/tab.rb +11 -0
  346. data/lib/design_system/nhsuk/builders/table.rb +68 -0
  347. data/lib/design_system/nhsuk/form_builder.rb +83 -0
  348. data/lib/design_system/nhsuk.rb +18 -0
  349. data/lib/design_system/registry.rb +40 -0
  350. data/lib/design_system/version.rb +3 -0
  351. data/lib/design_system.rb +7 -0
  352. data/lib/tasks/design_system_tasks.rake +4 -0
  353. data/lib/tasks/govuk.rake +122 -0
  354. data/lib/tasks/nhsuk.rake +108 -0
  355. data/public/design_system/static/design_system-0.7.0/design_system.js +1309 -0
  356. data/public/design_system/static/govuk-frontend-5.11.1/fonts/bold-affa96571d-v2.woff +0 -0
  357. data/public/design_system/static/govuk-frontend-5.11.1/fonts/bold-b542beb274-v2.woff2 +0 -0
  358. data/public/design_system/static/govuk-frontend-5.11.1/fonts/light-94a07e06a1-v2.woff2 +0 -0
  359. data/public/design_system/static/govuk-frontend-5.11.1/fonts/light-f591b13f7d-v2.woff +0 -0
  360. data/public/design_system/static/govuk-frontend-5.11.1/govuk-frontend.min.js +1 -0
  361. data/public/design_system/static/govuk-frontend-5.11.1/govuk-frontend.min.js.map +1 -0
  362. data/public/design_system/static/govuk-frontend-5.11.1/images/favicon.ico +0 -0
  363. data/public/design_system/static/govuk-frontend-5.11.1/images/favicon.svg +1 -0
  364. data/public/design_system/static/govuk-frontend-5.11.1/images/govuk-crest.svg +1 -0
  365. data/public/design_system/static/govuk-frontend-5.11.1/images/govuk-icon-180.png +0 -0
  366. data/public/design_system/static/govuk-frontend-5.11.1/images/govuk-icon-192.png +0 -0
  367. data/public/design_system/static/govuk-frontend-5.11.1/images/govuk-icon-512.png +0 -0
  368. data/public/design_system/static/govuk-frontend-5.11.1/images/govuk-icon-mask.svg +1 -0
  369. data/public/design_system/static/govuk-frontend-5.11.1/images/govuk-opengraph-image.png +0 -0
  370. data/public/design_system/static/govuk-frontend-5.11.1/manifest.json +39 -0
  371. data/public/design_system/static/govuk-frontend-5.11.1/rebrand/images/favicon.ico +0 -0
  372. data/public/design_system/static/govuk-frontend-5.11.1/rebrand/images/favicon.svg +1 -0
  373. data/public/design_system/static/govuk-frontend-5.11.1/rebrand/images/govuk-crest.svg +1 -0
  374. data/public/design_system/static/govuk-frontend-5.11.1/rebrand/images/govuk-icon-180.png +0 -0
  375. data/public/design_system/static/govuk-frontend-5.11.1/rebrand/images/govuk-icon-192.png +0 -0
  376. data/public/design_system/static/govuk-frontend-5.11.1/rebrand/images/govuk-icon-512.png +0 -0
  377. data/public/design_system/static/govuk-frontend-5.11.1/rebrand/images/govuk-icon-mask.svg +1 -0
  378. data/public/design_system/static/govuk-frontend-5.11.1/rebrand/images/govuk-opengraph-image.png +0 -0
  379. data/public/design_system/static/govuk-frontend-5.11.1/rebrand/manifest.json +39 -0
  380. data/public/design_system/static/nhsuk-frontend-9.6.4/favicons/apple-touch-icon-180x180.png +0 -0
  381. data/public/design_system/static/nhsuk-frontend-9.6.4/favicons/apple-touch-icon.png +0 -0
  382. data/public/design_system/static/nhsuk-frontend-9.6.4/favicons/favicon-192x192.png +0 -0
  383. data/public/design_system/static/nhsuk-frontend-9.6.4/favicons/favicon.ico +0 -0
  384. data/public/design_system/static/nhsuk-frontend-9.6.4/favicons/favicon.png +0 -0
  385. data/public/design_system/static/nhsuk-frontend-9.6.4/favicons/favicon.svg +3 -0
  386. data/public/design_system/static/nhsuk-frontend-9.6.4/favicons/largetile-310x310.png +0 -0
  387. data/public/design_system/static/nhsuk-frontend-9.6.4/favicons/mediumtile-144x144.png +0 -0
  388. data/public/design_system/static/nhsuk-frontend-9.6.4/favicons/mediumtile-150x150.png +0 -0
  389. data/public/design_system/static/nhsuk-frontend-9.6.4/favicons/smalltile-70x70.png +0 -0
  390. data/public/design_system/static/nhsuk-frontend-9.6.4/favicons/widetile-310x150.png +0 -0
  391. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-arrow-left.svg +3 -0
  392. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-arrow-right-circle.svg +4 -0
  393. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-arrow-right.svg +3 -0
  394. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-chevron-left.svg +3 -0
  395. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-chevron-right.svg +3 -0
  396. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-close.svg +3 -0
  397. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-cross.svg +4 -0
  398. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-emdash-small.svg +3 -0
  399. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-emdash.svg +3 -0
  400. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-minus.svg +4 -0
  401. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-plus.svg +4 -0
  402. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-search.svg +3 -0
  403. data/public/design_system/static/nhsuk-frontend-9.6.4/icons/icon-tick.svg +3 -0
  404. data/public/design_system/static/nhsuk-frontend-9.6.4/logos/logo-nhs.svg +5 -0
  405. data/public/design_system/static/nhsuk-frontend-9.6.4/logos/nhs-logo.png +0 -0
  406. data/public/design_system/static/nhsuk-frontend-9.6.4/logos/open-graph.png +0 -0
  407. data/public/design_system/static/nhsuk-frontend-9.6.4/nhsuk.js +4 -0
  408. data/public/design_system/static/nhsuk-frontend-9.6.4/nhsuk.min.js +1 -0
  409. data/public/design_system/static/stimulus-3.2.2/stimulus-loading.js +87 -0
  410. data/public/design_system/static/tailwind-4.1.6/index.js +8 -0
  411. metadata +517 -0
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'design_system/generic/builders/summary_list'
4
+
5
+ module DesignSystem
6
+ module Govuk
7
+ module Builders
8
+ class SummaryList < ::DesignSystem::Generic::Builders::SummaryList
9
+ private
10
+
11
+ def render_row(row)
12
+ row_classes = ['govuk-summary-list__row']
13
+ row_classes << 'govuk-summary-list__row--no-actions' if row[:actions].empty?
14
+
15
+ content_tag(:div, class: row_classes.join(' ')) do
16
+ [render_key(row),
17
+ render_value(row),
18
+ render_actions(row)].compact.join.html_safe
19
+ end
20
+ end
21
+
22
+ def render_value(row)
23
+ return if row[:values].nil? || row[:values].empty?
24
+
25
+ content_tag(:dd, class: 'govuk-summary-list__value') do
26
+ if row[:values].length == 1
27
+ wrap_value(row[:values].first)
28
+ else
29
+ row[:values].map { |value| wrap_value(value) }.join.html_safe
30
+ end
31
+ end
32
+ end
33
+
34
+ def wrap_value(value)
35
+ if value[:options]&.dig(:path)
36
+ link_to(value[:content], value[:options][:path] || '#', class: 'govuk-link')
37
+ else
38
+ content_tag(:p, value[:content], class: 'govuk-body')
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'design_system/generic/builders/tab'
4
+
5
+ module DesignSystem
6
+ module Govuk
7
+ module Builders
8
+ # This class provides GOVUK Tab.
9
+ class Tab < ::DesignSystem::Generic::Builders::Tab
10
+ def render_tabs
11
+ @tab = ::DesignSystem::Components::Tab.new(self)
12
+
13
+ yield @tab
14
+ content_tag(:div, class: "#{brand}-tabs", 'data-module': "#{brand}-tabs") do
15
+ safe_buffer = ActiveSupport::SafeBuffer.new
16
+
17
+ safe_buffer.concat(content_tag(:h2, @tab.title, class: "#{brand}-tabs__title")) if @tab.title
18
+ safe_buffer.concat(tabs_list_content) if @tab.tabs.present?
19
+ safe_buffer.concat(tabs_body_content) if @tab.tabs.present?
20
+ safe_buffer
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def tabs_list_content
27
+ content_tag(:ul, class: "#{brand}-tabs__list") do
28
+ @tab.tabs.each_with_object(ActiveSupport::SafeBuffer.new) do |(name, _content, id, sel), link_buffer|
29
+ style = if sel
30
+ "#{brand}-tabs__list-item #{brand}-tabs__list-item--selected"
31
+ else
32
+ "#{brand}-tabs__list-item"
33
+ end
34
+ link_buffer.concat(
35
+ content_tag(:li, class: style) do
36
+ content_tag(:a, name, class: "#{brand}-tabs__tab", href: "##{id}")
37
+ end
38
+ )
39
+ end
40
+ end
41
+ end
42
+
43
+ def tabs_body_content
44
+ @tab.tabs.each_with_object(ActiveSupport::SafeBuffer.new) do |(_name, content, id, sel), body_buffer|
45
+ style = if sel
46
+ "#{brand}-tabs__panel"
47
+ else
48
+ "#{brand}-tabs__panel #{brand}-tabs__panel--hidden"
49
+ end
50
+ body_buffer.concat(content_tag(:div, content, class: style, id:))
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'design_system/generic/builders/table'
4
+
5
+ module DesignSystem
6
+ module Govuk
7
+ module Builders
8
+ # This concern is used to provide GOVUK Table.
9
+ class Table < ::DesignSystem::Generic::Builders::Table
10
+ private
11
+
12
+ def table_content
13
+ content_tag(:table, nil, class: "#{brand}-table #{brand}-table--small-text-until-tablet") do
14
+ safe_buffer = ActiveSupport::SafeBuffer.new
15
+
16
+ if @table.caption
17
+ safe_buffer.concat(content_tag(:caption, @table.caption,
18
+ class: "#{brand}-table__caption #{brand}-table__caption--m"))
19
+ end
20
+ safe_buffer.concat(render_headers)
21
+ safe_buffer.concat(render_rows)
22
+
23
+ safe_buffer
24
+ end
25
+ end
26
+
27
+ # brand specific <th>
28
+ def render_headers
29
+ content_tag(:thead, class: "#{brand}-table__head") do
30
+ content_tag(:tr, class: "#{brand}-table__row") do
31
+ @table.columns.each_with_object(ActiveSupport::SafeBuffer.new) do |column, header_buffer|
32
+ header_buffer.concat(render_header_cell(column, 'col'))
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ def render_header_cell(cell, scope)
39
+ classes = "#{brand}-table__header"
40
+ classes += " #{brand}-table__header--numeric" if cell_numeric?(cell)
41
+
42
+ content_tag(:th, cell_content(cell), cell[:options].merge(scope:, class: classes))
43
+ end
44
+
45
+ # brand specific <tr>
46
+ def render_rows
47
+ content_tag(:tbody, class: "#{brand}-table__body") do
48
+ @table.rows.each_with_object(ActiveSupport::SafeBuffer.new) do |row, rows_buffer|
49
+ rows_buffer.concat(render_row(row))
50
+ end
51
+ end
52
+ end
53
+
54
+ def render_row(row)
55
+ content_tag(:tr, class: "#{brand}-table__row") do
56
+ row.each_with_object(ActiveSupport::SafeBuffer.new).with_index do |(cell, cell_buffer), index|
57
+ cell_buffer.concat(render_cell(cell, index, 'row'))
58
+ end
59
+ end
60
+ end
61
+
62
+ def render_cell(cell, index, scope)
63
+ if index.zero?
64
+ render_header_cell(cell, scope)
65
+ else
66
+ render_data_cell(cell)
67
+ end
68
+ end
69
+
70
+ def render_data_cell(cell)
71
+ classes = "#{brand}-table__cell"
72
+ classes += " #{brand}-table__cell--numeric" if cell_numeric?(cell)
73
+
74
+ content_tag(:td, cell_content(cell), cell[:options].merge(class: classes))
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,430 @@
1
+ require 'design_system/generic/form_builder'
2
+ require 'govuk_design_system_formbuilder'
3
+
4
+ module DesignSystem
5
+ # Module namespace containing all the form builders
6
+ module Govuk
7
+ # The Govuk version of the form builder
8
+ class FormBuilder < DesignSystem::Generic::FormBuilder
9
+ include GOVUKDesignSystemFormBuilder::Builder
10
+
11
+ def initialize(object_name, object, template, options)
12
+ object_name = object_name.to_s if object_name.is_a?(Symbol)
13
+ super
14
+
15
+ config.brand = self.class.brand
16
+ end
17
+
18
+ # TODO: will be supported in next PR
19
+ # dividers
20
+
21
+ # Same interface as ActionView::Helpers::FormHelper.check_box, but with label automatically added.
22
+ def ds_check_box(method, options = {}, checked_value = '1', unchecked_value = '0')
23
+ value = checked_value == '1' ? true : checked_value
24
+ unchecked_value = false if unchecked_value == '0'
25
+
26
+ # First try to find a custom translation for this specific value
27
+ # If no custom translation provided, fall back to the default value
28
+ custom_translation = translated_label_for_value(method, value)
29
+ label = if custom_translation.include?('Translation missing')
30
+ optional_label(value, options)
31
+ else
32
+ optional_label(value, options, custom_translation)
33
+ end
34
+
35
+ hint = options.delete(:hint)
36
+ hint = { text: hint } if hint
37
+
38
+ # link_errors [Boolean] controls whether this radio button should be linked to from {#govuk_error_summary}
39
+ # exclusive [Boolean] sets the checkbox so that when checked none of its siblings can be too. Usually
40
+ # used for the 'None of these apply to me' option found beneath a {#govuk_check_box_divider}.
41
+ govuk_check_box(method, value, unchecked_value, hint:, label:, link_errors: false, multiple: true,
42
+ exclusive: false, **options)
43
+ end
44
+
45
+ def ds_check_boxes_fieldset(method, options = {}, &)
46
+ legend = optional_legend(method, options)
47
+ hint = options.delete(:hint)
48
+ hint = { text: hint } if hint
49
+
50
+ # multiple [Boolean] controls whether the check box is part of a collection or represents a single attribute
51
+ govuk_check_boxes_fieldset(method,
52
+ legend:, caption: {}, hint:, small: false, form_group: {}, multiple: true, **options, &)
53
+ end
54
+
55
+ # Same interface as ActionView::Helpers::FormOptionsHelper.collection_check_boxes, but with legend automatically added.
56
+ def ds_collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {},
57
+ &)
58
+ legend = optional_legend(method, options)
59
+ hint = options.delete(:hint)
60
+ hint = { text: hint } if hint
61
+ hint_method = options.delete(:hint_method)
62
+ caption = options.delete(:caption) || {}
63
+ form_group = options.delete(:form_group) || {}
64
+ include_hidden = options.delete(:include_hidden) || config.default_collection_check_boxes_include_hidden
65
+
66
+ govuk_collection_check_boxes(method, collection, value_method, text_method, hint_method, hint:, legend:,
67
+ caption:, small: false, form_group:, include_hidden:, **html_options, &)
68
+ end
69
+
70
+ # Same interface as ActionView::Helpers::FormOptionsHelper.collection_radio_buttons, but with legend automatically added.
71
+ def ds_collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {}, &)
72
+ hint = options.delete(:hint)
73
+ hint = { text: hint } if hint
74
+ hint_method = options.delete(:hint_method)
75
+ bold_labels = options.delete(:bold_labels)
76
+ caption = options.delete(:caption) || {}
77
+ form_group = options.delete(:form_group) || {}
78
+ include_hidden = options.delete(:include_hidden) || true
79
+ legend = optional_legend(method, options)
80
+
81
+ # value_method [Symbol, Proc] The method called against each member of the collection to provide the value.
82
+ # When a +Proc+ is provided it must take a single argument that is a single member of the collection
83
+ # text_method [Symbol, Proc, nil] The method called against each member of the collection to provide the label text.
84
+ # When a +Proc+ is provided it must take a single argument that is a single member of the collection.
85
+ # When a +nil+ value is provided the label text will be retrieved from the locale.
86
+ # hint_method [Symbol, Proc, nil] The method called against each member of the collection to provide the hint text.
87
+ # When a +Proc+ is provided it must take a single argument that is a single member of the collection.
88
+ # When a +nil+ value is provided the hint text will be retrieved from the locale. This is the default and param can be omitted.
89
+ # legend [NilClass,Hash,Proc] options for configuring the legend. Legend will be omitted if +nil+.
90
+ # inline [Boolean] controls whether the radio buttons are displayed inline or not
91
+ # small [Boolean] controls whether small radio buttons are used instead of regular-sized ones
92
+ # bold_labels [Boolean] controls whether the radio button labels are bold
93
+ # include_hidden [Boolean] controls whether a hidden field is inserted to allow for empty submissions
94
+ # legend text [String] the fieldset legend's text content
95
+ # legend size [String] the size of the fieldset legend font, can be +xl+, +l+, +m+ or +s+
96
+ # legend tag [Symbol,String] the tag used for the fieldset's header, defaults to +h1+.
97
+ # legend hidden [Boolean] control the visibility of the legend. Hidden legends will still be read by screenreaders
98
+ # legend kwargs [Hash] additional arguments are applied as attributes on the +legend+ element
99
+ govuk_collection_radio_buttons(method, collection, value_method, text_method, hint_method:, hint:, legend:,
100
+ caption:, inline: false, small: false, bold_labels:, include_hidden:, form_group:, **html_options, &)
101
+ end
102
+
103
+ # Same interface as ActionView::Helpers::FormOptionsHelper.collection_select, but with label automatically added.
104
+ # label, hint, caption and form_group should be provided as options rather than html_options
105
+ def ds_collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
106
+ label = optional_label(method, options)
107
+
108
+ hint = options.delete(:hint)
109
+ hint = { text: hint } if hint
110
+
111
+ # attribute_name [Symbol] The name of the attribute
112
+ # collection [Enumerable<Object>] Options to be added to the +select+ element
113
+ # value_method [Symbol] The method called against each member of the collection to provide the value
114
+ # text_method [Symbol] The method called against each member of the collection to provide the text
115
+ # options (rails_options) [Hash] Options hash passed through to Rails' +collection_select+ helper
116
+ govuk_collection_select(method, collection, value_method, text_method, options:, hint:, label:,
117
+ caption: {}, form_group: {}, **html_options)
118
+ end
119
+
120
+ # Same interface as ActionView::Helpers::FormHelper.date_field, but with label automatically added.
121
+ def ds_date_field(method, options = {})
122
+ legend = optional_legend(method, options)
123
+ hint = options.delete(:hint)
124
+ hint = { text: hint } if hint
125
+
126
+ # omit_day [Boolean] do not render a day input, only capture month and year
127
+ # maxlength_enabled [Boolean] adds maxlength attribute to day, month and year inputs (2, 2, and 4, respectively)
128
+ # segments [Hash] allows Rails' multiparameter attributes to be overridden on a field-by-field basis. Hash must
129
+ # contain +day:+, +month:+ and +year:+ keys. Defaults to the default value set in the +default_date_segments+ setting in {GOVUKDesignSystemFormBuilder.DEFAULTS}
130
+ # date_of_birth [Boolean] if +true+ {https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#Values birth date auto completion attributes}
131
+ # will be added to the inputs
132
+ govuk_date_field(method, hint:, legend:, caption: {}, date_of_birth: false, omit_day: false,
133
+ maxlength_enabled: false, segments: config.default_date_segments, form_group: {}, **options)
134
+ end
135
+
136
+ # Same interface as ActionView::Helpers::FormHelper.email_field, but with label automatically added.
137
+ def ds_email_field(method, options = {})
138
+ label = optional_label(method, options)
139
+ hint = options.delete(:hint)
140
+ hint = { text: hint } if hint
141
+
142
+ govuk_email_field(method, hint:, label:, caption: {}, width: nil, extra_letter_spacing: false, form_group: {},
143
+ prefix_text: nil, suffix_text: nil, **options)
144
+ end
145
+
146
+ def ds_error_summary(title = nil, options = nil)
147
+ title, options = separate_content_or_options(title, options)
148
+ title ||= I18n.t('activerecord.errors.title')
149
+
150
+ # title [String] the error summary heading
151
+ # link_base_errors_to [Symbol,String] set the field that errors on +:base+ are linked
152
+ # to, as there won't be a field representing the object base.
153
+ # order [Array<Symbol>] the attribute order in which error messages are displayed. Ordered
154
+ # attributes will appear first and unordered ones will be last, sorted in the default manner (in
155
+ # which they were defined on the model).
156
+ # kwargs [Hash] kwargs additional arguments are applied as attributes to the error summary +div+ element
157
+ # block [Block] arbitrary HTML that will be rendered between title and error message list
158
+ # presenter [Class,Object] the class or object that is responsible for formatting a list of error
159
+ # messages that will be rendered in the summary.
160
+ govuk_error_summary(title, presenter: config.default_error_summary_presenter, link_base_errors_to: nil,
161
+ order: nil, **options)
162
+ end
163
+
164
+ # Same interface as ActionView::Helpers::FormHelper.field_set_tag, but with legend and fieldset tags automatically added.
165
+ def ds_field_set_tag(legend = nil, options = nil, &)
166
+ options ||= {}
167
+ legend_options = options.delete(:legend) || {}
168
+ custom_translation = I18n.t('helpers.fieldset.legend')
169
+ legend = { text: legend || custom_translation }.merge(legend_options)
170
+
171
+ govuk_fieldset(legend:, caption: {}, described_by: nil, **options, &)
172
+ end
173
+
174
+ # Same interface as ActionView::Helpers::FormHelper.file_field, but with label automatically added
175
+ def ds_file_field(method, options = {})
176
+ label = optional_label(method, options)
177
+ hint = options.delete(:hint)
178
+ hint = { text: hint } if hint
179
+
180
+ # javascript [Boolean] Configures whether to add HTML for the javascript-enhanced version of the component
181
+ govuk_file_field(method, label:, caption: {}, hint:, form_group: {}, javascript: false, **options)
182
+ end
183
+
184
+ # Same interface as ActionView::Helpers::FormHelper.hidden_field, but with label automatically added and takes a show_text option
185
+ def ds_hidden_field(method, options = {})
186
+ @brand = config.brand
187
+
188
+ options[:class] = Array(options[:class])
189
+ options[:class] << "#{@brand}-visually-hidden"
190
+
191
+ label_hash = options.delete(:label) || {}
192
+ label = ds_label(method, label_hash)
193
+ show_text = options.delete(:show_text)
194
+
195
+ content_tag(:div, class: "#{@brand}-form-group") do
196
+ components = []
197
+ components << label if label
198
+ components << hidden_field(method, **options)
199
+ components << content_tag(:span, show_text, class: "#{@brand}-body-m") if show_text
200
+
201
+ safe_join(components)
202
+ end
203
+ end
204
+
205
+ # Same interface as ActionView::Helpers::FormHelper.label
206
+ def ds_label(method, content_or_options = nil, options = nil, &)
207
+ content, options = separate_content_or_options(content_or_options, options)
208
+ text = content || translated_label(method)
209
+
210
+ # size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
211
+ # tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
212
+ # hidden [Boolean] control the visability of the label. Hidden labels will stil be read by screenreaders
213
+ # kwargs [Hash] additional arguments are applied as attributes on the +label+ element
214
+ govuk_label(method, text:, size: nil, hidden: false, tag: nil, caption: nil, **options)
215
+ end
216
+
217
+ # Same interface as ActionView::Helpers::FormHelper.number_field, but with label automatically added.
218
+ def ds_number_field(method, options = {})
219
+ label = optional_label(method, options)
220
+ hint = options.delete(:hint)
221
+ hint = { text: hint } if hint
222
+
223
+ govuk_number_field(method, hint:, label:, caption: {}, width: nil, extra_letter_spacing: false, form_group: {},
224
+ prefix_text: nil, suffix_text: nil, **options)
225
+ end
226
+
227
+ # Same interface as ActionView::Helpers::FormHelper.password_field, but with label automatically added.
228
+ def ds_password_field(method, options = {})
229
+ label = optional_label(method, options)
230
+ hint = options.delete(:hint)
231
+ hint = { text: hint } if hint
232
+
233
+ # caption [Hash] configures or sets the caption content which is inserted above the label
234
+ # caption text [String] the caption text
235
+ # caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
236
+ # caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
237
+ # kwargs [Hash] kwargs additional arguments are applied as attributes to the +input+ element
238
+ # form_group [Hash] configures the form group
239
+ # form_group kwargs [Hash] additional attributes added to the form group
240
+ # show_password_text [String] button text when the password is hidden. Defaults to "Show"
241
+ # hide_password_text [String] button text when the password is shown. Defaults to "Hide"
242
+ # show_password_aria_label_text [String] button text exposed to assistive technologies, like screen readers,
243
+ # when the password is hidden. Defaults to "Show password"
244
+ # hide_password_aria_label_text [String] button text exposed to assistive technologies, like screen readers,
245
+ # when the password is visible. Defaults to "Hide password"
246
+ # password_shown_announcement_text [String] Announcement made to screen reader users when their password has
247
+ # become visible in plain text. Defaults to "Your password is visible"
248
+ # password_hidden_announcement_text [String] Announcement made to screen reader users when their password has
249
+ # been obscured and is not visible. Defaults to "Your password is hidden"
250
+ govuk_password_field(method, hint:, label:, caption: {}, form_group: {}, show_password_text: nil,
251
+ hide_password_text: nil, show_password_aria_label_text: nil,
252
+ hide_password_aria_label_text: nil, password_shown_announcement_text: nil,
253
+ password_hidden_announcement_text: nil, **options)
254
+ end
255
+
256
+ # Same interface as ActionView::Helpers::FormHelper.phone_field, but with label automatically added.
257
+ def ds_phone_field(method, options = {})
258
+ label = optional_label(method, options)
259
+ hint = options.delete(:hint)
260
+ hint = { text: hint } if hint
261
+
262
+ govuk_phone_field(method, hint:, label:, caption: {}, width: nil, extra_letter_spacing: false, form_group: {},
263
+ prefix_text: nil, suffix_text: nil, **options)
264
+ end
265
+
266
+ # Same interface as ActionView::Helpers::FormHelper.radio_button, but with label automatically added.
267
+ def ds_radio_button(method, tag_value, options = {})
268
+ label = optional_label(tag_value, options)
269
+ hint = options.delete(:hint)
270
+ hint = { text: hint } if hint
271
+
272
+ govuk_radio_button(method, tag_value, hint:, label:, link_errors: false, **options)
273
+ end
274
+
275
+ def ds_radio_buttons_fieldset(method, options = {}, &)
276
+ legend = optional_legend(method, options)
277
+ hint = options.delete(:hint)
278
+ hint = { text: hint } if hint
279
+
280
+ govuk_radio_buttons_fieldset(method,
281
+ hint:, legend:, caption: {}, inline: false, small: false, form_group: {}, **options, &)
282
+ end
283
+
284
+ # Same interface as ActionView::Helpers::FormOptionsHelper.select, but with label automatically added.
285
+ # label, hint, caption and form_group should be provided as options rather than html_options
286
+ def ds_select(method, choices = nil, options = {}, html_options = {}, &)
287
+ choices, options, html_options = separate_choices_or_options(choices, options, html_options)
288
+
289
+ label = optional_label(method, options)
290
+ hint = options.delete(:hint)
291
+ hint = { text: hint } if hint
292
+
293
+ # choices [Array,Hash] The +option+ values, usually provided via
294
+ # the +options_for_select+ or +grouped_options_for_select+ helpers.
295
+ # if it's not specified, an empty select element will be created
296
+ # example: form.ds_select :department_id, { options }
297
+ govuk_select(method, choices, options:, label:, hint:, form_group: {}, caption: {}, **html_options, &)
298
+ end
299
+
300
+ # Same interface as ActionView::Helpers::FormBuiler.submit, but with label automatically added.
301
+ def ds_submit(value = nil, **options)
302
+ # text [String,Proc] the button text. When a +Proc+ is provided its contents will be rendered within the button element
303
+ # type [Symbol] the type of submit button, can be :secondary, :warning. The button is a primary button if unspecified
304
+ # inverse [Boolean] inverts the colours of the button. Note this isn't yet part of the design system.
305
+ # prevent_double_click [Boolean] adds JavaScript to safeguard the
306
+ # form from being submitted more than once
307
+ # validate [Boolean] adds the formnovalidate to the submit button when true, this disables all
308
+ # client-side validation provided by the browser. This is to provide a more consistent and accessible user
309
+ # experience
310
+ # disabled [Boolean] makes the button disabled when true
311
+ # kwargs [Hash] kwargs additional arguments are applied as attributes to the +button+ element
312
+ # block [Block] When content is passed in via a block the submit element and the block content will
313
+ # be wrapped in a +<div class="govuk-button-group">+ which will space the buttons and links within
314
+ # evenly.
315
+ type = options.delete(:type)
316
+ warning = type == :warning
317
+ secondary = type == :secondary
318
+
319
+ govuk_submit(text = value || config.default_submit_button_text, warning:, secondary:, inverse: false, prevent_double_click: true,
320
+ validate: config.default_submit_validate, disabled: false, **options)
321
+ end
322
+
323
+ # Same interface as ActionView::Helpers::FormHelper.text_area, but with label automatically added.
324
+ def ds_text_area(method, options = {})
325
+ label = optional_label(method, options)
326
+ hint = options.delete(:hint)
327
+ hint = { text: hint } if hint
328
+
329
+ # max_words [Integer] adds the GOV.UK max word count
330
+ # max_chars [Integer] adds the GOV.UK max characters count
331
+ # threshold [Integer] only show the +max_words+ and +max_chars+ warnings once a threshold (percentage) is reached
332
+ # rows [Integer] sets the initial number of rows
333
+ govuk_text_area(method, hint:, label:, caption: {}, max_words: nil, max_chars: nil, rows: 5, threshold: nil,
334
+ form_group: {}, **options)
335
+ end
336
+
337
+ # Same interface as ActionView::Helpers::FormHelper.text_field, but with label automatically added.
338
+ def ds_text_field(method, options = {})
339
+ label = optional_label(method, options)
340
+ hint = options.delete(:hint)
341
+ hint = { text: hint } if hint
342
+
343
+ # width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
344
+ # or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
345
+ # extra_letter_spacing [Boolean] when true adds space between characters to increase the readability of
346
+ # sequences of letters and numbers. Defaults to +false+.
347
+ # caption [Hash] configures or sets the caption content which is inserted above the label
348
+ # caption text [String] the caption text
349
+ # caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
350
+ # caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
351
+ # form_group [Hash] configures the form group
352
+ # form_group kwargs [Hash] additional attributes added to the form group
353
+ # prefix_text [String] the text placed before the input. No prefix will be added if left +nil+
354
+ # suffix_text [String] the text placed after the input. No suffix will be added if left +nil+
355
+ # block [Block] arbitrary HTML that will be rendered between the hint and the input
356
+ govuk_text_field(method, hint:, label:, caption: {}, width: nil, extra_letter_spacing: false,
357
+ form_group: {}, prefix_text: nil, suffix_text: nil, **options)
358
+ end
359
+
360
+ # Same interface as ActionView::Helpers::FormHelper.url_field, but with label automatically added.
361
+ def ds_url_field(method, options = {})
362
+ label = optional_label(method, options)
363
+ hint = options.delete(:hint)
364
+ hint = { text: hint } if hint
365
+
366
+ govuk_url_field(method, hint:, label:, caption: {}, width: nil, extra_letter_spacing: false, form_group: {},
367
+ prefix_text: nil, suffix_text: nil, **options)
368
+ end
369
+
370
+ private
371
+
372
+ def optional_label(method_or_value, options, fallback_text = nil)
373
+ # We want to fallback to the default label text if no custom text is provided
374
+ label_or_legend_content(method_or_value, options, :label, fallback_text)
375
+ end
376
+
377
+ def optional_legend(method_or_value, options, fallback_text = nil)
378
+ # We want to fallback to the default legend text if no custom text is provided
379
+ label_or_legend_content(method_or_value, options, :legend, fallback_text)
380
+ end
381
+
382
+ # This helper generates label or legend content
383
+ def label_or_legend_content(method_or_value, options, key, fallback_text = nil)
384
+ default_content = { size: nil, text: fallback_text || translated_label(method_or_value) }
385
+ custom_content = options.delete(key) || {}
386
+ content = default_content.merge(custom_content)
387
+ content[:text] ||= default_content[:text]
388
+ content
389
+ end
390
+
391
+ def translated_label(method)
392
+ # We need to retrieve the label translation in the same way as Tags::Label
393
+ content ||= ActionView::Helpers::Tags::Translator.
394
+ new(object, object_name, method, scope: 'helpers.label').
395
+ translate
396
+ content || method.humanize
397
+ end
398
+
399
+ def translated_label_for_value(method, value)
400
+ # This method is used to translate the label for a given value
401
+ # Example: assign an alternative name for checkbox items
402
+ method_and_value = "#{method}.#{value}"
403
+ translation = ActionView::Helpers::Tags::Translator.
404
+ new(object, object_name, method_and_value, scope: 'helpers.options').
405
+ translate
406
+ # If translation returns the humanized version of the value,
407
+ # it means no translation was found, so return the original value
408
+ # Extra condition: if value contains dots and translation is only the last part
409
+ if translation == value.to_s.humanize ||
410
+ (value.to_s.include?('.') && translation == value.to_s.split('.').last.humanize)
411
+ value.to_s
412
+ else
413
+ translation
414
+ end
415
+ end
416
+
417
+ # GOVUKDesignSystemFormBuilder::Base field_id method
418
+ def govuk_field_id(method, link_errors: false)
419
+ GOVUKDesignSystemFormBuilder::Base.new(self, object_name, method).field_id(link_errors:)
420
+ end
421
+
422
+ # GOVUKDesignSystemFormBuilder::Base has_errors? method
423
+ def has_errors?(method = nil)
424
+ object.respond_to?(:errors) &&
425
+ object.errors.any? &&
426
+ object.errors.messages[method].present?
427
+ end
428
+ end
429
+ end
430
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This is the GOV.UK adapter for the design system
4
+
5
+ require_relative 'govuk/builders/button'
6
+ require_relative 'govuk/builders/callout'
7
+ require_relative 'govuk/builders/fixed_elements'
8
+ require_relative 'govuk/builders/heading'
9
+ require_relative 'govuk/builders/link'
10
+ require_relative 'govuk/builders/notification'
11
+ require_relative 'govuk/builders/pagination_renderer'
12
+ require_relative 'govuk/builders/panel'
13
+ require_relative 'govuk/builders/summary_list'
14
+ require_relative 'govuk/builders/tab'
15
+ require_relative 'govuk/builders/table'
16
+
17
+ require_relative 'govuk/form_builder'
18
+
19
+ DesignSystem::Registry.register('govuk')
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DesignSystem
4
+ module Nhsuk
5
+ module Builders
6
+ # This class provides Nhsuk Button.
7
+ class Button < ::DesignSystem::Govuk::Builders::Button
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DesignSystem
4
+ module Nhsuk
5
+ module Builders
6
+ # This generates html for rendering callout for Nhsuk
7
+ class Callout < ::DesignSystem::Generic::Builders::Callout
8
+ end
9
+ end
10
+ end
11
+ end