From e7c697d24ad15d963fcf2c7081489712f2c2b3ae Mon Sep 17 00:00:00 2001 From: Guillaume Hivert Date: Wed, 21 Aug 2024 15:06:47 +0200 Subject: [PATCH] feat: add html.none --- .prettierrc | 3 ++- redraw/src/redraw.ffi.mjs | 1 + redraw/src/redraw/html.gleam | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.prettierrc b/.prettierrc index dd0d952..8c124bb 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,6 @@ { "printWidth": 80, "semi": false, - "proseWrap": "always" + "proseWrap": "always", + "trailingComma": "all" } diff --git a/redraw/src/redraw.ffi.mjs b/redraw/src/redraw.ffi.mjs index 35e494b..0514165 100644 --- a/redraw/src/redraw.ffi.mjs +++ b/redraw/src/redraw.ffi.mjs @@ -118,6 +118,7 @@ export function addProxy(Component) { /** Generate JSX using the JSX factory. * `jsx` is for dynamic components, while `jsxs` is for static components. */ export function jsx(value, props_, children_) { + if (value === "none_") return null if (value === "text_") return children_ let children = children_?.toArray?.() let isStatic = true diff --git a/redraw/src/redraw/html.gleam b/redraw/src/redraw/html.gleam index 9920ddd..e66820b 100644 --- a/redraw/src/redraw/html.gleam +++ b/redraw/src/redraw/html.gleam @@ -31,6 +31,10 @@ pub fn title(attrs, content) { redraw.jsx("title", attrs, [text(content)]) } +pub fn none() { + redraw.jsx("none_", Nil, Nil) +} + pub fn text(content: String) -> Component { redraw.jsx("text_", Nil, content) }