From 24feec3bc4b94f8da461ef6f22a703398788ff72 Mon Sep 17 00:00:00 2001 From: Moritz Dieing <63721811+moritzdieing@users.noreply.github.com> Date: Sun, 7 Mar 2021 12:44:52 +0100 Subject: [PATCH 1/3] Better replacement of type variables --- frontend/src/type-input-listener.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/frontend/src/type-input-listener.js b/frontend/src/type-input-listener.js index 7fa5f09..479aadf 100644 --- a/frontend/src/type-input-listener.js +++ b/frontend/src/type-input-listener.js @@ -22,16 +22,16 @@ function listener(area) { var value = parseBack(area.value); var start = area.selectionStart; var end = area.selectionEnd; - if (value.startsWith('t') && isNumeric(value.substr(1, value.length - 1))) { - area.value = value.replace('t', '\u03C4'); - area.value = area.value.replace(/[0123456789]/g, toUnicode); - } else { - area.value = value; - } + // ignore brackets, allow '>' or spaces in front and '-' or spaces at the end of string + area.value = value.replace(/(^|\s+|\(|\)|>)t[0-9]+(?=\s+|\)|\(|\-|$)/ig, replacer); area.selectionStart = start; area.selectionEnd = end; } +function replacer(value) { + value = value.replace('t', '\u03C4'); + return value.replace(/[0123456789]/g, toUnicode); +} function toUnicode(number) { return subscripted[number]; @@ -44,10 +44,6 @@ function toNumber(unicode) { } function parseBack(value) { - value = value.replace('\u03C4', 't'); + value = value.replaceAll('\u03C4', 't'); return value.replace(/./g, toNumber); -} - -function isNumeric(value) { - return /^\d+$/.test(value); -} +} \ No newline at end of file From b635a9c5c69b87d8633122f7a7af94279bfe64c5 Mon Sep 17 00:00:00 2001 From: ucrhh Date: Sun, 7 Mar 2021 13:02:09 +0100 Subject: [PATCH 2/3] make control panel on startpage fixed in position --- frontend/styles/view/start-page.css | 7 +------ .../typicalc/view/content/ControlPanel.java | 2 ++ .../content/infocontent/StartPageView.java | 19 ++++++++++++------- .../TypeInferenceView.java | 14 ++++++++------ 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/frontend/styles/view/start-page.css b/frontend/styles/view/start-page.css index 8b9f079..592c51f 100644 --- a/frontend/styles/view/start-page.css +++ b/frontend/styles/view/start-page.css @@ -1,5 +1,5 @@ #startPage-Heading { - margin-top: 50px; + margin-top: 20px; margin-bottom: 10px; font-size: 50px; } @@ -26,11 +26,6 @@ margin-bottom: 0; } -#controlPanel { - margin-top: auto; - margin-bottom: 15px; -} - #startPage { padding: 0; display: flex; diff --git a/src/main/java/edu/kit/typicalc/view/content/ControlPanel.java b/src/main/java/edu/kit/typicalc/view/content/ControlPanel.java index 6ff1af8..2ae2ee3 100644 --- a/src/main/java/edu/kit/typicalc/view/content/ControlPanel.java +++ b/src/main/java/edu/kit/typicalc/view/content/ControlPanel.java @@ -42,6 +42,8 @@ public class ControlPanel extends HorizontalLayout implements LocaleChangeObserv previousStep = new Button(new Icon(VaadinIcon.ANGLE_LEFT), evt -> view.previousStepButton()); previousStep.setId(PREVIOUS_STEP_ID); share = new Button(new Icon(VaadinIcon.CONNECT), evt -> view.shareButton()); + share.getStyle().set("margin-left", "auto"); + lastStep.getStyle().set("margin-right", "auto"); add(share, firstStep, previousStep, nextStep, lastStep); } diff --git a/src/main/java/edu/kit/typicalc/view/content/infocontent/StartPageView.java b/src/main/java/edu/kit/typicalc/view/content/infocontent/StartPageView.java index 827cd96..1d66dba 100644 --- a/src/main/java/edu/kit/typicalc/view/content/infocontent/StartPageView.java +++ b/src/main/java/edu/kit/typicalc/view/content/infocontent/StartPageView.java @@ -5,12 +5,7 @@ import com.flowingcode.vaadin.addons.carousel.Slide; import com.vaadin.flow.component.Text; import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.dependency.JsModule; -import com.vaadin.flow.component.html.Anchor; -import com.vaadin.flow.component.html.Div; -import com.vaadin.flow.component.html.H1; -import com.vaadin.flow.component.html.Hr; -import com.vaadin.flow.component.html.Paragraph; -import com.vaadin.flow.component.html.Span; +import com.vaadin.flow.component.html.*; import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.component.progressbar.ProgressBar; import com.vaadin.flow.i18n.LocaleChangeEvent; @@ -53,6 +48,7 @@ public class StartPageView extends VerticalLayout implements ControlPanelView, L * Fills the view with content. */ public StartPageView() { + VerticalLayout content = new VerticalLayout(); ControlPanel controlPanel = new ControlPanel(this); controlPanel.setId(CONTROL_PANEL_ID); controlPanel.setEnabledShareButton(false); @@ -81,8 +77,17 @@ public class StartPageView extends VerticalLayout implements ControlPanelView, L slideProgress = new ProgressBar(slideShow.getStartPosition(), slideShow.getSlides().length - 1); slideProgress.setId(SLIDE_PROGRESS_ID); - add(heading, line1, textContainer, slideProgress, slideShow, line2, controlPanel); + content.setAlignItems(Alignment.CENTER); + content.add(heading, line1, textContainer, slideProgress, slideShow, line2); setId(START_PAGE_ID); + + Footer footer = new Footer(controlPanel); + footer.setWidthFull(); + footer.getStyle().set("position", "sticky"); + footer.getStyle().set("bottom", "1em"); + footer.getStyle().set("background-color", "white"); + content.setWidthFull(); + add(content, footer); } private Carousel createScenarioCarousel() { diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java index edb5a35..784578c 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java @@ -6,7 +6,7 @@ import com.vaadin.flow.component.UI; import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.dependency.JavaScript; import com.vaadin.flow.component.html.Div; -import com.vaadin.flow.component.orderedlayout.Scroller; +import com.vaadin.flow.component.html.Footer; import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.i18n.LocaleChangeEvent; import com.vaadin.flow.i18n.LocaleChangeObserver; @@ -33,7 +33,6 @@ public class TypeInferenceView extends VerticalLayout * Route of this view. */ public static final String ROUTE = "infer"; - private static final String SCROLLER_ID = "scroller"; private static final String CONTENT_ID = "content"; private static final String ID = "type-inference-view"; @@ -64,14 +63,17 @@ public class TypeInferenceView extends VerticalLayout content = new Div(); content.setId(CONTENT_ID); controlPanel = new ControlPanel(this); - Scroller scroller = new Scroller(content); - scroller.setId(SCROLLER_ID); - scroller.setScrollDirection(Scroller.ScrollDirection.BOTH); - add(scroller, controlPanel); treeNumbers = lc.getTreeNumbers(); setContent(); controlPanel.setEnabledFirstStep(false); controlPanel.setEnabledPreviousStep(false); + + Footer footer = new Footer(controlPanel); + footer.getStyle().set("position", "sticky"); + footer.getStyle().set("bottom", "1em"); + content.getStyle().set("overflow", "auto"); + content.setWidthFull(); + add(content, footer); } private void setContent() { From e06041bfcbcb94c66b6aacd50f6f7bf1ba4e97c3 Mon Sep 17 00:00:00 2001 From: Moritz Dieing <63721811+moritzdieing@users.noreply.github.com> Date: Sun, 7 Mar 2021 13:03:35 +0100 Subject: [PATCH 3/3] Autoselect for ShareDialog --- frontend/src/share-dialog-autoselect.js | 12 ++++++++++++ .../content/typeinferencecontent/ShareDialog.java | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 frontend/src/share-dialog-autoselect.js diff --git a/frontend/src/share-dialog-autoselect.js b/frontend/src/share-dialog-autoselect.js new file mode 100644 index 0000000..05c3f26 --- /dev/null +++ b/frontend/src/share-dialog-autoselect.js @@ -0,0 +1,12 @@ +window.autoSelect = (className) => { + let el = document.getElementsByClassName(className); + Array.from(el).forEach(field => { + field.addEventListener('focus', event => { + let e = event.target.shadowRoot.querySelector('input'); + if (!e) { + e = event.target.shadowRoot.querySelector('textArea'); + } + e.setSelectionRange(0, e.value.length); + }); + }); +} \ No newline at end of file diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java index 5b5df8a..84e566b 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java @@ -1,6 +1,8 @@ package edu.kit.typicalc.view.content.typeinferencecontent; +import com.vaadin.flow.component.UI; import com.vaadin.flow.component.dependency.CssImport; +import com.vaadin.flow.component.dependency.JsModule; import com.vaadin.flow.component.dialog.Dialog; import com.vaadin.flow.component.html.H3; import com.vaadin.flow.component.icon.Icon; @@ -15,6 +17,7 @@ import com.vaadin.flow.i18n.LocaleChangeObserver; /** * Contains GUI elements to extract the URL and LaTeX code of the currently shown proof tree. */ +@JsModule("./src/share-dialog-autoselect.js") @CssImport("./styles/view/share-dialog.css") public class ShareDialog extends Dialog implements LocaleChangeObserver { @@ -62,6 +65,7 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver { packageArea.setClassName(FIELD_CLASS); latexArea.setValue(latexCode); latexArea.setClassName(FIELD_CLASS); + UI.getCurrent().getPage().executeJs("window.autoSelect($0)", FIELD_CLASS); layout.add(urlField, packageArea, latexArea);