Skip to content

Commit be2a2ea

Browse files
committed
Add custom asset handlers for app asset paths
Also, replace `image-url` helper instances with CSS url() function See rails/dartsass-rails#18
1 parent 35d3443 commit be2a2ea

File tree

11 files changed

+49
-34
lines changed

11 files changed

+49
-34
lines changed

app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss

+20-20
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
display: table-cell;
99
width: 60px;
1010
height: 45px;
11-
background: image-url("govuk_publishing_components/action-link-arrow.png");
12-
background: image-url("govuk_publishing_components/action-link-arrow.svg"), linear-gradient(transparent, transparent);
11+
background: url("govuk_publishing_components/action-link-arrow.png");
12+
background: url("govuk_publishing_components/action-link-arrow.svg"), linear-gradient(transparent, transparent);
1313
background-repeat: no-repeat;
1414
background-position: 0 50%;
1515
background-size: 45px auto;
@@ -96,17 +96,17 @@
9696

9797
.gem-c-action-link--white-arrow {
9898
&::before {
99-
background-image: image-url("govuk_publishing_components/action-link-arrow--white.png");
100-
background-image: image-url("govuk_publishing_components/action-link-arrow--white.svg"), linear-gradient(transparent, transparent);
99+
background-image: url("govuk_publishing_components/action-link-arrow--white.png");
100+
background-image: url("govuk_publishing_components/action-link-arrow--white.svg"), linear-gradient(transparent, transparent);
101101
}
102102
}
103103

104104
.gem-c-action-link--blue-arrow {
105105
&::before {
106106
width: 36px;
107107
height: 28px;
108-
background: image-url("govuk_publishing_components/action-link-arrow--blue.png");
109-
background: image-url("govuk_publishing_components/action-link-arrow--blue.svg"), linear-gradient(transparent, transparent);
108+
background: url("govuk_publishing_components/action-link-arrow--blue.png");
109+
background: url("govuk_publishing_components/action-link-arrow--blue.svg"), linear-gradient(transparent, transparent);
110110
background-repeat: no-repeat;
111111
background-size: 28px auto;
112112
background-position: 0 0;
@@ -123,8 +123,8 @@
123123
&::before {
124124
width: 30px;
125125
height: 30px;
126-
background: image-url("govuk_publishing_components/action-link-arrow--simple.png");
127-
background: image-url("govuk_publishing_components/action-link-arrow--simple.svg"), linear-gradient(transparent, transparent);
126+
background: url("govuk_publishing_components/action-link-arrow--simple.png");
127+
background: url("govuk_publishing_components/action-link-arrow--simple.svg"), linear-gradient(transparent, transparent);
128128
background-repeat: no-repeat;
129129
background-size: 25px auto;
130130
background-position: 0 2px;
@@ -135,8 +135,8 @@
135135
&::before {
136136
width: 30px;
137137
height: 30px;
138-
background: image-url("govuk_publishing_components/action-link-arrow--simple-light.png");
139-
background: image-url("govuk_publishing_components/action-link-arrow--simple-light.svg"), linear-gradient(transparent, transparent);
138+
background: url("govuk_publishing_components/action-link-arrow--simple-light.png");
139+
background: url("govuk_publishing_components/action-link-arrow--simple-light.svg"), linear-gradient(transparent, transparent);
140140
background-repeat: no-repeat;
141141
background-size: 25px auto;
142142
background-position: 0 2px;
@@ -145,15 +145,15 @@
145145

146146
.gem-c-action-link--dark-icon {
147147
&::before {
148-
background: image-url("govuk_publishing_components/action-link-arrow--dark.png");
149-
background: image-url("govuk_publishing_components/action-link-arrow--dark.svg"), linear-gradient(transparent, transparent);
148+
background: url("govuk_publishing_components/action-link-arrow--dark.png");
149+
background: url("govuk_publishing_components/action-link-arrow--dark.svg"), linear-gradient(transparent, transparent);
150150
}
151151
}
152152

153153
.gem-c-action-link--dark-large-icon {
154154
&::before {
155-
background: image-url("govuk_publishing_components/action-link-arrow--dark.png");
156-
background: image-url("govuk_publishing_components/action-link-arrow--dark.svg"), linear-gradient(transparent, transparent);
155+
background: url("govuk_publishing_components/action-link-arrow--dark.png");
156+
background: url("govuk_publishing_components/action-link-arrow--dark.svg"), linear-gradient(transparent, transparent);
157157
height: 34px;
158158
width: 40px;
159159
background-repeat: no-repeat;
@@ -170,8 +170,8 @@
170170
&::before {
171171
width: 36px;
172172
height: 28px;
173-
background: image-url("govuk_publishing_components/action-link-arrow--light.png");
174-
background: image-url("govuk_publishing_components/action-link-arrow--light.svg"), linear-gradient(transparent, transparent);
173+
background: url("govuk_publishing_components/action-link-arrow--light.png");
174+
background: url("govuk_publishing_components/action-link-arrow--light.svg"), linear-gradient(transparent, transparent);
175175
background-repeat: no-repeat;
176176
background-size: 28px auto;
177177
background-position: 0 0;
@@ -203,7 +203,7 @@
203203

204204
.gem-c-action-link--transparent-icon {
205205
&::before {
206-
background-image: image-url("govuk_publishing_components/action-link-arrow--transparent.svg");
206+
background-image: url("govuk_publishing_components/action-link-arrow--transparent.svg");
207207
}
208208
}
209209

@@ -213,7 +213,7 @@
213213
&::before {
214214
height: 30px;
215215
width: 30px;
216-
background-image: image-url("govuk_publishing_components/action-link-arrow--brexit.svg");
216+
background-image: url("govuk_publishing_components/action-link-arrow--brexit.svg");
217217
background-repeat: no-repeat;
218218
background-size: 18px auto;
219219
background-position: 0 2px;
@@ -238,8 +238,8 @@
238238
&::before {
239239
width: 80px;
240240
height: 70px;
241-
background: image-url("govuk_publishing_components/action-link--nhs.png");
242-
background: image-url("govuk_publishing_components/action-link--nhs.svg"), linear-gradient(transparent, transparent);
241+
background: url("govuk_publishing_components/action-link--nhs.png");
242+
background: url("govuk_publishing_components/action-link--nhs.svg"), linear-gradient(transparent, transparent);
243243
background-repeat: no-repeat;
244244
background-size: 85% auto;
245245
background-position: 0 50%;

app/assets/stylesheets/govuk_publishing_components/components/_input.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $search-icon-size: 40px;
1212
width: $search-icon-size;
1313
height: $search-icon-size;
1414
height: govuk-px-to-rem($search-icon-size);
15-
background: image-url("govuk_publishing_components/icon-search.svg") no-repeat -3px center;
15+
background: url("govuk_publishing_components/icon-search.svg") no-repeat -3px center;
1616
}
1717

1818
// this overrides styles from static that break the look of the component

app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "govuk_publishing_components/individual_component_support";
2+
13
@import "govuk_publishing_components/components/search";
24
@import "govuk_publishing_components/components/skip-link";
35
@import "govuk/components/header/header";

app/assets/stylesheets/govuk_publishing_components/components/_option-select.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112

113113
.gem-c-option-select__filter-input {
114114
@include govuk-font(19);
115-
background: image-url("option-select/input-icon.svg") govuk-colour("white") no-repeat -5px -3px;
115+
background: url("option-select/input-icon.svg") govuk-colour("white") no-repeat -5px -3px;
116116

117117
@include govuk-media-query($from: tablet) {
118118
@include govuk-font(16);

app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,19 @@
8282
}
8383

8484
@mixin crest($crest) {
85-
background: image-url("govuk_publishing_components/crests/#{$crest}_13px.png") no-repeat 5px 0;
85+
background: url("govuk_publishing_components/crests/#{$crest}_13px.png") no-repeat 5px 0;
8686
background-size: auto 20px;
8787

8888
@include govuk-device-pixel-ratio {
89-
background-image: image-url("govuk_publishing_components/crests/#{$crest}_13px_x2.png");
89+
background-image: url("govuk_publishing_components/crests/#{$crest}_13px_x2.png");
9090
}
9191

9292
@include govuk-media-query($from: tablet) {
93-
background: image-url("govuk_publishing_components/crests/#{$crest}_18px.png") no-repeat 6px 0;
93+
background: url("govuk_publishing_components/crests/#{$crest}_18px.png") no-repeat 6px 0;
9494
background-size: auto 26px;
9595

9696
@include govuk-device-pixel-ratio {
97-
background-image: image-url("govuk_publishing_components/crests/#{$crest}_18px_x2.png");
97+
background-image: url("govuk_publishing_components/crests/#{$crest}_18px_x2.png");
9898
}
9999
}
100100
}

app/assets/stylesheets/govuk_publishing_components/components/_print-link.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ $gem-c-print-link-background-height: 18px;
1919

2020
.gem-c-print-link__link,
2121
.gem-c-print-link__button {
22-
background: image-url("govuk_publishing_components/icon-print.png") no-repeat govuk-spacing(2) 50%;
22+
background: url("govuk_publishing_components/icon-print.png") no-repeat govuk-spacing(2) 50%;
2323
background-size: $gem-c-print-link-background-width $gem-c-print-link-background-height;
2424
padding: govuk-spacing(2) govuk-spacing(2) govuk-spacing(2) (govuk-spacing(4) + $gem-c-print-link-background-width);
2525
text-decoration: none;
2626

2727
@include govuk-device-pixel-ratio($ratio: 2) {
28-
background-image: image-url("govuk_publishing_components/icon-print-2x.png");
28+
background-image: url("govuk_publishing_components/icon-print-2x.png");
2929
}
3030

3131
&:hover {

app/assets/stylesheets/govuk_publishing_components/components/_search.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ $large-input-size: 50px;
268268
.search-toggle {
269269
display: none;
270270
background-color: govuk-colour("blue");
271-
background-image: image-url("govuk_publishing_components/search-button.png");
271+
background-image: url("govuk_publishing_components/search-button.png");
272272
background-position: 0 50%;
273273
background-repeat: no-repeat;
274274
float: right;

app/assets/stylesheets/govuk_publishing_components/components/govspeak/_advisory.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $high-alert-border: #cc0000;
44
.govspeak, // Legacy class name that's still used in some content items - needs to be kept until `.govspeak` is removed from the content items.
55
.gem-c-govspeak {
66
.advisory {
7-
background-image: image-url("govuk_publishing_components/icon-important.svg");
7+
background-image: url("govuk_publishing_components/icon-important.svg");
88
background-repeat: no-repeat;
99
background-size: 30px 30px;
1010
background-position: 98% center;

app/assets/stylesheets/govuk_publishing_components/components/govspeak/_form-download.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
a {
1515
display: block;
1616
font-weight: 600;
17-
background-image: image-url("govuk_publishing_components/icon-file-download.svg");
17+
background-image: url("govuk_publishing_components/icon-file-download.svg");
1818
background-repeat: no-repeat;
1919
background-size: 40px 40px;
2020
min-height: 2.5em;

app/assets/stylesheets/govuk_publishing_components/components/govspeak/_warning-callout.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
margin: 2em 0;
1717

1818
// Add '!' icon
19-
background-image: image-url("govuk_publishing_components/icon-important.svg");
19+
background-image: url("govuk_publishing_components/icon-important.svg");
2020
background-size: $icon-size $icon-size;
2121
background-repeat: no-repeat;
2222
min-height: $icon-size;
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
$govuk-image-url-function: "image-url";
2-
$govuk-font-url-function: "font-url";
1+
// Custom image URL function
2+
// https://github.com/alphagov/govuk-frontend/blob/9f05cea739d14d4cbf18e79b17228045ca84b3ba/packages/govuk-frontend/src/govuk/settings/_assets.scss#L30-L55
3+
4+
@function app-image-url($filename) {
5+
@return url("#{$filename}");
6+
}
7+
// Custom font URL function
8+
// https://github.com/alphagov/govuk-frontend/blob/9f05cea739d14d4cbf18e79b17228045ca84b3ba/packages/govuk-frontend/src/govuk/settings/_assets.scss#L57-L82
9+
10+
@function app-font-url($filename) {
11+
@return url("#{$filename}");
12+
}
13+
14+
$govuk-image-url-function: "app-image-url";
15+
$govuk-font-url-function: "app-font-url";

0 commit comments

Comments
 (0)