add formatter to attach a color variant to its data
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
const families = {
|
||||
9: 'depart',
|
||||
22: 'critique',
|
||||
63: 'echo',
|
||||
6: 'reflexion',
|
||||
7: 'lecture',
|
||||
8: 'sensible',
|
||||
23: 'kit'
|
||||
// TODO creation ?
|
||||
}
|
||||
|
||||
|
||||
export function formatData (data, log = false) {
|
||||
function formatSingle (text) {
|
||||
text.variant = text.families ? families[text.families[0].id] : 'black'
|
||||
for (const arrType of ['siblings', 'children', 'parents']) {
|
||||
if (arrType in text && text[arrType]) {
|
||||
formatData(text[arrType], log)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(data)) {
|
||||
data.forEach(formatSingle)
|
||||
} else {
|
||||
formatSingle(data)
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
Reference in New Issue
Block a user