Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
React/SVG Texto multilínea generado dinámicamente

Actualmente estoy escribiendo un generador basado en React y SVG usando mechanic.design (un framework JS). Este generador tiene diferentes posibilidades de entrada que son declaradas por diferentes campos.

Ahora tengo el siguiente problema y es que tengo un campo de texto y cuando se hace demasiado largo sale de mi ViewBox y no hace un salto de línea. He leído en línea que un salto de línea no es compatible con SVG, pero tengo curiosidad por saber si se puede hacer de forma indirecta usando React.

La configuración manual de saltos de línea es algo que he visto hacer con texto estático, pero el generador crea texto dinámico con diferentes longitudes, por lo que no puedo configurar manualmente los saltos.

Debajo de un código para la parte visual:

 import React, { useEffect, useState } from "react"; import ImgBanner from './assets/banner.svg'; import "./styles.css"; export const handler = ({ inputs, mechanic }) => { const { width, height, schriftfarbe, subtitel, titel, titel2, untertitel, } = inputs; useEffect(() => { mechanic.done(); }, []); return ( <svg width={width} height={height}> <rect width={width} height={height} /> <image href={ImgBanner} width={width} height={height} /> <image x={950} y={-10} width={200} height={200} href={href} > </image> {/* The text */} <text x={25} y={75} fill={schriftfarbe} textAnchor="start" fontWeight="regular" fontFamily="Garnett Regular" fontSize={30} > {subtitel} </text> <text x={25} y={height / 2} fill={schriftfarbe} textAnchor="start" fontWeight="regular" fontFamily="Garnett Regular" fontSize={72} > {titel} <tspan> </tspan> </text> <text x={25} y={height / 2 + 90} fill={schriftfarbe} textAnchor="start" fontWeight="regular" fontFamily="Garnett Regular" fontSize={72} > {titel2} </text> <text x={25} y={575} fill={schriftfarbe} textAnchor="start" fontWeight="regular" fontFamily="Garnett Regular" fontSize={30} > {untertitel} </text> </svg> ); };

¡Gracias por adelantado!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda