From 0686fe4da54cc6436ab8b098f8f166570c2d750c Mon Sep 17 00:00:00 2001 From: Danny Wahl Date: Fri, 9 Feb 2024 17:22:56 -0700 Subject: [PATCH] add MDUI demo --- isp-site/src/components/mdtoui.jsx | 81 ++++++++++-------------------- isp-site/src/index.js | 27 +++++----- isp-site/src/routes/mdui.jsx | 4 +- 3 files changed, 43 insertions(+), 69 deletions(-) diff --git a/isp-site/src/components/mdtoui.jsx b/isp-site/src/components/mdtoui.jsx index 61ad5eaf..6b25ec45 100644 --- a/isp-site/src/components/mdtoui.jsx +++ b/isp-site/src/components/mdtoui.jsx @@ -16,10 +16,7 @@ import { } from "@instructure/ui"; const filterChildrenProps = (props) => { - const filteredChildren = props.children.filter( - (child) => typeof child !== "string", - ); - return filteredChildren; + return props.children.filter((child) => typeof child !== "string"); }; const mdtoui = { @@ -33,9 +30,8 @@ const mdtoui = { del: ({ node, ...props }) => , blockquote: ({ node, ...props }) => { props = { ...props, children: filterChildrenProps(props) }; - const quoteArr = props.children[0].props.children[0].split("--", 2); - const quote = quoteArr[0]; - const author = quoteArr.length > 1 ? quoteArr[1] : false; + const [quote, author] = + props.children[0].props.children.split("--", 2) || false; return ( {author ? : <>} @@ -76,7 +72,7 @@ const mdtoui = { } return ( {children.map((node, i) => { if (tasklist) { + const label = [...node.props.children]; const { children, ...liProps } = node.props; - children.shift(); - const check = liProps.checked ? true : false; return ( - + ); } - return ; + return ; })} ); @@ -119,7 +118,7 @@ const mdtoui = { return ( {children.map((node, i) => { - return ; + return ; })} ); @@ -145,55 +144,29 @@ const mdtoui = { return ( {children.map((node, i) => { - const { children, ...thbProps } = node.props; if (node.type === "thead") { + const { children, ...theadProps } = node.props; return ( - - {children.map((node, i) => { - const { children, ...trProps } = node.props; - return ( - - {children.map((node, i) => { - return ( - - ); - })} - - ); - })} + + + {children.props.children.map((node, i) => { + return ( + + ); + })} + ); } + const { children, ...tbodyProps } = node.props; return ( - + {children.map((node, i) => { const { children, ...trProps } = node.props; return ( - + {children.map((node, i) => { - if (Object.hasOwn(node.props, "style")) { - var align = "start"; - switch (node.props.style.textAlign) { - case "left": - align = "start"; - break; - case "center": - align = "center"; - break; - case "right": - align = "end"; - break; - default: - align = "start"; - } - } - return ( - - ); + return ; })} ); diff --git a/isp-site/src/index.js b/isp-site/src/index.js index 44f02a5b..57600e28 100644 --- a/isp-site/src/index.js +++ b/isp-site/src/index.js @@ -7,7 +7,7 @@ import "./index.css"; import { InstUISettingsProvider, canvas, View } from "@instructure/ui"; import Links from "routes/links"; -// import MDUI from "routes/mdui"; +import MDUI from "routes/mdui"; import Markdown from "routes/markdown"; import ErrorPage from "routes/error"; import { ParentBrands } from "variables/brands"; @@ -65,6 +65,19 @@ routes.push({ ], }); +// Markdown to InstructureUI showcase +routes.push({ + path: "/mdui", + element: , + // errorElement: , + children: [ + { + path: ":language", + element: , + }, + ], +}); + // All others routes.push({ path: "*", @@ -77,18 +90,6 @@ routes.push({ ], }); -/*{ - path: "/mdui", - element: , - errorElement: , - children: [ - { - path: ":language", - element: , - }, - ], - },*/ - const router = createHashRouter(routes); const root = ReactDOM.createRoot(document.getElementById("root")).render( diff --git a/isp-site/src/routes/mdui.jsx b/isp-site/src/routes/mdui.jsx index 459c6dbe..e8e75732 100644 --- a/isp-site/src/routes/mdui.jsx +++ b/isp-site/src/routes/mdui.jsx @@ -20,8 +20,8 @@ import { Grid, } from "@instructure/ui"; import { useParams } from "react-router-dom"; -import { getStrings, getLang } from "variables/langs"; -import { strings } from "strings/mdui"; +import { getStrings, getLang } from "utils/langs"; +import strings from "strings/mdui"; // Components import RenderTopNavBar from "components/RenderTopNavBar";