docs: clarify static Research Shelf specification

This commit is contained in:
Kinneyzhang 2026-08-26 00:29:34 +08:00
parent cbbd5122ba
commit aeaaea1aba
3 changed files with 46 additions and 23 deletions

View File

@ -429,12 +429,15 @@ user's prior local additions cannot collide with the generated dataset."
(defun etaf-research-shelf--filter-label (form key fallback) (defun etaf-research-shelf--filter-label (form key fallback)
"Return the static FILTER label from FORM for KEY, or FALLBACK." "Return the static FILTER label from FORM for KEY, or FALLBACK."
(let ((entry (etaf-research-shelf--static-child form 'filter))) (let ((entry
(etaf-research-shelf--static-child
form 'research-shelf-filter-spec)))
(or (and entry (eq (plist-get (cdr entry) :key) key) (or (and entry (eq (plist-get (cdr entry) :key) key)
(plist-get (cdr entry) :label)) (plist-get (cdr entry) :label))
(let ((entry (cl-find-if (let ((entry (cl-find-if
(lambda (item) (lambda (item)
(and (consp item) (eq (car item) 'filter) (and (consp item)
(eq (car item) 'research-shelf-filter-spec)
(eq (plist-get (cdr item) :key) key))) (eq (plist-get (cdr item) :key) key)))
(cdr form)))) (cdr form))))
(or (and entry (plist-get (cdr entry) :label)) fallback))))) (or (and entry (plist-get (cdr entry) :label)) fallback)))))
@ -653,11 +656,21 @@ user's prior local additions cannot collide with the generated dataset."
(lambda () (lambda ()
(etaf-research-shelf--theme-defaults model)) (etaf-research-shelf--theme-defaults model))
:name 'research-shelf-theme)) :name 'research-shelf-theme))
(header (etaf-research-shelf--static-child static-form 'header)) (header
(filters (etaf-research-shelf--static-child static-form 'filters)) (etaf-research-shelf--static-child
(main (etaf-research-shelf--static-child static-form 'main)) static-form 'research-shelf-header-spec))
(library (etaf-research-shelf--static-child main 'library)) (filters
(detail (etaf-research-shelf--static-child main 'detail))) (etaf-research-shelf--static-child
static-form 'research-shelf-filter-specs))
(content
(etaf-research-shelf--static-child
static-form 'research-shelf-content-spec))
(library
(etaf-research-shelf--static-child
content 'research-shelf-library-spec))
(detail
(etaf-research-shelf--static-child
content 'research-shelf-detail-spec)))
(unless initial-result (unless initial-result
(etaf-on-mounted (etaf-on-mounted
(lambda () (lambda ()

View File

@ -1,16 +1,21 @@
;; Static composition only. Storage, state, Components, and events live in ;; Static application specification only.
;; the same-basename `.el' companion. ;;
;; `research-shelf-shell' is the runtime Component defined in the same-basename
;; `.el' companion. The `*-spec' forms below are inert configuration nodes;
;; they are read by that Component and are not built-in ETAF tags or implicit
;; Components. Storage, state, behavior, and events stay in the companion.
(research-shelf-shell (research-shelf-shell
:title "Research Shelf" :title "Research Shelf"
:subtitle "A quiet place for unfinished ideas" :subtitle "A quiet place for unfinished ideas"
(header :eyebrow "A quiet place for unfinished ideas") (research-shelf-header-spec
(filters :eyebrow "A quiet place for unfinished ideas")
(filter :key all :label "All") (research-shelf-filter-specs
(filter :key reading :label "In progress") (research-shelf-filter-spec :key all :label "All")
(filter :key unread :label "Unread") (research-shelf-filter-spec :key reading :label "In progress")
(filter :key finished :label "Finished") (research-shelf-filter-spec :key unread :label "Unread")
(filter :key starred :label "★ Starred")) (research-shelf-filter-spec :key finished :label "Finished")
(main (research-shelf-filter-spec :key starred :label "★ Starred"))
(library :title "Reading queue") (research-shelf-content-spec
(detail :title "Selected item")) (research-shelf-library-spec :title "Reading queue")
(footer :label "SQLite · saved locally")) (research-shelf-detail-spec :title "Selected item"))
(research-shelf-footer-spec :label "SQLite · saved locally"))

View File

@ -169,14 +169,19 @@ database and mounts a test buffer before running BODY."
(should (equal (plist-get (cdr form) :title) "Research Shelf")) (should (equal (plist-get (cdr form) :title) "Research Shelf"))
(should (equal (mapcar #'car (should (equal (mapcar #'car
(cl-remove-if-not #'consp (cdr form))) (cl-remove-if-not #'consp (cdr form)))
'(header filters main footer))) '(research-shelf-header-spec
research-shelf-filter-specs
research-shelf-content-spec
research-shelf-footer-spec)))
(let* ((filters (cl-find-if (let* ((filters (cl-find-if
(lambda (entry) (and (consp entry) (lambda (entry) (and (consp entry)
(eq (car entry) 'filters))) (eq (car entry)
'research-shelf-filter-specs)))
(cdr form))) (cdr form)))
(all-filter (cl-find-if (all-filter (cl-find-if
(lambda (entry) (and (consp entry) (lambda (entry) (and (consp entry)
(eq (car entry) 'filter) (eq (car entry)
'research-shelf-filter-spec)
(eq (plist-get (cdr entry) :key) (eq (plist-get (cdr entry) :key)
'all))) 'all)))
(cdr filters)))) (cdr filters))))