Skip to content

Commit

Permalink
refactor: format the code
Browse files Browse the repository at this point in the history
Signed-off-by: chankruze <[email protected]>
  • Loading branch information
chankruze committed Oct 10, 2024
1 parent 3d00678 commit eb2a91c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/www/src/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
declare namespace JSX {
interface IntrinsicElements {
"sp-split-view": React.DetailedHTMLProps<
'sp-split-view': React.DetailedHTMLProps<
React.HTMLAttributes<HTMLElement>,
HTMLElement
>;
Expand Down
30 changes: 15 additions & 15 deletions packages/www/src/web-components/play-ground.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import "@spectrum-web-components/split-view/sp-split-view.js";
import type { WebContext } from "brisa";
import '@spectrum-web-components/split-view/sp-split-view.js';
import type { WebContext } from 'brisa';

export default async function PlayGround(
{ defaultValue }: { defaultValue: string },
{ state, css, cleanup, onMount, self }: WebContext,
) {
const code = state<string>("");
const preview: HTMLIFrameElement = self.querySelector("#preview-iframe")!;
const activeTab = state<string>("tab-wc");
const code = state<string>('');
const preview: HTMLIFrameElement = self.querySelector('#preview-iframe')!;
const activeTab = state<string>('tab-wc');

function onReceiveCompiledCode(e: MessageEvent) {
if (e.data.source !== "brisa-playground-preview") return;
if (e.data.source !== 'brisa-playground-preview') return;
if (e.data.ready) sendDefaultCode();
if (typeof e.data.code === "string") {
if (typeof e.data.code === 'string') {
code.value = e.data.code;
}
}
Expand All @@ -22,11 +22,11 @@ export default async function PlayGround(
}

onMount(() => {
window.addEventListener("message", onReceiveCompiledCode);
window.addEventListener('message', onReceiveCompiledCode);
});

cleanup(() => {
window.removeEventListener("message", onReceiveCompiledCode);
window.removeEventListener('message', onReceiveCompiledCode);
});

css`
Expand Down Expand Up @@ -125,8 +125,8 @@ export default async function PlayGround(
role="tab"
title="Web Component"
aria-label="Web Component"
aria-selected={activeTab.value === "tab-wc"}
onClick={() => (activeTab.value = "tab-wc")}
aria-selected={activeTab.value === 'tab-wc'}
onClick={() => (activeTab.value = 'tab-wc')}
>
Web Component
</button>
Expand All @@ -136,23 +136,23 @@ export default async function PlayGround(
role="tab"
title="Compiled Code"
aria-label="Compiled Code"
aria-selected={activeTab.value === "tab-compiled"}
onClick={() => (activeTab.value = "tab-compiled")}
aria-selected={activeTab.value === 'tab-compiled'}
onClick={() => (activeTab.value = 'tab-compiled')}
>
Compiled Code
</button>
</div>

<div
id="tab-wc"
class={`tab-content ${activeTab.value === "tab-wc" ? "active" : ""}`}
class={`tab-content ${activeTab.value === 'tab-wc' ? 'active' : ''}`}
>
<slot name="preview-iframe" />
</div>

<div
id="tab-compiled"
class={`tab-content ${activeTab.value === "tab-compiled" ? "active" : ""}`}
class={`tab-content ${activeTab.value === 'tab-compiled' ? 'active' : ''}`}
>
<textarea disabled>{code.value}</textarea>
</div>
Expand Down

0 comments on commit eb2a91c

Please sign in to comment.