本文整理汇总了TypeScript中snabbdom.thunk函数的典型用法代码示例。如果您正苦于以下问题:TypeScript thunk函数的具体用法?TypeScript thunk怎么用?TypeScript thunk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了thunk函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: userBox
function userBox(ctrl: Controller) {
const data = ctrl.getData();
if (!data.user) return;
let ratingHtml = data.user.rating;
if (ctrl.vm.round) {
let diff = ctrl.vm.round.ratingDiff,
klass = '';
if (diff >= 0) {
diff = '+' + diff;
if (diff > 0) klass = 'up';
} else if (diff === 0) diff = '+0';
else {
diff = '−' + (-diff);
klass = 'down';
}
ratingHtml += ' <span class="rp ' + klass + '">' + diff + '</span>';
}
const hash = ctrl.recentHash();
return h('div.side_box.rating', [
h('h2', {
hook: innerHTML(ctrl.trans('yourPuzzleRatingX', strong(ratingHtml)))
}),
h('div', thunk('div.rating_chart.' + hash, ratingChart, [ctrl, hash]))
]);
}
开发者ID:ddugovic,项目名称:lila,代码行数:25,代码来源:side.ts
示例2: render
export function render(ctrl: AnalyseCtrl): MaybeVNode {
if (!ctrl.data.analysis || !ctrl.showComputer() || (ctrl.study && ctrl.study.vm.toolTab() !== 'serverEval')) return;
// don't cache until the analysis is complete!
const buster = ctrl.data.analysis.partial ? Math.random() : '';
const cacheKey = '' + buster + !!ctrl.retro;
return thunk('div.advice_summary', doRender, [ctrl, cacheKey]);
}
开发者ID:mate-amargo,项目名称:lila,代码行数:10,代码来源:acpl.ts
示例3: main
export function main(ctrl: StudyCtrl): VNode {
const current = ctrl.currentChapter(),
data = ctrl.practice!.data;
return h('div.side_box.study_box', [
h('div.title', [
h('i.practice.icon.' + data.study.id),
h('div.text', [
h('h1', data.study.name),
h('em', data.study.desc)
])
]),
h('div.list.chapters', {
hook: bind('click', e => {
e.preventDefault();
const target = e.target as HTMLElement;
const id = (target.parentNode as HTMLElement).getAttribute('data-id') || target.getAttribute('data-id');
if (id) ctrl.setChapter(id, true);
return false;
})
}, ctrl.chapters.list().map(function(chapter) {
const loading = ctrl.vm.loading && chapter.id === ctrl.vm.nextChapterId;
const active = !ctrl.vm.loading && current && current.id === chapter.id;
const completion = data.completion[chapter.id] ? 'done' : 'ongoing';
return [
h('a.elem.chapter', {
key: chapter.id,
attrs: {
href: data.url + '/' + chapter.id,
'data-id': chapter.id
},
class: { active, loading }
}, [
h('span.status.' + completion, {
attrs: {
'data-icon': ((loading || active) && completion === 'ongoing') ? 'G' : 'E'
}
}),
h('h3', chapter.name)
])
];
}).reduce(function(a, b) { return a.concat(b); }, [])),
h('div.finally', [
h('a.back', {
attrs: {
'data-icon': 'I',
href: '/practice',
title: 'More practice'
}
}),
thunk('select.selector', selector, [data])
])
]);
}
开发者ID:lexisvar,项目名称:lila,代码行数:55,代码来源:studyPracticeView.ts
示例4: render
export function render(ctrl: AnalyseCtrl): MaybeVNode {
if (!ctrl.data.analysis || !ctrl.showComputer()) return;
// don't cache until the analysis is complete!
const firstEval = ctrl.mainline[0].eval;
const firstKey = firstEval ? firstEval.cp : Math.random();
const cacheKey = '' + firstKey + !!ctrl.retro;
return thunk('div.advice_summary', doRender, [ctrl, cacheKey]);
}
开发者ID:lexisvar,项目名称:lila,代码行数:11,代码来源:acpl.ts
示例5: render
export function render(ctrl: AnalyseCtrl): VNode | undefined {
if (ctrl.studyPractice || ctrl.embed) return;
if (!ctrl.data.analysis || !ctrl.showComputer() || (ctrl.study && ctrl.study.vm.toolTab() !== 'serverEval'))
return h('div.analyse__acpl');
// don't cache until the analysis is complete!
const buster = ctrl.data.analysis.partial ? Math.random() : '';
let cacheKey = '' + buster + !!ctrl.retro;
if (ctrl.study) cacheKey += ctrl.study.data.chapter.id;
return h('div.analyse__acpl', thunk('div.advice-summary', doRender, [ctrl, cacheKey]));
}
开发者ID:ornicar,项目名称:lila,代码行数:14,代码来源:acpl.ts
示例6: renderLine
function renderLine(ctrl: Ctrl, line: Line) {
const textNode = renderText(line.t, ctrl.opts.parseMoves);
if (line.u === 'lichess') return h('li.system', textNode);
if (line.c) return h('li', [
h('span', '[' + line.c + ']'),
textNode
]);
const userNode = thunk('a', line.u, userLink, [line.u]);
return h('li', {
}, ctrl.moderation() ? [
line.u ? lineAction(line.u) : null,
userNode,
textNode
] : [userNode, textNode]);
}
开发者ID:lexisvar,项目名称:lila,代码行数:20,代码来源:discussion.ts
示例7: userBox
export function userBox(ctrl: Controller) {
const data = ctrl.getData();
if (!data.user) return;
let ratingHtml = data.user.rating;
if (ctrl.vm.round) {
let diff = ctrl.vm.round.ratingDiff,
tag = 'bad';
if (diff) {
if (diff > 0) {
diff = '+' + diff;
tag = 'good';
}
else diff = '−' + (-diff);
ratingHtml += ` <${tag} class="rp">${diff}</${tag}>`;
}
}
const hash = ctrl.recentHash();
return h('div.puzzle__side__user', [
h('h2', {
hook: innerHTML(ctrl.trans('yourPuzzleRatingX', strong(ratingHtml)))
}),
h('div', thunk('div.rating_chart.' + hash, ratingChart, [ctrl, hash]))
]);
}
开发者ID:ornicar,项目名称:lila,代码行数:24,代码来源:side.ts
示例8: view
export function view(root: StudyCtrl): VNode {
const chapter = root.tags.getChapter(),
tagKey = chapter.tags.map(t => t[1]).join(','),
key = chapter.id + root.data.name + chapter.name + root.data.likes + tagKey + root.vm.mode.write;
return thunk('div.undertable_inner.' + chapter.id, doRender, [root, key]);
}
开发者ID:luanlv,项目名称:lila,代码行数:6,代码来源:studyTags.ts
示例9: function
export default function(ctrl) {
if (!ctrl.getData().user) return;
return thunk('div.puzzle__history', render, [ctrl, ctrl.recentHash()]);
};
开发者ID:ornicar,项目名称:lila,代码行数:4,代码来源:history.ts
注:本文中的snabbdom.thunk函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论