From ff7b02bda80e8a2737328eff038274d57cd80324 Mon Sep 17 00:00:00 2001 From: log101 Date: Thu, 7 Dec 2023 09:45:21 +0000 Subject: [PATCH] style: add navigation styles --- assets/scss/style.scss | 17 +++ layouts/_default/baseof.html | 5 +- layouts/_default/list.html | 2 +- layouts/partials/pagination.html | 131 ++++++++++++++++++ ...s_871e1d33253f63f556fbcaa4227752be.content | 2 +- ...scss_871e1d33253f63f556fbcaa4227752be.json | 2 +- 6 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 layouts/partials/pagination.html diff --git a/assets/scss/style.scss b/assets/scss/style.scss index 7d85264..a2c79fb 100644 --- a/assets/scss/style.scss +++ b/assets/scss/style.scss @@ -151,7 +151,12 @@ padding: 0; /* Remove default padding */ margin: 0; /* Adjust margin as needed */ justify-content: center; /* Center the pagination items */ + align-items: center; font-family: Inter; + a { + text-decoration: none; + color: #252525; + } } .pagination .page-item { @@ -167,3 +172,15 @@ #site-footer { width: 400px; } + +[aria-disabled="true"] { + text-decoration: none !important; + } + +.page-item { + &.active { + a { + text-decoration: none !important; + } + } +} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 7ac7e20..7bc1621 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -37,7 +37,10 @@ {{ block "header" . -}}{{ end -}} {{ block "main" . -}}{{ end -}} - {{ block "footer" . -}}{{ end }} + + {{ $main := resources.Get "js/main.js" -}} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index d3cd320..d550828 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -20,10 +20,10 @@ {{ end }} - {{ template "_internal/pagination.html" . }} {{ end }} {{ define "footer" }} +{{ partial "pagination.html" . }} {{ partial "footer.html" . }} {{ end }} diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html new file mode 100644 index 0000000..4157ec3 --- /dev/null +++ b/layouts/partials/pagination.html @@ -0,0 +1,131 @@ +{{- $validFormats := slice "default" "terse" }} + +{{- $msg1 := "When passing a map to the internal pagination template, one of the elements must be named 'page', and it must be set to the context of the current page." }} +{{- $msg2 := "The 'format' specified in the map passed to the internal pagination template is invalid. Valid choices are: %s." }} + +{{- $page := . }} +{{- $format := "default" }} + +{{- if reflect.IsMap . }} + {{- with .page }} + {{- $page = . }} + {{- else }} + {{- errorf $msg1 }} + {{- end }} + {{- with .format }} + {{- $format = lower . }} + {{- end }} +{{- end }} + +{{- if in $validFormats $format }} + {{- if gt $page.Paginator.TotalPages 1 }} + + {{- end }} +{{- else }} + {{- errorf $msg2 (delimit $validFormats ", ") }} +{{- end -}} + +{{/* Format: default +{{/* --------------------------------------------------------------------- */}} +{{- define "partials/inline/pagination/default" }} + {{- with .Paginator }} + {{- $currentPageNumber := .PageNumber }} + + {{- with .Prev }} +
  • + +
  • + {{- else }} +
  • + +
  • + {{- end }} + + {{- $slots := 5 }} + {{- $start := math.Max 1 (sub .PageNumber (math.Floor (div $slots 2))) }} + {{- $end := math.Min .TotalPages (sub (add $start $slots) 1) }} + {{- if lt (add (sub $end $start) 1) $slots }} + {{- $start = math.Max 1 (add (sub $end $slots) 1) }} + {{- end }} + + {{- range $k := seq $start $end }} + {{- if eq $.Paginator.PageNumber $k }} +
  • + {{ $k }} +
  • + {{- else }} +
  • + {{ $k }} +
  • + {{- end }} + {{- end }} + + {{- with .Next }} +
  • + +
  • + {{- else }} +
  • + +
  • + {{- end }} + + {{- end }} +{{- end -}} + +{{/* Format: terse +{{/* --------------------------------------------------------------------- */}} +{{- define "partials/inline/pagination/terse" }} + {{- with .Paginator }} + {{- $currentPageNumber := .PageNumber }} + + {{- with .First }} + {{- if ne $currentPageNumber .PageNumber }} +
  • + +
  • + {{- end }} + {{- end }} + + {{- with .Prev }} +
  • + +
  • + {{- end }} + + {{- $slots := 3 }} + {{- $start := math.Max 1 (sub .PageNumber (math.Floor (div $slots 2))) }} + {{- $end := math.Min .TotalPages (sub (add $start $slots) 1) }} + {{- if lt (add (sub $end $start) 1) $slots }} + {{- $start = math.Max 1 (add (sub $end $slots) 1) }} + {{- end }} + + {{- range $k := seq $start $end }} + {{- if eq $.Paginator.PageNumber $k }} +
  • + {{ $k }} +
  • + {{- else }} +
  • + {{ $k }} +
  • + {{- end }} + {{- end }} + + {{- with .Next }} +
  • + +
  • + {{- end }} + + {{- with .Last }} + {{- if ne $currentPageNumber .PageNumber }} +
  • + +
  • + {{- end }} + {{- end }} + {{- end }} +{{- end -}} diff --git a/resources/_gen/assets/scss/scss/style.scss_871e1d33253f63f556fbcaa4227752be.content b/resources/_gen/assets/scss/scss/style.scss_871e1d33253f63f556fbcaa4227752be.content index d38a51b..2f7030e 100644 --- a/resources/_gen/assets/scss/scss/style.scss_871e1d33253f63f556fbcaa4227752be.content +++ b/resources/_gen/assets/scss/scss/style.scss_871e1d33253f63f556fbcaa4227752be.content @@ -1 +1 @@ -#page{height:100vh;margin:0}#spotlight{display:flex;min-height:100vh;flex-direction:column;align-items:start;justify-content:space-between;max-width:400px;margin:auto;font-size:1.5rem}@media(max-width:448px){#spotlight{margin-left:24px}}#home-center{display:flex;flex-direction:column;flex-grow:1;align-items:flex-start;margin-top:10vh}#home-title{color:#202020;font-family:Inter;font-size:48px;font-style:normal;font-weight:500;line-height:normal}#home-nav{display:flex;flex-direction:column}#home-nav a{color:#252525;font-family:Inter;font-size:40px;font-style:normal;font-weight:400;line-height:150%;text-decoration-line:underline}.post-item .post-day,.post-item a{color:#252525;font-family:Inter;font-size:40px;font-style:normal;font-weight:400;line-height:150%;text-decoration-line:underline}#site-footer,#home-footer{width:100%}#site-footer p,#home-footer p{color:#5c5c5c;font-family:Inter;font-size:20px;font-style:normal;font-weight:300;line-height:normal;display:flex;gap:8px;justify-content:center}#site-footer a,#home-footer a{color:#5c5c5c;font-family:Inter;font-size:20px;font-style:normal;font-weight:300;line-height:normal;display:flex;gap:8px;justify-content:center;text-decoration:none}#site-footer a:hover,#home-footer a:hover{text-decoration:underline}.posts-group{width:400px}.back-title{font-family:Inter;font-size:20px;font-style:normal;font-weight:400}.back-title a{text-decoration:none;color:#252525}.back-title a:hover{text-decoration:underline;color:#151515}.post-item{display:flex;justify-content:space-between;align-items:center;width:100%}.post-item a{font-size:30px}.post-item .post-day{font-size:30px;text-decoration:none;color:#787878}.pagination{display:flex;list-style:none;padding:0;margin:0;justify-content:center;font-family:Inter}.pagination .page-item{margin:0}.pagination .page-link{display:block;padding:5px 10px;margin:0 2px}#site-footer{width:400px} \ No newline at end of file +#page{height:100vh;margin:0}#spotlight{display:flex;min-height:100vh;flex-direction:column;align-items:start;justify-content:space-between;max-width:400px;margin:auto;font-size:1.5rem}@media(max-width:448px){#spotlight{margin-left:24px}}#home-center{display:flex;flex-direction:column;flex-grow:1;align-items:flex-start;margin-top:10vh}#home-title{color:#202020;font-family:Inter;font-size:48px;font-style:normal;font-weight:500;line-height:normal}#home-nav{display:flex;flex-direction:column}#home-nav a{color:#252525;font-family:Inter;font-size:40px;font-style:normal;font-weight:400;line-height:150%;text-decoration-line:underline}.post-item .post-day,.post-item a{color:#252525;font-family:Inter;font-size:40px;font-style:normal;font-weight:400;line-height:150%;text-decoration-line:underline}#site-footer,#home-footer{width:100%}#site-footer p,#home-footer p{color:#5c5c5c;font-family:Inter;font-size:20px;font-style:normal;font-weight:300;line-height:normal;display:flex;gap:8px;justify-content:center}#site-footer a,#home-footer a{color:#5c5c5c;font-family:Inter;font-size:20px;font-style:normal;font-weight:300;line-height:normal;display:flex;gap:8px;justify-content:center;text-decoration:none}#site-footer a:hover,#home-footer a:hover{text-decoration:underline}.posts-group{width:400px}.back-title{font-family:Inter;font-size:20px;font-style:normal;font-weight:400}.back-title a{text-decoration:none;color:#252525}.back-title a:hover{text-decoration:underline;color:#151515}.post-item{display:flex;justify-content:space-between;align-items:center;width:100%}.post-item a{font-size:30px}.post-item .post-day{font-size:30px;text-decoration:none;color:#787878}.pagination{display:flex;list-style:none;padding:0;margin:0;justify-content:center;align-items:center;font-family:Inter}.pagination a{text-decoration:none;color:#252525}.pagination .page-item{margin:0}.pagination .page-link{display:block;padding:5px 10px;margin:0 2px}#site-footer{width:400px}[aria-disabled=true]{text-decoration:none!important}.page-item.active a{text-decoration:none!important} \ No newline at end of file diff --git a/resources/_gen/assets/scss/scss/style.scss_871e1d33253f63f556fbcaa4227752be.json b/resources/_gen/assets/scss/scss/style.scss_871e1d33253f63f556fbcaa4227752be.json index 1df0d57..4321b72 100644 --- a/resources/_gen/assets/scss/scss/style.scss_871e1d33253f63f556fbcaa4227752be.json +++ b/resources/_gen/assets/scss/scss/style.scss_871e1d33253f63f556fbcaa4227752be.json @@ -1 +1 @@ -{"Target":"css/style.min.dd07bb0d6a75bc893e253d7929db53d7b6973c27c5fa5672c5b491e607c2bd3c.css","MediaType":"text/css","Data":{"Integrity":"sha256-3Qe7DWp1vIk+JT15KdtT17aXPCfF+lZyxbSR5gfCvTw="}} \ No newline at end of file +{"Target":"css/style.min.47c6d76a98c0536b40e5fcc553d9770c9361d646f05ac807bb6c59ffa7caa6c2.css","MediaType":"text/css","Data":{"Integrity":"sha256-R8bXapjAU2tA5fzFU9l3DJNh1kbwWsgHu2xZ/6fKpsI="}} \ No newline at end of file