Skip to content

Commit

Permalink
Update UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-asriyan committed Aug 31, 2024
1 parent d528edc commit fd4c803
Show file tree
Hide file tree
Showing 21 changed files with 325 additions and 293 deletions.
61 changes: 9 additions & 52 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
import { _ } from 'svelte-i18n';
import { randomStr } from './utils';
import Analytics from './analytics.svelte';
import LanguageSelector from './components/language-selector.svelte';
import Page from './components/index.svelte';
import { environment, isProduction } from './settings';
import './app.scss';
let header;
let roomId: string;
let isOnline: boolean;
const testPrefix = 'test_';
const syncHashAndRoomId = function () {
Expand All @@ -26,72 +23,32 @@
syncHashAndRoomId();
</script>

<svelte:window on:hashchange={syncHashAndRoomId} bind:online={isOnline}></svelte:window>
<svelte:window on:hashchange={syncHashAndRoomId}></svelte:window>

<Analytics/>

{#if !isProduction}
<span class="uk-position-fixed uk-text-warning" style:top="0" style:left="0" style:z-index="10">
<span class="uk-position-fixed uk-text-warning" style:top="0" style:left="0" style:z-index="1000">
Running in non-production environment: environment="{ environment }", isProd={ isProduction }
</span>
{/if}

<h1 bind:this={header} class="header" class:offline={!isOnline}>
{#if isOnline}
🎬 Watch Together
{:else}
{ $_('noInternet')}
{/if}
</h1>

<div class="uk-section-secondary window-height uk-flex uk-flex-column">
<div style:height={header?.clientHeight + 'px'}></div>
<div class="uk-flex-1 uk-flex uk-flex-center">
{#if roomId}
<Page roomId={roomId} headerHeight={header?.clientHeight}/>
{/if}
</div>
<div class="uk-text-small uk-text-muted uk-text-center uk-padding">
<LanguageSelector />
<div class="uk-margin-top">
<span>{ $_('poweredBy') }</span>
· <a class="uk-text-muted" href="https://svelte.dev" target="_blank">Svelte</a>
· <a class="uk-text-muted" href="https://firebase.google.com" target="_blank">Firebase</a>
· <a class="uk-text-muted" href="https://vidstack.io" target="_blank">Vidstack</a>
· <a class="uk-text-muted" href="https://webtorrent.io" target="_blank">WebTorrent</a>
· <a class="uk-text-muted" href="https://getuikit.com" target="_blank">UIkit</a>
</div>
<div>
<a class="uk-text-muted" href="https://asriyan.me" target="_blank">Ed Asriyan</a>
</div>
</div>
{#if roomId}
<Page roomId={roomId} />
{/if}
</div>

<style lang="scss">
.window-height {
min-height: 100lvh;
}
.header {
position: fixed;
color: white;
width: 100%;
margin: 0;
text-align: center;
font-family: Avenir Next;
font-size: 2rem;
padding: 1rem 0;
border-bottom: 1px solid rgb(255 255 255 / .1);
background-color: rgba(1, 1, 1, 0.9);
z-index: 2;
transition: background-color 500ms ease-in-out;
}
.offline {
background-color: red;
}
.uk-section-secondary {
background-color: #000;
}
.footer {
z-index: 1;
}
</style>
13 changes: 10 additions & 3 deletions src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ html {
background-color: #000;
}

.glass {
border: 1px solid rgba(255, 255, 255, .25);
background-color: rgba(255, 255, 255, 0.01);
box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.25);
backdrop-filter: blur(30px) brightness(70%);
}

.tile {
border: 1px solid rgb(255 255 255 / .1);
background-color: #1c1c1c;
border-radius: 1rem;
@extend .glass;
padding: 2rem 1rem;
color: white;
border-radius: 1rem;
}

.video-text {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts">
import { _ } from 'svelte-i18n';
import Interpolator from './interpolator.svelte';
import { track, ClickEvent } from '../analytics.svelte';
import type { Room } from '../stores/room';
import Loader from './loader.svelte';
import Interpolator from '../interpolator.svelte';
import { track, ClickEvent } from '../../analytics.svelte';
import type { Room } from '../../stores/room';
import Loader from '../loader.svelte';
export let room: Room;
Expand Down Expand Up @@ -48,7 +48,7 @@
{:else}
{#if url}
<div
class="uk-button uk-button-link uk-text-lowercase"
class="uk-button-link uk-text-lowercase pointer"
uk-tooltip={canShare ? $_('invite.clickToShare') : $_('invite.clickToCopy')}
on:click={linkClick}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import { fade } from 'svelte/transition';
import { _ } from 'svelte-i18n';
import prettierBytes from 'prettier-bytes';
import { track, ClickEvent, UrlPasteEvent } from '../analytics.svelte';
import Interpolator from './interpolator.svelte';
import { getExampleVideo, haveExamples } from '../stores/video-example';
import { track, ClickEvent, UrlPasteEvent } from '../../analytics.svelte';
import Interpolator from '../interpolator.svelte';
import { getExampleVideo, haveExamples } from '../../stores/video-example';
import VideoSelectorBtn from './video-selector-btn.svelte';
import { downloadSpeed, uploadSpeed, progress, isSeeding, peers } from '../stores/web-torrent';
import { Room } from '../stores/room';
import Loader from './loader.svelte';
import normalizeSource, { SourceType } from '../normalize-source';
import { blob } from '../stores/blob';
import { downloadSpeed, uploadSpeed, progress, isSeeding, peers } from '../../stores/web-torrent';
import { Room } from '../../stores/room';
import Loader from '../loader.svelte';
import normalizeSource, { SourceType } from '../../normalize-source';
import { blob } from '../../stores/blob';
export let room: Room;
Expand Down Expand Up @@ -108,7 +108,9 @@
{ $_('selectVideo.link.hintEmpty') }
<Interpolator text={$_('selectVideo.link.help')} let:data={data}>
{#if data.name === 'link'}
<a href="https://telegra.ph/How-to-watch-movies-from-websites-together-online-03-17" target="_blank" on:click={clickUrlTutorial}>{ data.text }</a>
<u>
<a href="https://telegra.ph/How-to-watch-movies-from-websites-together-online-03-17" target="_blank" on:click={clickUrlTutorial}>{ data.text }</a>
</u>
{/if}
</Interpolator>
{/if}
Expand All @@ -130,7 +132,9 @@
{ $_('selectVideo.file.hint') }
<Interpolator text={$_('selectVideo.file.help')} let:data={data}>
{#if data.name === 'link'}
<a href="https://www.youtube.com/watch?v=FsT7kUaqBdM" target="_blank" on:click={clickDownloadTutorial}>{ data.text }</a>
<u>
<a href="https://www.youtube.com/watch?v=FsT7kUaqBdM" target="_blank" on:click={clickDownloadTutorial}>{ data.text }</a>
</u>
{/if}
</Interpolator>
</div>
Expand Down
146 changes: 146 additions & 0 deletions src/components/controls/index.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<script lang="ts">
import { tick } from 'svelte';
import { _ } from 'svelte-i18n';
import type { Room } from '../../stores/room';
import { blob } from '../../stores/blob';
import CardCopyUrl from './card-copy-url.svelte';
import CardVideoSelector from './card-video-selector.svelte';
import Users from './users/index.svelte';
import Interpolator from '../interpolator.svelte';
import LanguageSelector from './language-selector.svelte';
import { ClickEvent, track } from '../../analytics.svelte';
import { randomStr } from '../../utils';
import normalizeSource from '../../normalize-source';
export let room: Room;
$: users = room?.users;
$: url = room?.url;
$: highlightVideoSelector = room && !$url && !$blob;
$: highlightInvite = room && !highlightVideoSelector && $users?.length < 1;
const updateRoom = function (newRoomId: string) {
document.location.hash = `#${newRoomId}`;
};
const generateNewRoom = function () {
if (confirm($_('room.generateNewRoom.confirmation'))) {
updateRoom(randomStr(6));
track(new ClickEvent(room, { target: 'generate_new_room' }));
}
};
const joinAnotherRoom = function () {
const input = prompt($_('invite.joinPromt'));
if (!input) return;
let newRoomId;
try {
const url = new URL(input);
if (url.protocol === location.protocol && url.host === location.host && url.hash.length > 1) {
newRoomId = url.hash.slice(1);
} else {
throw 0;
}
} catch {
newRoomId = input;
}
updateRoom(newRoomId, false);
track(new ClickEvent(room, { target: 'join_another_room' }));
};
const isDesktop = window.matchMedia('(min-width: 960px)').matches;
$: if (isDesktop && url) {
tick().then(() => scroll(normalizeSource($url) ? 'top' : 'bottom', true));
}
const scroll = function (direction: 'top' | 'bottom', smooth: boolean = true) {
window.scrollTo({
top: direction === 'top' ? 0 : 9999,
behavior: smooth ? 'smooth' : 'instant'
});
};
</script>

<div class="uk-container uk-grid-collapse uk-grid-match" uk-grid>
<div class="uk-width-1-2@m uk-padding-small">
<div class="tile uk-width-1-1">
<h2 class="uk-card-title uk-text-center" class:gradient-text={highlightVideoSelector}>🍿 { $_('selectVideo.title') }</h2>
<CardVideoSelector room={room} />
</div>
</div>
<div class="uk-width-1-2@m uk-padding-small">
<div class:gradient-border={highlightInvite}>
<div class="tile uk-text-center uk-width-1-1">
<h2 class="uk-card-title" class:gradient-text={highlightInvite}>👥 { $_('invite.title') }</h2>
<CardCopyUrl room={room} />
</div>
</div>
<div class="uk-width-1-1 uk-margin-top">
<Users users={$users} />
</div>
<div class="button uk-flex uk-margin-top uk-flex-column">
<button class="uk-button uk-button-default glass" on:click={generateNewRoom}>
{ $_('room.generateNewRoom.button') }
</button>
</div>
<div class="button uk-flex uk-margin-top uk-flex-column">
<button class="uk-button uk-button-default glass" on:click={joinAnotherRoom}>
{ $_('room.joinAnotherRoom') }
</button>
</div>
</div>
</div>
<div class="uk-text-small uk-width-1-1 uk-text-center uk-margin-medium-top">
<Interpolator text={$_('feedback.linkText')} let:data={data}>
{#if data.name === 'link'}
<a href={$_('feedback.link')} target="_blank">{ data.text }</a>
{/if}
</Interpolator>
</div>
<div class="footer uk-text-small uk-text-muted uk-text-center uk-padding">
<LanguageSelector />
<div class="uk-margin-top">
<span>{ $_('poweredBy') }</span>
· <a class="uk-text-muted" href="https://svelte.dev" target="_blank">Svelte</a>
· <a class="uk-text-muted" href="https://firebase.google.com" target="_blank">Firebase</a>
· <a class="uk-text-muted" href="https://vidstack.io" target="_blank">Vidstack</a>
· <a class="uk-text-muted" href="https://webtorrent.io" target="_blank">WebTorrent</a>
· <a class="uk-text-muted" href="https://getuikit.com" target="_blank">UIkit</a>
</div>
<div>
<a class="uk-text-muted" href="https://asriyan.me" target="_blank">Ed Asriyan</a>
</div>
</div>

<style lang="scss">
@keyframes moveGradient {
50% {
background-position: 100% 100%;
opacity: 60%;
}
}
@keyframes hue {
from {
filter: hue-rotate(0deg);
}
to {
filter: hue-rotate(-360deg);
}
}
.gradient-text {
color: transparent !important;
background-image: linear-gradient(92deg, #f35626, #feac3a);
background-clip: text;
animation: hue 5s infinite linear;
}
.uk-card-title {
font-weight: bold;;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { _, locale } from 'svelte-i18n';
import { locales } from '../i18n/index';
import { track, LocaleChangedEvent } from '../analytics.svelte';
import { locales } from '../../i18n/index';
import { track, LocaleChangedEvent } from '../../analytics.svelte';
const onLanguageChanged = function () {
track(new LocaleChangedEvent({ locale: $locale as string }));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { _ } from 'svelte-i18n';
import type { User as UserModel } from '../../stores/user';
import { me } from '../../stores/me';
import type { User as UserModel } from '../../../stores/user';
import { me } from '../../../stores/me';
import User from './user.svelte';
export let users: UserModel[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { _ } from 'svelte-i18n';
export let userName: string;
export let canEdit: string;
export let canEdit: boolean;
export let status: string;
const maxLength = 10;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { _ } from 'svelte-i18n';
import { track, ClickEvent } from '../analytics.svelte';
import Loader from './loader.svelte';
import { blob } from '../stores/blob';
import { sendFile } from '../stores/web-torrent';
import normalizeSource, { SourceType } from '../normalize-source';
import type { Room } from '../stores/room';
import { track, ClickEvent } from '../../analytics.svelte';
import Loader from '../loader.svelte';
import { blob } from '../../stores/blob';
import { sendFile } from '../../stores/web-torrent';
import normalizeSource, { SourceType } from '../../normalize-source';
import type { Room } from '../../stores/room';
export let forceLocal: boolean = false;
export let room: Room;
Expand Down
Loading

0 comments on commit fd4c803

Please sign in to comment.