todo-webclient/client/modal.ls

63 lines
1.5 KiB
Plaintext

h = require 'maquette' .h
# formulaire création de listes
# formulaire création de tâches
# confirmation de suppression de listes, de tâches, de colonnes
Modal = (args) ->
self = {
modal-args: args.modal-args || {}
visible: args.visible || false
content: args.content || []
background-args: args.background-args || []
on-validation: args.on-validation || ->
on-cancellation: args.on-cancellation || ->
validation-label: args.validation-label || "Ok"
cancellation-label: args.cancellation-label || "Cancel"
}
self.render = ->
console.log "Rendering a modal: ", self, self.content
is-active = (if self.visible == true then \.is-active else "")
h \div.modal + is-active, self.modal-args, [
h \div.modal-background self.background-args
h \div.modal-content {} [
h \div.box [
self.content
h \hr []
h \div.columns {} [
h \div.column {} [
h \button.button.is-fullwidth {
onclick: ->
self.visible := false
self.on-validation self
} [ self.validation-label ]
]
h \div.column {} [
h \button.button.is-fullwidth {
onclick: ->
self.visible := false
self.on-cancellation self
} [ self.cancellation-label ]
]
]
]
h \button.button.modal-close {
aria-label: "close"
onclick: ->
self.visible := false
self.on-cancellation self
} []
]
]
self
module.exports = Modal