Skip to content

Commit c75f4d6

Browse files
committed
Wrap everything in support query
EdgeHTML is the only browser engine that supports `-ms-ime-align`, so we can check Edge 12 - 18 by applying this property. https://browserstrangeness.github.io/css_hacks.html We can target Edge 16 - 18 more specifically, but keeping it simple for now. This approach just wraps almost everything in a check to see the browser DOESN'T support `-ms-ime-align`, but separates some spacing and border styles to make things look tolerable.
1 parent 857bc20 commit c75f4d6

File tree

1 file changed

+69
-61
lines changed
  • packages/govuk-frontend/src/govuk/components/details

1 file changed

+69
-61
lines changed

packages/govuk-frontend/src/govuk/components/details/_index.scss

+69-61
Original file line numberDiff line numberDiff line change
@@ -7,82 +7,90 @@
77
display: block;
88
}
99

10-
.govuk-details__summary {
11-
// Make the focus outline shrink-wrap the text content of the summary
12-
display: inline-block;
13-
14-
// Absolutely position the marker against this element
15-
position: relative;
10+
.govuk-details__text {
11+
padding-top: govuk-spacing(3);
12+
padding-bottom: govuk-spacing(3);
13+
padding-left: govuk-spacing(4);
14+
border-left: $govuk-border-width solid $govuk-border-colour;
15+
}
1616

17+
.govuk-details__summary {
1718
margin-bottom: govuk-spacing(1);
19+
}
1820

19-
// Allow for absolutely positioned marker and align with disclosed text
20-
padding-left: govuk-spacing(4) + $govuk-border-width;
21-
22-
// Style the summary to look like a link...
23-
color: $govuk-link-colour;
24-
cursor: pointer;
25-
26-
&:hover {
27-
color: $govuk-link-hover-colour;
21+
// Fix for older browsers which:
22+
// - support ES6 modules but not the <details> element (Edge 16 - 18)
23+
// - do not support ES6 modules or the <details> element (eg, IE8+)
24+
// -ms-ime-align is only supported by Edge 12 - 18
25+
// Older browsers ignore the entire feature query and use the styles above
26+
@supports not (-ms-ime-align: auto) {
27+
.govuk-details__summary {
28+
// Make the focus outline shrink-wrap the text content of the summary
29+
display: inline-block;
30+
31+
// Absolutely position the marker against this element
32+
position: relative;
33+
34+
// Allow for absolutely positioned marker and align with disclosed text
35+
padding-left: govuk-spacing(4) + $govuk-border-width;
36+
37+
// Style the summary to look like a link...
38+
color: $govuk-link-colour;
39+
cursor: pointer;
40+
41+
&:hover {
42+
color: $govuk-link-hover-colour;
43+
}
44+
45+
&:focus {
46+
@include govuk-focused-text;
47+
}
2848
}
29-
30-
&:focus {
31-
@include govuk-focused-text;
49+
// ...but only underline the text, not the arrow
50+
.govuk-details__summary-text {
51+
@include govuk-link-decoration;
3252
}
33-
}
34-
35-
// ...but only underline the text, not the arrow
36-
.govuk-details__summary-text {
37-
@include govuk-link-decoration;
38-
}
3953

40-
.govuk-details__summary:hover .govuk-details__summary-text {
41-
@include govuk-link-hover-decoration;
42-
}
54+
.govuk-details__summary:hover .govuk-details__summary-text {
55+
@include govuk-link-hover-decoration;
56+
}
4357

44-
// Remove the underline when focussed to avoid duplicate borders
45-
.govuk-details__summary:focus .govuk-details__summary-text {
46-
text-decoration: none;
47-
}
58+
// Remove the underline when focussed to avoid duplicate borders
59+
.govuk-details__summary:focus .govuk-details__summary-text {
60+
text-decoration: none;
61+
}
4862

49-
// Remove the default details marker so we can style our own consistently and
50-
// ensure it displays in Firefox (see implementation.md for details)
51-
.govuk-details__summary::-webkit-details-marker {
52-
display: none;
53-
}
63+
// Remove the default details marker so we can style our own consistently and
64+
// ensure it displays in Firefox (see implementation.md for details)
65+
.govuk-details__summary::-webkit-details-marker {
66+
display: none;
67+
}
5468

55-
// Append our own open / closed marker using a pseudo-element
56-
.govuk-details__summary::before {
57-
content: "";
58-
position: absolute;
69+
// Append our own open / closed marker using a pseudo-element
70+
.govuk-details__summary::before {
71+
content: "";
72+
position: absolute;
5973

60-
top: -1px;
61-
bottom: 0;
62-
left: 0;
74+
top: -1px;
75+
bottom: 0;
76+
left: 0;
6377

64-
margin: auto;
78+
margin: auto;
6579

66-
@include govuk-shape-arrow($direction: right, $base: 14px);
80+
@include govuk-shape-arrow($direction: right, $base: 14px);
6781

68-
.govuk-details[open] > & {
69-
@include govuk-shape-arrow($direction: down, $base: 14px);
82+
.govuk-details[open] > & {
83+
@include govuk-shape-arrow($direction: down, $base: 14px);
84+
}
7085
}
71-
}
72-
73-
.govuk-details__text {
74-
padding-top: govuk-spacing(3);
75-
padding-bottom: govuk-spacing(3);
76-
padding-left: govuk-spacing(4);
77-
border-left: $govuk-border-width solid $govuk-border-colour;
78-
}
7986

80-
.govuk-details__text p {
81-
margin-top: 0;
82-
margin-bottom: govuk-spacing(4);
83-
}
87+
.govuk-details__text p {
88+
margin-top: 0;
89+
margin-bottom: govuk-spacing(4);
90+
}
8491

85-
.govuk-details__text > :last-child {
86-
margin-bottom: 0;
92+
.govuk-details__text > :last-child {
93+
margin-bottom: 0;
94+
}
8795
}
8896
}

0 commit comments

Comments
 (0)