feat(web/radial): newlines support (#316)

* feat(radial): Support newlines

* chore: update to `  \n` to match markdown
This commit is contained in:
Jag
2023-05-01 02:07:17 -07:00
committed by GitHub
parent 60ef88c08f
commit bda2c2657a
2 changed files with 6 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ export const debugRadial = () => {
items: [ items: [
{ icon: 'palette', label: 'Paint' }, { icon: 'palette', label: 'Paint' },
{ icon: 'warehouse', label: 'Garage' }, { icon: 'warehouse', label: 'Garage' },
{ icon: 'palette', label: 'Quite long text' }, { icon: 'palette', label: 'Quite long \ntext' },
{ icon: 'palette', label: 'Paint' }, { icon: 'palette', label: 'Paint' },
{ icon: 'warehouse', label: 'Garage' }, { icon: 'warehouse', label: 'Garage' },
], ],

View File

@@ -155,8 +155,11 @@ const RadialMenu: React.FC = () => {
height={25} height={25}
fixedWidth fixedWidth
/> />
<text x={iconX} y={iconY + 25} fill="#fff" textAnchor="middle" pointerEvents="none"> <text x={iconX} y={iconY + (item.label.includes(" \n") ? 7 : 25)} fill="#fff" textAnchor="middle" pointerEvents="none">
{item.label} {item.label.includes(" \n")
? item.label.split(" \n").map((value) => <tspan x={iconX} dy="1.2em">{value}</tspan>)
: item.label
}
</text> </text>
</g> </g>
</g> </g>