Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Enhance WASM landing #206

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/api/$$.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { checkRedirects } from '../lib/marketing-redirects.mjs'

async function catchAll() {
async function catchAll () {
return {
statusCode: 302,
location: '/404',
}
}

export const get = [checkRedirects, catchAll]
export const get = [ checkRedirects, catchAll ]
2 changes: 1 addition & 1 deletion app/api/cta/$event.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import QRCode from 'qrcode'
import data from '@begin/data'

export async function get(req) {
export async function get (req) {
const { event } = req.pathParameters
const dataUrl = await QRCode.toDataURL(`https://enhance.dev/cta/${event}`)
const gacode =
Expand Down
2 changes: 1 addition & 1 deletion app/api/cta/views.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import data from '@begin/data'

export async function get() {
export async function get () {
let views = await data.get({
table: 'views',
key: 'cta',
Expand Down
2 changes: 1 addition & 1 deletion app/api/discord.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export async function get() {
export async function get () {
return {
statusCode: 302,
location: 'https://discord.gg/J8bUSfKs8W',
Expand Down
2 changes: 1 addition & 1 deletion app/api/docs.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export async function get() {
export async function get () {
return {
statusCode: 301,
location: '/docs/',
Expand Down
13 changes: 7 additions & 6 deletions app/api/docs/$$.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ const arcdown = new Arcdown({
markdownItToc: {
containerClass: 'toc mbe2 mis-2 leading2',
listType: 'ul',
level: [1, 2, 3],
level: [ 1, 2, 3 ],
},
},
plugins: [arcStaticImg],
plugins: [ arcStaticImg ],
hljs: {
sublanguages: { javascript: ['xml', 'css'] },
plugins: [new HljsLineWrapper({ className: 'code-line' })],
sublanguages: { javascript: [ 'xml', 'css' ] },
plugins: [ new HljsLineWrapper({ className: 'code-line' }) ],
},
})

/** @type {import('@enhance/types').EnhanceApiFn} */
export async function get(request) {
export async function get (request) {
const { path: activePath } = request
let docPath = activePath.replace(/^\/?docs\//, '') || 'index'

Expand Down Expand Up @@ -61,7 +61,8 @@ export async function get(request) {
let docMarkdown
try {
docMarkdown = readFileSync(docURL.pathname, 'utf-8')
} catch (_err) {
}
catch (_err) {
let searchTerm = null
if (!docPath.endsWith('/index')) {
const docPathParts = docPath.split('/')
Expand Down
2 changes: 1 addition & 1 deletion app/api/email/interest/add.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import data from '@begin/data'

/** @type {import('@enhance/types').EnhanceApiFn} */
export async function post(req) {
export async function post (req) {
const email = req.body.email
const timestamp = new Date(Date.now()).toISOString()
await data.set({ table: 'email', email, timestamp })
Expand Down
2 changes: 1 addition & 1 deletion app/api/index.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import navDataLoader from '../docs/nav-data.mjs'

/** @type {import('@enhance/types').EnhanceApiFn} */
export async function get({ query }) {
export async function get ({ query }) {
const { thanks } = query

const cacheControl =
Expand Down
23 changes: 23 additions & 0 deletions app/api/wasm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import navDataLoader from '../docs/nav-data.mjs'

/** @type {import('@enhance/types').EnhanceApiFn} */
export async function get ({ query }) {
const { thanks } = query

const cacheControl =
process.env.ARC_ENV === 'production'
? 'max-age=86400'
: 'no-cache, no-store, must-revalidate, max-age=0, s-maxage=0'

const navData = navDataLoader('docs', '/wasm')

return {
headers: {
'cache-control': cacheControl,
},
json: {
thanks,
navData,
},
}
}
2 changes: 1 addition & 1 deletion app/api/why-enhance.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import navDataLoader from '../docs/nav-data.mjs'

export async function get() {
export async function get () {
const navData = navDataLoader('docs', '/why-enhance')

const cacheControl =
Expand Down
7 changes: 4 additions & 3 deletions app/docs/hljs-line-wrapper.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable fp/no-class */

export default class {
constructor(options) {
constructor (options) {
this.className = options.className
}

'after:highlight'(result) {
'after:highlight' (result) {
const tokens = []

const safelyTagged = result.value.replace(
Expand All @@ -17,7 +17,8 @@ export default class {

if (match === '</span>') {
tokens.pop()
} else {
}
else {
tokens.push(match)
}

Expand Down
19 changes: 10 additions & 9 deletions app/docs/nav-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const data = [
path: '/docs/routing/api-routes/',
label: 'API Routes',
hasChildren: true,
items: ['middleware', 'tutorial'],
items: [ 'middleware', 'tutorial' ],
},
],
},
Expand All @@ -76,7 +76,7 @@ export const data = [
path: '/docs/elements/html/',
label: 'HTML',
hasChildren: true,
items: ['slots'],
items: [ 'slots' ],
},
{
slug: 'state',
Expand Down Expand Up @@ -114,15 +114,15 @@ export const data = [
slug: 'alternatives',
path: '/docs/enhance-styles/alternatives/',
hasChildren: true,
items: ['tailwind', 'sass'],
items: [ 'tailwind', 'sass' ],
},
],
},
{
type: TYPE.category,
label: 'Enhance UI',
slug: 'enhance-ui',
items: [{ slug: 'image', label: 'Image (beta)' }],
items: [ { slug: 'image', label: 'Image (beta)' } ],
},
{
type: TYPE.category,
Expand All @@ -143,7 +143,7 @@ export const data = [
slug: 'testing',
path: '/docs/patterns/testing/',
hasChildren: true,
items: [{ slug: 'webdriverio', label: 'WebdriverIO' }],
items: [ { slug: 'webdriverio', label: 'WebdriverIO' } ],
},
'architect-migration',
],
Expand Down Expand Up @@ -215,13 +215,13 @@ export const other = {
},
}

export function unslug(string) {
export function unslug (string) {
return string
.replace(/-/g, ' ')
.replace(/(^\w{1})|(\s+\w{1})/g, (l) => l.toUpperCase())
}

function parseItems(items, root, activePath) {
function parseItems (items, root, activePath) {
const parsedItems = items.map((item) => {
if (typeof item === 'string') {
// create full item from shorthand item
Expand All @@ -231,7 +231,8 @@ function parseItems(items, root, activePath) {
path: `/${root}/${item}`,
label: unslug(item),
}
} else {
}
else {
if (!item.type) {
item.type = 'doc'
}
Expand All @@ -252,7 +253,7 @@ function parseItems(items, root, activePath) {
return item
})

function testForActive(i) {
function testForActive (i) {
return i.active || i.items?.some(testForActive)
}

Expand Down
26 changes: 13 additions & 13 deletions app/elements/app-wrap.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function AppWrap({ html, state = {} }) {
export default function AppWrap ({ html, state = {} }) {
// const modals = Array(Math.parseInt(state.attrs?.quantity || 1)).fill(0)
// space or comma separated values for modal names "one,two three"
const modals = state?.attrs?.modals?.split(/[\s*,?\s*]/) || []
Expand Down Expand Up @@ -60,8 +60,8 @@ export default function AppWrap({ html, state = {} }) {


${modals
.map(
(modalName) => /* css*/ `
.map(
(modalName) => /* css*/ `
/* Hide main content when modal opens. Hidden from screen readers and traps focus */
:host
> input[name='group-click-${modalName}']:not(:checked)
Expand All @@ -81,12 +81,12 @@ export default function AppWrap({ html, state = {} }) {
display: block;
}
`
)
.join('\n')}
)
.join('\n')}
</style>
${modals
.map(
(modalName) => /* html*/ `
.map(
(modalName) => /* html*/ `
<input
tabindex="-1"
aria-hidden="true"
Expand All @@ -102,13 +102,13 @@ export default function AppWrap({ html, state = {} }) {
name="group-key-${modalName}"
type="radio" />
`
)
.join('')}
)
.join('')}

<slot name="main"></slot>
${modals
.map(
(modalName) => /* html*/ `
.map(
(modalName) => /* html*/ `
<div class="modal-container" id="modal-container-${modalName}">
<button
class="overlay"
Expand All @@ -131,8 +131,8 @@ export default function AppWrap({ html, state = {} }) {
</div>
<form id="modal-form-${modalName}"></form>
`
)
.join('')}
)
.join('')}
<script>
// TODO: set aria-hidden on main
// TODO: change main to inert and not display none when dialog open
Expand Down
2 changes: 1 addition & 1 deletion app/elements/axol-wink.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function AxolWink({ html }) {
export default function AxolWink ({ html }) {
return html`
<style>
:host {
Expand Down
2 changes: 1 addition & 1 deletion app/elements/begin-logo.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function BeginLogo({ html }) {
export default function BeginLogo ({ html }) {
return html`
<svg
width="16"
Expand Down
2 changes: 1 addition & 1 deletion app/elements/cherub-head.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function CherubHead({ html }) {
export default function CherubHead ({ html }) {
return html`
<style>
:host {
Expand Down
2 changes: 1 addition & 1 deletion app/elements/cherub-mascot.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function CherubMascot({ html }) {
export default function CherubMascot ({ html }) {
return html`
<style>
:host {
Expand Down
2 changes: 1 addition & 1 deletion app/elements/cta-qrcode.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function CtaQrcode({ html, state }) {
export default function CtaQrcode ({ html, state }) {
const { store } = state
const { dataUrl } = store
return html`<img src="${dataUrl}" />`
Expand Down
10 changes: 5 additions & 5 deletions app/elements/doc/callout.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const LEVELS = ['note', 'tip', 'info', 'caution', 'danger']
const MARKS = ['📝', '💡', 'ℹ️', '⚠️', '🔥']
const LEVELS = [ 'note', 'tip', 'info', 'caution', 'danger' ]
const MARKS = [ '📝', '💡', 'ℹ️', '⚠️', '🔥' ]
const generatedStyles = LEVELS.map(
(level) => `
callout-container.callout-${level} {
background-color: var(--callout-${level})
}`
).join('\n')

export default function Callout({ html, state }) {
export default function Callout ({ html, state }) {
const { attrs } = state
const thin = typeof attrs.thin !== 'undefined'
const level = attrs.level || 'note'
Expand Down Expand Up @@ -56,8 +56,8 @@ export default function Callout({ html, state }) {
align-items-center
">
${mark?.length > 0 && mark !== 'none'
? `<callout-mark class="text2 align-self-start">${mark}</callout-mark>`
: ''}
? `<callout-mark class="text2 align-self-start">${mark}</callout-mark>`
: ''}
<div>
<slot></slot>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/elements/doc/code-mirror.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import arc from '@architect/functions'

export default function DocCodeMirror({ html /* state */ }) {
export default function DocCodeMirror ({ html /* state */ }) {
// const { attrs = {} } = state
// let {
// lang = 'javascript',
Expand Down
2 changes: 1 addition & 1 deletion app/elements/doc/code.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import arc from '@architect/functions'
const moduleUrl = arc.static('js/elements/doc-code.mjs')

export default function DocCode({ html }) {
export default function DocCode ({ html }) {
return html`
<style>
:host {
Expand Down
2 changes: 1 addition & 1 deletion app/elements/doc/content.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function DocContent({ html }) {
export default function DocContent ({ html }) {
return html`
<style>
:host > * {
Expand Down
2 changes: 1 addition & 1 deletion app/elements/doc/link-callout.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function LinkCallout({ html, state }) {
export default function LinkCallout ({ html, state }) {
const { attrs } = state
const link = attrs.link || '/'
const mark = attrs.mark || 'none'
Expand Down
2 changes: 1 addition & 1 deletion app/elements/doc/video.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import arc from '@architect/functions'

export default function DocVideo({ html, state }) {
export default function DocVideo ({ html, state }) {
const { attrs } = state
const playbackId = attrs['playback-id']
const name = attrs.name || 'Enhance Video'
Expand Down
Loading