@magic
@magic-modules/example
custom module
Mod Component Title, passed via props
Component, a second component in /assets/modules/Component.mjs
Mod sourcecode:
export const View = state =>div({ class: 'Mod' }, [h3('Mod.Mod'),p(['this is Mod. it gets loaded from ',Link({ to: 'https://github.com/magic/core/blob/master/example/assets/modules/Mod.mjs' }, '/assets/modules/Mod.mjs'),' automatically, no need to import it.',]),p(['the state of this module: ', JSON.stringify(state.module)]),])export const state = {module: {test: 'testing',},}export const style = {margin: '0 0 1em',padding: '0.5em',border: '1px solid',borderColor: 'green',h3: {margin: 0,},}export const global = {state: {module: true,},}
Component sourcecode:
export const View = props => {props = typeof props === 'string' ? { header: props } : propsCHECK_PROPS(props, propTypes, 'Component')const header = props.header || props.titlereturn div({ class: 'Component' }, \[header && h5(header),p(['Component, a second component in ',Link({ to: 'https://github.com/magic/core/blob/master/example/assets/modules/Component.mjs' },'/assets/modules/Component.mjs',),]),])}export const style = {border: '1px solid orange',}export const propTypes = {Component: [{ key: 'header', type: ['string', 'array'], required: ['title'] }],}