Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested placeholders and a few other changes #9

Merged
merged 14 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@
},
{
"name": "Setup Common Lisp Environment",
"uses": "40ants/setup-lisp@v2",
"uses": "40ants/setup-lisp@v3",
"with": {
"asdf-system": "reblocks-ui"
},
"if": "steps.cache.outputs.cache-hit != 'true'"
},
{
"name": "Change dist to Ultralisp",
"run": "echo 'dist ultralisp http://dist.ultralisp.org' > qlfile",
"name": "Change dist to Ultralisp if qlfile does not exist",
"run": "if [[ ! -e qlfile ]]; then echo 'dist ultralisp http://dist.ultralisp.org' > qlfile; fi",
"shell": "bash"
},
{
Expand All @@ -72,12 +72,12 @@
},
{
"name": "Install SBLint wrapper",
"run": "qlot exec ros install 40ants-linter",
"run": "qlot exec ros install 40ants-asdf-system 40ants-linter",
"shell": "bash"
},
{
"name": "Run Linter",
"run": "qlot exec 40ants-linter --system \"reblocks-ui, reblocks-ui-docs, reblocks-ui-examples\"",
"run": "qlot exec 40ants-linter --system \"reblocks-ui, reblocks-ui-docs, reblocks-ui-examples\" --imports",
"shell": "bash"
}
]
Expand Down Expand Up @@ -122,7 +122,7 @@
},
{
"name": "Setup Common Lisp Environment",
"uses": "40ants/setup-lisp@v2",
"uses": "40ants/setup-lisp@v3",
"with": {
"asdf-system": "reblocks-ui"
},
Expand All @@ -145,7 +145,7 @@
},
{
"name": "Run Critic for \"reblocks-ui\" system",
"run": "qlot exec lisp-critic --ignore function-too-long reblocks-ui",
"run": "qlot exec lisp-critic --ignore function-too-long,check-prefix reblocks-ui",
"shell": "bash"
}
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
{
"name": "Setup Common Lisp Environment",
"uses": "40ants/setup-lisp@v2",
"uses": "40ants/setup-lisp@v3",
"with": {
"asdf-system": "reblocks-ui-docs"
},
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "RELEASE",
"on": {
"push": {
"branches": [
"master"
]
}
},
"jobs": {
"autotag": {
"permissions": {
"contents": "write"
},
"runs-on": "ubuntu-latest",
"env": {
"OS": "ubuntu-latest"
},
"steps": [
{
"name": "Checkout Code",
"uses": "actions/checkout@v3"
},
{
"name": "Create release tag",
"uses": "butlerlogic/action-autotag@8bc1ad456dcdee34e8c6ffbce991cc31793578c2",
"with": {
"root": "ChangeLog.md",
"regex_pattern": "^## (?<version>\\d+\\.\\d+\\.\\d+.*?)( |\\n).*$",
"tag_prefix": "v"
},
"env": {
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
}
}
]
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/env/
/.qlot/
.DS_Store
*.fasl
10 changes: 10 additions & 0 deletions docs/changelog.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
"JS"
"UI"
"40ANTS-DOC"))
(0.16.0 2022-12-12
"
Changed
=======

- Functions REBLOCKS-UI/FORM:ERROR-PLACEHOLDER and REBLOCKS-UI/FORM:FORM-ERROR-PLACEHOLDER now
can be called not only inside the REBLOCKS-UI/FORM:WITH-HTML-FORM macro body, but also in any
function within.
- Added CSS attribute display none/block for popup.
")
(0.15.0 2022-11-26
"
New
Expand Down
1 change: 0 additions & 1 deletion docs/core.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#:reblocks-ui/core)
(:import-from #:40ants-doc
#:defsection)
(:import-from #:reblocks)
(:export #:@core))
(in-package #:reblocks-ui-docs/core)

Expand Down
3 changes: 2 additions & 1 deletion docs/form.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(:use #:cl)
(:import-from #:40ants-doc
#:defsection)
(:import-from #:reblocks)
(:import-from #:reblocks/doc/example
#:defexample)
(:import-from #:reblocks-ui/form
Expand All @@ -12,6 +11,8 @@
#:field-error)
(:import-from #:reblocks/html
#:with-html)
(:import-from #:reblocks-ui/core)
(:import-from #:reblocks/widget)
(:export #:@form))
(in-package #:reblocks-ui-docs/form)

Expand Down
2 changes: 1 addition & 1 deletion docs/index.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(:use #:cl)
(:import-from #:40ants-doc
#:defsection)
(:import-from #:reblocks)
(:import-from #:reblocks/doc/example
#:defexample)
(:import-from #:docs-config
Expand All @@ -20,6 +19,7 @@
#:@form)
(:import-from #:reblocks-ui-docs/core
#:@core)
(:import-from #:reblocks/widget)
(:export #:@index
#:@readme))
(in-package #:reblocks-ui-docs/index)
Expand Down
2 changes: 2 additions & 0 deletions examples/form-errors.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
(:use #:cl)
(:import-from #:reblocks/app
#:defapp)
(:import-from #:reblocks/server)
(:import-from #:reblocks/session)
(:import-from #:reblocks/widget
#:update
#:defwidget)
Expand Down
4 changes: 2 additions & 2 deletions qlfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
("quicklisp" .
(:class qlot/source/dist:source-dist
:initargs (:distribution "http://beta.quicklisp.org/dist/quicklisp.txt" :%version :latest)
:version "2022-11-07"))
:version "2023-10-21"))
("ultralisp" .
(:class qlot/source/dist:source-dist
:initargs (:distribution "http://dist.ultralisp.org" :%version :latest)
:version "20221126115000"))
:version "20231212181000"))
3 changes: 3 additions & 0 deletions reblocks-ui-docs.asd
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
:description "Documentation for Reblocks UI widgets."
:homepage "https://40ants.com/reblocks-ui/"
:source-control (:git "https://github.com/40ants/reblocks-ui"))



3 changes: 3 additions & 0 deletions reblocks-ui.asd
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@
(read-sequence seq stream))
seq)))
:in-order-to ((test-op (test-op reblocks-ui-test))))


(asdf:register-system-packages "log4cl" '("LOG"))
12 changes: 10 additions & 2 deletions src/ci.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
#:build-docs)
(:import-from #:40ants-ci/workflow
#:defworkflow)
(:import-from #:40ants-ci/jobs/autotag)
(:import-from #:40ants-ci/jobs/critic
#:critic))
(in-package reblocks-ui/ci)


(defworkflow release
:on-push-to "master"
:jobs ((40ants-ci/jobs/autotag:autotag)))


(defworkflow docs
:on-push-to "master"
:on-pull-request t
Expand All @@ -27,9 +33,11 @@
:cache t
:jobs ((linter :asdf-systems ("reblocks-ui"
"reblocks-ui-docs"
"reblocks-ui-examples"))
"reblocks-ui-examples")
:check-imports t)
(critic :ignore-critiques
;; Seems Lisp Critic counts docstring lines too :(
("function-too-long"))
("function-too-long"
"check-prefix"))
;; (run-tests :coverage t)
))
1 change: 1 addition & 0 deletions src/core.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
(:nicknames #:reblocks-ui)

(:import-from #:reblocks-parenscript)
(:import-from #:log)
(:import-from #:parenscript
#:chain)
(:import-from #:reblocks/widget
Expand Down
51 changes: 31 additions & 20 deletions src/form.lisp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(defpackage #:reblocks-ui/form
(:use #:cl)
(:import-from #:log4cl)
(:import-from #:log)
(:import-from #:spinneret)
(:import-from #:reblocks/actions
#:make-action-url
#:make-action)
Expand Down Expand Up @@ -303,6 +304,9 @@ $('~A').foundation();
(error-placeholder-message widget)))))


(defvar *error-placeholder-func*)


(defun error-placeholder (name &key (widget-class 'error-placeholder))
"This function creates and renders a widget to show an error message related to some form field.

Expand All @@ -311,18 +315,26 @@ $('~A').foundation();
NAME argument should be a string denoting a form field. Later, you can call FIELD-ERROR function
to signal an error from the action function. You will need to pass the NAME as the first argument
to the FIELD-ERROR function."
(declare (ignore name widget-class))
(error "This function should be called inside WITH-HTML-FORM macro."))
(cond
((boundp '*error-placeholder-func*)
(funcall *error-placeholder-func* name :widget-class widget-class))
(t
(error "This function should be called inside WITH-HTML-FORM macro."))))


(defvar *form-error-placeholder-func*)

(defun form-error-placeholder (&key (widget-class 'form-error-placeholder))
"This function creates and renders a widget to show an error for the whole form.

It should be called inside WITH-HTML-FORM macro.

Later, you can call FORM-ERROR function to signal an error from the action function."
(declare (ignore widget-class))
(error "This function should be called inside WITH-HTML-FORM macro."))
(cond
((boundp '*form-error-placeholder-func*)
(funcall *form-error-placeholder-func* :widget-class widget-class))
(t
(error "This function should be called inside WITH-HTML-FORM macro."))))


(defun %render-error-placeholder (name widget-class error-placeholders)
Expand Down Expand Up @@ -391,21 +403,20 @@ $('~A').foundation();
(%render-error-placeholder name widget-class error-placeholders))
(form-error-placeholder (&key (widget-class 'form-error-placeholder))
(%render-form-error-placeholder widget-class error-placeholders)))
(declare (ignorable (function error-placeholder)
(function form-error-placeholder)))

(%render-form ,method-type
,action
,body
:id ,id
:class ,class
:enctype ,enctype
:use-ajax-p ,use-ajax-p
:extra-submit-code ,extra-submit-code
:requires-confirmation-p ,requires-confirmation-p
:confirm-question ,confirm-question
:submit-fn ,submit-fn
:error-placeholders error-placeholders)))))
(let ((*error-placeholder-func* #'error-placeholder)
(*form-error-placeholder-func* #'form-error-placeholder))
(%render-form ,method-type
,action
,body
:id ,id
:class ,class
:enctype ,enctype
:use-ajax-p ,use-ajax-p
:extra-submit-code ,extra-submit-code
:requires-confirmation-p ,requires-confirmation-p
:confirm-question ,confirm-question
:submit-fn ,submit-fn
:error-placeholders error-placeholders))))))


(defun render-button (name &key
Expand Down
2 changes: 2 additions & 0 deletions src/popup.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
:height 100vh
:background "rgba(0,0,0,0.5)"
:opacity 0
:display none
:pointer-events none
:transition 0.5s all

Expand All @@ -88,6 +89,7 @@
:padding 25px
:transition 0.5s all))
((:and .popup .active)
:display block
:opacity 1
:pointer-events all
:transition 0.5s all
Expand Down