Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Learn page 4 call catalog section UI #120

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
22916d2
Update: dependencies
NayoBaez Mar 24, 2023
bfed57b
feature: setup styling foundation with grid
NayoBaez Mar 24, 2023
e84fe6f
feature: implement map function to grid images
NayoBaez Mar 27, 2023
28bcf95
Styling: add padding to box and button
NayoBaez Mar 27, 2023
b142581
fix: remove margin top and bottom
NayoBaez Apr 22, 2023
8edf762
fix: margin top & bottom
NayoBaez Apr 22, 2023
e9babbd
feature: add playbutton for orca-call
NayoBaez Jun 2, 2023
e769b49
feature: built component for call catalog grid
NayoBaez Sep 26, 2023
6346e54
feature: setup call catalog grid inside component
NayoBaez Sep 26, 2023
b7e263c
feature: install useSound Hook
NayoBaez Sep 26, 2023
ded5f6e
feature: import useSound Hook & Orca Calls
NayoBaez Sep 26, 2023
64ff30f
feature: add pause button for sound toggle
NayoBaez Sep 26, 2023
610fcf9
fix: set next.js version back to 12.0.9
NayoBaez Sep 26, 2023
4e26dab
feature: import useState for toggle functions in array of sounds
NayoBaez Sep 26, 2023
c4f667e
feature: create toggle function for each playbutton in array of sounds
NayoBaez Sep 26, 2023
3a89957
feature: create toggle function for each pausebutton in array of sounds
NayoBaez Sep 26, 2023
5e23cc2
feature: add ternary operator to toggle between play/pause button
NayoBaez Sep 26, 2023
15f1326
fix: grid & inner content responsiveness
NayoBaez Sep 26, 2023
247e23d
feature: add orca call tags for each sound
NayoBaez Sep 27, 2023
e2d37c8
feature: add link to access call catalog
NayoBaez Sep 27, 2023
1af3c4f
fix: errors from log
NayoBaez Sep 27, 2023
4593783
feature: replace image with spectrogram for corresponding call label
NayoBaez Sep 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](https://github.com/orcasound/orcahome/blob/master/CONTRIBUTING.md)
[![CI](https://github.com/orcasound/orcahome/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/orcasound/orcahome/actions/workflows/ci.yml)

This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). Developed initially as a Google Summer of Code project in 2021 by [Isabella Macchiavello](https://www.linkedin.com/in/isabella-macchiavello-223338205/), the [code is deployed via Netlify](https://orcahome.netlify.app/).
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). Developed initially as a Google Summer of Code project in 2021 by [Isabella Macchiavello](https://www.linkedin.com/in/isabella-macchiavello-223338205/), the [code is deployed via Netlify](https://orcahome.netlify.app/).

## Getting Started

Expand Down
1,588 changes: 1,404 additions & 184 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"react": "17.0.2",
"react-audio-player": "^0.17.0",
"react-dom": "17.0.2",
"react-scroll": "^1.8.4"
"react-scroll": "^1.8.4",
"use-sound": "^4.0.1"
},
"devDependencies": {
"@types/node": "^16.11.22",
Expand Down
Binary file added public/audio/FO-S01.mp3
Binary file not shown.
Binary file added public/audio/FO-S02.mp3
Binary file not shown.
Binary file added public/audio/FO-S03.mp3
Binary file not shown.
Binary file added public/audio/FO-S04.mp3
Binary file not shown.
Binary file added public/audio/FO-S05.mp3
Binary file not shown.
Binary file added public/audio/FO-S06.mp3
Binary file not shown.
Binary file added public/images/learn/FO-S01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/learn/FO-S02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/learn/FO-S03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/learn/FO-S04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/learn/FO-S05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/learn/FO-S06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
168 changes: 168 additions & 0 deletions src/components/Learn/CallCatalogGrid.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
import PauseCircleIcon from '@mui/icons-material/PauseCircle'
import PlayCircleIcon from '@mui/icons-material/PlayCircle'
import { Box, Button, Grid, IconButton, Link, Typography } from '@mui/material'
import Image from 'next/image'
import React from 'react'
import useSound from 'use-sound'

import SO1 from '../../../public/audio/FO-S01.mp3'
import SO2 from '../../../public/audio/FO-S02.mp3'
import SO3 from '../../../public/audio/FO-S03.mp3'
import SO4 from '../../../public/audio/FO-S04.mp3'
import SO5 from '../../../public/audio/FO-S05.mp3'
import SO6 from '../../../public/audio/FO-S06.mp3'
import FOS01 from '../../../public/images/learn/FO-S01.png'
import FOS02 from '../../../public/images/learn/FO-S02.png'
import FOS03 from '../../../public/images/learn/FO-S03.png'
import FOS04 from '../../../public/images/learn/FO-S04.png'
import FOS05 from '../../../public/images/learn/FO-S05.png'
import FOS06 from '../../../public/images/learn/FO-S06.png'

const CallCatalogGrid = () => {
const [isPlaying, setIsPlaying] = React.useState(Array(6).fill(false))

const [playS01, { stop: stopS01 }] = useSound(SO1)
const [playS02, { stop: stopS02 }] = useSound(SO2)
const [playS03, { stop: stopS03 }] = useSound(SO3)
const [playS04, { stop: stopS04 }] = useSound(SO4)
const [playS05, { stop: stopS05 }] = useSound(SO5)
const [playS06, { stop: stopS06 }] = useSound(SO6)

const playArray = [playS01, playS02, playS03, playS04, playS05, playS06]
const stopArray = [stopS01, stopS02, stopS03, stopS04, stopS05, stopS06]
const spectrogram = [FOS01, FOS02, FOS03, FOS04, FOS05, FOS06]
const orcaCallTags = [
'Orca call S01',
'Orca call S02',
'Orca call S03',
'Orca call S04',
'Orca call S05',
'Orca call S06-L',
]

function playSound(index) {
const updatedIsPlaying = [...isPlaying]
updatedIsPlaying[index] = true
setIsPlaying(updatedIsPlaying)
playArray[index]()
}

function stopSound(index) {
const updatedIsPlaying = [...isPlaying]
updatedIsPlaying[index] = false
setIsPlaying(updatedIsPlaying)
stopArray[index]()
}

return (
<div>
<Box
sx={{
borderRadius: '33px',
bgcolor: '#ffff',
my: '50px',
py: '50px',
px: '20px',
textAlign: 'center',
}}
>
<Grid
container
spacing={{ xs: 2, md: 8 }}
columns={{ xs: 4, sm: 8, md: 12 }}
px={{ xs: '5px', md: '30px' }}
>
{playArray.map((play, index) => (
<Grid
item
xs={12}
sm={6}
md={4}
key={index}
sx={{
position: 'relative',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Box
sx={{
position: 'relative',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100%',
}}
>
<Image
src={spectrogram[index]}
alt={`Orca Call ${index}`}
style={{ width: '100%' }}
/>
<Box
sx={{
position: 'absolute',
top: '40%',
left: '50%',
transform: 'translate(-50%, -50%)',
marginTop: '20px',
}}
>
{isPlaying[index] ? (
<IconButton
onClick={() => stopSound(index)}
sx={{
color: '#c4c4c4',
}}
>
<PauseCircleIcon
sx={{
fontSize: 100,
}}
/>
</IconButton>
) : (
<IconButton
onClick={() => playSound(index)}
sx={{
color: '#c4c4c4',
}}
>
<PlayCircleIcon
sx={{
fontSize: { xs: 80, md: 90, lg: 100 },
}}
/>
</IconButton>
)}
</Box>
</Box>
<Typography mt={1} variant="p" fontSize="20px" color="black">
{orcaCallTags[index]}
</Typography>
</Grid>
))}
</Grid>
<Link
href="https://orcasound.net/data/product/SRKW/call-catalog/no-narration_flac+mp3+ogg+spectrograms/mp3/"
target="_blank"
>
<Button
variant="contained"
sx={{
borderRadius: '30px',
mt: 6,
py: 2,
px: 5,
}}
>
Access Call Catalog
</Button>
</Link>
</Box>
</div>
)
}

export default CallCatalogGrid
6 changes: 5 additions & 1 deletion src/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ import clsx from 'clsx'
import NextLink, { LinkProps as NextLinkProps } from 'next/link'
import { useRouter } from 'next/router'
import { forwardRef } from 'react'
import * as React from 'react'

// Add support for the sx prop for consistency with the other branches.
const Anchor = styled('a')({})

interface NextLinkComposedProps
extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>,
Omit<NextLinkProps, 'href' | 'as'> {
Omit<
NextLinkProps,
'href' | 'as' | 'onClick' | 'onMouseEnter' | 'onTouchStart'
> {
to: NextLinkProps['href']
linkAs?: NextLinkProps['as']
href?: NextLinkProps['href']
Expand Down
18 changes: 17 additions & 1 deletion src/pages/learn.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Typography } from '@mui/material'
import Head from 'next/head'
import Image from 'next/image'
import ReactAudioPlayer from 'react-audio-player'
Expand All @@ -9,6 +10,7 @@ import organization1 from '../../public/images/partner1.png'
import organization2 from '../../public/images/partner2.png'
import roundorca from '../../public/images/roundorca.png'
import salishsea from '../../public/images/salishsea.png'
import CallCatalogGrid from '../components/Learn/CallCatalogGrid'
import TopBanner from '../components/TopBanner'
import learnStyles from '../styles/Learn.module.css'

Expand All @@ -18,7 +20,6 @@ export const learn = () => {
<Head>
<title>Orcasound</title>
</Head>

<TopBanner
bannerImg={LearnBanner}
pageTitle={`Learn`}
Expand Down Expand Up @@ -113,6 +114,21 @@ export const learn = () => {
educational organizations in the Pudget Sound regions`}
</p>
</div>

<div className={learnStyles.callCatalog}>
<Typography variant="h1" fontSize="44px" align="left" mt={5} mb={3}>
Southern Resident Killer Whale Call Catalog
</Typography>
<Typography variant="p" fontSize="20px" align="left">
Now that you’ve familiarized youself with the 3 most common calls,
dive in to the call catalog to learn the vocalizations you will hear
when listening to the livestreaming hydrophones during orca events.
</Typography>
<br />
<br />
<CallCatalogGrid />
</div>

<div className={learnStyles.org}>
<Image src={organization1} alt="Seattle aquarium exhibit" />
<a href="https://killerwhaletales.org/">
Expand Down
7 changes: 7 additions & 0 deletions src/styles/Learn.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@
text-align: left;
}

.callCatalog {
background-color: #090f2e;
color: white;
padding: 40px 100px;
/* margin: top & bottom depending on sections above and below */
}

.org {
width: 100%;
height: auto;
Expand Down
Loading