Skip to content

Commit 39d74a7

Browse files
stefanoriganoqsm-odoo
authored andcommitted
[FIX] web_editor: improve web_editor UI style preservation
* add and use preservation mixins to prevent undesired customizations made by themes * remove some style preservation code (and use the mixins instead) * add UI states' colour variables
1 parent 63fdde6 commit 39d74a7

File tree

4 files changed

+145
-47
lines changed

4 files changed

+145
-47
lines changed

addons/web_editor/static/src/js/widgets.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ var LinkDialog = Dialog.extend({
11451145
$preview.attr("target", new_window ? '_blank' : "")
11461146
.attr("href", url && url.length ? url : "#")
11471147
.html((label && label.length ? label : url))
1148-
.attr("class", classes.replace(/pull-\w+/, ''));
1148+
.attr("class", classes.replace(/pull-\w+/, '') + " o_btn_preview");
11491149
});
11501150
}
11511151
});

addons/web_editor/static/src/less/web_editor.variables.less

+119
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
@o-we-color-text-normal: #999999;
1010
@o-we-color-text-light: #d4d5d7;
1111
@o-we-color-danger: #e6586c;
12+
@o-we-color-warning: #f0ad4e;
13+
@o-we-color-success: #40ad67;
14+
@o-we-color-info: #6999a8;
1215

1316
@o-we-sidebar-width: 210px;
1417

@@ -76,3 +79,119 @@
7679
from { background: @odoo-brand-optional; }
7780
to { width: 0; background: transparent; }
7881
}
82+
83+
84+
// ============ Preservetion mixins ===============
85+
// Used to preserve web_editor and website UI from themes customizations
86+
87+
.o-w-preserve-base() {
88+
font-family: @o-we-font-family;
89+
line-height: 1.42857143;
90+
color: @o-we-color-divider;
91+
92+
.text-muted {
93+
color: @o-we-color-text-normal;
94+
}
95+
}
96+
97+
.o-w-preserve-headings() {
98+
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
99+
font-family: @o-we-font-family;
100+
line-height: 1.42857143;
101+
color: @o-we-color-dark;
102+
font-weight: bold;
103+
}
104+
}
105+
106+
.o-w-preserve-links() {
107+
a:not(.o_btn_preview) {
108+
color: @odoo-brand-optional;
109+
110+
&:focus, &:active, &:focus:active {
111+
outline: none!important;
112+
}
113+
}
114+
}
115+
116+
.o-w-preserve-forms() {
117+
.form-control {
118+
height: 34px;
119+
padding: 6px 12px;
120+
font-size: 14px;
121+
line-height: 1.42857143;
122+
border: 1px solid @o-we-color-text-light;
123+
color: #555;
124+
background-color: #fff;
125+
border-radius: 0;
126+
}
127+
}
128+
129+
.o-w-preserve-modals() {
130+
background: 0;
131+
132+
.modal-content {
133+
border-radius: 0;
134+
background-color: @o-we-color-paper;
135+
136+
.modal-body {
137+
background-color: white;
138+
}
139+
.modal-footer {
140+
text-align: left;
141+
}
142+
}
143+
}
144+
145+
.o-w-preserve-btn() {
146+
.btn:not(.o_btn_preview) {
147+
border-width: 1px;
148+
border-radius: 0;
149+
font-weight: normal;
150+
.button-size(6px; 12px; 14px; 1.42857143; 0);
151+
152+
&.btn-primary {
153+
.button-variant(white, @odoo-brand-optional, darken(@odoo-brand-optional,5%));
154+
text-transform: uppercase;
155+
}
156+
&.btn-default {
157+
.button-variant(@odoo-brand-optional, white, @o-we-color-text-light);
158+
text-transform: uppercase;
159+
}
160+
&.btn-link {
161+
.button-variant(@odoo-brand-optional, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0));
162+
}
163+
&.btn-success {
164+
.button-variant(white; @o-we-color-success; darken(@o-we-color-success, 5%));
165+
}
166+
&.btn-info {
167+
.button-variant(white; @o-we-color-info; darken(@o-we-color-info, 5%));
168+
}
169+
&.btn-warning {
170+
.button-variant(white; @o-we-color-warning; darken(@o-we-color-warning, 5%));
171+
}
172+
&.btn-danger {
173+
.button-variant(white; @o-we-color-danger; darken(@o-we-color-danger, 5%));
174+
}
175+
176+
&.btn-lg {
177+
.button-size(10px; 16px; 18px; 1.3333333; 0);
178+
}
179+
&.btn-sm {
180+
.button-size(5px; 10px; 12px; 1.5; 0);
181+
}
182+
&.btn-xs {
183+
.button-size(1px; 5px; 12px; 1.5; 0);
184+
}
185+
}
186+
}
187+
188+
.o-w-preserve-wells() {
189+
.well {
190+
padding: 19px;
191+
margin-bottom: 20px;
192+
background-color: @o-we-color-paper;
193+
border: 1px solid darken(@o-we-color-paper,5%);
194+
border-radius: 0;
195+
.box-shadow(none);
196+
}
197+
}

addons/web_editor/static/src/xml/editor.xml

+11-11
Original file line numberDiff line numberDiff line change
@@ -251,31 +251,31 @@
251251
<span class="caret"/></a>
252252
<ul aria-labelledby="dLabel" class="dropdown-menu" role="menu">
253253
<li>
254-
<label class="btn btn-link">Link
254+
<label class="btn btn-link o_btn_preview">Link
255255
<input checked="checked" class="link-style" name="link-style-type" type="radio" value=""/></label>
256256
</li>
257257
<li>
258-
<label class="btn btn-default">Basic
258+
<label class="btn btn-default o_btn_preview">Basic
259259
<input class="link-style" name="link-style-type" type="radio" value="btn-default"/></label>
260260
</li>
261261
<li>
262-
<label class="btn btn-success">Success
262+
<label class="btn btn-success o_btn_preview">Success
263263
<input class="link-style" name="link-style-type" type="radio" value="btn-success"/></label>
264264
</li>
265265
<li>
266-
<label class="btn btn-primary">Primary
266+
<label class="btn btn-primary o_btn_preview">Primary
267267
<input class="link-style" name="link-style-type" type="radio" value="btn-primary"/></label>
268268
</li>
269269
<li>
270-
<label class="btn btn-info">Info
270+
<label class="btn btn-info o_btn_preview">Info
271271
<input class="link-style" name="link-style-type" type="radio" value="btn-info"/></label>
272272
</li>
273273
<li>
274-
<label class="btn btn-warning">Warning
274+
<label class="btn btn-warning o_btn_preview">Warning
275275
<input class="link-style" name="link-style-type" type="radio" value="btn-warning"/></label>
276276
</li>
277277
<li>
278-
<label class="btn btn-danger">Danger
278+
<label class="btn btn-danger o_btn_preview">Danger
279279
<input class="link-style" name="link-style-type" type="radio" value="btn-danger"/></label>
280280
</li>
281281
</ul>
@@ -287,19 +287,19 @@
287287
<span class="caret"/></a>
288288
<ul aria-labelledby="dLabel" class="dropdown-menu" role="menu">
289289
<li>
290-
<label class="btn btn-default btn-xs">Extra Small
290+
<label class="btn btn-default btn-xs o_btn_preview">Extra Small
291291
<input class="link-style" name="link-style-size" type="radio" value="btn-xs"/></label>
292292
</li>
293293
<li>
294-
<label class="btn btn-default btn-sm">Small
294+
<label class="btn btn-default btn-sm o_btn_preview">Small
295295
<input class="link-style" name="link-style-size" type="radio" value="btn-sm"/></label>
296296
</li>
297297
<li>
298-
<label class="btn btn-default">Default
298+
<label class="btn btn-default o_btn_preview">Default
299299
<input checked="checked" class="link-style" name="link-style-size" type="radio" value=""/></label>
300300
</li>
301301
<li>
302-
<label class="btn btn-default btn-lg">Large
302+
<label class="btn btn-default btn-lg o_btn_preview">Large
303303
<input class="link-style" name="link-style-size" type="radio" value="btn-lg"/></label>
304304
</li>
305305
</ul>

addons/website/static/src/less/website.ui.components.less

+14-35
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,25 @@
11
// MODALS
22
body .modal {
3-
a {
4-
&:focus, &:active, &:focus:active {
5-
outline: none!important;
6-
}
7-
}
83

94
&.o_website_modal {
10-
font-family: @o-we-font-family;
11-
12-
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
13-
font-family: @o-we-font-family;
14-
}
5+
.o-w-preserve-base();
6+
.o-w-preserve-headings();
7+
.o-w-preserve-forms();
8+
.o-w-preserve-links();
9+
.o-w-preserve-btn();
10+
.o-w-preserve-wells();
11+
.o-w-preserve-modals();
1512

1613
.modal-content {
17-
border-radius: 0;
18-
color: initial!important;
19-
background-color: @o-we-color-paper!important;
2014
.modal-header .o_subtitle {
2115
margin-left: 10px;
2216
}
2317
.modal-body {
24-
color: inherit!important;
25-
background-color: transparent!important;
2618
.o_modal_header {
2719
.o-webclient-padding(@top: 10px, @bottom: 10px);
2820
.clearfix();
2921
}
3022
}
31-
.modal-footer {
32-
text-align: left;
33-
34-
.btn {
35-
border-radius: 0;
36-
37-
&.btn-primary {
38-
.button-variant(white, @odoo-brand-optional, @odoo-brand-optional);
39-
text-transform: uppercase;
40-
}
41-
&.btn-default {
42-
.button-variant(@odoo-brand-optional, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0));
43-
text-transform: uppercase;
44-
}
45-
&.btn-link {
46-
.button-variant(@odoo-brand-optional, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0));
47-
}
48-
}
49-
}
5023
}
5124

5225
@media (min-width: @screen-sm-min) {
@@ -89,7 +62,6 @@ body .modal {
8962

9063
.modal-content {
9164
background-color: black!important;
92-
color: lightgray!important;
9365
border: 3px outset gray;
9466
border-radius: 20px;
9567

@@ -99,6 +71,7 @@ body .modal {
9971
font-family: @o-we-font-family;
10072

10173
h4 {
74+
color: lightgray;
10275
font-family:inherit;
10376
font-weight: normal;
10477

@@ -109,6 +82,8 @@ body .modal {
10982
}
11083

11184
.modal-body {
85+
background-color: inherit!important;
86+
border-radius: 20px;
11287
padding: 15px;
11388

11489
@mobile-preview-width: 320px;
@@ -324,6 +299,10 @@ body .modal {
324299

325300
// ACE EDITOR
326301
.o_ace_view_editor {
302+
.o-w-preserve-base();
303+
.o-w-preserve-btn();
304+
.o-w-preserve-forms();
305+
327306
.o-position-absolute(@odoo-navbar-height, 0, 0);
328307
position: fixed;
329308
z-index: 1001;

0 commit comments

Comments
 (0)