initial commit

This commit is contained in:
J Taylor 2021-06-21 15:19:43 +01:00
parent b7856e275a
commit 42c46f1f1c
13 changed files with 104 additions and 10 deletions

View File

@ -16,7 +16,14 @@ import PropTypes from 'prop-types';
* ---
* Specify which room we would like to join
*/
export const Intro = ({ room, error, domain, onJoin, fetching = false }) => {
export const Intro = ({
room,
error,
domain,
onJoin,
title,
fetching = false,
}) => {
const [roomName, setRoomName] = useState();
const [owner, setOwner] = useState(false);
const [fetchToken, setFetchToken] = useState(false);
@ -27,7 +34,7 @@ export const Intro = ({ room, error, domain, onJoin, fetching = false }) => {
return (
<Card>
<CardHeader>Daily Basic Call Example</CardHeader>
<CardHeader>{title}</CardHeader>
<CardBody>
{error && (
<Well variant="error">
@ -67,6 +74,7 @@ export const Intro = ({ room, error, domain, onJoin, fetching = false }) => {
Intro.propTypes = {
room: PropTypes.string,
title: PropTypes.string,
error: PropTypes.string,
domain: PropTypes.string.isRequired,
onJoin: PropTypes.func.isRequired,

View File

@ -0,0 +1 @@
// Note: I am here because next-transpile-modules requires a mainfile

View File

@ -1,4 +1,10 @@
const withPlugins = require('next-compose-plugins');
const withTM = require('next-transpile-modules')(['@dailyjs/shared']);
module.exports = withPlugins([withTM]);
const packageJson = require('./package.json');
module.exports = withPlugins([withTM], {
env: {
PROJECT_TITLE: packageJson.description,
},
});

View File

@ -1,5 +1,6 @@
{
"name": "@dailyjs/basic-call",
"description": "Basic Call Example",
"version": "0.1.0",
"private": true,
"scripts": {

View File

@ -1,4 +1,5 @@
import React from 'react';
import GlobalHead from '@dailyjs/shared/components/GlobalHead';
import GlobalStyle from '@dailyjs/shared/components/GlobalStyle';
import Head from 'next/head';
import PropTypes from 'prop-types';
@ -7,13 +8,9 @@ function App({ Component, pageProps }) {
return (
<>
<Head>
<title>Daily - Basic Call Example</title>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600&display=swap"
rel="stylesheet"
/>
<title>Daily - {process.env.PROJECT_TITLE}</title>
</Head>
<GlobalHead />
<GlobalStyle />
<Component {...pageProps} />
</>

View File

@ -66,6 +66,7 @@ export default function Index({ domain, isConfigured = false }) {
<NotConfigured />
) : (
<Intro
title={process.env.PROJECT_TITLE}
room={roomName}
error={tokenError}
fetching={fetchingToken}
@ -119,6 +120,9 @@ export async function getStaticProps() {
// Pass through domain as prop
return {
props: { domain: process.env.DAILY_DOMAIN || null, isConfigured },
props: {
domain: process.env.DAILY_DOMAIN || null,
isConfigured,
},
};
}

View File

@ -0,0 +1,14 @@
import React from 'react';
import Head from 'next/head';
export const GlobalHead = () => (
<Head>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600&display=swap"
rel="stylesheet"
/>
</Head>
);
export default GlobalHead;

View File

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

View File

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

View File

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

View File

@ -0,0 +1,24 @@
{
"name": "@dailyjs/text-chat",
"description": "Basic Call + Chat Example",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"@dailyjs/shared": "*",
"@dailyjs/basic-call": "*",
"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

@ -0,0 +1,3 @@
import App from '@dailyjs/basic-call/pages/_app';
export default App;

View File

@ -0,0 +1,17 @@
import Index from '@dailyjs/basic-call/pages';
export async function getStaticProps() {
// Check that both domain and key env vars are set
const isConfigured =
!!process.env.DAILY_DOMAIN && !!process.env.DAILY_API_KEY;
// Pass through domain as prop
return {
props: {
domain: process.env.DAILY_DOMAIN || null,
isConfigured,
},
};
}
export default Index;