Skip to content

Commit

Permalink
feat(hiccup-svg): fix #194, add baseline support
Browse files Browse the repository at this point in the history
- add BASE_LINE value mappings
- update convertAttrib()
  • Loading branch information
postspectacular committed Sep 4, 2020
1 parent 5989427 commit f8d4a38
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/hiccup-svg/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const TEXT_ALIGN: { [id: string]: string } = {
end: "end",
};

const BASE_LINE: Record<string, string> = {
top: "text-top",
bottom: "text-bottom",
};

/**
* Takes a normalized hiccup tree of {@link @thi.ng/geom# | @thi.ng/geom} or
* {@link @thi.ng/hdom-canvas# | @thi.ng/hdom-canvas} shape definitions and recursively
Expand Down Expand Up @@ -145,7 +150,7 @@ const convertAttrib = (res: any, id: string, v: any) => {
res["text-anchor"] = TEXT_ALIGN[v];
break;
case "baseline":
// no SVG support?
res["dominant-baseline"] = BASE_LINE[v] || v;
break;
case "filter":
// TODO needs to be translated into <filter> def first
Expand Down

0 comments on commit f8d4a38

Please sign in to comment.