Skip to content
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
39 changes: 30 additions & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,47 @@
<script setup lang="ts">
import { Icon } from "@iconify/vue";
import { useMediaQuery } from "@vueuse/core";
import { computed, ref, watch } from "vue";
import Header from "~/components/header/Header.vue";
import IoContainer from "~/components/IoContainer.vue";
import Sidebar from "~/components/sidebar/Sidebar.vue";
import { loadingOxc } from "~/composables/oxc";

const isDesktop = useMediaQuery("(min-width: 1024px)");
const settingsOpen = ref(isDesktop.value);
const mobileSettingsOpen = computed(() => settingsOpen.value && !isDesktop.value);
watch(isDesktop, (desktop) => {
settingsOpen.value = desktop;
});
</script>

<template>
<Suspense>
<div class="w-screen flex bg-background md:h-screen">
<Sidebar />
<div class="min-w-0 flex flex-1 flex-col">
<Header />
<IoContainer />
<div class="app-shell flex h-dvh w-full flex-col overflow-hidden bg-sidebar text-foreground">
<Header :settings-open="settingsOpen" @toggle-settings="settingsOpen = !settingsOpen" />
<div class="relative flex min-h-0 flex-1">
<button
v-if="mobileSettingsOpen"
class="absolute inset-0 z-20 bg-black/25 backdrop-blur-[2px]"
aria-label="Close configuration"
tabindex="-1"
@click="settingsOpen = false"
/>
<Sidebar :open="settingsOpen" :modal="!isDesktop" @close="settingsOpen = false" />
<IoContainer :inert="mobileSettingsOpen" />
</div>
</div>

<template #fallback>
<div class="h-screen w-screen flex flex-col items-center justify-center gap-4 text-2xl">
<Icon icon="ri:loader-2-line" class="animate-spin text-6xl" />
<span v-if="loadingOxc">Loading Oxc wasm...</span>
<span v-else>Loading resources...</span>
<div
class="flex h-dvh flex-col items-center justify-center gap-4 bg-background text-foreground"
>
<img src="/logo-without-border.svg" class="h-10 w-10" alt="Oxc" />
<div class="flex items-center gap-2 text-sm text-muted-foreground" role="status">
<Icon icon="ri:loader-2-line" class="animate-spin text-primary" />
<span v-if="loadingOxc">Loading Oxc wasm…</span>
<span v-else>Loading resources…</span>
</div>
</div>
</template>
</Suspense>
Expand Down
16 changes: 12 additions & 4 deletions src/components/IoContainer.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { Icon } from "@iconify/vue";
import { useMediaQuery } from "@vueuse/core";
import { computed } from "vue";
import { useOxc } from "~/composables/oxc";
Expand Down Expand Up @@ -27,11 +28,18 @@ function stringifyError(error: unknown) {
</script>

<template>
<main class="min-h-0 flex flex-1">
<Splitter :direction="splitterDirection" class="flex-1">
<main class="workspace min-h-0 min-w-0 flex flex-1" aria-label="Code workspace">
<Splitter :direction="splitterDirection" class="min-w-0 flex-1">
<SplitterPanel :default-size="50" :min-size="20" class="flex flex-col">
<div class="h-full min-w-0 flex flex-1 flex-col pt-2">
<div class="min-h-50vh flex-grow-2 flex-basis-none">
<div class="source-heading flex shrink-0 items-center justify-between gap-3 px-4">
<div class="flex min-w-0 items-center gap-2 text-xs font-medium">
<Icon icon="ri:code-s-slash-line" class="h-4 w-4 shrink-0 text-primary" />
<span class="truncate">test.{{ options.parser.extension }}</span>
</div>
<span class="text-xs text-muted-foreground">Source</span>
</div>
<div class="h-full min-h-0 min-w-0 flex flex-1 flex-col">
<div class="min-h-0 flex-1">
<InputEditor
:language="monacoLanguage"
:filename="`/test.${options.parser.extension}`"
Expand Down
8 changes: 6 additions & 2 deletions src/components/MonacoEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ watch(
function initMonaco() {
const editorOptions: monaco.editor.IStandaloneEditorConstructionOptions = {
minimap: { enabled: false },
fontSize: 14,
scrollBeyondLastLine: true,
fontSize: 13,
lineHeight: 23,
padding: { top: 16, bottom: 16 },
lineNumbersMinChars: 3,
scrollBeyondLastLine: false,
smoothScrolling: true,
fixedOverflowWidgets: true,
fontFamily: `ui-monospace, Menlo, Monaco, "Cascadia Code", "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro","Fira Mono", "Droid Sans Mono", "Courier New", monospace`,
...props.options,
Expand Down
31 changes: 26 additions & 5 deletions src/components/header/Header.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
<script setup lang="ts">
import { Icon } from "@iconify/vue";
import Logo from "../sidebar/Logo.vue";
import Media from "./Media.vue";
import Nav from "./Nav.vue";
import Switch from "./Switch.vue";

defineProps<{ settingsOpen: boolean }>();
defineEmits<{ "toggle-settings": [] }>();
</script>

<template>
<header class="h-16 w-full flex items-center justify-between border-b border-border px-8">
<Logo class="visible lg:invisible" />
<div class="hidden md:flex">
<Nav />
<Switch />
<header
class="app-header flex h-16 shrink-0 items-center justify-between gap-4 border-b border-border px-4 sm:px-6"
>
<div class="flex min-w-0 items-center gap-4">
<Logo />
<span class="h-5 w-px bg-border" aria-hidden="true" />
<span class="text-sm font-medium tracking-tight">Playground</span>
</div>
<div class="flex items-center gap-3">
<Nav class="hidden md:flex" />
<Media />
<Switch />
<button
class="flex h-8 w-8 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
:class="{ 'bg-accent text-primary': settingsOpen }"
aria-label="Toggle configuration"
title="Toggle configuration"
aria-controls="configuration-sidebar"
:aria-expanded="settingsOpen"
@click="$emit('toggle-settings')"
>
<Icon icon="ri:equalizer-2-line" class="h-4 w-4" />
</button>
</div>
</header>
</template>
12 changes: 5 additions & 7 deletions src/components/header/Media.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { Icon } from "@iconify/vue";
</script>

<template>
<div
class="hidden items-center before:ml-4 before:mr-2 before:h-6 before:w-px xl:flex before:bg-border before:content-['']"
>
<div class="header-media hidden items-center border-l border-border pl-3 xl:flex">
<ul class="flex items-center">
<li>
<a
Expand All @@ -17,7 +15,7 @@ import { Icon } from "@iconify/vue";
>
<Icon
icon="ri:twitter-x-fill"
class="h-5 w-5 text-foreground hover:text-primary transition-colors"
class="h-4 w-4 text-muted-foreground transition-colors hover:text-foreground"
/>
</a>
</li>
Expand All @@ -31,7 +29,7 @@ import { Icon } from "@iconify/vue";
>
<Icon
icon="ri:bluesky-fill"
class="h-5 w-5 text-foreground hover:text-primary transition-colors"
class="h-4 w-4 text-muted-foreground transition-colors hover:text-foreground"
/>
</a>
</li>
Expand All @@ -45,7 +43,7 @@ import { Icon } from "@iconify/vue";
>
<Icon
icon="ri:discord-fill"
class="h-5 w-5 text-foreground hover:text-primary transition-colors"
class="h-4 w-4 text-muted-foreground transition-colors hover:text-foreground"
/>
</a>
</li>
Expand All @@ -59,7 +57,7 @@ import { Icon } from "@iconify/vue";
>
<Icon
icon="ri:github-fill"
class="h-5 w-5 text-foreground hover:text-primary transition-colors"
class="h-4 w-4 text-muted-foreground transition-colors hover:text-foreground"
/>
</a>
</li>
Expand Down
23 changes: 14 additions & 9 deletions src/components/header/Nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import {
target="_blank"
rel="noopener"
>
<span class="text-sm text-foreground font-medium hover:text-primary"> Guide </span>
<span
class="text-xs text-muted-foreground font-medium transition-colors hover:text-foreground"
>
Guide
</span>
<Icon icon="ri:arrow-right-up-line" class="ml-1 h-3 w-3 text-muted-foreground" />
</a>
</NavigationMenuLink>
Expand All @@ -33,7 +37,10 @@ import {
target="_blank"
rel="noopener"
>
<span class="text-sm text-foreground font-medium hover:text-primary">Learn</span>
<span
class="text-xs text-muted-foreground font-medium transition-colors hover:text-foreground"
>Learn</span
>
<Icon icon="ri:arrow-right-up-line" class="ml-1 h-3 w-3 text-muted-foreground" />
</a>
</NavigationMenuLink>
Expand All @@ -44,16 +51,14 @@ import {
class="flex items-center px-3"
href="https://oxc.rs/docs/contribute/introduction.html"
>
<span class="text-sm text-foreground font-medium hover:text-primary"> Contribute </span>
<span
class="text-xs text-muted-foreground font-medium transition-colors hover:text-foreground"
>
Contribute
</span>
<div class="i-ri:arrow-right-up-line ml-1 h-3 w-3 text-muted-foreground" />
</NavigationMenuLink>
</NavigationMenuItem>

<NavigationMenuItem>
<NavigationMenuLink class="flex items-center px-3" href="#" active>
<span class="text-sm text-primary font-medium">Playground</span>
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
</template>
52 changes: 8 additions & 44 deletions src/components/header/Switch.vue
Original file line number Diff line number Diff line change
@@ -1,52 +1,16 @@
<script setup lang="ts">
import { Icon } from "@iconify/vue";
import {
SwitchRoot,
SwitchThumb,
useForwardPropsEmits,
type SwitchRootEmits,
type SwitchRootProps,
} from "radix-vue";
import { computed, type HTMLAttributes } from "vue";
import { dark } from "~/composables/state";
import { cn } from "~/utils/cn";

const props = defineProps<SwitchRootProps & { class?: HTMLAttributes["class"] }>();
const emits = defineEmits<SwitchRootEmits>();
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props;

return delegated;
});

const forwarded = useForwardPropsEmits(delegatedProps, emits);
</script>

<template>
<div
class="hidden items-center before:ml-2 before:mr-4 before:h-6 before:w-px xl:flex before:bg-border before:content-['']"
<button
type="button"
class="theme-toggle flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border bg-background text-muted-foreground transition-colors hover:border-primary/40 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
:aria-label="dark ? 'Switch to light theme' : 'Switch to dark theme'"
:title="dark ? 'Switch to light theme' : 'Switch to dark theme'"
@click="dark = !dark"
>
<SwitchRoot
v-bind="forwarded"
v-model:checked="dark"
role="switch"
:class="
cn(
'peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full bg-muted border border-muted hover:border-primary transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50',
props.class,
)
"
>
<SwitchThumb
:class="
cn(
'pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0',
'flex items-center justify-center',
)
"
>
<Icon :icon="dark ? 'ri:moon-line' : 'ri:sun-line'" class="scale-[0.7]" />
</SwitchThumb>
</SwitchRoot>
</div>
<Icon :key="String(dark)" :icon="dark ? 'ri:moon-line' : 'ri:sun-line'" class="h-4 w-4" />
</button>
</template>
2 changes: 1 addition & 1 deletion src/components/output/ExecutionPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ watch([() => props.baselineCode, () => props.baselineSourceMap, () => props.base
<template>
<section class="h-full min-h-0 flex flex-col" aria-label="Output execution">
<div
class="flex shrink-0 flex-wrap items-center gap-2 border-b px-2 py-1.5"
class="flex min-h-11 shrink-0 flex-wrap items-center gap-1 border-b border-border px-3 py-1.5"
role="group"
aria-label="Output actions"
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/output/OutputPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ onMounted(updateRunOptions);
>
<TabsList
as="nav"
class="relative h-auto flex flex-shrink-0 justify-start gap-0 overflow-auto rounded-none px-2"
class="output-tabs relative flex h-[45px] shrink-0 items-stretch justify-start gap-0 overflow-x-auto rounded-none p-0"
>
<TabsTrigger value="codegen"> Printed </TabsTrigger>
<TabsTrigger value="ast"> ESTree AST </TabsTrigger>
Expand Down
6 changes: 5 additions & 1 deletion src/components/output/OutputPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ function escapeHtml(text: string): string {
</script>

<template>
<CopyContainer :value="code || ''" :hide-copy="hideCopy" class="min-w-0 w-full flex">
<CopyContainer
:value="code || ''"
:hide-copy="hideCopy"
class="output-preview min-w-0 w-full flex"
>
<div class="flex-1 overflow-auto text-sm leading-relaxed">
<!-- Loading skeleton -->
<div v-if="showLoading && !highlightedCode" class="animate-pulse">
Expand Down
35 changes: 11 additions & 24 deletions src/components/sidebar/Codegen.vue
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
<script setup lang="ts">
import Checkbox from "~/components/ui/Checkbox.vue";
import { useOxc } from "~/composables/oxc";
import OptionsDisclosure from "./OptionsDisclosure.vue";

const { options } = await useOxc();
</script>

<template>
<section class="flex flex-col gap-3" aria-labelledby="codegen-heading">
<h2 id="codegen-heading" class="text-base font-medium">Codegen</h2>

<div class="flex flex-col gap-2" role="group" aria-label="Codegen options">
<Checkbox v-model="options.codegen.normal" label="comment" label-class="text-xs font-mono" />

<Checkbox
v-model="options.codegen.jsdoc"
label="jsdoc comment"
label-class="text-xs font-mono"
/>

<Checkbox
v-model="options.codegen.annotation"
label="annotation comment"
label-class="text-xs font-mono"
/>

<Checkbox
v-model="options.codegen.legal"
label="legal comment"
label-class="text-xs font-mono"
/>
</div>
<section class="settings-section" aria-labelledby="codegen-heading">
<h2 id="codegen-heading">Codegen</h2>
<OptionsDisclosure label="Preserve comments">
<div class="flex flex-col gap-1" role="group" aria-label="Codegen options">
<Checkbox v-model="options.codegen.normal" label="Standard comments" title="normal" />
<Checkbox v-model="options.codegen.jsdoc" label="JSDoc comments" title="jsdoc" />
<Checkbox v-model="options.codegen.annotation" label="Annotations" title="annotation" />
<Checkbox v-model="options.codegen.legal" label="Legal comments" title="legal" />
</div>
</OptionsDisclosure>
</section>
</template>
Loading
Loading