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 = {}
self.modal-args = args.modal-args || {}
self.visible = args.visible || false
self.content = args.content || []
self.background-args = args.background-args || []
self.on-validation = args.on-validation || ->
self.on-cancellation = args.on-cancellation || ->
self.validation-label = args.validation-label || "Ok"
self.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