Skip to content

Commit

Permalink
feat: implement header and layout in page.svelte
Browse files Browse the repository at this point in the history
  • Loading branch information
triptu committed Oct 7, 2022
1 parent 1369ffb commit f56642e
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ A hello world app for Svelte + 100ms. Built with SvelteKit.
1. directly in the components, subscribing with the proper selector and calling the unsubscribe method in onDestroy
2. Creating a few helper svelte store wrappers in hmsStores.ts for commonly used selectors
8. Create a hmsStore.ts file with helper function to convert from hms to svelte store and create two stores for isConnected and peers in the room.
9.
9. Implement page.svelte, also add a leave on unload function for handling tab closing. Implement header with a logo and a leave button.
10.
22 changes: 22 additions & 0 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
<script>
import './styles.css';
import {hmsActions} from "./hms.ts";
import Conference from "./Conference.svelte";
import JoinForm from "./JoinForm.svelte";
import Header from "./Header.svelte";
import Footer from "./Footer.svelte";
import {hmsIsConnected} from "./hmsStores.ts";
function leaveRoom() {
hmsActions.leave();
}
</script>

<!-- leave room on tab close -->
<svelte:window on:unload={leaveRoom} />

<svelte:head>
<title>100ms Svelte App</title>
<meta name="description" content="Svelte HMS World" />
</svelte:head>

<Header/>
{#if $hmsIsConnected}
<Conference />
{:else}
<JoinForm />
{/if}
<Footer/>
1 change: 1 addition & 0 deletions src/routes/Conference.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Conference</p>
30 changes: 30 additions & 0 deletions src/routes/Header.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<script>
import {hmsIsConnected} from "./hmsStores.ts";
import {hmsActions} from "./hms.ts";
function leaveRoom() {
hmsActions.leave();
}
</script>


<header>
<img
class="logo"
src="https://www.100ms.live/assets/logo.svg"
alt="100ms Logo"
/>

{#if hmsIsConnected}
<button id="leave-btn" class="btn-danger" on:click={leaveRoom}> Leave Room </button>
{/if}
</header>

<style>
header {
padding: 10px;
display: flex;
align-items: center;
justify-content: space-between;
}
</style>
1 change: 1 addition & 0 deletions src/routes/JoinForm.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Join Form</p>
11 changes: 11 additions & 0 deletions src/routes/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ pre {
color: var(--color-text);
}

.btn-danger {
border: 1px solid transparent;
border-radius: 4px;
padding: 6px 14px;
background-color: #f44336;
color: white;
font-family: inherit;
font-size: 14px;
cursor: pointer;
}

.text-column {
display: flex;
max-width: 48rem;
Expand Down

0 comments on commit f56642e

Please sign in to comment.