Debian Codegraph @

resources/src/jquery/jquery.makeCollapsible.styles.less

raw
1 /**
2 * These rules prevent re-flows relating to collapsible on-wiki elements (T42812).
3 * This is done by temporarily creating a pseudo element in the place that JavaScript will insert
4 * a toggle control. The same CSS rules that control the positioning of the toggle control will apply
5 * to the pseudo element. When the JavaScript has executed
6 * (See corresponding non-render blocking CSS in jquery.makeCollapsible)
7 * all pseudo elements will be removed.
8 *
9 * Currently we support all the examples on [[mw:Manual:Collapsible_elements/Demo/Simple]]
10 * All examples on [[mw:Manual:Collapsible_elements/Demo/Advanced]] are supported with the following
11 * exceptions
12 * - Custom collapsible 4 (table-row)
13 * -- CSS selector would be too complicated
14 * - Collapsible div nested in collapsed div
15 * -- Given it's not easy to identify the collapsed content via CSS, text will be shown until
16 * JavaScript has loaded
17 * - "Combination example"
18 * -- At a later time, we may want to support the use of of `attr`, but given the code
19 * complexity we will not for the time being (see https://davidwalsh.name/css-content-attr)
20 */
21
22 // This selector is used frequently in the code to indicate that the JavaScript has successfully completed
23 // it's execution and pseudo elements can be disabled. For readability and maintainability it is separated
24 // as a LESS variable.
25 @exclude: ~'.mw-made-collapsible';
26
27 .client-js {
28 ol.mw-collapsible::before,
29 ul.mw-collapsible::before,
30 .mw-collapsible-toggle-li {
31 /*
32 * Rather than inherit any margins from the general li selector - make sure this is explicit
33 * to avoid reflows
34 */
35 display: list-item;
36 list-style: none;
37 margin-bottom: 0.1em;
38 }
39
40 // Reset when mw-collapsible-toggle-li is rendered
41 ol.mw-made-collapsible::before,
42 ul.mw-made-collapsible::before {
43 display: none;
44 }
45
46 // table.: Where the tbody or thead is the first child of the collapsible table
47 .mw-collapsible:not( @{exclude} ) .mw-collapsible-toggle-placeholder:before,
48 ol.mw-collapsible:not( @{exclude} ):before,
49 ul.mw-collapsible:not( @{exclude} ):before,
50 table.mw-collapsible:not( @{exclude} ) :first-child tr:first-child th:last-child:before,
51 table.mw-collapsible:not( @{exclude} ) > caption:first-child:after,
52 div.mw-collapsible:not( @{exclude} ):before {
53 content: '[@{msg-collapsible-collapse}]';
54 }
55
56 .mw-collapsed:not( @{exclude} ) .mw-collapsible-toggle-placeholder:before,
57 td.mw-collapsed:not( @{exclude} ):before,
58 table.mw-collapsed:not( @{exclude} ) :first-child tr:first-child th:last-child:before,
59 table.mw-collapsed:not( @{exclude} ) > caption:first-child:after,
60 div.mw-collapsed:not( @{exclude} ):before {
61 content: '[@{msg-collapsible-expand}]';
62 }
63
64 // Any element with id beginning `mw-customcollapsible` will have special treatment
65 .mw-collapsible[ id^='mw-customcollapsible' ] th::before,
66 .mw-collapsible[ id^='mw-customcollapsible' ]::before {
67 content: none !important; // stylelint-disable-line declaration-no-important
68 }
69
70 // Any element with a placeholder toggle will have special treatment
71 // (this is a separate rule, because :has() is not supported by all browsers yet)
72 /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
73 .mw-collapsible:not( @{exclude} ):has( .mw-collapsible-toggle, .mw-collapsible-toggle-placeholder ) th::before,
74 .mw-collapsible:not( @{exclude} ):has( .mw-collapsible-toggle, .mw-collapsible-toggle-placeholder )::before {
75 content: none !important; // stylelint-disable-line declaration-no-important
76 }
77
78 // Special case for table where first child is caption element
79 table.mw-collapsible:not( @{exclude} ) > caption:first-child:after {
80 float: none;
81 display: block;
82 }
83
84 // Use the exclude selector to ensure animations do not break
85 .mw-collapsed:not( @{exclude} ) {
86 // Avoid FOUC/reflows on collapsed elements by making sure they are opened by default (T42812)
87 // > thead + tbody: 'https://www.mediawiki.org/wiki/Manual:Collapsible_elements/Demo/Simple#Collapsed_by_default'
88 > p,
89 > table,
90 > thead + tbody,
91 tr:not( :first-child ),
92 .mw-collapsible-content {
93 display: none;
94 }
95 }
96 }
97
98 /* Collapsible elements in the UI (outside of the content area) are not in either .mw-content-ltr or
99 * .mw-content-rtl. Align them based on the user language. */
100 .mw-collapsible:not( @{exclude} ) th:before,
101 .mw-collapsible:not( @{exclude} ):before,
102 .mw-collapsible-toggle-placeholder,
103 .mw-collapsible-toggle {
104 float: right;
105 }
106
107 /* For collapsible elements in the content area, override the alginment based on the content language. */
108 /* @noflip */
109 .mw-content-ltr,
110 .mw-content-rtl .mw-content-ltr {
111 .mw-collapsible:not( @{exclude} ) th:before,
112 .mw-collapsible:not( @{exclude} ):before,
113 .mw-collapsible-toggle-placeholder,
114 .mw-collapsible-toggle {
115 float: right;
116 }
117 }
118
119 /* @noflip */
120 .mw-content-rtl,
121 .mw-content-ltr .mw-content-rtl {
122 .mw-collapsible:not( @{exclude} ) th:before,
123 .mw-collapsible:not( @{exclude} ):before,
124 .mw-collapsible-toggle-placeholder,
125 .mw-collapsible-toggle {
126 float: left;
127 }
128 }
129
130 /* list-items go as wide as their parent element, don't float them inside list items */
131 li,
132 .mw-content-ltr li,
133 .mw-content-rtl li,
134 .mw-content-ltr .mw-content-rtl li,
135 .mw-content-rtl .mw-content-ltr li {
136 .mw-collapsible-toggle-placeholder,
137 .mw-collapsible-toggle {
138 float: none;
139 }
140 }
141
142 // special treatment for list items to match above
143 // !important necessary to override overly-specific float left and right above.
144 ol.mw-collapsible:not( @{exclude} ):before,
145 ul.mw-collapsible:not( @{exclude} ):before {
146 float: none !important; // stylelint-disable-line declaration-no-important
147 }