PluginProbe
Code Snippets / 4.0.0-beta.1
Code Snippets v4.0.0-beta.1
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / css / common / _wp-admin.scss

_wp-admin.scss in Code Snippets 4.0.0-beta.1, at css/common/_wp-admin.scss

152 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 @use 'theme';
2
3 /**
4 * WordPress 7.0 admin compatibility.
5 *
6 * WP 7.0 ships the "modern" admin redesign, which enlarges native form controls
7 * (40px tall vs. 30/32px), reduces their corner radius (2px vs. 3/4px) and recolours
8 * secondary buttons with a transparent fill and the modern accent (#3858E9). Our admin
9 * UI was designed against the classic control metrics and the brand accent (#2271b1),
10 * so the redesign throws our spacing and colours out of alignment.
11 *
12 * These rules restore the classic control metrics for native elements inside our admin
13 * pages so the layout renders consistently on both WP 6.9 and WP 7.0. They deliberately
14 * leave the admin menu, admin bar and `@wordpress/components` React widgets untouched —
15 * only native inputs/buttons rendered inside our own markup are normalised.
16 */
17
18 @mixin classic-controls {
19 // Native single-line text controls and selects: restore 30px height + classic border.
20 // `@wordpress/components` inputs/selects (`.components-*`) keep their own design — they
21 // are excluded so React widgets such as the tags token field are left untouched.
22 // `.snippet-priority` (the borderless list-table priority field) is excluded so it keeps
23 // its plain transparent styling rather than gaining a bordered box.
24 input[type='text']='text']:not([class*='components-']),
25 input[type='search']='search']:not([class*='components-']),
26 input[type='number']='number']:not([class*='components-'], .snippet-priority),
27 input[type='email']='email']:not([class*='components-']),
28 input[type='url']='url']:not([class*='components-']),
29 input[type='password']='password']:not([class*='components-']),
30 input[type='tel']='tel']:not([class*='components-']) {
31 // `min-block-size` (not a fixed `block-size`) so controls floor at 30px but can still
32 // flex-stretch where the layout calls for it (e.g. the 54px cloud search bar).
33 min-block-size: theme.$control-height;
34 padding-block: 0;
35 padding-inline: 8px;
36 border: 1px solid theme.$control-border;
37 border-radius: 4px;
38 line-height: 2;
39 color: theme.$control-text;
40 font-size: 14px;
41
42 &:focus {
43 border-color: theme.$accent;
44 box-shadow: 0 0 0 1px theme.$accent;
45 outline: 2px solid transparent;
46 }
47 }
48
49 // Selects: same metrics, but preserve room for the WP dropdown chevron on the inline-end
50 // side. WP 7.0 keeps the chevron as a background image; clamping both paddings to 8px (as
51 // for text inputs) would let the arrow overlap the text, so the inline-end padding is wider.
52 select:not([class*='components-']) {
53 min-block-size: theme.$control-height;
54 padding-block: 0;
55 padding-inline: 8px 24px;
56 border: 1px solid theme.$control-border;
57 border-radius: 3px;
58
59 // WP 7.0 leaves a tall (≈38px) line-height on selects, pushing the value off-centre in
60 // the 30px control. Pin it so the text stays vertically centred.
61 line-height: 2;
62 color: theme.$control-text;
63 font-size: 14px;
64
65 &:focus {
66 border-color: theme.$accent;
67 box-shadow: 0 0 0 1px theme.$accent;
68 outline: 2px solid transparent;
69 }
70 }
71
72 // Secondary buttons: restore classic geometry, the grey fill and the brand accent
73 // border/text in place of WP 7.0's transparent + modern-blue treatment. `.button-primary`
74 // is excluded so its solid fill below is not overwritten.
75 .button:not(.button-primary),
76 .button-secondary {
77 min-block-size: theme.$control-height;
78 padding-block: 0;
79 padding-inline: 12px;
80 border-radius: 3px;
81 line-height: 2.3077;
82 font-size: 13px;
83 font-weight: 400;
84 background: #f6f7f7;
85 border-color: theme.$accent;
86 color: theme.$accent;
87
88 &:hover:not(:disabled) {
89 background: #f0f0f1;
90 border-color: theme.$accent-hover;
91 color: theme.$accent-hover;
92 }
93
94 &:focus:not(:disabled) {
95 border-color: #3582c4;
96 box-shadow: 0 0 0 1px #3582c4;
97 outline: 2px solid transparent;
98 }
99 }
100
101 // Primary buttons: WP 7.0 recolours these with the modern accent and drops the solid
102 // fill. Restore the classic solid brand-accent fill with white text.
103 .button-primary {
104 min-block-size: theme.$control-height;
105 padding-block: 0;
106 padding-inline: 12px;
107 border-radius: 3px;
108 line-height: 2.3077;
109 font-size: 13px;
110 font-weight: 400;
111 background: theme.$accent;
112 border-color: theme.$accent;
113 color: #fff;
114
115 &:hover:not(:disabled) {
116 background: theme.$accent-hover;
117 border-color: theme.$accent-hover;
118 color: #fff;
119 }
120
121 &:focus:not(:disabled) {
122 background: theme.$accent-hover;
123 border-color: theme.$accent-hover;
124 box-shadow: 0 0 0 1px #fff, 0 0 0 3px theme.$accent;
125 outline: 2px solid transparent;
126 }
127 }
128
129 // Small buttons stay compact rather than inheriting the 40px control height.
130 .button-small {
131 min-block-size: 26px;
132 line-height: 2.1818;
133 font-size: 11px;
134 }
135
136 // WP 7.0's taller button line-height leaks onto dashicon glyphs inside buttons (e.g. the
137 // conditions badge icon), pushing them out of vertical alignment. Reset it so icons stay
138 // centred — mirrors the existing `.button svg` rule for SVG icons.
139 .button .dashicons {
140 line-height: 1;
141 }
142 }
143
144 // Scope to our admin page content. We intentionally keep this to a single `.wrap` class so
145 // the rules sit just above WordPress core defaults (which we must override) but below the
146 // plugin's own more-specific per-control rules, which are emitted later in each bundle and so
147 // win on equal specificity. This lets bespoke controls (conditions button, row-action links,
148 // priority input, etc.) keep their intended styling without per-element exclusions here.
149 .wrap {
150 @include classic-controls;
151 }
152