Lightly parse state.data
; should end up with:
-
<Any>
-
<Blockquote>
-
<Preformatted>
-
<AnyList>
-
parseAny
-
<Header>
-
<Paragraph>
-
-
// CodexRenderer can render classes (default), attributes, | |
// or components. | |
<CodexRenderer | |
render={{ | |
h1: "font-semibold text-3xl leading-tight text-black antialiased", | |
h2: "font-semibold text-2xl leading-tight text-black antialiased", | |
h3: "font-semibold text-xl leading-tight text-black antialiased", | |
h4: "font-semibold text-xl leading-tight text-black antialiased", | |
h5: "font-semibold text-xl leading-tight text-black antialiased", | |
h6: "font-semibold text-xl leading-tight text-black antialiased", |
This spec explores what a structured Tailwind CSS resolver could work based on informed experience.
A couple months ago, I authored something I called stylex.js
— the idea was to provide React a parser/resolver for inline styles using a declarative API. Eventually, I stopped working on this project for favor of Tailwind CSS. Despite enjoying Tailwind CSS, I have incredibly fond memories of working in stylex.js
because it afforded me the ability to be declarative and conditional with design.
Here is in essence how stylex.js
worked. Given the following code:
.
import React from "react" | |
import ReactDOM from "react-dom" | |
// https://stackoverflow.com/a/33292942 | |
function timeout(timeoutMs) { | |
return new Promise(resolve => setTimeout(resolve, timeoutMs)) | |
} | |
;(async () => { | |
const root = document.getElementById("root") |
// import App from "EditorApp/EditorApp" | |
// import React from "react" | |
// import ReactDOM from "react-dom" | |
// | |
// import "debug.css" | |
// import "stylesheets/prism/custom.css" | |
// import "stylesheets/tailwind/color-vars.css" | |
// import "stylesheets/tailwind/em-context.css" | |
// import "stylesheets/tailwind/tailwind.generated.css" | |
// |
import areEqualJSON from "lib/areEqualJSON" | |
import omitKey from "lib/omitKey" | |
import React from "react" | |
import toArray from "lib/toArray" | |
import { typeMap } from "./typeMaps" | |
// Converts intermediary elements to React elements. | |
function toReactElements(elements) { | |
const reactElements = [] | |
for (const each of toArray(elements)) { |
import useMethods from "use-methods" | |
// NOTE: The following imports are intentionally unsorted. | |
import { | |
lock, | |
unlock, | |
} from "./lock" | |
import { | |
focus, |
.prose { | |
color: #4a5568; | |
max-width: 65ch; | |
} | |
.prose [class~=lead] { | |
color: #4a5568; | |
font-size: 1.25em; | |
line-height: 1.6; | |
margin-top: 1.2em; | |
margin-bottom: 1.2em; |
Hello, world!