Skip to content

Commit

Permalink
💄 Add rudimentary layout to distinguish elements #8
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Fihlon <[email protected]>
  • Loading branch information
McPringle committed Dec 22, 2024
1 parent cb92699 commit cb261f7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
16 changes: 16 additions & 0 deletions src/main/frontend/themes/rallyman/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,19 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/swiss/fihlon/rallyman/ui/component/EventSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

}
6 changes: 3 additions & 3 deletions src/main/java/swiss/fihlon/rallyman/ui/view/HomeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit cb261f7

Please sign in to comment.