ml-in-barcelona / jsoo-react

js_of_ocaml bindings for ReactJS. Based on ReasonReact.
https://ml-in-barcelona.github.io/jsoo-react
MIT License
138 stars 19 forks source link

Svg.rect x/y attributes ? #176

Closed zeroexcuses closed 1 year ago

zeroexcuses commented 1 year ago

How do we set the x/y attributes on Svg.rect ?

schinns commented 1 year ago

It looks like Svg.rect has props x and y: https://github.com/ml-in-barcelona/jsoo-react/blob/4cae40f36bb9f4b7980e9ca11e63a992b01d3a8f/ppx/html.ml#L1480-L1481

https://github.com/ml-in-barcelona/jsoo-react/blob/4cae40f36bb9f4b7980e9ca11e63a992b01d3a8f/ppx/html.ml#L2262

I haven't tested, but I imagine something like this:

open Svg;
module Prop = {
  include Html.Prop;
  include Svg.Prop;
};

React.Dom.render(
  <svg width="100" height="100">
    <rect y="20" x="20" width="60" height="60" />
  </svg>,
  Dom_html.element(c),
)

edit: referenced this block of code for the example above.