fix (banner) add text separately from spacers to allow for i18n during rendering
This commit is contained in:
parent
ccf2ff3931
commit
c147c6b652
2 changed files with 12 additions and 6 deletions
|
@ -12,8 +12,12 @@ export const bannerMacros = {
|
||||||
}
|
}
|
||||||
so.path.attr('data-text-dy', so.dy).attr('data-text-class', `${so.className} center`)
|
so.path.attr('data-text-dy', so.dy).attr('data-text-class', `${so.className} center`)
|
||||||
const spacer = ' '.repeat(so.spaces)
|
const spacer = ' '.repeat(so.spaces)
|
||||||
let banner = spacer
|
|
||||||
for (let i = 0; i < so.repeat; i++) banner += so.text + ' '.repeat(so.spaces)
|
for (let i = 0; i < so.repeat; i++) {
|
||||||
so.path.attr('data-text', banner)
|
so.path.attr('data-text', spacer)
|
||||||
|
so.path.attr('data-text', so.text)
|
||||||
|
}
|
||||||
|
|
||||||
|
so.path.attr('data-text', spacer)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe('Banner Plugin Tests', () => {
|
||||||
pattern.draft()
|
pattern.draft()
|
||||||
const c = pattern.parts[0].test.paths.example
|
const c = pattern.parts[0].test.paths.example
|
||||||
expect(c.attributes.get('data-text')).to.equal(
|
expect(c.attributes.get('data-text')).to.equal(
|
||||||
'            foo            foo            foo            foo            foo            foo            foo            foo            foo            foo            '
|
'             foo              foo              foo              foo              foo              foo              foo              foo              foo              foo             '
|
||||||
)
|
)
|
||||||
expect(c.attributes.get('data-text-class').trim()).to.equal('center')
|
expect(c.attributes.get('data-text-class').trim()).to.equal('center')
|
||||||
expect(c.attributes.get('data-text-dy')).to.equal('-1')
|
expect(c.attributes.get('data-text-dy')).to.equal('-1')
|
||||||
|
@ -56,7 +56,7 @@ describe('Banner Plugin Tests', () => {
|
||||||
const pattern = new design()
|
const pattern = new design()
|
||||||
pattern.draft()
|
pattern.draft()
|
||||||
const c = pattern.parts[0].test.paths.example2
|
const c = pattern.parts[0].test.paths.example2
|
||||||
expect(c.attributes.get('data-text')).to.equal('  foo  foo  ')
|
expect(c.attributes.get('data-text')).to.equal('   foo    foo   ')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Number of repetitions should be configurable', () => {
|
it('Number of repetitions should be configurable', () => {
|
||||||
|
@ -82,6 +82,8 @@ describe('Banner Plugin Tests', () => {
|
||||||
const pattern = new design()
|
const pattern = new design()
|
||||||
pattern.draft()
|
pattern.draft()
|
||||||
const c = pattern.parts[0].test.paths.example3
|
const c = pattern.parts[0].test.paths.example3
|
||||||
expect(c.attributes.get('data-text')).to.equal(' foo foo foo foo ')
|
expect(c.attributes.get('data-text')).to.equal(
|
||||||
|
'  foo   foo   foo   foo  '
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue