Merge branch 'develop' into more-lint
This commit is contained in:
commit
c0ede14d74
118 changed files with 2870 additions and 4892 deletions
|
@ -31,7 +31,7 @@ export const plugin = {
|
|||
},
|
||||
},
|
||||
macros: {
|
||||
title: function (so) {
|
||||
title: function (so, { points, scale, locale, store }) {
|
||||
const prefix = so.prefix || ''
|
||||
|
||||
// Passing `false` will remove the title
|
||||
|
@ -43,7 +43,7 @@ export const plugin = {
|
|||
`_${prefix}_titleFor`,
|
||||
`_${prefix}_exportDate`,
|
||||
])
|
||||
delete this.points[id]
|
||||
delete points[id]
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -59,36 +59,36 @@ export const plugin = {
|
|||
}
|
||||
|
||||
so = { ...defaults, ...so }
|
||||
so.scale = so.scale * this.context.settings.scale
|
||||
so.scale = so.scale * scale
|
||||
let overwrite = true
|
||||
if (so.append) overwrite = false
|
||||
this.points[`_${prefix}_titleNr`] = so.at
|
||||
points[`_${prefix}_titleNr`] = so.at
|
||||
.clone()
|
||||
.attr('data-text', so.nr, overwrite)
|
||||
.attr('data-text-class', 'text-4xl fill-note font-bold')
|
||||
.attr('data-text-transform', transform(so.at))
|
||||
let shift = 8
|
||||
if (so.title) {
|
||||
this.points[`_${prefix}_titleName`] = so.at
|
||||
points[`_${prefix}_titleName`] = so.at
|
||||
.shift(-90 - so.rotation, shift * so.scale)
|
||||
.attr('data-text', so.title)
|
||||
.attr('data-text-class', 'text-lg fill-current font-bold')
|
||||
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, 13 * so.scale)))
|
||||
shift += 8
|
||||
}
|
||||
let name = this.context.config?.data?.name || 'No Name'
|
||||
let name = store.data?.name || 'No Name'
|
||||
name = name.replace('@freesewing/', '')
|
||||
this.points[`_${prefix}_titlePattern`] = so.at
|
||||
points[`_${prefix}_titlePattern`] = so.at
|
||||
.shift(-90 - so.rotation, shift * so.scale)
|
||||
.attr('data-text', name)
|
||||
.attr('data-text', 'v' + (this.context.config?.data?.version || 'No Version'))
|
||||
.attr('data-text', 'v' + (store.data?.version || 'No Version'))
|
||||
.attr('data-text-class', 'fill-note')
|
||||
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, shift * so.scale)))
|
||||
if (this.context.settings.metadata && this.context.settings.metadata.for) {
|
||||
if (store.data.for) {
|
||||
shift += 8
|
||||
this.points[`_${prefix}_titleFor`] = so.at
|
||||
points[`_${prefix}_titleFor`] = so.at
|
||||
.shift(-90 - so.rotation, shift * so.scale)
|
||||
.attr('data-text', '( ' + this.context.settings.metadata.for + ' )')
|
||||
.attr('data-text', '( ' + store.data.for + ' )')
|
||||
.attr('data-text-class', 'fill-current font-bold')
|
||||
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, shift * so.scale)))
|
||||
}
|
||||
|
@ -98,11 +98,11 @@ export const plugin = {
|
|||
let mins = now.getMinutes()
|
||||
if (hours < 10) hours = `0${hours}`
|
||||
if (mins < 10) mins = `0${mins}`
|
||||
this.points[`_${prefix}_exportDate`] = so.at
|
||||
points[`_${prefix}_exportDate`] = so.at
|
||||
.shift(-90 - so.rotation, shift * so.scale)
|
||||
.attr(
|
||||
'data-text',
|
||||
now.toLocaleDateString(this.context.settings.locale || 'en', {
|
||||
now.toLocaleDateString(locale || 'en', {
|
||||
weekday: 'long',
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
|
|
|
@ -8,35 +8,37 @@ describe('Title Plugin Tests', () => {
|
|||
it('Should run the title macro', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, macro }) => {
|
||||
draft: ({ points, Point, macro, part }) => {
|
||||
points.anchor = new Point(-12, -34)
|
||||
macro('title', {
|
||||
at: points.anchor,
|
||||
nr: 3,
|
||||
title: 'unitTest',
|
||||
})
|
||||
|
||||
return part
|
||||
},
|
||||
plugins: [plugin],
|
||||
}
|
||||
const Pattern = new Design({
|
||||
data: { name: 'testPattern', version: 99 },
|
||||
parts: [part],
|
||||
plugins: [plugin],
|
||||
})
|
||||
const pattern = new Pattern()
|
||||
pattern.draft().render()
|
||||
let p = pattern.parts.test.points.__titleNr
|
||||
let p = pattern.parts[0].test.points.__titleNr
|
||||
expect(p.x).to.equal(-12)
|
||||
expect(p.y).to.equal(-34)
|
||||
expect(p.attributes.get('data-text')).to.equal('3')
|
||||
expect(p.attributes.get('data-text-class')).to.equal('text-4xl fill-note font-bold')
|
||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||
expect(p.attributes.get('data-text-y')).to.equal('-34')
|
||||
p = pattern.parts.test.points.__titleName
|
||||
p = pattern.parts[0].test.points.__titleName
|
||||
expect(p.attributes.get('data-text')).to.equal('unitTest')
|
||||
expect(p.attributes.get('data-text-class')).to.equal('text-lg fill-current font-bold')
|
||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||
expect(p.attributes.get('data-text-y')).to.equal('-26')
|
||||
p = pattern.parts.test.points.__titlePattern
|
||||
p = pattern.parts[0].test.points.__titlePattern
|
||||
expect(p.attributes.get('data-text')).to.equal('testPattern v99')
|
||||
expect(p.attributes.get('data-text-class')).to.equal('fill-note')
|
||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||
|
@ -46,7 +48,7 @@ describe('Title Plugin Tests', () => {
|
|||
it('Should run the title macro with append flag', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, macro }) => {
|
||||
draft: ({ points, Point, macro, part }) => {
|
||||
points.anchor = new Point(-12, -34).attr('data-text', '#')
|
||||
macro('title', {
|
||||
at: points.anchor,
|
||||
|
@ -54,16 +56,18 @@ describe('Title Plugin Tests', () => {
|
|||
title: 'unitTest',
|
||||
append: true,
|
||||
})
|
||||
|
||||
return part
|
||||
},
|
||||
plugins: [plugin],
|
||||
}
|
||||
const Pattern = new Design({
|
||||
data: { name: 'testPattern', version: 99 },
|
||||
parts: [part],
|
||||
plugins: [plugin],
|
||||
})
|
||||
const pattern = new Pattern()
|
||||
pattern.draft().render()
|
||||
let p = pattern.parts.test.points.__titleNr
|
||||
let p = pattern.parts[0].test.points.__titleNr
|
||||
expect(p.x).to.equal(-12)
|
||||
expect(p.y).to.equal(-34)
|
||||
expect(p.attributes.get('data-text')).to.equal('# 3')
|
||||
|
@ -75,7 +79,7 @@ describe('Title Plugin Tests', () => {
|
|||
it('Should run the title macro with point prefix', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, macro }) => {
|
||||
draft: ({ points, Point, macro, part }) => {
|
||||
points.anchor = new Point(-12, -34).attr('data-text', '#')
|
||||
macro('title', {
|
||||
at: points.anchor,
|
||||
|
@ -83,28 +87,30 @@ describe('Title Plugin Tests', () => {
|
|||
title: 'unitTest',
|
||||
prefix: 'foo',
|
||||
})
|
||||
|
||||
return part
|
||||
},
|
||||
plugins: [plugin],
|
||||
}
|
||||
const Pattern = new Design({
|
||||
data: { name: 'testPattern', version: 99 },
|
||||
parts: [part],
|
||||
plugins: [plugin],
|
||||
})
|
||||
const pattern = new Pattern()
|
||||
pattern.draft().render()
|
||||
let p = pattern.parts.test.points._foo_titleNr
|
||||
let p = pattern.parts[0].test.points._foo_titleNr
|
||||
expect(p.x).to.equal(-12)
|
||||
expect(p.y).to.equal(-34)
|
||||
expect(p.attributes.get('data-text')).to.equal('3')
|
||||
expect(p.attributes.get('data-text-class')).to.equal('text-4xl fill-note font-bold')
|
||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||
expect(p.attributes.get('data-text-y')).to.equal('-34')
|
||||
p = pattern.parts.test.points._foo_titleName
|
||||
p = pattern.parts[0].test.points._foo_titleName
|
||||
expect(p.attributes.get('data-text')).to.equal('unitTest')
|
||||
expect(p.attributes.get('data-text-class')).to.equal('text-lg fill-current font-bold')
|
||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||
expect(p.attributes.get('data-text-y')).to.equal('-26')
|
||||
p = pattern.parts.test.points._foo_titlePattern
|
||||
p = pattern.parts[0].test.points._foo_titlePattern
|
||||
expect(p.attributes.get('data-text')).to.equal('testPattern v99')
|
||||
expect(p.attributes.get('data-text-class')).to.equal('fill-note')
|
||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue