Skip to content

Commit 3aedf0d

Browse files
Replace image-url asset helper instances
Replace instances with CSS url() function. See rails/dartsass-rails#18. Also, add asset handlers to ensure fonts and images are correctly referenced. See https://frontend.design-system.service.gov.uk/importing-css-assets-and-javascript/#copy-the-font-and-image-files-into-your-application. Co-Authored-By: Martin Jones <[email protected]>
1 parent 6196e06 commit 3aedf0d

File tree

10 files changed

+40
-27
lines changed

10 files changed

+40
-27
lines changed

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

Lines changed: 12 additions & 12 deletions
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;
@@ -98,8 +98,8 @@
9898
&::before {
9999
width: 30px;
100100
height: 30px;
101-
background: image-url("govuk_publishing_components/action-link-arrow--simple.png");
102-
background: image-url("govuk_publishing_components/action-link-arrow--simple.svg"), linear-gradient(transparent, transparent);
101+
background: url("govuk_publishing_components/action-link-arrow--simple.png");
102+
background: url("govuk_publishing_components/action-link-arrow--simple.svg"), linear-gradient(transparent, transparent);
103103
background-repeat: no-repeat;
104104
background-size: 25px auto;
105105
background-position: 0 2px;
@@ -110,8 +110,8 @@
110110
&::before {
111111
width: 30px;
112112
height: 30px;
113-
background: image-url("govuk_publishing_components/action-link-arrow--simple-light.png");
114-
background: image-url("govuk_publishing_components/action-link-arrow--simple-light.svg"), linear-gradient(transparent, transparent);
113+
background: url("govuk_publishing_components/action-link-arrow--simple-light.png");
114+
background: url("govuk_publishing_components/action-link-arrow--simple-light.svg"), linear-gradient(transparent, transparent);
115115
background-repeat: no-repeat;
116116
background-size: 25px auto;
117117
background-position: 0 2px;
@@ -120,8 +120,8 @@
120120

121121
.gem-c-action-link--dark-large-icon {
122122
&::before {
123-
background: image-url("govuk_publishing_components/action-link-arrow--dark.png");
124-
background: image-url("govuk_publishing_components/action-link-arrow--dark.svg"), linear-gradient(transparent, transparent);
123+
background: url("govuk_publishing_components/action-link-arrow--dark.png");
124+
background: url("govuk_publishing_components/action-link-arrow--dark.svg"), linear-gradient(transparent, transparent);
125125
height: 34px;
126126
width: 40px;
127127
background-repeat: no-repeat;
@@ -138,8 +138,8 @@
138138
&::before {
139139
width: 36px;
140140
height: 28px;
141-
background: image-url("govuk_publishing_components/action-link-arrow--light.png");
142-
background: image-url("govuk_publishing_components/action-link-arrow--light.svg"), linear-gradient(transparent, transparent);
141+
background: url("govuk_publishing_components/action-link-arrow--light.png");
142+
background: url("govuk_publishing_components/action-link-arrow--light.svg"), linear-gradient(transparent, transparent);
143143
background-repeat: no-repeat;
144144
background-size: 28px auto;
145145
background-position: 0 0;
@@ -162,8 +162,8 @@
162162
&::before {
163163
height: 30px;
164164
width: 35px;
165-
background: image-url("govuk_publishing_components/action-link-arrow--dark.png");
166-
background: image-url("govuk_publishing_components/action-link-arrow--dark.svg"), linear-gradient(transparent, transparent);
165+
background: url("govuk_publishing_components/action-link-arrow--dark.png");
166+
background: url("govuk_publishing_components/action-link-arrow--dark.svg"), linear-gradient(transparent, transparent);
167167
background-repeat: no-repeat;
168168
background-size: 25px auto;
169169
background-position: 0 2px;

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

Lines changed: 1 addition & 1 deletion
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/_option-select.scss

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ $large-input-size: 50px;
9595
// Note: this is a non-standard CSS feature and will not do anything in Firefox. https://bugzilla.mozilla.org/show_bug.cgi?id=1417753
9696
&::-webkit-search-cancel-button {
9797
-webkit-appearance: none;
98-
background-image: image-url("govuk_publishing_components/icon-close.svg");
98+
background-image: url("govuk_publishing_components/icon-close.svg");
9999
background-position: center;
100100
background-repeat: no-repeat;
101101
cursor: pointer;
@@ -281,7 +281,7 @@ $large-input-size: 50px;
281281
.search-toggle {
282282
display: none;
283283
background-color: govuk-colour("blue");
284-
background-image: image-url("govuk_publishing_components/search-button.png");
284+
background-image: url("govuk_publishing_components/search-button.png");
285285
background-position: 0 50%;
286286
background-repeat: no-repeat;
287287
float: right;

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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;
Lines changed: 15 additions & 2 deletions
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)