import React from 'react'
import { translateStrings } from './utils.mjs'
export const TextSpans = ({ point, t }) => {
const translated = translateStrings(t, point.attributes.list['data-text'])
const text = []
if (translated.indexOf('\n') !== -1) {
// Handle muti-line text
let key = 0
let lines = translated.split('\n')
text.push({lines.shift()})
for (let line of lines) {
key++
text.push(
{line.toString().replace(/"/g, '"')}
)
}
} else text.push({translated})
return text
}
export const Text = ({ point, t }) => (
)
export const TextOnPath = ({ path, pathId, t }) => {
const textPathProps = {
xlinkHref: '#' + pathId,
startOffset: '0%',
}
const translated = translateStrings(t, path.attributes.text)
const align = path.attributes.list['data-text-class'].join(' ')
if (align && align.indexOf('center') > -1) textPathProps.startOffset = '50%'
else if (align && align.indexOf('right') > -1) textPathProps.startOffset = '100%'
return (
)
}