Skip to content

Commit

Permalink
Fix Viewport for Desktop and Mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
mithandir committed Sep 10, 2023
1 parent 58265f7 commit b6cbdf7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/main/java/ch/climbd/newsfeed/views/LatestView.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ public class LatestView extends VerticalLayout {

@PostConstruct
public void init() {
super.setWidth(commonComponents.isMobile() ? "100%" : "90%");

var image = new Image(baseUrl + "/logo.svg", "Title");
image.setWidth("8em");
image.getStyle().set("margin-left", commonComponents.isMobile() ? "2%" : "10%");
image.getStyle().set("margin-left", commonComponents.isMobile() ? "0" : "10%");
var heading = new H1("cycling news");
var header = new HorizontalLayout(image, heading);
header.setWidthFull();
Expand All @@ -62,10 +64,10 @@ public void init() {
sourceData = new LinkedList<>(mongo.findAllOrderedByDate(commonSessionComponents.getSelectedLanguages()));
newsItems = newsItemComponent.createNewsItem(sourceData);
newsItems.setWidthFull();
newsItems.getStyle().set("margin-left", commonComponents.isMobile() ? "2%" : "10%");
newsItems.getStyle().set("margin-left", commonComponents.isMobile() ? "0" : "10%");

var searchBar = searchComponent.createSearchBar(newsItems);
searchBar.getStyle().set("margin-left", commonComponents.isMobile() ? "2%" : "10%");
searchBar.getStyle().set("margin-left", commonComponents.isMobile() ? "0" : "10%");
add(searchBar);
add(newsItems);

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/ch/climbd/newsfeed/views/PopularView.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ public class PopularView extends VerticalLayout {

@PostConstruct
public void init() {
super.setWidth(commonComponents.isMobile() ? "100%" : "90%");

var image = new Image(baseUrl + "/logo.svg", "Title");
image.setWidth("8em");
image.getStyle().set("margin-left", commonComponents.isMobile() ? "2%" : "10%");
image.getStyle().set("margin-left", commonComponents.isMobile() ? "0" : "10%");
var heading = new H1("cycling news");
var header = new HorizontalLayout(image, heading);
header.setWidthFull();
Expand All @@ -53,10 +55,10 @@ public void init() {

VerticalLayout newsItems = newsItemComponent.createNewsItem(mongo.findAllOrderedByVotes(commonSessionComponents.getSelectedLanguages()));
newsItems.setWidthFull();
newsItems.getStyle().set("margin-left", commonComponents.isMobile() ? "2%" : "10%");
newsItems.getStyle().set("margin-left", commonComponents.isMobile() ? "0" : "10%");

var searchBar = searchComponent.createSearchBar(newsItems);
searchBar.getStyle().set("margin-left", commonComponents.isMobile() ? "2%" : "10%");
searchBar.getStyle().set("margin-left", commonComponents.isMobile() ? "0" : "10%");
add(searchBar);
add(newsItems);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public Set<String> getSelectedLanguages() {

public MenuBar createMenu() {
var menu = new MenuBar();
menu.setWidthFull();
menu.setOpenOnHover(true);

createIconItem(menu, VaadinIcon.NEWSPAPER, "Recent", null).addClickListener(listenerNewest);
Expand All @@ -68,7 +69,7 @@ public MenuBar createMenu() {
german.setCheckable(true);
german.setChecked(selectedLanguages.contains("de"));

menu.getStyle().set("margin-left", commonComponents.isMobile() ? "2%" : "10%");
menu.getStyle().set("margin-left", commonComponents.isMobile() ? "0" : "10%");

return menu;
}
Expand Down

0 comments on commit b6cbdf7

Please sign in to comment.