Add admonition

pull/645/head
Tienson Qin 2020-05-31 18:31:58 +08:00
parent 258e267a54
commit fa6b9fa9de
3 changed files with 106 additions and 24 deletions

View File

@ -247,7 +247,7 @@
(->elem
:a
(cond->
{:href href}
{:href href}
title
(assoc :title title))
(map-inline config label))
@ -260,8 +260,8 @@
(->elem
:a
(cond->
{:href href
:target "_blank"}
{:href href
:target "_blank"}
title
(assoc :title title))
(map-inline config label))))))
@ -383,15 +383,15 @@
[:span ""])]
[:a.flex.flex-row.items-center.justify-center
(cond->
{:draggable true
:on-drag (fn [event]
)
:on-drag-over (fn [event]
)
:on-drop (fn [event]
)
:style {:width 14
:height 24}}
{:draggable true
:on-drag (fn [event]
)
:on-drag-over (fn [event]
)
:on-drop (fn [event]
)
:style {:width 14
:height 24}}
(not dummy?)
(assoc :href (str "/page/" uuid)
:on-click (fn [e]
@ -485,12 +485,12 @@
(util/input? target)
(and (util/sup? target)
(d/has-class? target "fn")))
(util/stop e)
(handler/reset-cursor-range! (gdom/getElement heading-id))
(state/set-editing!
edit-input-id
(handler/remove-level-spaces content format)
heading))))}
(util/stop e)
(handler/reset-cursor-range! (gdom/getElement heading-id))
(state/set-editing!
edit-input-id
(handler/remove-level-spaces content format)
heading))))}
heading-part
;; non-heading children
@ -676,6 +676,24 @@
:margin-left "0.25rem"}})
[:div "Empty"]))])
(rum/defc admonition
[type options content]
(when-let [icon (case (string/lower-case (name type))
"note" svg/note
"tip" svg/tip
"important" svg/important
"caution" svg/caution
"warning" svg/warning
nil)]
[:div.admonitionblock {:class type}
[:table
[:tbody
[:tr
[:td.icon (icon)]
[:td.content
[:div.paragraph
content]]]]]]))
(defn block
[config item]
(try
@ -719,6 +737,20 @@
["Custom" "query" options content]
(custom-query config options content)
["Custom" "note" options content]
(admonition "note" options content)
["Custom" "tip" options content]
(admonition "tip" options content)
["Custom" "important" options content]
(admonition "important" options content)
["Custom" "caution" options content]
(admonition "caution" options content)
["Custom" "warning" options content]
(admonition "warning" options content)
["Custom" name options l]
(->elem

View File

@ -65,6 +65,58 @@
(def close (hero-icon "M6 18L18 6M6 6L18 18"))
(def plus (hero-icon "M12 4v16m8-8H4"))
(rum/defc note
[]
[:svg.h-8.w-8.svg-shadow
{:view-box "0 0 512 512"
:fill "currentColor"
:color "#19407c"}
[:path
{:d
"M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z"}]])
;; #111
;; text-shadow 1px 1px 2px rgba(155,155,0,.8)
(rum/defc tip
[]
[:svg.h-8.w-8.tip-shadow
{:view-box "0 0 352 512"
:fill "currentColor"
:color "#111"}
[:path
{:d
"M96.06 454.35c.01 6.29 1.87 12.45 5.36 17.69l17.09 25.69a31.99 31.99 0 0 0 26.64 14.28h61.71a31.99 31.99 0 0 0 26.64-14.28l17.09-25.69a31.989 31.989 0 0 0 5.36-17.69l.04-38.35H96.01l.05 38.35zM0 176c0 44.37 16.45 84.85 43.56 115.78 16.52 18.85 42.36 58.23 52.21 91.45.04.26.07.52.11.78h160.24c.04-.26.07-.51.11-.78 9.85-33.22 35.69-72.6 52.21-91.45C335.55 260.85 352 220.37 352 176 352 78.61 272.91-.3 175.45 0 73.44.31 0 82.97 0 176zm176-80c-44.11 0-80 35.89-80 80 0 8.84-7.16 16-16 16s-16-7.16-16-16c0-61.76 50.24-112 112-112 8.84 0 16 7.16 16 16s-7.16 16-16 16z"}]])
(rum/defc important
[]
[:svg.h-8.w-8.svg-shadow
{:view-box "0 0 512 512"
:fill "currentColor"
:color "#bf0000"}
[:path
{:d
"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"}]])
(rum/defc caution
[]
[:svg.h-8.w-8.svg-shadow
{:view-box "0 0 384 512"
:fill "currentColor"
:color "#bf3400"}
[:path
{:d
"M216 23.86c0-23.8-30.65-32.77-44.15-13.04C48 191.85 224 200 224 288c0 35.63-29.11 64.46-64.85 63.99-35.17-.45-63.15-29.77-63.15-64.94v-85.51c0-21.7-26.47-32.23-41.43-16.5C27.8 213.16 0 261.33 0 320c0 105.87 86.13 192 192 192s192-86.13 192-192c0-170.29-168-193-168-296.14z"}]])
(rum/defc warning
[]
[:svg.h-8.w-8.svg-shadow
{:view-box "0 0 576 512"
:fill "currentColor"
:color "#bf6900"}
[:path
{:d
"M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"}]])
(rum/defc caret-down
[]
[:svg
@ -220,6 +272,4 @@
{:fill "currentColor",
:d
"M23.9455 16.5615C23.6366 17.7364 22.0985 18.4931 20.5102 18.2516C18.9219 18.01 17.8849 16.8618 18.1938 15.6868C18.5028 14.5119 20.0409 13.7552 21.6291 13.9967C23.2174 14.2382 24.2545 15.3865 23.9455 16.5615Z"}]]
)
)

View File

@ -555,9 +555,9 @@
:or {pull-now? true}}]
(periodically-update-repo-status repo-url)
(periodically-pull repo-url pull-now?)
(periodically-push-tasks repo-url)
;; (when-not config/dev?
;; (periodically-push-tasks repo-url))
;; (periodically-push-tasks repo-url)
(when-not config/dev?
(periodically-push-tasks repo-url))
)
(defn render-local-images!