diff --git a/frontend/styles/view/main/inference-rule-field.css b/frontend/styles/view/main/inference-rule-field.css index 772164f..92651bc 100644 --- a/frontend/styles/view/main/inference-rule-field.css +++ b/frontend/styles/view/main/inference-rule-field.css @@ -12,8 +12,9 @@ #headerField { border-bottom: 2px solid #e8e8e8; background-color: #f8f8f8; + display: grid; + grid-template-columns: 1fr repeat(1, auto) 1fr; align-items: center; - justify-content: center; width: 100%; padding: 0.5em 0em; border-radius: 5px 5px 0 0; @@ -23,6 +24,11 @@ margin: 1px; } +#copyButton { + margin-left: auto; + margin-right: 10%; +} + #main { align-items: center; justify-content: center; diff --git a/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java b/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java index 4ef8a1b..ee89c7b 100644 --- a/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java +++ b/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java @@ -7,6 +7,8 @@ import com.vaadin.flow.component.dependency.JsModule; import com.vaadin.flow.component.html.H4; import com.vaadin.flow.component.icon.Icon; import com.vaadin.flow.component.icon.VaadinIcon; +import com.vaadin.flow.component.notification.Notification; +import com.vaadin.flow.component.notification.NotificationVariant; import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.i18n.LocaleChangeEvent; @@ -30,6 +32,7 @@ public class InferenceRuleField extends VerticalLayout implements LocaleChangeOb private static final String HEADER_ID = "headerField"; private static final String MAIN_ID = "main"; private static final String RULE_NAME_ID = "ruleName"; + private static final String COPY_BUTTON_ID = "copyButton"; private final String nameKey; private final Button copyButton; @@ -48,22 +51,25 @@ public class InferenceRuleField extends VerticalLayout implements LocaleChangeOb HorizontalLayout header = new HorizontalLayout(); header.setId(HEADER_ID); this.ruleName = new H4(getTranslation(nameKey)); + this.copyButton = new Button(new Icon(VaadinIcon.CLIPBOARD)); + copyButton.addClickListener(event -> { + UI.getCurrent().getPage().executeJs("window.copyToClipboard($0)", latex); + Notification.show(getTranslation("root.copied")).addThemeVariants(NotificationVariant.LUMO_PRIMARY); + }); + copyButton.setId(COPY_BUTTON_ID); ruleName.setId(RULE_NAME_ID); - header.add(ruleName); + header.add(ruleName, copyButton); VerticalLayout main = new VerticalLayout(); main.setId(MAIN_ID); - this.copyButton = new Button(getTranslation("root.copyLatex"), new Icon(VaadinIcon.CLIPBOARD)); MathjaxDisplay rule = new MathjaxDisplay(latex); - copyButton.addClickListener(event -> UI.getCurrent().getPage().executeJs("window.copyToClipboard($0)", latex)); - main.add(rule, copyButton); + main.add(rule); add(header, main); setId(INFERENCE_RULE_FIELD_ID); } - + @Override public void localeChange(LocaleChangeEvent event) { - copyButton.setText(getTranslation("root.copyLatex")); ruleName.setText(getTranslation(nameKey)); } diff --git a/src/main/resources/language/translation_de.properties b/src/main/resources/language/translation_de.properties index ab90777..5f45830 100644 --- a/src/main/resources/language/translation_de.properties +++ b/src/main/resources/language/translation_de.properties @@ -1,6 +1,6 @@ root.close=Schließen root.save=Speichern -root.copyLatex=Kopiere Latex-Code +root.copied=LaTeX-Code in Zwischenablage kopiert. root.selectExample=Beispiel auswählen: root.typeInfer=Typisieren root.operatingHelp=Hilfe diff --git a/src/main/resources/language/translation_en.properties b/src/main/resources/language/translation_en.properties index 19fe514..63542ce 100644 --- a/src/main/resources/language/translation_en.properties +++ b/src/main/resources/language/translation_en.properties @@ -1,6 +1,6 @@ root.close=Close root.save=Save -root.copyLatex=Copy latex code +root.copied=LaTeX code copied to clipboard. root.selectExample=Select example: root.typeInfer=Type root.operatingHelp=Help