Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Sprotty JSX/TSX support #419

Closed
glatuske opened this issue Jan 31, 2024 · 2 comments · Fixed by #430
Closed

Enhance Sprotty JSX/TSX support #419

glatuske opened this issue Jan 31, 2024 · 2 comments · Fixed by #430
Assignees
Milestone

Comments

@glatuske
Copy link

Sprotty uses JSX/TSX for the graph views. Building components as described in React documentation (https://react.dev/learn/passing-props-to-a-component) is not possible due to normalization of attributes (normalizeAttrs). Also some SVG attributes cannot be passed as expected (e.g. attrs-font-size instead of font-size)

Current:
`@injectable()
export class NodeView extends ShapeView {

render(node: Readonly<SNodeImpl & CustomNode>, context: RenderingContext): VNode | undefined {
	return <g >
		{Tooltip({ type: node.type })}
		{Rectangle({ size: node.size, fill: node.fillColor })}
                    <text class-sprotty-label={true} attrs-font-size="7">{label.text}</text>
		{context.renderChildren(node)}
	</g>;
}

}`

Expected:
`@injectable()
export class NodeView extends ShapeView {

render(node: Readonly<SNodeImpl & CustomNode>, context: RenderingContext): VNode | undefined {
	return <g >
		<Tooltip type={node.type} />
		<Rectangle size={size: node.size} fill={node.fillColor} />
                    <text class-sprotty-label={true} font-size="7">{label.text}</text>
		{context.renderChildren(node)}
	</g>;
}

}`

@tortmayr
Copy link
Contributor

Potential related issue: #178

@jbicker
Copy link
Contributor

jbicker commented Feb 15, 2024

I will take care of this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants