From fc28dcdca068f1694b2a48814b51a873737b87fc Mon Sep 17 00:00:00 2001 From: bblake Date: Tue, 4 Apr 2023 14:34:17 -0500 Subject: [PATCH] adding-mithril --- .../lib/playground/createMithrilPlayground.js | 33 +++++++++++++++++++ build/lib/playground/index.js | 2 ++ .../6-form-input/3-radio/mithril/PickPill.js | 2 +- .../7-webapp-features/1-render-app/lit/app.js | 2 +- public/framework/mithril.svg | 2 +- 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 build/lib/playground/createMithrilPlayground.js diff --git a/build/lib/playground/createMithrilPlayground.js b/build/lib/playground/createMithrilPlayground.js new file mode 100644 index 00000000..9d98a85c --- /dev/null +++ b/build/lib/playground/createMithrilPlayground.js @@ -0,0 +1,33 @@ +import nodePath from "node:path"; + +export default function createMithrilREPL() { + const BASE_URL = "https://flems.io/"; + + function utoa(data) { + return btoa(unescape(encodeURIComponent(data))); + } + + function generateURLFromData(data) { + return `${BASE_URL}${utoa(JSON.stringify(data))}`; + } + + function fromContentByFilename(contentByFilename) { + console.log("contentByFilename", contentByFilename); + const data = Object.keys(contentByFilename).map((filename) => { + const content = contentByFilename[filename]; + const parsedFilename = nodePath.parse(filename); + return { + name: parsedFilename.name, + type: parsedFilename.ext.split(".").pop(), + source: content, + }; + }); + + const url = generateURLFromData(data); + return url; + } + + return { + fromContentByFilename, + }; +} diff --git a/build/lib/playground/index.js b/build/lib/playground/index.js index 1e05a653..75ec8175 100644 --- a/build/lib/playground/index.js +++ b/build/lib/playground/index.js @@ -1,3 +1,4 @@ +import createMithrilPlayground from "./createMithrilPlayground.js"; import createAlpinePlayground from "./createAlpinePlayground.js"; import createSveltePlayground from "./createSveltePlayground.js"; import createVue3Playground from "./createVue3Playground.js"; @@ -5,6 +6,7 @@ import createSolidPlayground from "./createSolidPlayground.js"; import createMarkoPlayground from "./createMarkoPlayground.js"; export default { + mithril: createMithrilPlayground(), vue3: createVue3Playground(), svelte: createSveltePlayground(), alpine: createAlpinePlayground(), diff --git a/content/6-form-input/3-radio/mithril/PickPill.js b/content/6-form-input/3-radio/mithril/PickPill.js index a6d51ac7..a303117c 100644 --- a/content/6-form-input/3-radio/mithril/PickPill.js +++ b/content/6-form-input/3-radio/mithril/PickPill.js @@ -16,7 +16,7 @@ export default function PickPill() { m("input", { id: pill, checked: picked == pill, - type: RadioNodeList, + type: "radio", value: pill, onchange: handleChange, }), diff --git a/content/7-webapp-features/1-render-app/lit/app.js b/content/7-webapp-features/1-render-app/lit/app.js index 458b5a37..7cd33111 100644 --- a/content/7-webapp-features/1-render-app/lit/app.js +++ b/content/7-webapp-features/1-render-app/lit/app.js @@ -1,7 +1,7 @@ import { LitElement, html } from "lit"; import { customElement } from "lit/decorators.js"; -@customElement("x-app") +// @customElement("x-app") export class XApp extends LitElement { render() { return html`

Hello world

`; diff --git a/public/framework/mithril.svg b/public/framework/mithril.svg index a86fb2b7..682c91d3 100644 --- a/public/framework/mithril.svg +++ b/public/framework/mithril.svg @@ -1,2 +1,2 @@ - +