Skip to content

Commit 0d35415

Browse files
committed
Default to native styling
1 parent 4d6a8b0 commit 0d35415

File tree

2 files changed

+63
-22
lines changed

2 files changed

+63
-22
lines changed

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

+19-22
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,16 @@
55
@include govuk-responsive-margin(6, "bottom");
66

77
display: block;
8-
9-
border-left: $govuk-border-width-wide solid $govuk-border-colour;
108
}
119

1210
.govuk-details__summary {
1311
// Make the focus outline shrink-wrap the text content of the summary
1412
display: inline-block;
1513

16-
margin-top: govuk-spacing(3);
17-
1814
margin-bottom: govuk-spacing(1);
1915
}
2016

2117
.govuk-details__summary-text {
22-
@include govuk-typography-weight-bold;
23-
@include govuk-responsive-margin(4, "bottom");
24-
padding-left: govuk-spacing(4);
25-
2618
> :first-child {
2719
margin-top: 0;
2820
}
@@ -48,6 +40,25 @@
4840
margin-bottom: 0;
4941
}
5042

43+
// Hack to target IE8 - IE11 (and REALLY old Firefox)
44+
// These browsers don't support the details element, so fall back to looking
45+
// like inset text
46+
@media screen\0 {
47+
.govuk-details {
48+
border-left: $govuk-border-width-wide solid $govuk-border-colour;
49+
}
50+
51+
.govuk-details__summary {
52+
margin-top: govuk-spacing(3);
53+
}
54+
55+
.govuk-details__summary-text {
56+
@include govuk-typography-weight-bold;
57+
@include govuk-responsive-margin(4, "bottom");
58+
padding-left: govuk-spacing(4);
59+
}
60+
}
61+
5162
// We wrap styles for newer browsers in a feature query, which is ignored by
5263
// older browsers, which always expand the details element.
5364
//
@@ -57,19 +68,11 @@
5768
// - support ES6 modules but not the <details> element (Edge 16 - 18)
5869
// - do not support ES6 modules or the <details> element (eg, IE8+)
5970
@supports not (-ms-ime-align: auto) {
60-
// Override default border
61-
.govuk-details {
62-
border-left: none;
63-
}
64-
6571
.govuk-details__summary {
6672

6773
// Absolutely position the marker against this element
6874
position: relative;
6975

70-
// Override default top margin
71-
margin-top: 0;
72-
7376
// Allow for absolutely positioned marker and align with disclosed text
7477
padding-left: govuk-spacing(4) + $govuk-border-width;
7578

@@ -88,12 +91,6 @@
8891
// ...but only underline the text, not the arrow
8992
.govuk-details__summary-text {
9093
@include govuk-link-decoration;
91-
// Override default font weight
92-
@include govuk-typography-weight-regular;
93-
// Override default margin
94-
margin-bottom: 0;
95-
// Override default padding
96-
padding-left: 0;
9794
}
9895

9996
.govuk-details__summary:hover .govuk-details__summary-text {

packages/govuk-frontend/src/govuk/components/details/implementation.md

+44
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
11
## Implementation notes
22

3+
### Styling in older browsers
4+
5+
#### Browsers with support for `type=module`, `<details>` and feature queries
6+
7+
https://browsersl.ist/#q=supports+details+and+supports+css-featurequeries+and+supports+es6-module&region=GB
8+
9+
Previously, we provided a polyfill for older browsers which do not support the
10+
`<details>` component. Since most browsers now DO support `<details>`, we've
11+
removed that polyfill, and we need to make sure browsers which don't support
12+
`<details>` don't use any styles that make them look interactable.
13+
14+
By wrapping these styles in a feature query, we can capture the vast majority of
15+
browsers which have full support.
16+
17+
#### Browsers that support `type=module` and feature queries but not `<details>`
18+
19+
https://browsersl.ist/#q=supports+es6-module+and+not+supports+details+and+supports+css-featurequeries&region=GB
20+
21+
This only affects Edge 16 - 18. We filter these out of the support query by
22+
checking for `-ms-ime-align: auto`, which isn't supported by any other browsers.
23+
24+
#### Browsers that support `<details>` but not `type=module` or feature queries
25+
26+
https://browsersl.ist/#q=supports+details+and+not+supports+css-featurequeries+and+not+supports+es6-module&region=GB
27+
28+
These will default to their native styling of the `<details>` element, with a
29+
few of our spacing and font styles.
30+
31+
#### Browsers which don't support `<details>`, `type=module` or feature queries
32+
33+
https://browsersl.ist/#q=%3E0.0000001%25+and+not+supports+details+and+not+supports+es6-module+and+not+supports+css-featurequeries&region=GB
34+
35+
This is largely IE 8 - 11.
36+
37+
We can account for IE by styling them like inset text, via a `@media screen\0`
38+
hack that no other browser supports.
39+
40+
#### Browsers that support feature queries, but not `<details>` or `type=module`
41+
42+
https://browsersl.ist/#q=supports+css-featurequeries+and+not+supports+details+and+not+supports+es6-module&region=GB
43+
44+
This is the only gap, as these browsers will get styled to look interactable,
45+
even though they aren't. This is largely Opera Mini.
46+
347
### Marker styling
448

549
Firefox uses display: list-item to show the arrow marker for the summary

0 commit comments

Comments
 (0)