Goal: As a user, I want to see the list of all games with an alternative compact template
Keywords: conditional template
- Display compact template in games list
- In
games.html
, addGAMES_TEMPLATE_COMPACT
HTML blocks - Recreate a template loop for it and bind game fields
- Switch between templates
-
In
games.dart
, add an observable fieldisCompact
@observable bool isCompact = false;
-
Add a click handler on the toggle button to reverse the value of
isCompact
compact(Event e, var detail, Element target) => isCompact = !isCompact;
-
In
games.html
, use conditional templates to display the right template (Hints)GAMES_TEMPLATE_COMPACT
whenisCompact
istrue
GAMES_TEMPLATE_DETAILED
whenisCompact
isfalse
Hints:
Bonus:
- Switch the toggle button class between
icon-th-list
andicon-th
in function ofisCompact
value