|
1 | 1 | using Abies.Conduit.Routing; |
2 | 2 | using Abies.Conduit.Services; |
| 3 | +using Abies.DOM; |
3 | 4 | using System.Threading.Tasks; |
4 | 5 | using static Abies.Conduit.Main.Message.Event; |
5 | 6 | using static Abies.UrlRequest; |
@@ -222,24 +223,32 @@ public static (Model model, IEnumerable<Command> commands) Update(Abies.Message |
222 | 223 | } |
223 | 224 |
|
224 | 225 | } |
225 | | - |
226 | | - |
| 226 | + private static Node WithLayout(Node page, Model model) => |
| 227 | + div([], [ |
| 228 | + Navigation.View(model), |
| 229 | + page |
| 230 | + ]); |
227 | 231 |
|
228 | 232 | public static Document View(Model model) |
229 | 233 | => model.Page switch |
230 | 234 | { |
231 | | - Page.Redirect => new Document(string.Format(Title, "Redirect"), h1([], [text("Redirecting...")])), |
232 | | - Page.NotFound => new Document(string.Format(Title, "Not Found"), h1([], [text("Not Found")])), |
233 | | - Page.Home home => new Document(string.Format(Title, nameof(Conduit.Page.Home)), Conduit.Page.Home.Page.View(home.Model)), |
234 | | - Page.Settings settings => new Document(string.Format(Title, nameof(Conduit.Page.Settings)), Conduit.Page.Settings.Page.View(settings.Model)), |
235 | | - Page.Login login => new Document(string.Format(Title, nameof(Conduit.Page.Login)), Conduit.Page.Login.Page.View(login.Model)), |
236 | | - Page.Register register => new Document(string.Format(Title, nameof(Conduit.Page.Register)), Conduit.Page.Register.Page.View(register.Model)), Page.Profile profile => new Document(string.Format(Title, nameof(Conduit.Page.Profile)), Conduit.Page.Profile.Page.View(profile.Model)), |
237 | | - Page.ProfileFavorites profileFavorites => new Document(string.Format(Title, "Profile Favorites"), Conduit.Page.Profile.Page.View(profileFavorites.Model)), |
238 | | - Page.Article article => new Document(string.Format(Title, nameof(Conduit.Page.Article)), Conduit.Page.Article.Page.View(article.Model)), |
239 | | - Page.NewArticle newArticle => new Document(string.Format(Title, "New Article"), Conduit.Page.Editor.Page.View(newArticle.Model)), |
240 | | - _ => new Document(string.Format(Title, "Not Found"), h1([], [text("Not Found")])) |
| 235 | + Page.Redirect => new Document(string.Format(Title, "Redirect"), WithLayout(h1([], [text("Redirecting...")]), model)), |
| 236 | + Page.NotFound => new Document(string.Format(Title, "Not Found"), WithLayout(h1([], [text("Not Found")]), model)), |
| 237 | + Page.Home home => new Document(string.Format(Title, nameof(Conduit.Page.Home)), WithLayout(Conduit.Page.Home.Page.View(home.Model), model)), |
| 238 | + Page.Settings settings => new Document(string.Format(Title, nameof(Conduit.Page.Settings)), WithLayout(Conduit.Page.Settings.Page.View(settings.Model), model)), |
| 239 | + Page.Login login => new Document(string.Format(Title, nameof(Conduit.Page.Login)), WithLayout(Conduit.Page.Login.Page.View(login.Model), model)), |
| 240 | + Page.Register register => new Document(string.Format(Title, nameof(Conduit.Page.Register)), WithLayout(Conduit.Page.Register.Page.View(register.Model), model)), |
| 241 | + Page.Profile profile => new Document(string.Format(Title, nameof(Conduit.Page.Profile)), WithLayout(Conduit.Page.Profile.Page.View(profile.Model), model)), |
| 242 | + Page.ProfileFavorites profileFavorites => new Document(string.Format(Title, "Profile Favorites"), WithLayout(Conduit.Page.Profile.Page.View(profileFavorites.Model), model)), |
| 243 | + Page.Article article => new Document(string.Format(Title, nameof(Conduit.Page.Article)), WithLayout(Conduit.Page.Article.Page.View(article.Model), model)), |
| 244 | + Page.NewArticle newArticle => new Document(string.Format(Title, "New Article"), WithLayout(Conduit.Page.Editor.Page.View(newArticle.Model), model)), |
| 245 | + _ => new Document(string.Format(Title, "Not Found"), WithLayout(h1([], [text("Not Found")]), model)) |
241 | 246 | }; |
242 | 247 |
|
| 248 | + |
| 249 | + |
| 250 | + |
| 251 | + |
243 | 252 | public static Abies.Message OnUrlChanged(Url url) |
244 | 253 | => new UrlChanged(url); |
245 | 254 |
|
|
0 commit comments