1
0
Fork 0

fix (banner) add text separately from spacers to allow for i18n during rendering

This commit is contained in:
Enoch Riese 2023-04-18 16:40:30 -04:00
parent ccf2ff3931
commit c147c6b652
2 changed files with 12 additions and 6 deletions

View file

@ -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 + '&#160;'.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)
}, },
} }

View file

@ -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(
'&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' '&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foo &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foo &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foo &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foo &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foo &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foo &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foo &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foo &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foo &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foo &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'
) )
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('&#160;&#160;foo&#160;&#160;foo&#160;&#160;') expect(c.attributes.get('data-text')).to.equal('&#160;&#160; foo &#160;&#160; foo &#160;&#160;')
}) })
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('&#160;foo&#160;foo&#160;foo&#160;foo&#160;') expect(c.attributes.get('data-text')).to.equal(
'&#160; foo &#160; foo &#160; foo &#160; foo &#160;'
)
}) })
}) })