1
0
Fork 0
freesewing/packages/freesewing.shared/components/workbench/draft/text-on-path/index.js

26 lines
789 B
JavaScript
Raw Normal View History

2022-01-25 11:22:09 +01:00
const TextOnPath = (props) => {
const text = []
// Handle translation
let translated = ''
for (let string of props.path.attributes.getAsArray('data-text')) {
2022-01-27 13:57:54 +01:00
translated += props.app.t(string, false, props.language).replace(/"/g, '"') + ' '
2022-01-25 11:22:09 +01:00
}
const textPathProps = {
xlinkHref: '#' + props.pathId,
startOffset: '0%'
}
const align = props.path.attributes.get('data-text-class')
if (align && align.indexOf('center') > -1) textPathProps.startOffset = '50%'
else if (align && align.indexOf('right') > -1) textPathProps.startOffset = '100%'
return (
<text>
<textPath {...textPathProps}>
<tspan {...props.path.attributes.asPropsIfPrefixIs('data-text-')}>{translated}</tspan>
</textPath>
</text>
)
}
export default TextOnPath