diff --git a/docs/parser/helpers.js b/docs/parser/helpers.js index 1c71356..802d06a 100644 --- a/docs/parser/helpers.js +++ b/docs/parser/helpers.js @@ -1,9 +1,9 @@ -module.exports.contentAsText = async function(doc, rootLevel) { +module.exports.contentAsText = async function(doc, rootLevel, includeCurrent = false) { const { level, next, line, head } = doc const linesAsArray = [] - - let contentDepth = -1 + if (includeCurrent) linesAsArray.push(line()) + let contentDepth = includeCurrent ? level() : -1 while(await next(rootLevel)) { if (contentDepth === -1 && !!line()) contentDepth = level() diff --git a/docs/parser/nodes/Button.js b/docs/parser/nodes/Button.js new file mode 100644 index 0000000..c7e0941 --- /dev/null +++ b/docs/parser/nodes/Button.js @@ -0,0 +1,23 @@ +const { contentAsText } = require('../helpers.js') + +module.exports = async function (doc, rootLevel) { + const { next, line, match, tail, level, head } = doc + + const node = { + type: head(), + variant: tail() || 'neutral', + class: '', + href: '', + text: '' + } + + while (await next(rootLevel)) { + if (match('class')) node.class = tail() + else if (match('href')) node.href = tail() + else { + node.text = await contentAsText(doc, rootLevel, true) + } + } + + return node +} diff --git a/docs/parser/nodes/index.js b/docs/parser/nodes/index.js index 6b0d086..d986170 100644 --- a/docs/parser/nodes/index.js +++ b/docs/parser/nodes/index.js @@ -1,7 +1,15 @@ const parseNode = require('./Node.js') -module.exports.Section = parseNode +module.exports.Section = async (doc, rootLevel) => { + const variant = doc.tail() + return { variant, ...(await parseNode(doc, rootLevel)) } +} + module.exports.Div = parseNode -module.exports.Logo = doc => ({ type: `Logo` }) +module.exports.Logo = doc => ({ + type: `Logo`, + variant: doc.tail() || 'light' +}) module.exports.Markdown = require('./Markdown.js') module.exports.CodeExample = require('./CodeExample.js') +module.exports.Button = require('./Button.js') diff --git a/docs/src/_includes/layout.njk b/docs/src/_includes/layout.njk index 523d100..6b47b0c 100644 --- a/docs/src/_includes/layout.njk +++ b/docs/src/_includes/layout.njk @@ -12,6 +12,7 @@ + {{ Node('Navbar') }} {% for child in children %} {{ Node(child.type, child) }} {% endfor %} diff --git a/docs/src/_includes/nodes/Button.njk b/docs/src/_includes/nodes/Button.njk new file mode 100644 index 0000000..a0f88cf --- /dev/null +++ b/docs/src/_includes/nodes/Button.njk @@ -0,0 +1,14 @@ +{% set commonClasses = "px-12 py-3 text-white rounded-md w-auto" %} +{% macro render(node) %} + + {{ node.text | safe }} + +{% endmacro %} diff --git a/docs/src/_includes/nodes/CodeExample.njk b/docs/src/_includes/nodes/CodeExample.njk index f7f047b..e051dad 100644 --- a/docs/src/_includes/nodes/CodeExample.njk +++ b/docs/src/_includes/nodes/CodeExample.njk @@ -26,7 +26,7 @@ set languageMeta = { {{ languageMeta[id].name }}
{{ code | highlight(id) | safe }}
diff --git a/docs/src/_includes/nodes/Logo.njk b/docs/src/_includes/nodes/Logo.njk index 392f957..ebf3900 100644 --- a/docs/src/_includes/nodes/Logo.njk +++ b/docs/src/_includes/nodes/Logo.njk @@ -1,2 +1,13 @@ {% macro render(node) %} + {% if node.variant != 'small' %} +
+ + Terrace +
+ {% else %} +
+ + Terrace +
+ {% endif %} {% endmacro %} diff --git a/docs/src/_includes/nodes/Markdown.njk b/docs/src/_includes/nodes/Markdown.njk index 22d68df..fba2c0e 100644 --- a/docs/src/_includes/nodes/Markdown.njk +++ b/docs/src/_includes/nodes/Markdown.njk @@ -1,5 +1,5 @@ {% macro render(node) %} -
+
{{ node.text | safe }}
{% endmacro %} diff --git a/docs/src/_includes/nodes/Navbar.njk b/docs/src/_includes/nodes/Navbar.njk new file mode 100644 index 0000000..2e5bb4f --- /dev/null +++ b/docs/src/_includes/nodes/Navbar.njk @@ -0,0 +1,21 @@ +{% from "./Node.njk" import Node %} + +{% macro render(node) %} + +{% endmacro %} diff --git a/docs/src/_includes/nodes/SearchBox.njk b/docs/src/_includes/nodes/SearchBox.njk new file mode 100644 index 0000000..527050d --- /dev/null +++ b/docs/src/_includes/nodes/SearchBox.njk @@ -0,0 +1,8 @@ +{% macro render(node) %} +
+ + + + +
+{% endmacro %} diff --git a/docs/src/_includes/nodes/Section.njk b/docs/src/_includes/nodes/Section.njk index 88cf34b..597781b 100644 --- a/docs/src/_includes/nodes/Section.njk +++ b/docs/src/_includes/nodes/Section.njk @@ -1,9 +1,17 @@ {% from "./Node.njk" import Node %} +{% set variants = { + light: "bg-gradient-to-t from-neutral-50/50 to-neutral-50", + dark: "bg-gradient-to-t from-neutral-900 to-neutral-800" +} +%} + {% macro render(node) %} -
- {% for child in node.children %} - {{ Node(child.type, child) }} - {% endfor %} +
+
+ {% for child in node.children %} + {{ Node(child.type, child) }} + {% endfor %} +
{% endmacro %} diff --git a/docs/src/index.tce b/docs/src/index.tce index 9e9af3b..5ad87b2 100644 --- a/docs/src/index.tce +++ b/docs/src/index.tce @@ -5,13 +5,10 @@ description Terrace gets out of your way to let you just write Section light - class flex gap-16 - + class pb-64 Div - class flex flex-column gap-16 - - Logo - + class flex flex-col gap-8 w-full items-start + Logo light Markdown A simple structured data syntax for - **Configuration** @@ -20,6 +17,9 @@ Section light Terrace gets out of your way to let you - **just write** + Button primary + href /docs/getting-started + Get Started CodeExample terrace diff --git a/docs/src/public/logo.png b/docs/src/public/logo.png new file mode 100644 index 0000000..bf7236a Binary files /dev/null and b/docs/src/public/logo.png differ diff --git a/docs/tailwind.config.js b/docs/tailwind.config.js index c90727d..b9c2898 100644 --- a/docs/tailwind.config.js +++ b/docs/tailwind.config.js @@ -44,7 +44,7 @@ module.exports = { '2xl': '1.563rem', '3xl': '1.953rem', '4xl': '2.441rem', - '5xl': '3.052rem', + '5xl': '3.25rem', }, extend: { fontFamily: {