From 10c461f9b862ed1bfe98b98a6e5adaac702bb734 Mon Sep 17 00:00:00 2001 From: nidhal-labidi Date: Wed, 12 Mar 2025 13:19:22 +0100 Subject: [PATCH] feat: use FlottformTextInput classes to show an example of bidirectional text messaging Signed-off-by: nidhal-labidi --- servers/demo/src/api.ts | 4 + servers/demo/src/routes/+page.svelte | 5 + .../[endpointId]/+page.svelte | 143 ++++++++++++++ .../routes/flottform-messaging/+page.svelte | 186 ++++++++++++++++++ 4 files changed, 338 insertions(+) create mode 100644 servers/demo/src/routes/flottform-messaging-client/[endpointId]/+page.svelte create mode 100644 servers/demo/src/routes/flottform-messaging/+page.svelte diff --git a/servers/demo/src/api.ts b/servers/demo/src/api.ts index 526a36b..d444d50 100644 --- a/servers/demo/src/api.ts +++ b/servers/demo/src/api.ts @@ -21,3 +21,7 @@ export const createExpenseReportClientUrl = async ({ endpointId }: { endpointId: export const createDeExpenseReportClientUrl = async ({ endpointId }: { endpointId: string }) => { return `${window.location.origin}${base}/belegeinreichung-client/${endpointId}`; }; + +export const createFlottformMessagingClientUrl = async ({ endpointId }: { endpointId: string }) => { + return `${window.location.origin}${base}/flottform-messaging-client/${endpointId}`; +}; diff --git a/servers/demo/src/routes/+page.svelte b/servers/demo/src/routes/+page.svelte index 0ba96a6..cd05e6b 100644 --- a/servers/demo/src/routes/+page.svelte +++ b/servers/demo/src/routes/+page.svelte @@ -64,5 +64,10 @@ title="Customized default UI" description="See how you can tailor Flottform's default UI to better match your design, while still retaining all the powerful features of the original interface. This demo lets you explore how easy it is to adapt the default elements to fit seamlessly with your brand's style." /> + diff --git a/servers/demo/src/routes/flottform-messaging-client/[endpointId]/+page.svelte b/servers/demo/src/routes/flottform-messaging-client/[endpointId]/+page.svelte new file mode 100644 index 0000000..a41a02d --- /dev/null +++ b/servers/demo/src/routes/flottform-messaging-client/[endpointId]/+page.svelte @@ -0,0 +1,143 @@ + + + + Flottform DEMO + + +
+
+

Flottform Messaging - Client

+
+ {#if connectionStatus === 'init'} +
+

Trying to connect to the host...

+
+ {:else if connectionStatus === 'connected'} +
+
+ {#if messages.length === 0} +

+ You're connected to Host! You can start exchanging messages! +

+ {/if} + {#each messages as message} +
+

{message.text}

+
+ {/each} +
+
+ e.key === 'Enter' && handleSend()} + /> +
+ + +
+
+
+ {/if} + {#if connectionStatus === 'disconnected'} +
+

Connection Channel Disconnected!

+

+ Do want to connect one more time? Scan the QR code from the other peer or paste the link + to the browser! +

+
+ {/if} + {#if connectionStatus === 'error'} +
+

+ Connection Failed with the following error: {error} +

+ +
+ {/if} +
+
+
+ + diff --git a/servers/demo/src/routes/flottform-messaging/+page.svelte b/servers/demo/src/routes/flottform-messaging/+page.svelte new file mode 100644 index 0000000..d3479ca --- /dev/null +++ b/servers/demo/src/routes/flottform-messaging/+page.svelte @@ -0,0 +1,186 @@ + + + + Flottform DEMO + + +
+
+

Flottform Messaging - Host

+
+ {#if connectionStatus === 'new'} +
+

Start a new connection to chat with someone else!

+ +
+ {:else if connectionStatus === 'endpoint-created'} +
+
+ QR Code +
+

+ Scan the QR code or use the link below to connect your device +

+
+ {connectionInfo.link} + +
+ +
+ {:else if connectionStatus === 'connected'} +
+
+ {#if messages.length === 0} +

+ You're connected to Client! You can start exchanging messages! +

+ {/if} + {#each messages as message} +
+

{message.text}

+
+ {/each} +
+
+ e.key === 'Enter' && handleSend()} + /> +
+ + +
+
+
+ {/if} + {#if connectionStatus === 'disconnected'} +
+

Channel is disconnected!

+

Do want to connect one more time? Click the button below!

+ +
+ {/if} + {#if connectionStatus === 'error'} +
+

+ Connection Channel Failed with the following error: {error} +

+ +
+ {/if} +
+
+
+ +