diff --git a/beta/src/components/Layout/HomeContent.js b/beta/src/components/Layout/HomeContent.js index b6fb414be..e8e369e0e 100644 --- a/beta/src/components/Layout/HomeContent.js +++ b/beta/src/components/Layout/HomeContent.js @@ -353,20 +353,22 @@ function Example1() {

- Album.js + VideoRow.js

-
{`function Album({ album }) { +
{`function VideoRow({ video }) { return (
- -

{album.title}

-

{album.year}

- + + +

{video.title}

+

{video.description}

+
+
); } @@ -375,11 +377,12 @@ function Example1() {
- @@ -391,26 +394,26 @@ function Example1() { } function Example2() { - const [albums, setAlbums] = useState([ + const videos = [ { id: 0, - name: 'First album', - year: 'Release year', - artwork: 'blue', + title: 'First video', + description: 'Video description', + image: 'blue', }, { id: 1, - name: 'Second album', - year: 'Release year', - artwork: 'red', + title: 'Second video', + description: 'Video description', + image: 'red', }, { id: 2, - name: 'Third album', - year: 'Release year', - artwork: 'green', + title: 'Third video', + description: 'Video description', + image: 'green', }, - ]); + ]; return (
@@ -419,23 +422,23 @@ function Example2() {

- AlbumList.js + VideoList.js

-
{`function AlbumList({ albums }) { - let heading = 'No Albums Yet'; - if (albums.length > 0) { - heading = albums.length + ' Albums'; +
{`function VideoList({ videos }) { + let heading = 'No Videos Yet'; + if (videos.length > 0) { + heading = videos.length + ' Videos'; } return (

{heading}

- {albums.map(album => - + {videos.map(video => + )}
); @@ -444,7 +447,7 @@ function Example2() {
- +
@@ -454,101 +457,24 @@ function Example2() { } function Example3() { - const [artistPromise, setPostPromise] = useState(null); - const [albumsPromise, setAlbumsPromise] = useState(null); - const [albums, setAlbums] = useState([ + const [playlistPromise, setPostPromise] = useState(null); + const [videosPromise, setAlbumsPromise] = useState(null); + const videos = [ { - id: 13, - name: 'Let It Be', - year: 1970, - artwork: - 'https://e.snmc.io/i/600/w/5c91497d86b2a17f89bfb0f9462b458f/3264656/the-beatles-let-it-be-Cover-Art.jpg', - }, - { - id: 12, - name: 'Abbey Road', - year: 1969, - artwork: - 'https://e.snmc.io/i/600/w/556a5058d86284041d4ac0852ce0a23b/6617288/the-beatles-abbey-road-Cover-Art.jpg', - }, - { - id: 11, - name: 'Yellow Submarine', - year: 1969, - artwork: - 'https://e.snmc.io/i/600/w/7ff05b4efcebcb870aa8b0c732f30714/9971128/the-beatles-yellow-submarine-Cover-Art.jpg', - }, - { - id: 10, - name: 'The Beatles', - year: 1968, - artwork: - 'https://e.snmc.io/i/600/w/1328de4857371d494f4778f83fb783f7/7430929/the-beatles-the-beatles-white-album-Cover-Art.jpg', - }, - { - id: 9, - name: 'Magical Mystery Tour', - year: 1967, - artwork: - 'https://e.snmc.io/i/600/w/71026c3dcec012f38cb6f96a87d31390/5770162/the-beatles-magical-mystery-tour-Cover-Art.jpg', - }, - { - id: 8, - name: "Sgt. Pepper's Lonely Hearts Club Band", - year: 1967, - artwork: - 'https://e.snmc.io/i/600/w/5ab702b0fbf94f6ac96731cbed054eb0/6617240/the-beatles-sgt-peppers-lonely-hearts-club-band-Cover-Art.jpg', - }, - { - id: 7, - name: 'Revolver', - year: 1966, - artwork: - 'https://e.snmc.io/i/600/w/d1dc1ba868e70b299ebd6733fa4fbf5b/6112311/the-beatles-revolver-Cover-Art.png', - }, - { - id: 6, - name: 'Rubber Soul', - year: 1965, - artwork: - 'https://e.snmc.io/i/600/w/9fa4dfd4de69b639e08f6a5b346a52c6/5248558/the-beatles-rubber-soul-Cover-Art.jpg', - }, - { - id: 5, - name: 'Help!', - year: 1965, - artwork: - 'https://e.snmc.io/i/600/w/cec66c7556b30248d9c6a54b44098787/2635809/the-beatles-help-Cover-Art.jpg,', - }, - { - id: 4, - name: 'Beatles For Sale', - year: 1964, - artwork: - 'https://e.snmc.io/i/600/w/e55b1e8ed7145c767ccb4aafd3ae02cb/2305142/the-beatles-beatles-for-sale-Cover-Art.jpg', - }, - { - id: 3, - name: "A Hard Day's Night", - year: 1964, - artwork: - 'https://e.snmc.io/i/600/w/e859a9a29b890f294189e558de07e3b9/5247969/the-beatles-a-hard-days-night-Cover-Art.jpg', - }, - { - id: 2, - name: 'With The Beatles', - year: 1963, - artwork: - 'https://e.snmc.io/i/600/w/ce20c23673292626968286ff246e11f0/6084996/the-beatles-with-the-beatles-Cover-Art.jpg', + id: 0, + title: 'React 18 Keynote', + description: 'Andrew Clark, Lauren Tan, Juan Tejada, Ricky Hanlon', + url: 'https://www.youtube.com/watch?v=FZ0cG47msEk&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=1', + image: 'https://i.imgur.com/WAkFBlj.jpg', }, { id: 1, - name: 'Please Please Me', - year: 1963, - artwork: - 'https://e.snmc.io/i/600/w/32e9a260edd19b0cfc84cd333aac992a/10434810/the-beatles-please-please-me-Cover-Art.jpg', + title: 'React 18 for app developers', + description: 'Andrew Clark, Lauren Tan, Juan Tejada, Ricky Hanlon', + url: 'https://www.youtube.com/watch?v=ytudH8je5ko&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=2', + image: 'https://i.imgur.com/Wqcw83j.jpg', }, - ]); + ]; return (
@@ -557,7 +483,7 @@ function Example3() {

- artists/[slug].js + playlists/[slug].js

{`import { db } from './database.js'; import { Suspense } from 'react'; -async function ArtistPage({ slug }) { - const artist = await db.Artists.find({ slug }); +async function PlaylistPage({ slug }) { + const playlist = await db.Playlists.findOne({ slug }); return (
- -

{artist.name}

+ +

{playlist.name}

- }> - + }> +
); } -async function Discography({ artistId }) { - const albums = await db.Albums.find({ artistId }); - return ; +async function Playlist({ playlistId }) { + const videos = await db.Videos.findMany({ playlistId }); + return ; }`}
@@ -594,14 +520,14 @@ async function Discography({ artistId }) {
-
@@ -635,20 +561,20 @@ function BrowserChrome({children, setPostPromise, setAlbumsPromise}) { const simulatedAlbumsMs = 2200; function handleRestart() { - const artistPromise = new Promise((resolve) => { + const playlistPromise = new Promise((resolve) => { setTimeout(() => { - artistPromise._resolved = true; + playlistPromise._resolved = true; resolve(); }, simulatedArtistMs); }); - const albumsPromise = new Promise((resolve) => { + const videosPromise = new Promise((resolve) => { setTimeout(() => { - albumsPromise._resolved = true; + videosPromise._resolved = true; resolve(); }, simulatedAlbumsMs); }); - setPostPromise(artistPromise); - setAlbumsPromise(albumsPromise); + setPostPromise(playlistPromise); + setAlbumsPromise(videosPromise); setRestartId((id) => id + 1); } @@ -659,7 +585,7 @@ function BrowserChrome({children, setPostPromise, setAlbumsPromise}) {
example.com - /artists/the-beatles + /playlists/react-conf-2021
- +

- {artist.name} + {playlist.name}

}> - +
); @@ -743,30 +669,30 @@ function LoadingDiscography() { ); } -function Discography({artist, albumsPromise}) { - if (albumsPromise && !albumsPromise._resolved) { - throw albumsPromise; +function Discography({playlist, videosPromise}) { + if (videosPromise && !videosPromise._resolved) { + throw videosPromise; } - return ; + return ; } -function AlbumList({albums, children}) { - let headingText = 'No Albums Yet'; - if (albums.length > 0) { - headingText = albums.length + ' Albums'; +function VideoList({videos, children}) { + let headingText = 'No Videos Yet'; + if (videos.length > 0) { + headingText = videos.length + ' Videos'; } return (

{headingText}

- - {albums.map((album) => ( - +
+ {videos.map((video) => ( + ))} {children} - +
); } @@ -787,31 +713,17 @@ function Cover({background, children}) { ); } -function Album({album}) { +function VideoRow({video}) { return ( - - - - -

- {album.name} -

-

{album.year}

-
- -
-
- ); -} - -function Stack({children, gap}) { - return ( -
- {children} + ); } @@ -824,23 +736,14 @@ function Code({children}) { ); } -function Row({children, gap}) { +function VideoThumbnail({video}) { + const {image} = video; return ( -
- {children} -
- ); -} - -function Artwork({image}) { - return ( -
{image !== 'blue' && image !== 'red' && image !== 'green' ? null : ( - + )} -
+ ); } -function ArtworkPlaceholder() { +function ThumbnailPlaceholder() { return (