Skip to content

Commit

Permalink
feat(demo): add base demo class
Browse files Browse the repository at this point in the history
  • Loading branch information
elPeiretti authored and javier-godoy committed Sep 5, 2024
1 parent 172fe46 commit 8b586ea
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*-
* #%L
* LocaleComboBox Add-on
* %%
* Copyright (C) 2024 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.flowingcode.vaadin.addons.localecombobox;

import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment;
import com.vaadin.flow.component.orderedlayout.FlexComponent.JustifyContentMode;

@SuppressWarnings("serial")
public class BaseLocaleComboBoxDemo extends Div {

protected HorizontalLayout createHorizontalContainer(String title, LocaleComboBox combo) {
Span titleSpan = new Span(new Text(title));
titleSpan.setWidth("300px");
HorizontalLayout container = new HorizontalLayout();
container.setWidthFull();
container.setAlignItems(Alignment.CENTER);
container.setJustifyContentMode(JustifyContentMode.BETWEEN);
container.add(titleSpan, combo);
container.expand(combo);
return container;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
package com.flowingcode.vaadin.addons.localecombobox;

import com.flowingcode.vaadin.addons.demo.DemoSource;
import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment;
import com.vaadin.flow.component.orderedlayout.FlexComponent.JustifyContentMode;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import java.util.Arrays;
Expand All @@ -37,7 +31,7 @@
@PageTitle("Display modes")
@SuppressWarnings("serial")
@Route(value = "demo", layout = LocaleComboBoxDemoView.class)
public class DisplayModeDemo extends Div {
public class DisplayModeDemo extends BaseLocaleComboBoxDemo {

public DisplayModeDemo() {

Expand Down Expand Up @@ -70,18 +64,4 @@ public DisplayModeDemo() {
// show-source add(selectedLocaleCombo);
}

// #if vaadin eq 0
private HorizontalLayout createHorizontalContainer(String title, LocaleComboBox combo) {
Span titleSpan = new Span(new Text(title));
titleSpan.setWidth("300px");
HorizontalLayout container = new HorizontalLayout();
container.setWidthFull();
container.setAlignItems(Alignment.CENTER);
container.setJustifyContentMode(JustifyContentMode.BETWEEN);
container.add(titleSpan, combo);
container.expand(combo);
return container;
}
// #endif

}

0 comments on commit 8b586ea

Please sign in to comment.