diff --git a/src/main/frontend/themes/rallyman/styles.css b/src/main/frontend/themes/rallyman/styles.css index 9ec69a0..f523f6b 100644 --- a/src/main/frontend/themes/rallyman/styles.css +++ b/src/main/frontend/themes/rallyman/styles.css @@ -15,3 +15,19 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ + +h1 { + margin-bottom: 1em; +} + +.event-summary { + border: 1px solid black; + display: inline-block; + margin: 0 1em 1em 0; + padding: 1em; + width: 20em; +} + +.event-name { + font-weight: bold; +} diff --git a/src/main/java/swiss/fihlon/rallyman/ui/component/EventList.java b/src/main/java/swiss/fihlon/rallyman/ui/component/EventOverview.java similarity index 87% rename from src/main/java/swiss/fihlon/rallyman/ui/component/EventList.java rename to src/main/java/swiss/fihlon/rallyman/ui/component/EventOverview.java index 432ea5a..51cac53 100644 --- a/src/main/java/swiss/fihlon/rallyman/ui/component/EventList.java +++ b/src/main/java/swiss/fihlon/rallyman/ui/component/EventOverview.java @@ -21,10 +21,10 @@ import org.jetbrains.annotations.NotNull; import swiss.fihlon.rallyman.service.DatabaseService; -public class EventList extends Div { +public class EventOverview extends Div { - public EventList(@NotNull final DatabaseService databaseService) { - setClassName("eventsOverview"); + public EventOverview(@NotNull final DatabaseService databaseService) { + addClassName("event-overview"); databaseService.getUpcomingEvents() .map(EventSummary::new) .forEach(this::add); diff --git a/src/main/java/swiss/fihlon/rallyman/ui/component/EventSummary.java b/src/main/java/swiss/fihlon/rallyman/ui/component/EventSummary.java index 61a4351..8cb9595 100644 --- a/src/main/java/swiss/fihlon/rallyman/ui/component/EventSummary.java +++ b/src/main/java/swiss/fihlon/rallyman/ui/component/EventSummary.java @@ -17,6 +17,7 @@ */ package swiss.fihlon.rallyman.ui.component; +import com.vaadin.flow.component.Component; import com.vaadin.flow.component.Text; import com.vaadin.flow.component.html.Div; import org.jetbrains.annotations.NotNull; @@ -26,9 +27,16 @@ public class EventSummary extends Div { public EventSummary(@NotNull final EventSummaryData eventSummaryData) { - add(new Div(new Text(eventSummaryData.name()))); - add(new Div(new Text(FormatterUtil.formatDateTime(eventSummaryData.date())))); - add(new Div(new Text(eventSummaryData.location()))); + addClassName("event-summary"); + add(createDiv("event-name", new Text(eventSummaryData.name()))); + add(createDiv("event-date", new Text(FormatterUtil.formatDateTime(eventSummaryData.date())))); + add(createDiv("event-location", new Text(eventSummaryData.location()))); + } + + private Component createDiv(@NotNull final String className, @NotNull final Component... components) { + final var div = new Div(components); + div.addClassName(className); + return div; } } diff --git a/src/main/java/swiss/fihlon/rallyman/ui/view/HomeView.java b/src/main/java/swiss/fihlon/rallyman/ui/view/HomeView.java index 5c5ac1c..8df4444 100644 --- a/src/main/java/swiss/fihlon/rallyman/ui/view/HomeView.java +++ b/src/main/java/swiss/fihlon/rallyman/ui/view/HomeView.java @@ -23,16 +23,16 @@ import com.vaadin.flow.server.auth.AnonymousAllowed; import org.jetbrains.annotations.NotNull; import swiss.fihlon.rallyman.service.DatabaseService; -import swiss.fihlon.rallyman.ui.component.EventList; +import swiss.fihlon.rallyman.ui.component.EventOverview; @AnonymousAllowed @Route(value = "", layout = WebsiteLayout.class) public final class HomeView extends Div { public HomeView(@NotNull final DatabaseService databaseService) { - setClassName("homeView"); + addClassName("home-view"); add(new H1("Welcome to RallyMan")); - add(new EventList(databaseService)); + add(new EventOverview(databaseService)); } } diff --git a/src/main/java/swiss/fihlon/rallyman/ui/view/WebsiteLayout.java b/src/main/java/swiss/fihlon/rallyman/ui/view/WebsiteLayout.java index 0025989..2f09c46 100644 --- a/src/main/java/swiss/fihlon/rallyman/ui/view/WebsiteLayout.java +++ b/src/main/java/swiss/fihlon/rallyman/ui/view/WebsiteLayout.java @@ -30,6 +30,7 @@ public final class WebsiteLayout extends VerticalLayout implements RouterLayout private final Main main; public WebsiteLayout() { + addClassName("website-layout"); this.main = new Main(); add(main); } diff --git a/src/test/java/swiss/fihlon/rallyman/ui/component/EventListTest.java b/src/test/java/swiss/fihlon/rallyman/ui/component/EventListTest.java index 24fe0a4..4e96fb8 100644 --- a/src/test/java/swiss/fihlon/rallyman/ui/component/EventListTest.java +++ b/src/test/java/swiss/fihlon/rallyman/ui/component/EventListTest.java @@ -37,7 +37,7 @@ void happyCase() { when(databaseService.getUpcomingEvents()) .thenReturn(Stream.of(new EventSummaryData(42L, "Test Name", LocalDateTime.MAX, "Test Location"))); - final var eventList = new EventList(databaseService); + final var eventList = new EventOverview(databaseService); assertEquals(1, eventList.getChildren().count()); assertInstanceOf(EventSummary.class, eventList.getChildren().findFirst().orElseThrow()); }