Skip to content

Commit 20dfebd

Browse files
author
bravegrape
authored
Merge pull request #78 from alphagov/add-warning-text-partial
Add warning text extension
2 parents fd79d65 + b650d31 commit 20dfebd

4 files changed

Lines changed: 99 additions & 1 deletion

File tree

lib/assets/stylesheets/_core.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ $desktop-breakpoint: 992px !default;
3131
@import "modules/contribution-banner";
3232
@import "modules/technical-documentation";
3333
@import "modules/toc";
34+
@import "modules/warning-text";
3435
@import "modules/collapsible";
3536

3637
@import "accessibility";
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
.govuk-warning-text {
2+
font-family: nta,Arial,sans-serif;
3+
-webkit-font-smoothing: antialiased;
4+
-moz-osx-font-smoothing: grayscale;
5+
font-weight: 400;
6+
font-size: 16px;
7+
font-size: 1rem;
8+
line-height: 1.25;
9+
color: #0b0c0c;
10+
position: relative;
11+
margin-bottom: 20px;
12+
padding: 10px 0; }
13+
14+
@media print {
15+
.govuk-warning-text {
16+
font-family: sans-serif; } }
17+
@media (min-width: 40.0625em) {
18+
.govuk-warning-text {
19+
font-size: 19px;
20+
font-size: 1.1875rem;
21+
line-height: 1.31579; } }
22+
@media print {
23+
.govuk-warning-text {
24+
font-size: 14pt;
25+
line-height: 1.15;
26+
color: #000; } }
27+
@media (min-width: 40.0625em) {
28+
.govuk-warning-text {
29+
margin-bottom: 30px; } }
30+
.govuk-warning-text__assistive {
31+
position: absolute !important;
32+
width: 1px !important;
33+
height: 1px !important;
34+
margin: 0 !important;
35+
padding: 0 !important;
36+
overflow: hidden !important;
37+
clip: rect(0 0 0 0) !important;
38+
-webkit-clip-path: inset(50%) !important;
39+
clip-path: inset(50%) !important;
40+
border: 0 !important;
41+
white-space: nowrap !important; }
42+
43+
.govuk-warning-text__icon {
44+
font-family: nta,Arial,sans-serif;
45+
-webkit-font-smoothing: antialiased;
46+
-moz-osx-font-smoothing: grayscale;
47+
font-weight: 700;
48+
display: inline-block;
49+
position: absolute;
50+
top: 50%;
51+
left: 0;
52+
min-width: 32px;
53+
min-height: 29px;
54+
margin-top: -20px;
55+
padding-top: 3px;
56+
border: 3px solid #0b0c0c;
57+
border-radius: 50%;
58+
color: #fff;
59+
background: #0b0c0c;
60+
font-size: 1.6em;
61+
line-height: 29px;
62+
text-align: center;
63+
-webkit-user-select: none;
64+
-moz-user-select: none;
65+
-ms-user-select: none;
66+
user-select: none; }
67+
68+
@media print {
69+
.govuk-warning-text__icon {
70+
font-family: sans-serif; } }
71+
.govuk-warning-text__text {
72+
display: block;
73+
padding-left: 50px; }

lib/govuk_tech_docs.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
require 'govuk_tech_docs/tech_docs_html_renderer'
2121
require 'govuk_tech_docs/unique_identifier_extension'
2222
require 'govuk_tech_docs/unique_identifier_generator'
23+
require 'govuk_tech_docs/warning_text_extension'
2324
require 'govuk_tech_docs/api_reference/api_reference_extension'
2425

2526
module GovukTechDocs
@@ -58,7 +59,7 @@ def self.configure(context, options = {})
5859

5960
context.config[:tech_docs] = YAML.load_file('config/tech-docs.yml').with_indifferent_access
6061
context.activate :unique_identifier
61-
62+
context.activate :warning_text
6263
context.activate :api_reference
6364

6465
context.helpers do
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module GovukTechDocs
2+
class WarningTextExtension < Middleman::Extension
3+
def initialize(app, options_hash = {}, &block)
4+
super
5+
end
6+
7+
helpers do
8+
def warning_text(text)
9+
<<~EOS
10+
<div class="govuk-warning-text">
11+
<span class="govuk-warning-text__icon" aria-hidden="true">!</span>
12+
<strong class="govuk-warning-text__text">
13+
<span class="govuk-warning-text__assistive">Warning</span>
14+
#{text}
15+
</strong>
16+
</div>
17+
EOS
18+
end
19+
end
20+
end
21+
end
22+
23+
::Middleman::Extensions.register(:warning_text, GovukTechDocs::WarningTextExtension)

0 commit comments

Comments
 (0)