Messages
@magic-modules/messages
this is the @magic-modules Messages component. message popups for @magic.
installation:
npm install @magic-modules/messages
usage:
export const View = {
const message = {
// can be, but should not be, an array of modules too.
title: 'testwarning title',
// can be an array of modules too
content: 'testwarning content',
// leave empty to prevent the message from disappearing.
// if duration is smaller then 60, seconds are assumed, else milliseconds.
duration: 20,
// type can also be one of success, error, warning
type: 'info',
}
return button({ onclick: [actions.messages.add, message] }, 'add message')
}
custom messages type
export const View = () => {
const msg = {
type: 'newType',
title: 'newType title',
content: 'newType content',
duration: 5,
}
return button({ onclick: [actions.messages.add, msg] })
}
// needed in the ssr step for now,
// gets overwritten by @magic-modules/messages with the correct actions.
export const actions = {
messages: {},
}
export const style = vars => ({
'.Messages': {
'.Message.newType': {
h3: {
color: vars.colors.pink[900],
},
},
},
}
})
source
the source for this page is in the example directory and gets built and published to github using @magic/core