diff --git a/packages/svelte/src/lib/components/frame/examples/basic.svelte b/packages/svelte/src/lib/components/frame/examples/basic.svelte new file mode 100644 index 0000000000..914229c1bc --- /dev/null +++ b/packages/svelte/src/lib/components/frame/examples/basic.svelte @@ -0,0 +1,17 @@ + + + + {#snippet head()} + + {/snippet} +
+

Hello from inside the frame!

+

This content is rendered within our custom frame component using a Portal.

+
+ diff --git a/packages/svelte/src/lib/components/frame/examples/script.svelte b/packages/svelte/src/lib/components/frame/examples/script.svelte new file mode 100644 index 0000000000..3855af2911 --- /dev/null +++ b/packages/svelte/src/lib/components/frame/examples/script.svelte @@ -0,0 +1,23 @@ + + + { + const doc = frameRef?.contentDocument + if (!doc) return + const script = doc.createElement('script') + script.innerHTML = 'console.log("Hello from inside the frame!")' + doc.body.appendChild(script) + }} + style="border: 1px solid #ccc; width: 100%; height: var(--height)" +> +
+

Hello from inside the frame!

+

This content is rendered within our custom frame component using a Portal.

+
+ diff --git a/packages/svelte/src/lib/components/frame/examples/src-doc.svelte b/packages/svelte/src/lib/components/frame/examples/src-doc.svelte new file mode 100644 index 0000000000..fe3847216e --- /dev/null +++ b/packages/svelte/src/lib/components/frame/examples/src-doc.svelte @@ -0,0 +1,20 @@ + + + +

Hello from inside the frame!

+

This content is rendered within our custom frame component using a Portal.

+

The frame has custom initial content, including Font Awesome and Open Sans font.

+ diff --git a/packages/svelte/src/lib/components/frame/frame-content.svelte b/packages/svelte/src/lib/components/frame/frame-content.svelte new file mode 100644 index 0000000000..b42e236a81 --- /dev/null +++ b/packages/svelte/src/lib/components/frame/frame-content.svelte @@ -0,0 +1,19 @@ + + +{@render children()} diff --git a/packages/svelte/src/lib/components/frame/frame.stories.tsx b/packages/svelte/src/lib/components/frame/frame.stories.tsx new file mode 100644 index 0000000000..9ea142d5af --- /dev/null +++ b/packages/svelte/src/lib/components/frame/frame.stories.tsx @@ -0,0 +1,28 @@ +import type { Meta } from '@storybook/svelte' +import BasicExample from './examples/basic.svelte' +import ScriptExample from './examples/script.svelte' +import SrcDocExample from './examples/src-doc.svelte' + +const meta = { + title: 'Components / Frame', +} as Meta + +export default meta + +export const Basic = { + render: () => ({ + Component: BasicExample, + }), +} + +export const Script = { + render: () => ({ + Component: ScriptExample, + }), +} + +export const SrcDoc = { + render: () => ({ + Component: SrcDocExample, + }), +} diff --git a/packages/svelte/src/lib/components/frame/frame.svelte b/packages/svelte/src/lib/components/frame/frame.svelte new file mode 100644 index 0000000000..f3b225854b --- /dev/null +++ b/packages/svelte/src/lib/components/frame/frame.svelte @@ -0,0 +1,101 @@ + + + + + diff --git a/packages/svelte/src/lib/components/frame/index.ts b/packages/svelte/src/lib/components/frame/index.ts new file mode 100644 index 0000000000..1ba2d1e8f5 --- /dev/null +++ b/packages/svelte/src/lib/components/frame/index.ts @@ -0,0 +1,2 @@ +export { default as Frame } from './frame.svelte' +export type { FrameBaseProps, FrameProps } from './frame.svelte' diff --git a/packages/svelte/src/lib/components/index.ts b/packages/svelte/src/lib/components/index.ts index 616a4140eb..c895ee6aa4 100644 --- a/packages/svelte/src/lib/components/index.ts +++ b/packages/svelte/src/lib/components/index.ts @@ -1,6 +1,8 @@ export * from './avatar' export * from './factory' +export * from './frame' export * from './highlight' +export * from './portal' export * from './presence' export * from './qr-code' export * from './slider' diff --git a/packages/svelte/src/lib/components/portal/index.ts b/packages/svelte/src/lib/components/portal/index.ts new file mode 100644 index 0000000000..946627eaf8 --- /dev/null +++ b/packages/svelte/src/lib/components/portal/index.ts @@ -0,0 +1,2 @@ +export { default as Portal } from './portal.svelte' +export type { PortalProps } from './portal.svelte' diff --git a/packages/svelte/src/lib/components/portal/portal-consumer.svelte b/packages/svelte/src/lib/components/portal/portal-consumer.svelte new file mode 100644 index 0000000000..d4068b5cd4 --- /dev/null +++ b/packages/svelte/src/lib/components/portal/portal-consumer.svelte @@ -0,0 +1,9 @@ + + +{#if children} + {@render children()} +{/if} diff --git a/packages/svelte/src/lib/components/portal/portal.svelte b/packages/svelte/src/lib/components/portal/portal.svelte new file mode 100644 index 0000000000..1b2eaec14d --- /dev/null +++ b/packages/svelte/src/lib/components/portal/portal.svelte @@ -0,0 +1,25 @@ + + +