Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
B-i-t-K committed Dec 20, 2024
1 parent a16349d commit 9e16bf0
Show file tree
Hide file tree
Showing 91 changed files with 3,215 additions and 1,354 deletions.
26 changes: 24 additions & 2 deletions app/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@
import "./assets/style.css";
import "highlight.js/styles/github-dark-dimmed.min.css"
</script>
<style lang="scss"></style>
useSeoMeta({
description: 'Explore how HTML is parsed by the browser and common libraries.',
ogTitle: 'Dom-Explorer',
ogDescription: 'Explore how HTML is parsed by the browser and common libraries.',
ogImage: '/icon.svg',
twitterTitle: 'Dom-Explorer',
twitterDescription: 'Explore how HTML is parsed by the browser and common libraries.',
twitterImage: '/icon.svg',
twitterCard: 'summary'
})
useHead({
htmlAttrs: {
lang: 'en'
},
link: [
{
rel: 'icon',
type: 'image/png',
href: '/icon.svg'
}
]
})
</script>
6 changes: 3 additions & 3 deletions app/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
@tailwind components;
@tailwind utilities;


@layer base {
:root {
/* Name: custom color palette
Author: Ilias Ism
URL: https://gradient.page */

/* CSS: .bg-gradient { background: var(--gradient) } */
--gradient: linear-gradient(to top left,#000C40,#607D8B);
--gradient: linear-gradient(to top left, #000c40, #607d8b);
--background: 243 100% 98.26%;
--foreground: 243 10% 0.52%;

Expand Down Expand Up @@ -41,7 +42,6 @@

--radius: 0.5rem;


/* Name: custom color palette
Author: Ilias Ism
URL: https://gradient.page */
Expand Down Expand Up @@ -87,5 +87,5 @@
}

html {
@apply bg-black text-foreground;
@apply text-foreground bg-black;
}
24 changes: 21 additions & 3 deletions app/components/CodeEditor.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="group relative grid resize-y grid-cols-1 grid-rows-1">
<div class="group/editor relative grid resize-y grid-cols-1 grid-rows-1">
<div
el="output"
class="col-start-1 row-start-1 max-w-full whitespace-pre-wrap break-all rounded-md border bg-card p-2 font-mono text-card-foreground"
Expand All @@ -12,11 +12,13 @@
spellcheck="false"
:placeholder="placeholder"
:readonly="readOnly"
:disabled="readOnly"
rows="1"
class="col-start-1 row-start-1 h-full resize-none whitespace-pre-wrap break-all rounded-md border-none bg-transparent p-2 font-mono text-transparent caret-black/80 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring dark:caret-white/80"
class="col-start-1 row-start-1 h-full resize-none whitespace-pre-wrap break-all rounded-md border border-transparent bg-transparent p-2 font-mono text-transparent caret-black/80 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring dark:caret-white/80"
@keydown="onKeyDown"
/>
<div
class="absolute right-0 top-0 rounded-bl-md rounded-tr-md bg-muted px-1.5 pt-0.5 font-mono text-xs text-muted-foreground group-focus-within:bg-ring group-focus-within:text-white"
class="absolute right-0 top-0 rounded-bl-md rounded-tr-md bg-muted px-1.5 pt-0.5 font-mono text-xs text-muted-foreground group-focus-within/editor:bg-ring group-focus-within/editor:text-white"
>
{{ shortLang }}
</div>
Expand Down Expand Up @@ -70,4 +72,20 @@ const shortLang = computed(() => {
}
return props.lang;
});
function onKeyDown(e: KeyboardEvent) {
if (e.key === "Tab") {
e.preventDefault();
const el = textarea.value!;
const start = el.selectionStart;
const end = el.selectionEnd;
model.value =
model.value.substring(0, start) + "\t" + model.value.substring(end);
nextTick(() => {
el.selectionStart = el.selectionEnd = start + 1;
});
}
}
</script>
33 changes: 24 additions & 9 deletions app/components/CopyButton.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
<template>
<Tooltip :label="label">
<slot :copy="copy">
<Button size="icon" class="size-8">
<Icon name="copy" class="size-6" @click="copy" />
</Button>
</slot>
</Tooltip>
<Button :tooltip="_tooltip" :icon="_icon" :label="_label" @click="copy" />
</template>

<script lang="ts" setup>
import type { IconName } from "./ui/icon";
const props = defineProps<{
value: string;
noTooltip?: boolean;
tooltip?: string;
icon?: IconName;
label?: string;
}>();
const label = refAutoReset("Copy", 1000);
const copied = refAutoReset(false, 1000);
function copy() {
label.value = "Copied!";
copied.value = true;
navigator.clipboard.writeText(props.value);
}
const _tooltip = computed(() => {
if (!props.tooltip) return undefined;
return copied.value ? "Copied!" : props.tooltip;
});
const _label = computed(() => {
if (!props.label) return undefined;
return copied.value ? "Copied" : props.label;
});
const _icon = computed(() => {
if (!props.icon) return undefined;
return copied.value ? "check" : props.icon;
});
</script>
31 changes: 11 additions & 20 deletions app/components/DomExplorer/DomExplorerFrame.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
autofocus
:copy-code="false"
/>
<Pipeline v-if="pipeline" :input="state.input ?? ''" :pipeline="pipeline" />
<Pipelines :state="state" :read-only="settings.readonly" is-embed />
<a
v-if="isEmbed"
:href="href"
target="_blank"
class="absolute bottom-0 right-0 flex items-center rounded-tl border-l border-t border-[#00dc8266] bg-gray-900 px-2 text-[0.7rem] tracking-wide group-hover:pointer-events-none"
class="fixed bottom-0 right-0 z-[100] flex items-center rounded-tl border-l border-t border-[#00dc8266] bg-gray-900 px-2 text-[0.7rem] tracking-wide"
>
<DomExplorerIcon class="size-4" />
</a>
Expand All @@ -27,28 +28,18 @@
<script setup lang="ts">
import type { DomExplorerState } from "~/types";
definePageMeta({
layout: "empty",
});
const props = defineProps<{
defineProps<{
state: DomExplorerState;
filter?: string;
isEmbed?: boolean;
}>();
const pipeline = computed(() => {
if (props.filter) {
return props.state.pipelines.find((p) => p.id === props.filter);
}
return props.state.pipelines.at(0);
});
const settings = useDomExplorerSettings();
const route = useRoute();
const href = computed(() => {
const url = new URL("/Dom-Explorer/dom-explorer", window.location.origin);
url.hash = window.location.hash;
return url.href;
return resolveRemoteLink({
name: "index",
query: route.query,
hash: route.hash,
});
});
</script>
164 changes: 164 additions & 0 deletions app/components/DomExplorer/EmbedSettingsDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<template>
<DualSheet
title="Embed Options"
description="Embed one or more pipeline into your website."
>
<template #trigger>
<slot />
</template>
<template #center>
<Card class="relative max-w-full resize overflow-auto rounded-md">
<div class="rounded-t-md bg-secondary p-2">
<CardTitle class="relative flex justify-between gap-2">
Preview
<div
class="absolute -bottom-1 right-0 font-mono text-xs text-muted-foreground"
>
{{ Math.ceil(size.width.value) }}x{{
Math.ceil(size.height.value)
}}
</div>
</CardTitle>
</div>
<CardContent ref="frameContent" class="group p-0">
<DomExplorerFrame :state="_state" />
</CardContent>
</Card>
</template>
<template #side>
<div
class="grid grid-flow-row auto-rows-[minmax(32px,auto)] grid-cols-[auto_1fr] gap-x-8"
>
<Label class="content-center"> Input </Label>
<VisibilitySelect v-model="settings.input" />
<Label class="content-center"> Title Bar </Label>
<VisibilitySelect v-model="settings.titleBar" />
<Label
class="group col-span-full grid cursor-pointer grid-cols-[subgrid] content-center items-center"
>
Readonly
<Checkbox
id="readonly-check"
v-model="settings.readonly"
class="outline outline-1 outline-transparent transition-all group-hover:outline-blue-400"
/>
</Label>
<h2 class="col-span-full pb-2 pt-4 text-lg font-light">
Pipes Options
</h2>
<Label
class="group col-span-full grid cursor-pointer grid-cols-[subgrid] content-center items-center"
>
Title bar
<Checkbox
id="readonly-check"
v-model="settings.pipe.titleBar"
class="outline outline-1 outline-transparent transition-all group-hover:outline-blue-400"
/>
</Label>
<Label
class="group col-span-full grid cursor-pointer grid-cols-[subgrid] content-center items-center"
>
Settings button
<Checkbox
id="readonly-check"
v-model="settings.pipe.settings"
class="outline outline-1 outline-transparent transition-all group-hover:outline-blue-400"
/>
</Label>

<Label
class="group col-span-full grid cursor-pointer grid-cols-[subgrid] content-center items-center"
>
Render button
<Checkbox
id="readonly-check"
v-model="settings.pipe.render"
class="outline outline-1 outline-transparent transition-all group-hover:outline-blue-400"
/>
</Label>

<Label
class="group col-span-full grid cursor-pointer grid-cols-[subgrid] content-center items-center"
>
Skip button
<Checkbox
id="readonly-check"
v-model="settings.pipe.skip"
class="outline outline-1 outline-transparent transition-all group-hover:outline-blue-400"
/>
</Label>
</div>

<div class="flex flex-col gap-3 pb-4 pt-8">
<h2 class="col-span-full pb-2 pt-4 text-lg font-light">Code</h2>
<Textarea
:model-value="code"
spellcheck="false"
class="min-h-24 min-w-0 overflow-auto break-all font-mono"
/>
<div class="flex justify-between gap-4 pt-2">
<NuxtLink :to="url" target="_blank">
<Button label="Open in new tab" icon="externalLink" />
</NuxtLink>
<CopyButton :value="code" icon="copy" no-tooltip label="Copy code" />
</div>
</div>
</template>
</DualSheet>
</template>

<script lang="ts" setup>
import type { DomExplorerState } from "~/types";
const props = defineProps<{
state: DomExplorerState;
}>();
const _state = ref(cloneState(props.state));
watch(
() => props.state,
(state) => {
_state.value = cloneState(state);
},
);
const frameContent = ref();
const size = useElementBounding(frameContent);
const settings = createDomExplorerSettings({
input: "editable",
titleBar: "readonly",
readonly: true,
pipe: {
titleBar: true,
settings: true,
render: true,
skip: true,
},
});
const url = computed(() => {
return resolveRemoteLink({
name: "frame",
hash: "#" + b64EncodeUnicode(JSON.stringify(_state.value)),
query: {
input: settings.input,
titleBar: settings.titleBar,
readonly: settings.readonly ? "true" : "false",
"pipe[titleBar]": settings.pipe.titleBar ? "true" : "false",
"pipe[settings]": settings.pipe.settings ? "true" : "false",
"pipe[render]": settings.pipe.render ? "true" : "false",
"pipe[skip]": settings.pipe.skip ? "true" : "false",
},
});
});
const code = computed(() => {
const iframe = document.createElement("iframe");
iframe.sandbox.add("allow-scripts", "allow-modals", "allow-popups");
iframe.src = url.value;
return iframe.outerHTML;
});
</script>
Loading

0 comments on commit 9e16bf0

Please sign in to comment.