From 8fa35387252c26b83f1eaf180a2f7c06e3cbc945 Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Fri, 1 Nov 2024 15:02:01 +0800 Subject: [PATCH] :construction: WIP: add six extended formats to the task lists --- assets/css/_core/_root.scss | 4 ++- assets/css/_page/_single.scss | 32 +++++++++++++++++++++++ layouts/partials/function/task-lists.html | 29 +++++++++++++++----- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/assets/css/_core/_root.scss b/assets/css/_core/_root.scss index dd4af56d..20357ffa 100644 --- a/assets/css/_core/_root.scss +++ b/assets/css/_core/_root.scss @@ -1,7 +1,7 @@ :root { // Note: Custom variable values only support SassScript inside `#{}`. - // Theme colors varibles + // Theme colors variables @each $color, $value in $theme-colors { --#{$prefix}#{$color}: #{$value}; } @@ -22,6 +22,8 @@ --#{$prefix}scrollbar-track-color: transparent; --#{$prefix}scrollbar-width: thin; --#{$prefix}scrollbar-width-legacy: 12px; + + // TODO migrate SCSS variables to CSS variables } // Dark theme diff --git a/assets/css/_page/_single.scss b/assets/css/_page/_single.scss index 8785de12..c9c02e29 100644 --- a/assets/css/_page/_single.scss +++ b/assets/css/_page/_single.scss @@ -230,6 +230,38 @@ ul { list-style-type: disc; + + // Task lists + li[data-task] { + list-style: none; + margin-left: -1.5rem; + } + } + + // Task lists + li[data-task] { + color: var(--#{$prefix}task-color); + .checkbox-icon { + margin-right: 0.25em; + color: var(--#{$prefix}checkbox-color); + } + } + li[data-task='x'], + li[data-task='-'] { + --#{$prefix}task-color: var(--#{$prefix}secondary); + text-decoration: line-through; + } + li[data-task='x'] { + --#{$prefix}checkbox-color: var(--#{$prefix}primary); + } + li[data-task='/'] { + --#{$prefix}task-color: var(--#{$prefix}success); + } + li[data-task='!'] { + --#{$prefix}checkbox-color: var(--#{$prefix}danger); + } + li[data-task='?'] { + --#{$prefix}checkbox-color: var(--#{$prefix}warning); } dl { diff --git a/layouts/partials/function/task-lists.html b/layouts/partials/function/task-lists.html index d33e0cf7..e5a3820a 100644 --- a/layouts/partials/function/task-lists.html +++ b/layouts/partials/function/task-lists.html @@ -4,14 +4,20 @@ {{- $iconMap := dict " " "fa-regular fa-square" "x" "fa-solid fa-check-square" - ">" "fa-solid fa-calendar" - "<" "fa-solid fa-calendar-check" + "/" "fa-regular fa-square" + "-" "fa-solid fa-square-xmark" + "<" "fa-regular fa-calendar-plus" + ">" "fa-regular fa-calendar-minus" + "!" "fa-solid fa-circle-exclamation" + "\\?" "fa-regular fa-circle-question" -}} {{- $extendedSigns := slice -}} {{- range $sign, $icon := $iconMap -}} {{- $extendedSigns = $extendedSigns | append $sign -}} {{- end -}} +{{- /* TODO merge from config */ -}} + {{- /* The basic syntax is compatible with GitHub, Obsidian, and Typora. The basic format is as follows: @@ -19,20 +25,29 @@ - [x] Checked */ -}} {{- $icon := dict "Class" (add "checkbox-icon fa-fw " (index $iconMap " ")) | partial "plugin/icon.html" -}} -{{- $content := replaceRE `
  • (.+?)
  • ` (printf `
  • %s $1
  • ` $icon) . -}} +{{- $label := T (printf "taskList.%v" " ") -}} +{{- $content := replaceRE `
  • (.+?)
  • ` (printf `
  • %s$1
  • ` $label $icon) . -}} +{{- $label := T (printf "taskList.%v" "x") -}} {{- $icon := dict "Class" (add "checkbox-icon fa-fw " (index $iconMap "x")) | partial "plugin/icon.html" -}} -{{- $content = replaceRE `
  • (.+?)
  • ` (printf `
  • %s $1
  • ` $icon) $content -}} +{{- $content = replaceRE `
  • (.+?)
  • ` (printf `
  • %s$1
  • ` $label $icon) $content -}} {{- /* The extended syntax is compatible with Obsidian. The extended format is as follows: - - [>] Scheduled - - [<] Rescheduled + - [-] Cancelled + - [/] In Progress + - [<] Scheduled + - [>] Rescheduled + - [!] Important + - [?] Question */ -}} {{- range $extendedSigns -}} {{- $class := index $iconMap . | default "fa-solid fa-check-square" -}} {{- $icon := dict "Class" (add "checkbox-icon fa-fw " $class) | partial "plugin/icon.html" -}} - {{- $content = replaceRE (printf `
  • \[%s\] (.+?)
  • ` (htmlEscape .)) (printf `
  • %s $1
  • ` . $icon) $content -}} + {{- $sign := htmlEscape . -}} + {{- $originSign := replace . "\\" "" -}} + {{- $label := (T (printf "taskList.%v" $originSign)) | default (T (printf "taskList.%v" " ")) -}} + {{- $content = replaceRE (printf `
  • \[%s\] (.+?)
  • ` $sign) (printf `
  • %s$1
  • ` $originSign $label $icon) $content -}} {{- end -}} {{- return $content -}}