From 300c3f5c7d107596bdca6d2f2f90705908ee87fb Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Tue, 20 Mar 2018 14:01:32 +0000 Subject: [PATCH] In StandaloneApp, add example of pagination backed by navigation --- samples/StandaloneApp/Pages/FetchData.cshtml | 30 ++++++++++++++++++-- samples/StandaloneApp/wwwroot/css/site.css | 10 +++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/samples/StandaloneApp/Pages/FetchData.cshtml b/samples/StandaloneApp/Pages/FetchData.cshtml index 37484dbed4..7f3f50a428 100644 --- a/samples/StandaloneApp/Pages/FetchData.cshtml +++ b/samples/StandaloneApp/Pages/FetchData.cshtml @@ -1,4 +1,5 @@ @page "/fetchdata" +@page "/fetchdata/{StartDate:datetime}" @inject HttpClient Http

Weather forecast

@@ -32,15 +33,38 @@ else } +

+ + ◀ Previous + + + Next ▶ + +

} @functions { + public DateTime StartDate { get; set; } + WeatherForecast[] forecasts; - protected override async Task OnInitAsync() + public override void SetParameters(ParameterCollection parameters) { - var json = await Http.GetStringAsync("/sample-data/weather.json"); - forecasts = JsonUtil.Deserialize(json); + StartDate = DateTime.Now; + base.SetParameters(parameters); + } + + protected override async Task OnParametersSetAsync() + { + forecasts = await Http.GetJsonAsync( + $"/sample-data/weather.json?date={StartDate.ToString("yyyy-MM-dd")}"); + + // Because StandaloneApp doesn't really have a server endpoint to get dynamic data from, + // fake the DateFormatted values here. This would not apply in a real app. + for (var i = 0; i < forecasts.Length; i++) + { + forecasts[i].DateFormatted = StartDate.AddDays(i).ToShortDateString(); + } } class WeatherForecast diff --git a/samples/StandaloneApp/wwwroot/css/site.css b/samples/StandaloneApp/wwwroot/css/site.css index c7be6fae47..a255a98e6f 100644 --- a/samples/StandaloneApp/wwwroot/css/site.css +++ b/samples/StandaloneApp/wwwroot/css/site.css @@ -78,8 +78,12 @@ .navbar-nav > li a:hover { color: #fff; background-color: transparent; - text-decoration: none; -} -.navbar-nav > li a:focus { +} + +a:focus:not(:hover) { + color: #337ab7; +} + +a:hover, a:focus { text-decoration: none; }