govuk_publishing_components 1.8.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/application.scss +250 -14
- data/app/controllers/govuk_publishing_components/application_controller.rb +0 -15
- data/app/models/govuk_publishing_components/component_example.rb +8 -0
- data/app/views/govuk_publishing_components/component_guide/component_doc/_call.html.erb +2 -2
- data/app/views/layouts/govuk_publishing_components/application.html.erb +0 -4
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67bd6a32c2abf7c15f79bfe9fb3bbde61d610778
|
4
|
+
data.tar.gz: 3a54481bebf2ecadffb699ddf974c3a05789f926
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 647ac42a6ca57bc9d33390d22577cc805590c90278653fcd67cd5cb67c677fe703f9903f00637c55897abd3ded461d1bc743050d7bcb97a7c1fa985a29397074
|
7
|
+
data.tar.gz: 10b8f639b32628dd24ea08903ffb27474373714dc5020fbaacca395f3d268d8f7257715f0d14b66a9423451763e113a17ea99bd2b7a0fd1f423c0bf1b7beabff
|
@@ -4,7 +4,6 @@
|
|
4
4
|
@import "typography";
|
5
5
|
@import "colours";
|
6
6
|
|
7
|
-
$prism-background: #f5f2f0;
|
8
7
|
$border-color: #ccc;
|
9
8
|
|
10
9
|
.govuk-component-guide-wrapper {
|
@@ -74,15 +73,14 @@ $border-color: #ccc;
|
|
74
73
|
}
|
75
74
|
}
|
76
75
|
|
77
|
-
.
|
78
|
-
margin:
|
79
|
-
|
76
|
+
.component-call {
|
77
|
+
margin-top: $gutter-half;
|
78
|
+
margin-bottom: $gutter-half;
|
80
79
|
|
81
|
-
// Match Prism styles to avoid a flash as it renders
|
82
|
-
background: $prism-background;
|
83
80
|
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
84
81
|
font-size: 16px;
|
85
82
|
line-height: 1.5;
|
83
|
+
border: 1px solid $border-colour;
|
86
84
|
|
87
85
|
&[contenteditable]:hover {
|
88
86
|
cursor: text;
|
@@ -92,17 +90,15 @@ $border-color: #ccc;
|
|
92
90
|
outline: 3px solid $focus-colour;
|
93
91
|
}
|
94
92
|
|
95
|
-
pre
|
93
|
+
> pre {
|
96
94
|
padding: $gutter;
|
97
95
|
max-height: 300px;
|
98
|
-
|
96
|
+
overflow: auto;
|
99
97
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
.token.operator {
|
105
|
-
background: none;
|
98
|
+
> code {
|
99
|
+
font-family: inherit;
|
100
|
+
display: block;
|
101
|
+
}
|
106
102
|
}
|
107
103
|
}
|
108
104
|
|
@@ -218,3 +214,243 @@ html {
|
|
218
214
|
}
|
219
215
|
}
|
220
216
|
}
|
217
|
+
|
218
|
+
// Hide survey and cookie banners
|
219
|
+
// scss-lint:disable IdSelector
|
220
|
+
#user-satisfaction-survey-container,
|
221
|
+
#global-cookie-message {
|
222
|
+
display: none;
|
223
|
+
}
|
224
|
+
// scss-lint:enable IdSelector
|
225
|
+
|
226
|
+
// Rouge syntax highlighting
|
227
|
+
// Based on https://github.com/alphagov/tech-docs-template/blob/master/template/source/stylesheets/palette/_syntax-highlighting.scss
|
228
|
+
|
229
|
+
$code-00: scale-color($highlight-colour, $lightness:50%); // Default Background
|
230
|
+
$code-01: #f5f5f5; // Lighter Background (Unused)
|
231
|
+
$code-02: #bfc1c3; // Selection Background
|
232
|
+
$code-03: darken($secondary-text-colour, 2%); // Comments, Invisibles, Line Highlighting
|
233
|
+
$code-04: #e8e8e8; // Dark Foreground (Unused)
|
234
|
+
$code-05: $text-colour; // Default Foreground, Caret, Delimiters, Operators
|
235
|
+
$code-06: #ffffff; // Light Foreground (Unused)
|
236
|
+
$code-07: #ffffff; // Light Background (Unused)
|
237
|
+
|
238
|
+
$code-08: #ae5f3d; // Variables, XML Tags, Markup Link Text, Markup Lists
|
239
|
+
$code-09: #0E7754; // Integers, Boolean, Constants, XML Attributes, Markup Link Url
|
240
|
+
$code-0a: #4C4077; // Classes, Markup Bold, Search Text Background
|
241
|
+
$code-0b: $govuk-blue; // Strings, Inherited Class, Markup Code
|
242
|
+
$code-0c: $govuk-blue; // Support, Regular Expressions, Escape Characters, Markup Quotes
|
243
|
+
$code-0d: #4C4077; // Functions, Methods, Attribute IDs, Headings
|
244
|
+
$code-0e: #a71d5d; // Keywords, Storage, Selector, Markup Italic
|
245
|
+
$code-0f: #C92424; // Deprecated, Opening/Closing Embedded Language Tags e.g. <?php ?> (Unused)
|
246
|
+
|
247
|
+
$code-insert-bg: #DEF8CA;
|
248
|
+
$code-delete-bg: #FADDDD;
|
249
|
+
|
250
|
+
.component-highlight {
|
251
|
+
|
252
|
+
// Map Rouge / Pygments Tokens to work with 'Base 16' themes
|
253
|
+
|
254
|
+
background: $code-00;
|
255
|
+
color: $code-05;
|
256
|
+
|
257
|
+
//
|
258
|
+
// Comments
|
259
|
+
//
|
260
|
+
|
261
|
+
.c, // Comment
|
262
|
+
.cm, // Comment.Multiline
|
263
|
+
.cp, // Comment.Preproc
|
264
|
+
.c1, // Comment.Single
|
265
|
+
.cs { // Comment.Special
|
266
|
+
color: $code-03;
|
267
|
+
}
|
268
|
+
|
269
|
+
//
|
270
|
+
// Keywords
|
271
|
+
//
|
272
|
+
|
273
|
+
.k, // Keyword
|
274
|
+
.kc, // Keyword.Constant
|
275
|
+
.kd, // Keyword.Declaration
|
276
|
+
.kp, // Keyword.Pseudo
|
277
|
+
.kr { // Keyword.Reserved
|
278
|
+
color: $code-0e;
|
279
|
+
}
|
280
|
+
|
281
|
+
.kn { // Keyword.Namespace
|
282
|
+
color: $code-0c;
|
283
|
+
}
|
284
|
+
|
285
|
+
.kt { // Keyword.Type
|
286
|
+
color: $code-0a;
|
287
|
+
}
|
288
|
+
|
289
|
+
//
|
290
|
+
// Operators
|
291
|
+
//
|
292
|
+
|
293
|
+
.o, // Operator
|
294
|
+
.ow { // Operator.Word
|
295
|
+
color: $code-0c;
|
296
|
+
}
|
297
|
+
|
298
|
+
//
|
299
|
+
// Names
|
300
|
+
//
|
301
|
+
|
302
|
+
.n, // Name
|
303
|
+
.nb, // Name.Builtin
|
304
|
+
.bp, // Name.Builtin.Pseudo
|
305
|
+
.ni, // Name.Entity
|
306
|
+
.nl, // Name.Label
|
307
|
+
.py { // Name.Property
|
308
|
+
// Default styling
|
309
|
+
}
|
310
|
+
|
311
|
+
.nc, // Name.Class
|
312
|
+
.nn { // Name.Namespace
|
313
|
+
color: $code-0a;
|
314
|
+
}
|
315
|
+
|
316
|
+
.na, // Name.Attribute
|
317
|
+
.nf { // Name.Function
|
318
|
+
color: $code-0d;
|
319
|
+
}
|
320
|
+
|
321
|
+
.nv, // Name.Variable
|
322
|
+
.no, // Name.Constant
|
323
|
+
.vc, // Name.Variable.Class
|
324
|
+
.vg, // Name.Variable.Global
|
325
|
+
.vi { // Name.Variable.Instance
|
326
|
+
color: $code-08;
|
327
|
+
}
|
328
|
+
|
329
|
+
.nd { // Name.Decorator
|
330
|
+
color: $code-0c;
|
331
|
+
}
|
332
|
+
|
333
|
+
.nt, // Name.Tag
|
334
|
+
.nx { // Name.Other
|
335
|
+
color: $code-09;
|
336
|
+
}
|
337
|
+
|
338
|
+
.ne { // Name.Exception
|
339
|
+
color: $code-0f;
|
340
|
+
}
|
341
|
+
|
342
|
+
//
|
343
|
+
// Literals
|
344
|
+
//
|
345
|
+
|
346
|
+
.l { // Literal
|
347
|
+
color: $code-09;
|
348
|
+
}
|
349
|
+
|
350
|
+
.ld { // Literal.Date
|
351
|
+
color: $code-0b;
|
352
|
+
}
|
353
|
+
|
354
|
+
.m, // Literal.Number
|
355
|
+
.mf, // Literal.Number.Float
|
356
|
+
.mh, // Literal.Number.Hex
|
357
|
+
.mi, // Literal.Number.Integer
|
358
|
+
.il, // Literal.Number.Integer.Long
|
359
|
+
.mo { // Literal.Number.Oct
|
360
|
+
color: $code-09;
|
361
|
+
}
|
362
|
+
|
363
|
+
.s, // Literal.String
|
364
|
+
.sb, // Literal.String.Backtick
|
365
|
+
.s2, // Literal.String.Double
|
366
|
+
.sh { // Literal.String.Heredoc
|
367
|
+
color: $code-0b;
|
368
|
+
}
|
369
|
+
|
370
|
+
.sx, // Literal.String.Other
|
371
|
+
.sr, // Literal.String.Regex
|
372
|
+
.s1, // Literal.String.Single
|
373
|
+
.ss { // Literal.String.Symbol
|
374
|
+
color: $code-0b;
|
375
|
+
}
|
376
|
+
|
377
|
+
.se, // Literal.String.Escape
|
378
|
+
.si { // Literal.String.Interpol
|
379
|
+
color: $code-09;
|
380
|
+
}
|
381
|
+
|
382
|
+
.sd { // Literal.String.Doc
|
383
|
+
color: $code-03;
|
384
|
+
}
|
385
|
+
|
386
|
+
.sc { // Literal.String.Char
|
387
|
+
// Default styling
|
388
|
+
}
|
389
|
+
|
390
|
+
//
|
391
|
+
// Diffs
|
392
|
+
//
|
393
|
+
|
394
|
+
.gi { // Generic.Inserted
|
395
|
+
background-color: $code-insert-bg;
|
396
|
+
}
|
397
|
+
|
398
|
+
.gd { // Generic.Deleted
|
399
|
+
background-color: $code-delete-bg;
|
400
|
+
}
|
401
|
+
|
402
|
+
//
|
403
|
+
// Misc
|
404
|
+
//
|
405
|
+
|
406
|
+
.p { // Punctuation
|
407
|
+
// Default styling
|
408
|
+
}
|
409
|
+
|
410
|
+
.w { // Text.Whitespace
|
411
|
+
// Default styling
|
412
|
+
}
|
413
|
+
|
414
|
+
.hll { // Highlight
|
415
|
+
background-color: $code-02;
|
416
|
+
}
|
417
|
+
|
418
|
+
.err, // Error
|
419
|
+
.gr, // Generic.Error
|
420
|
+
.gt { // Generic.Traceback
|
421
|
+
color: $code-0f;
|
422
|
+
}
|
423
|
+
|
424
|
+
.gs { // Generic.Strong
|
425
|
+
font-weight: bold;
|
426
|
+
}
|
427
|
+
|
428
|
+
.ge { // Generic.Emph
|
429
|
+
font-style: italic;
|
430
|
+
}
|
431
|
+
|
432
|
+
.gh { // Generic.Heading
|
433
|
+
font-weight: bold;
|
434
|
+
}
|
435
|
+
|
436
|
+
.gu { // Generic.Subheading
|
437
|
+
color: $code-0a;
|
438
|
+
font-weight: bold;
|
439
|
+
}
|
440
|
+
|
441
|
+
.gp { // Generic.Prompt
|
442
|
+
color: $code-03;
|
443
|
+
font-weight: bold;
|
444
|
+
}
|
445
|
+
}
|
446
|
+
|
447
|
+
// Specific for this Gem, optimized for erb render statements
|
448
|
+
.component-highlight {
|
449
|
+
.s2 {
|
450
|
+
color: $code-08;
|
451
|
+
}
|
452
|
+
|
453
|
+
.n + .s2 {
|
454
|
+
color: $code-09;
|
455
|
+
}
|
456
|
+
}
|
@@ -6,7 +6,6 @@ module GovukPublishingComponents
|
|
6
6
|
protect_from_forgery with: :exception
|
7
7
|
before_action :set_custom_slimmer_headers
|
8
8
|
before_action :set_x_frame_options_header
|
9
|
-
before_action :set_no_banner_cookie
|
10
9
|
|
11
10
|
private
|
12
11
|
|
@@ -17,19 +16,5 @@ module GovukPublishingComponents
|
|
17
16
|
def set_x_frame_options_header
|
18
17
|
response.headers["X-Frame-Options"] = "ALLOWALL"
|
19
18
|
end
|
20
|
-
|
21
|
-
def set_no_banner_cookie
|
22
|
-
cookies['govuk_takenUserSatisfactionSurvey'] = {
|
23
|
-
value: 'yes',
|
24
|
-
domain: 'localhost',
|
25
|
-
path: '/component-guide'
|
26
|
-
}
|
27
|
-
|
28
|
-
cookies['seen_cookie_message'] = {
|
29
|
-
value: 'yes',
|
30
|
-
domain: 'localhost',
|
31
|
-
path: '/component-guide'
|
32
|
-
}
|
33
|
-
end
|
34
19
|
end
|
35
20
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rouge'
|
2
|
+
|
1
3
|
module GovukPublishingComponents
|
2
4
|
class ComponentExample
|
3
5
|
attr_reader :id,
|
@@ -16,6 +18,12 @@ module GovukPublishingComponents
|
|
16
18
|
id.humanize
|
17
19
|
end
|
18
20
|
|
21
|
+
def highlight_code(string_to_format = '')
|
22
|
+
formatter = Rouge::Formatters::HTML.new
|
23
|
+
lexer = Rouge::Lexers::ERB.new
|
24
|
+
formatter.format(lexer.lex(string_to_format)).html_safe
|
25
|
+
end
|
26
|
+
|
19
27
|
def pretty_data
|
20
28
|
JSON.pretty_generate(data).gsub('\\n', "\n ").gsub(/"(\w*)":/, '\1:').strip
|
21
29
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<div class="component-call
|
2
|
-
<pre
|
1
|
+
<div class="component-call component-highlight" contenteditable>
|
2
|
+
<pre><code><%= example.highlight_code("\<%= render \"#{@component_doc.partial_path}\" #{example.pretty_data} %\>") %></code></pre>
|
3
3
|
</div>
|
@@ -38,9 +38,5 @@
|
|
38
38
|
|
39
39
|
<%= yield %>
|
40
40
|
</main>
|
41
|
-
|
42
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/themes/prism.min.css" integrity="sha256-vtR0hSWRc3Tb26iuN2oZHt3KRUomwTufNIf5/4oeCyg=" crossorigin="anonymous" />
|
43
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/prism.min.js" integrity="sha256-Zb9yKJ/cfs+jG/zIOFL0QEuXr2CDKF7FR5YBJY3No+c=" crossorigin="anonymous"></script>
|
44
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/components/prism-ruby.min.js" integrity="sha256-e0SYaLys07GcwuYiWJ0aewa3AOR3hHFY1mNTppYPb34=" crossorigin="anonymous"></script>
|
45
41
|
</body>
|
46
42
|
</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_publishing_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 5.0.3
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rouge
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: govuk-lint
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|