本文整理汇总了TypeScript中@soil/dom.h.thead方法的典型用法代码示例。如果您正苦于以下问题:TypeScript h.thead方法的具体用法?TypeScript h.thead怎么用?TypeScript h.thead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@soil/dom.h
的用法示例。
在下文中一共展示了h.thead方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: handleEscape
.then((data: FoodDetails) => {
const details = h.dl({}, [
h.dt({}, ['Food group']),
h.dd({}, [data.fdgrp_desc]),
h.dt({}, ['Common name']),
h.dd({}, [data.long_desc + (data.comname ? ` (${data.comname})` : '')]),
h.dt({}, ['Scientific name']),
h.dd({}, [data.sciname || nbsp]),
h.dt({}, ['Inedible']),
h.dd({}, [(data.refuse || 0) + '%']),
h.dt({}, ['Inedible parts']),
h.dd({}, [data.ref_desc || nbsp]),
h.dt({}, ['Manufacturer']),
h.dd({}, [data.manufacname || nbsp])
])
const nutrition = h.table({}, [
h.thead({}, [
h.tr({}, [
h.th({}, ['Nutrient']),
h.th({}, ['Value']),
h.th({}, ['Minimum']),
h.th({}, ['Maximum']),
h.th({}, [
h.abbr({title: 'Added for fortification or enrichment'}, ['Added'])
])
]),
]),
h.tbody({}, data.nutrition.map(nut => h.tr({}, [
h.td({}, [nut.nutrdesc]),
h.td({}, [nut.nutr_val + ' ' + nut.units]),
h.td({}, [nut.min + ' ' + nut.units]),
h.td({}, [nut.max + ' ' + nut.units]),
h.td({}, [nut.add_nutr_mark ? 'Yes' : 'No'])
])))
])
const sources = h.table({style: {marginBottom: '20px'}}, [
h.thead({}, [
h.tr({}, [
h.th({}, ['Title']),
h.th({}, ['Authors']),
h.th({}, ['Journal']),
h.th({}, ['Year'])
]),
]),
h.tbody({}, data.sources.map(src => h.tr({}, [
h.td({}, [src.title]),
h.td({}, [src.authors]),
h.td({}, [src.journal]),
h.td({}, [src.year])
])))
])
const modal = h.div({className: 'overlay', onclick: () => removeModal()}, [
h.div({className: 'padded modal', onclick: evt => evt.stopPropagation()}, [
h.h2({}, ['Details']),
details,
h.div({style: {clear: 'both'}}),
h.h2({}, ['Nutrition facts']),
nutrition,
h.h2({}, ['Sources']),
sources
])
])
document.body.appendChild(modal)
window.addEventListener('keydown', handleEscape)
function handleEscape(evt: KeyboardEvent) {
if (evt.key === 'Escape') {
removeModal()
}
}
function removeModal() {
modal.remove()
window.removeEventListener('keydown', handleEscape)
}
})