當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript h.li方法代碼示例

本文整理匯總了TypeScript中@soil/dom.h.li方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript h.li方法的具體用法?TypeScript h.li怎麽用?TypeScript h.li使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@soil/dom.h的用法示例。


在下文中一共展示了h.li方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: nutrientItem

function nutrientItem(rdi: ExtendedRdi) {
    let className = 'incomplete'
    if (rdi.pct >= 90) {
        className = 'complete'
    }
    if (rdi.max && rdi.Nutr_Val > rdi.max) {
        className = 'exceeding'
    }
    if (!rdi.max && rdi.pct >= 110) {
        className = 'possibly-exceeding'
    }

    return h.li({className}, [
        h.h2({}, [
            h.a({
                title: rdi.display_name ? rdi.NutrDesc : '',
                href: '/top-foods/index.html?nutrient-id=' + rdi.Nutr_No
            }, [rdi.display_name || rdi.NutrDesc])
        ]),
        h.span({className: 'progress-start', title: 'Percentage and amount of the nutrient covered by 100 grams of this food'}, [
            `${rdi.pct.toFixed(2)}${nbsp}%, ${rdi.Nutr_Val}${nbsp}${rdi.Units} (`,
            h.abbr({title: 'Tolerable Upper Intake Level'}, ['UL']),
            `: ${rdi.max ? `${rdi.max}\u2009${rdi.Units}` : `unkown`})`
        ]),
        h.span({className: 'progress-end', title: 'Reference Daily Intake'}, [
            rdi.value + nbsp + rdi.Units
        ]),
        h.progress({max: 100, value: rdi.pct})
    ])
}
開發者ID:inad9300,項目名稱:kiwibit,代碼行數:30,代碼來源:food-details.ts

示例2: header

export function header() {
    return h.nav({className: 'header'}, [
        h.h1({}, [
            h.a({href: '/'}, ['Kiwibit'])
        ]),
        h.ul({}, [
            h.li({}, [
                h.a({href: 'foods-details'}, ['Food details'])
            ]),
            h.li({}, [
                h.a({href: 'top-foods'}, ['Top foods'])
            ]),
            h.li({}, [
                h.a({href: 'label-builder'}, ['Label builder'])
            ])
        ])
    ])
}
開發者ID:inad9300,項目名稱:kiwibit,代碼行數:18,代碼來源:header.ts

示例3: showFoodDetails

 .map(f => h.li({}, [
     h.span({
         tabIndex: 0,
         style: {cursor: 'pointer'},
         onclick: () => showFoodDetails(f.ndb_no),
         onkeydown: evt => {
             if (evt.key === 'Enter') {
                 showFoodDetails(f.ndb_no)
             }
         }
     }, [f.long_desc])
 ]))
開發者ID:inad9300,項目名稱:kiwibit,代碼行數:12,代碼來源:foods-details.ts

示例4:

                    .forEach(opt => {
                        for (let i = 0; i < selectedFoods.length; ++i) {
                            if (selectedFoods[i].ndb_no === opt.value) {
                                return;
                            }
                        }

                        selectedFoods.push({
                            ndb_no: opt.value,
                            long_desc: opt.textContent!
                        })
                        selectedFoodList.appendChild(h.li({}, [opt.textContent!]))
                    })
開發者ID:inad9300,項目名稱:kiwibit,代碼行數:13,代碼來源:label-builder.ts

示例5: foodGroupCircle

            .then(foods => {
                $resultList.innerHTML = ''

                if (foods.length === 0) {
                    $resultList.appendChild(
                        h.li({className: 'no-results'}, ['No results.'])
                    )
                    return
                }

                foods.forEach(food => $resultList.appendChild(
                    h.li({}, [
                        foodGroupCircle(food),
                        h.a({href: 'index.html?id=' + food.NDB_No}, [food.Long_Desc])
                    ])
                ))
            })
開發者ID:inad9300,項目名稱:kiwibit,代碼行數:17,代碼來源:findFoodsModal.ts

示例6: save

import {h} from '@soil/dom'
import {icon} from '../shared/dom/icon'

const page = h.div({className: 'page'}, [
    h.h1({className: 'main-title'}, ['Your profile']),
    h.form({}, [
        h.ul({className: 'field-list'}, [
            h.li({}, [
                h.label({htmlFor: 'field-age'}, ['Age']),
                h.input({id: 'field-age', type: 'number', min: '0', max: '150'})
            ]),
            h.li({}, [
                h.label({htmlFor: 'field-gender'}, ['Gender']),
                h.select({id: 'field-gender'}, [
                    h.option({value: 'M'}, ['Male']),
                    h.option({value: 'F'}, ['Female'])
                ])
            ])
        ]),
        h.hr(),
        h.button({onclick: () => save()}, [icon('save'), 'Save'])
    ])
])

function save() {
    // TODO
    console.log('Saving...')
}

document.body.appendChild(page)
開發者ID:inad9300,項目名稱:kiwibit,代碼行數:30,代碼來源:profile.ts


注:本文中的@soil/dom.h.li方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。