Skip to content

Commit 38cbb64

Browse files
committed
fix(forms): modernize CSS themes with :where() zero-specificity reset
Replace heavy opinionated color themes (light/dark/red/blue/green) with minimal :where() CSS reset that has zero specificity — themes and plugins always win. - Rewrite form-basic.css with :where() selectors (~48 lines vs ~320) - Remove form-themes.css content (deprecated placeholder) - Remove theme options from admin UI (only Inherit + Basic remain) - Add migration 5.0.0 to convert theme-* selections to basic - Add defensive theme-* fallback in get_stylesheet() - Remove mc4wp-form-theme class generation - Use CSS logical properties for RTL support - Keep alert color classes at normal specificity (functional) Fixes #844
1 parent ebe051c commit 38cbb64

8 files changed

Lines changed: 94 additions & 420 deletions

File tree

assets/src/css/form-basic.css

Lines changed: 30 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,61 @@
1-
.mc4wp-form input[name^="_mc4wp_honey"] { display: none !important; }
1+
/* Mailchimp for WP - Form Reset */
22

3-
/* Mailchimp for WP - Default Form Styles */
4-
.mc4wp-form-basic {
5-
margin: 1em 0;
6-
}
7-
8-
.mc4wp-form-basic label,
9-
.mc4wp-form-basic input {
10-
width: auto;
11-
box-sizing: border-box;
12-
cursor: auto;
13-
height: auto;
14-
vertical-align: baseline;
15-
line-height: normal;
3+
/* Hide honeypot field */
4+
.mc4wp-form input[name^="_mc4wp_honey"] {
5+
display: none !important;
166
}
177

18-
.mc4wp-form-basic label:after,
19-
.mc4wp-form-basic input:after {
20-
content: "";
21-
display: table;
22-
clear: both;
8+
/* Zero-specificity reset via :where() — themes/plugins always win */
9+
:where(.mc4wp-form) {
10+
margin: 1em 0;
2311
}
2412

25-
.mc4wp-form-basic label {
13+
:where(.mc4wp-form label) {
14+
display: block;
2615
font-weight: bold;
2716
margin-bottom: 6px;
28-
display: block;
29-
}
30-
31-
/* OLD STYLE: When input is a sibling (not nested) */
32-
.mc4wp-form-basic label + input {
33-
display: block;
3417
}
3518

36-
/* NEW STYLE: When input is nested inside label */
37-
.mc4wp-form-basic label > input {
19+
:where(.mc4wp-form label > input),
20+
:where(.mc4wp-form label > textarea),
21+
:where(.mc4wp-form label > select) {
3822
display: block;
3923
margin-top: 6px;
4024
font-weight: normal;
4125
}
4226

43-
/* Form Elements */
44-
.mc4wp-form-basic input[type="text"],
45-
.mc4wp-form-basic input[type="email"],
46-
.mc4wp-form-basic input[type="tel"],
47-
.mc4wp-form-basic input[type="url"],
48-
.mc4wp-form-basic input[type="date"],
49-
.mc4wp-form-basic textarea,
50-
.mc4wp-form-basic select {
51-
min-height: 32px;
27+
:where(.mc4wp-form input[type="text"]),
28+
:where(.mc4wp-form input[type="email"]),
29+
:where(.mc4wp-form input[type="tel"]),
30+
:where(.mc4wp-form input[type="url"]),
31+
:where(.mc4wp-form input[type="date"]),
32+
:where(.mc4wp-form textarea),
33+
:where(.mc4wp-form select) {
34+
box-sizing: border-box;
5235
width: 100%;
5336
max-width: 480px;
37+
min-height: 32px;
5438
}
5539

56-
.mc4wp-form-basic input[type="number"] {
40+
:where(.mc4wp-form input[type="number"]) {
5741
min-width: 40px;
5842
}
5943

60-
.mc4wp-form-basic input[type="checkbox"],
61-
.mc4wp-form-basic input[type="radio"] {
62-
position: relative;
63-
margin: 0 6px 0 0;
64-
padding: 0;
65-
height: 13px;
66-
width: 13px;
67-
display: inline-block;
68-
border: 0;
69-
}
70-
71-
/* NEW STYLE: Checkbox/radio nested in label - override inline-block */
72-
.mc4wp-form-basic label > input[type="checkbox"],
73-
.mc4wp-form-basic label > input[type="radio"] {
44+
:where(.mc4wp-form input[type="checkbox"]),
45+
:where(.mc4wp-form input[type="radio"]) {
7446
display: inline-block;
75-
margin-top: 0;
47+
margin-block: 0;
48+
margin-inline-end: 6px;
7649
}
7750

78-
.mc4wp-form-basic input[type="checkbox"] {
79-
appearance: checkbox;
80-
}
81-
82-
.mc4wp-form-basic input[type="radio"] {
83-
appearance: radio;
84-
}
85-
86-
.mc4wp-form-basic input[type="submit"],
87-
.mc4wp-form-basic button,
88-
.mc4wp-form-basic input[type="button"] {
51+
:where(.mc4wp-form input[type="submit"]),
52+
:where(.mc4wp-form button) {
8953
cursor: pointer;
9054
display: inline-block;
9155
appearance: none;
9256
}
9357

94-
/* Remove font-weight bold from nested elements */
95-
.mc4wp-form-basic label > span,
96-
.mc4wp-form-basic li > label {
97-
font-weight: normal;
98-
}
99-
100-
/* Alert */
58+
/* Alert colors — functional, normal specificity */
10159
.mc4wp-alert {
10260
color: #c09853;
10361
clear: both;
@@ -112,11 +70,5 @@
11270
}
11371

11472
.mc4wp-error {
115-
color: #CD5C5C;
116-
}
117-
118-
/* Right-To-Left specific styles */
119-
.rtl .mc4wp-form-basic input[type="checkbox"],
120-
.rtl .mc4wp-form-basic input[type="radio"] {
121-
margin: 0 0 0 6px;
73+
color: #cd5c5c;
12274
}

0 commit comments

Comments
 (0)