mirror of
https://github.com/skishore/makemeahanzi.git
synced 2025-10-31 02:45:49 +08:00
Get links to components working
This commit is contained in:
@ -1,7 +1,11 @@
|
|||||||
<template name="decomposition">
|
<template name="decomposition">
|
||||||
<div class="decomposition">
|
<div class="decomposition">
|
||||||
<div class="header"><div class="value">{{value}}</div> -</div>
|
<div class="header"><div class="value">{{value}}</div> -</div>
|
||||||
<div class="text">{{label}}</div>
|
{{#if link}}
|
||||||
|
<a class="text link" href="{{link}}">{{label}}</a>
|
||||||
|
{{else}}
|
||||||
|
<div class="text">{{label}}</div>
|
||||||
|
{{/if}}
|
||||||
{{#each children}}
|
{{#each children}}
|
||||||
{{> decomposition this}}
|
{{> decomposition this}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
@ -49,7 +53,7 @@
|
|||||||
{{#each metadata}}
|
{{#each metadata}}
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="control-label">{{format label}}</label>
|
<label class="control-label">{{format label}}</label>
|
||||||
<div class="value">{{value}}</div>
|
<div class="value">{{{linkify value}}}</div>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -18,6 +18,9 @@ const augmentTreeWithLabels = (node, dependencies) => {
|
|||||||
node.children.map((child) => augmentTreeWithLabels(child, dependencies));
|
node.children.map((child) => augmentTreeWithLabels(child, dependencies));
|
||||||
} else {
|
} else {
|
||||||
node.label = dependencies[node.value] || '(unknown)';
|
node.label = dependencies[node.value] || '(unknown)';
|
||||||
|
if (dependencies[node.value]) {
|
||||||
|
node.link = `#/codepoint/${node.value.charCodeAt(0)}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,11 +125,26 @@ const resize = () => {
|
|||||||
|
|
||||||
// Meteor template bindings.
|
// Meteor template bindings.
|
||||||
|
|
||||||
|
const linkify = (value) => {
|
||||||
|
const result = [];
|
||||||
|
for (let character of value) {
|
||||||
|
if (character.match(/[\u3400-\u9FBF]/)) {
|
||||||
|
result.push(`<a href="#/codepoint/${character.charCodeAt(0)}" ` +
|
||||||
|
`class="link">${character}</a>`);
|
||||||
|
} else {
|
||||||
|
result.push(character);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.join('');
|
||||||
|
}
|
||||||
|
|
||||||
Template.character.helpers({
|
Template.character.helpers({
|
||||||
character: () => character.get(),
|
character: () => character.get(),
|
||||||
metadata: () => metadata.get(),
|
metadata: () => metadata.get(),
|
||||||
tree: () => tree.get(),
|
tree: () => tree.get(),
|
||||||
|
|
||||||
|
linkify: linkify,
|
||||||
|
|
||||||
orientation: () => orientation.get(),
|
orientation: () => orientation.get(),
|
||||||
short: () => short.get(),
|
short: () => short.get(),
|
||||||
|
|
||||||
@ -137,7 +155,7 @@ Template.character.helpers({
|
|||||||
|
|
||||||
Template.order.helpers({
|
Template.order.helpers({
|
||||||
animations: () => animations.get(),
|
animations: () => animations.get(),
|
||||||
strokes: () => strokes.get().slice().reverse(),
|
strokes: () => (strokes.get() || []).slice().reverse(),
|
||||||
});
|
});
|
||||||
|
|
||||||
Meteor.startup(() => {
|
Meteor.startup(() => {
|
||||||
|
|||||||
@ -88,6 +88,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.text {
|
.text {
|
||||||
|
display: block;
|
||||||
margin-left: 31px;
|
margin-left: 31px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user