Skip to content

Commit 84fb5ef

Browse files
javier-godoypaodb
authored andcommitted
refactor: move inline styles to CSS
1 parent 0b6981b commit 84fb5ef

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/main/java/com/flowingcode/vaadin/addons/errorwindow/ErrorWindow.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.vaadin.flow.component.Html;
2424
import com.vaadin.flow.component.button.Button;
25+
import com.vaadin.flow.component.dependency.CssImport;
2526
import com.vaadin.flow.component.dialog.Dialog;
2627
import com.vaadin.flow.component.icon.VaadinIcon;
2728
import com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment;
@@ -42,6 +43,7 @@
4243
* @author pbartolo
4344
*/
4445
@SuppressWarnings("serial")
46+
@CssImport(value = "./flowingcode/error-window.css")
4547
public class ErrorWindow extends Dialog {
4648

4749
private static final Logger logger = LoggerFactory.getLogger(ErrorWindow.class);
@@ -116,6 +118,7 @@ private void initWindow() {
116118
setWidth("800px");
117119
setCloseOnEsc(true);
118120
setResizable(true);
121+
getElement().getThemeList().add("error-window");
119122
add(createMainLayout());
120123
}
121124

@@ -129,7 +132,7 @@ private VerticalLayout createMainLayout() {
129132
final Html title =
130133
new Html(
131134
String.format(
132-
"<h1 style='margin-top: 0; text-align: center; font-size: var(--lumo-font-size-xl);'>%s</h1>",
135+
"<h1 class='title'>%s</h1>",
133136
i18n.getCaption()));
134137

135138
title.getElement().getStyle().set("width", "100%");
@@ -203,7 +206,7 @@ protected Html createErrorLabel() {
203206
label =
204207
label.concat(
205208
String.format(
206-
"<br />%s<div style='text-align: center; font-weight: 600; font-size: var(--lumo-font-size-l); margin-top: 1em;'>%s</div>",
209+
"<br />%s<div class='uuid'>%s</div>",
207210
i18n.getInstructions(), uuid));
208211
}
209212
final Html errorLabel = new Html("<span>" + label + "</span>");
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[theme~="error-window"] .title {
2+
margin-top: 0;
3+
text-align: center;
4+
font-size: var(--lumo-font-size-xl);
5+
}
6+
7+
[theme~="error-window"] .uuid {
8+
text-align: center;
9+
font-weight: 600;
10+
font-size: var(--lumo-font-size-l);
11+
margin-top: 1em;
12+
}

0 commit comments

Comments
 (0)