removed WIP fitness demo from recent track management updates

This commit is contained in:
Jon 2021-07-23 14:56:40 +01:00
parent c322312343
commit 6024ae381f
25 changed files with 0 additions and 651 deletions

View File

@ -1,4 +0,0 @@
{
"presets": ["next/babel"],
"plugins": ["inline-react-svg"]
}

View File

@ -1,9 +0,0 @@
# Live Fitness
Brings together
- Live streaming
- Recording
- Flying emojis
- Pagination / track management
- Text chat

View File

@ -1,32 +0,0 @@
import React from 'react';
import App from '@dailyjs/basic-call/components/App';
import FlyingEmojiOverlay from '@dailyjs/flying-emojis/components/FlyingEmojis';
import { LiveStreamingProvider } from '@dailyjs/live-streaming/contexts/LiveStreamingProvider';
import { RecordingProvider } from '@dailyjs/recording/contexts/RecordingProvider';
import { ChatProvider } from '@dailyjs/text-chat/contexts/ChatProvider';
import { ClassStateProvider } from '../../context/ClassStateProvider';
import Room from '../Room';
/**
* We'll pass through our own custom Room for this example
* as the layout logic changes considerably for the basic demo
*/
export const LiveFitnessApp = () => (
<ChatProvider>
<LiveStreamingProvider>
<RecordingProvider>
<ClassStateProvider>
<FlyingEmojiOverlay />
<App
customComponentForState={{
room: () => <Room />,
}}
/>
</ClassStateProvider>
</RecordingProvider>
</LiveStreamingProvider>
</ChatProvider>
);
export default LiveFitnessApp;

View File

@ -1 +0,0 @@
export { LiveFitnessApp as default } from './App';

View File

@ -1,44 +0,0 @@
import React, { useMemo } from 'react';
import Button from '@dailyjs/shared/components/Button';
import HeaderCapsule from '@dailyjs/shared/components/HeaderCapsule';
import { useParticipants } from '@dailyjs/shared/contexts/ParticipantsProvider';
export const Header = () => {
const { participantCount } = useParticipants();
return useMemo(
() => (
<header className="room-header">
<img src="assets/daily-logo.svg" alt="Daily" className="logo" />
<HeaderCapsule variant="button">
{`${participantCount} ${
participantCount === 1 ? 'participant' : 'participants'
}`}
<Button size="tiny" variant="outline-dark">
Invite
</Button>
</HeaderCapsule>
<style jsx>{`
.room-header {
display: flex;
flex: 0 0 auto;
column-gap: var(--spacing-xxs);
box-sizing: border-box;
padding: var(--spacing-sm);
align-items: center;
width: 100%;
}
.logo {
margin-right: var(--spacing-xs);
}
`}</style>
</header>
),
[participantCount]
);
};
export default Header;

View File

@ -1,14 +0,0 @@
import React from 'react';
import { RoomContainer } from '@dailyjs/basic-call/components/Room/RoomContainer';
import { VideoContainer } from '@dailyjs/shared/components/VideoContainer';
import { Header } from './Header';
export const Room = () => (
<RoomContainer>
<Header />
<VideoContainer>Hello</VideoContainer>
</RoomContainer>
);
export default RoomContainer;

View File

@ -1 +0,0 @@
export { Room as default } from './Room';

View File

@ -1,221 +0,0 @@
import React, { useState } from 'react';
import Button from '@dailyjs/shared/components/Button';
import Loader from '@dailyjs/shared/components/Loader';
import { Well } from '@dailyjs/shared/components/Well';
import PropTypes from 'prop-types';
/**
* Splash
* ---
* - Checks our app is configured properly
* - Creates a new Daily room for this session
* - Calls the onJoin method with the room name and instructor (owner) status
*/
export const Splash = ({ onJoin, isConfigured }) => {
const [fetching, setFetching] = useState(false);
const [error, setError] = useState(false);
async function createRoom(asInstructor) {
// Create a new room for this class
setError(false);
setFetching(true);
console.log(`🚪 Creating new demo room...`);
// Create a room server side (using Next JS serverless)
const res = await fetch('/api/createRoom', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
privacy: 'private',
expiryMinutes: 10,
}),
});
const resJson = await res.json();
if (resJson.name) {
onJoin(resJson.name, asInstructor);
return;
}
setError(resJson.error || 'An unknown error occured');
setFetching(false);
}
return (
<div className="container">
<aside>
<a href="https://unsplash.com/@jordannix?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">
Photo by Jordan Nix on Unsplash
</a>
</aside>
<main>
<img
src="/assets/daily-logo-dark.svg"
alt="Daily"
className="branding"
/>
<div className="inner">
{(() => {
// Application is not yet configured (there are missing globals, such as domain and dev key)
if (!isConfigured)
return (
<>
<h2>Not configured</h2>
<p>
Please ensure you have set both the{' '}
<code>DAILY_API_KEY</code> and <code>DAILY_DOMAIN</code>{' '}
environmental variables. An example can be found in the
provided <code>env.example</code> file.
</p>
<p>
If you do not yet have a Daily developer account, please{' '}
<a
href="https://dashboard.daily.co/signup"
target="_blank"
rel="noreferrer"
>
create one now
</a>{' '}
. You can find your Daily API key on the{' '}
<a
href="https://dashboard.daily.co/developers"
target="_blank"
rel="noreferrer"
>
developer page
</a>
of the dashboard.
</p>
</>
);
// There was an error creating the room
if (error)
return (
<div>
<Well variant="error">{error}</Well>
An error occured when trying to create a demo room. Please
check that your environmental variables are correct and try
again.
</div>
);
// Loader whilst we create the room
if (fetching)
return (
<>
<Loader /> <p>Creating room, please wait...</p>
</>
);
// Introductory splash screen
return (
<>
<h2>Live fitness example</h2>
<p>
This example demonstrates how to use Daily JS to create a live
class experience. Please be sure to reference the project
readme first.
</p>
<p>
Note: all rooms created with this demo will have a 5 minute
expiry time. If you would like to create a longer running
room, please set the <code>DAILY_ROOM</code> environmental
variable to use your own custom room.
</p>
<hr />
<footer>
<Button
fullWidth
onClick={() => createRoom(true)}
disabled={fetching}
>
Join as instructor
</Button>
<Button
fullWidth
onClick={() => createRoom(false)}
variant="outline-gray"
disabled={fetching}
>
Join as student
</Button>
</footer>
</>
);
})()}
</div>
</main>
<style jsx>
{`
.container {
display: grid;
grid-template-columns: auto 620px;
height: 100vh;
}
main {
background: white;
display: flex;
flex-flow: column wrap;
padding: var(--spacing-sm);
box-sizing: border-box;
}
p {
color: var(--text-mid);
}
main .inner {
flex: 0;
margin: auto 0;
}
.branding {
flex: 0;
width: 108px;
}
hr {
margin: var(--spacing-md) 0;
}
aside {
background: url(/images/fitness-bg.jpg) no-repeat;
background-size: cover;
color: white;
font-size: 0.875rem;
display: flex;
align-items: flex-end;
padding: var(--spacing-xs);
box-sizing: border-box;
}
aside a {
color: white;
opacity: 0.65;
}
footer {
display: flex;
gap: var(--spacing-xxs);
}
`}
</style>
</div>
);
};
Splash.propTypes = {
onJoin: PropTypes.func,
isConfigured: PropTypes.bool,
};
export default Splash;

View File

@ -1 +0,0 @@
export { Splash as default } from './Splash';

View File

@ -1,30 +0,0 @@
import React from 'react';
import FlyingEmojiTrayButton from '@dailyjs/flying-emojis/components/Tray';
import LiveStreamingButton from '@dailyjs/live-streaming/components/Tray';
import RecordingButton from '@dailyjs/recording/components/Tray';
import { useParticipants } from '@dailyjs/shared/contexts/ParticipantsProvider';
import ChatTrayButton from '@dailyjs/text-chat/components/Tray';
export const Tray = () => {
const { isOwner } = useParticipants();
if (isOwner) {
return (
<>
<FlyingEmojiTrayButton />
<ChatTrayButton />
<LiveStreamingButton />
<RecordingButton />
</>
);
}
return (
<>
<FlyingEmojiTrayButton />
<ChatTrayButton />
</>
);
};
export default Tray;

View File

@ -1 +0,0 @@
export { Tray as default } from './Tray';

View File

@ -1,37 +0,0 @@
import React, { createContext, useContext, useEffect, useState } from 'react';
import { useParticipants } from '@dailyjs/shared/contexts/ParticipantsProvider';
import PropTypes from 'prop-types';
export const CLASS_STATE_PRE_LOBBY = 'pre-lobby';
export const CLASS_STATE_IN_SESSION = 'in_session';
export const CLASS_STATE_POST_LOBBY = 'post-lobby';
const ClassStateContext = createContext();
export const ClassStateProvider = ({ children }) => {
const [classState, setClassState] = useState(CLASS_STATE_PRE_LOBBY);
const { isOwner } = useParticipants();
useEffect(() => {
console.log('🧘 Class provider initialised');
}, []);
return (
<ClassStateContext.Provider
value={{
classState,
setClassState,
}}
>
{children}
</ClassStateContext.Provider>
);
};
ClassStateProvider.propTypes = {
children: PropTypes.node,
};
export const useClassState = () => useContext(ClassStateContext);

View File

@ -1,8 +0,0 @@
# Domain excluding 'https://' and 'daily.co' e.g. 'somedomain'
DAILY_DOMAIN=
# Obtained from https://dashboard.daily.co/developers
DAILY_API_KEY=
# Daily REST API endpoint
DAILY_REST_DOMAIN=https://api.daily.co/v1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 281 KiB

View File

@ -1,17 +0,0 @@
const withPlugins = require('next-compose-plugins');
const withTM = require('next-transpile-modules')([
'@dailyjs/shared',
'@dailyjs/basic-call',
'@dailyjs/flying-emojis',
'@dailyjs/text-chat',
'@dailyjs/live-streaming',
'@dailyjs/recording',
]);
const packageJson = require('./package.json');
module.exports = withPlugins([withTM], {
env: {
PROJECT_TITLE: packageJson.description,
},
});

View File

@ -1,29 +0,0 @@
{
"name": "@dailyjs/live-fitness",
"description": "Live Fitness Example",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@dailyjs/shared": "*",
"@dailyjs/basic-call": "*",
"@dailyjs/flying-emojis": "*",
"@dailyjs/text-chat": "*",
"@dailyjs/live-streaming": "*",
"@dailyjs/recording": "*",
"next": "^11.0.0",
"pluralize": "^8.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"babel-plugin-module-resolver": "^4.1.0",
"next-compose-plugins": "^2.2.1",
"next-transpile-modules": "^8.0.0"
}
}

View File

@ -1,118 +0,0 @@
import React, { useState, useEffect } from 'react';
import { CallProvider } from '@dailyjs/shared/contexts/CallProvider';
import { MediaDeviceProvider } from '@dailyjs/shared/contexts/MediaDeviceProvider';
import { ParticipantsProvider } from '@dailyjs/shared/contexts/ParticipantsProvider';
import { TracksProvider } from '@dailyjs/shared/contexts/TracksProvider';
import { UIStateProvider } from '@dailyjs/shared/contexts/UIStateProvider';
import { WaitingRoomProvider } from '@dailyjs/shared/contexts/WaitingRoomProvider';
import getDemoProps from '@dailyjs/shared/lib/demoProps';
import { useRouter } from 'next/router';
import PropTypes from 'prop-types';
import App from '../components/App';
/**
* Room page
* ---
*/
export default function Room({
room,
instructor,
domain,
customTrayComponent,
asides,
modals,
}) {
const [token, setToken] = useState();
const [tokenError, setTokenError] = useState();
const router = useRouter();
// Redirect to a 404 if we do not have a room
useEffect(
() => (!room || !domain) && router.replace('/not-found'),
[room, domain, router]
);
// Fetch a meeting token
useEffect(() => {
if (token || !room) {
return;
}
// We're using a simple Next serverless function to generate meeting tokens
// which could be replaced with your own serverside method that authenticates
// users / sets room owner status, user ID, user names etc
async function getToken() {
console.log(`🪙 Fetching meeting token for room '${room}'`);
const res = await fetch('/api/token', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ roomName: room, isOwner: !!instructor }),
});
const resJson = await res.json();
if (!resJson?.token) {
setTokenError(resJson?.error || true);
}
console.log(`🪙 Meeting token received`);
setToken(resJson.token);
}
getToken();
}, [token, room, instructor]);
if (!token) {
return <div>Fetching token...</div>;
}
if (tokenError) {
return <div>Token error</div>;
}
/**
* Main call UI
*/
return (
<UIStateProvider
customTrayComponent={customTrayComponent}
asides={asides}
modals={modals}
>
<CallProvider domain={domain} room={room} token={token}>
<ParticipantsProvider>
<TracksProvider>
<MediaDeviceProvider>
<WaitingRoomProvider>
<App />
</WaitingRoomProvider>
</MediaDeviceProvider>
</TracksProvider>
</ParticipantsProvider>
</CallProvider>
</UIStateProvider>
);
}
Room.propTypes = {
room: PropTypes.string.isRequired,
domain: PropTypes.string.isRequired,
instructor: PropTypes.bool,
customTrayComponent: PropTypes.node,
asides: PropTypes.arrayOf(PropTypes.func),
modals: PropTypes.arrayOf(PropTypes.func),
};
export async function getServerSideProps(context) {
const { room, instructor } = context.query;
const defaultProps = getDemoProps();
return {
props: { room, instructor: !!instructor, ...defaultProps },
};
}

View File

@ -1,12 +0,0 @@
import React from 'react';
import App from '@dailyjs/basic-call/pages/_app';
import LiveStreamingModal from '@dailyjs/live-streaming/components/LiveStreamingModal';
import RecordingModal from '@dailyjs/recording/components/RecordingModal';
import ChatAside from '@dailyjs/text-chat/components/ChatAside';
import Tray from '../components/Tray';
App.customTrayComponent = <Tray />;
App.asides = [ChatAside];
App.modals = [LiveStreamingModal, RecordingModal];
export default App;

View File

@ -1 +0,0 @@
../../basic-call/pages/api

View File

@ -1,35 +0,0 @@
import React from 'react';
import getDemoProps from '@dailyjs/shared/lib/demoProps';
import { useRouter } from 'next/router';
import PropTypes from 'prop-types';
import Splash from '../components/Splash';
/**
* Index page
* ---
*/
export default function Index({ isConfigured = false }) {
const router = useRouter();
function joinRoom(room, joinAsInstructor) {
// Redirect to room page
router.replace({
pathname: `/${room}`,
query: { instructor: !!joinAsInstructor },
});
}
return <Splash onJoin={joinRoom} isConfigured={!!isConfigured} />;
}
Index.propTypes = {
isConfigured: PropTypes.bool.isRequired,
};
export async function getStaticProps() {
const defaultProps = getDemoProps();
return {
props: defaultProps,
};
}

View File

@ -1,21 +0,0 @@
import React from 'react';
import MessageCard from '@dailyjs/shared/components/MessageCard';
export default function RoomNotFound() {
return (
<div className="not-found">
<MessageCard error header="Room not found">
The room you are trying to join does not exist. Have you created the
room using the Daily REST API or the dashboard?
</MessageCard>
<style jsx>{`
display: grid;
align-items: center;
justify-content: center;
grid-template-columns: 620px;
width: 100%;
height: 100vh;
`}</style>
</div>
);
}

View File

@ -1 +0,0 @@
../../shared/assets

View File

@ -1,14 +0,0 @@
<svg width="80" height="32" viewBox="0 0 80 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M21.5886 27.0149C23.8871 27.0149 25.7976 25.6716 26.6035 24.0896V26.6866H30.9021V4H26.6035V13.403C25.7379 11.8209 24.1856 10.7164 21.6782 10.7164C17.7677 10.7164 14.8125 13.7313 14.8125 18.8657V19.1045C14.8125 24.2985 17.7976 27.0149 21.5886 27.0149ZM22.8722 23.6418C20.7229 23.6418 19.2304 22.1194 19.2304 19.0149V18.7761C19.2304 15.6716 20.5737 14.0299 22.9916 14.0299C25.3498 14.0299 26.7229 15.6119 26.7229 18.7164V18.9552C26.7229 22.1194 25.1409 23.6418 22.8722 23.6418Z" fill="currentColor"/>
<path d="M37.9534 27.0149C40.4011 27.0149 41.7743 26.0597 42.6698 24.806V26.6866H46.8787V16.5075C46.8787 12.2687 44.1623 10.7164 40.3414 10.7164C36.5205 10.7164 33.5951 12.3582 33.3265 16.0597H37.416C37.5951 14.7164 38.3713 13.8507 40.0728 13.8507C42.0429 13.8507 42.6101 14.8657 42.6101 16.7164V17.3433H40.8489C36.0728 17.3433 32.7295 18.7164 32.7295 22.3582C32.7295 25.6418 35.1175 27.0149 37.9534 27.0149ZM39.2369 24C37.6548 24 36.9683 23.2537 36.9683 22.1194C36.9683 20.4478 38.431 19.9104 40.9384 19.9104H42.6101V21.2239C42.6101 22.9552 41.1474 24 39.2369 24Z" fill="currentColor"/>
<path d="M49.647 26.6866H53.9456V11.0746H49.647V26.6866ZM51.7665 8.95522C53.1694 8.95522 54.2441 7.9403 54.2441 6.59702C54.2441 5.25373 53.1694 4.23881 51.7665 4.23881C50.3933 4.23881 49.3187 5.25373 49.3187 6.59702C49.3187 7.9403 50.3933 8.95522 51.7665 8.95522Z" fill="currentColor"/>
<path d="M56.9765 26.6866H61.275V4H56.9765V26.6866Z" fill="currentColor"/>
<path d="M70.5634 32L78.9917 11.0746H74.8711L71.3499 20.4478L67.5589 11.0746H62.9021L69.1523 25.1953L66.3779 32H70.5634Z" fill="currentColor"/>
<path d="M0 32H4.1875L17.0766 0H12.9916L0 32Z" fill="url(#paint0_linear)"/>
<defs>
<linearGradient id="paint0_linear" x1="8.88727" y1="-0.222885" x2="8.88727" y2="30" gradientUnits="userSpaceOnUse">
<stop stop-color="#1BEBB9"/>
<stop offset="1" stop-color="#FF9254"/>
</linearGradient>
</defs>
</svg>

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 531 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 535 KiB