Skip to content

Commit

Permalink
feat(components): ✨ Add description to Stack component
Browse files Browse the repository at this point in the history
Stack component can show description by hovering the title
  • Loading branch information
mini-mirana committed Mar 9, 2022
1 parent 47ad740 commit 9cbdc34
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 1 deletion.
Binary file added public/sound/ask.mp3
Binary file not shown.
Binary file added public/sound/assemble.mp3
Binary file not shown.
Binary file added public/sound/click.mp3
Binary file not shown.
Binary file added public/sound/error.mp3
Binary file not shown.
Binary file added public/sound/information.mp3
Binary file not shown.
Binary file added public/sound/object.mp3
Binary file not shown.
Binary file added public/sound/readout.mp3
Binary file not shown.
Binary file added public/sound/toggle.mp3
Binary file not shown.
Binary file added public/sound/type.mp3
Binary file not shown.
Binary file added public/sound/warning.mp3
Binary file not shown.
50 changes: 49 additions & 1 deletion src/components/Stack/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@ import { useState, useEffect } from 'react'
import { useThree } from '@react-three/fiber'
import { useAspect /* Html */ } from '@react-three/drei'
import { Flex, Box } from '@react-three/flex'
import Arwes from 'arwes/lib/Arwes'
import Project from 'arwes/lib/Project'
import ThemeProvider from 'arwes/lib/ThemeProvider'
import createTheme from 'arwes/lib/tools/createTheme'
import SoundsProvider from 'arwes/lib/SoundsProvider'
import createSounds from 'arwes/lib/tools/createSounds'
import Words from 'arwes/lib/Words'
import { Text } from '../Text'

export function Stack({ width = 6, height = 4, distance = 8, content = [] }) {
export function Stack({ dom = null, width = 6, height = 4, distance = 8, content = [] }) {
const { size } = useThree()
const [vpWidth, vpHeight] = useAspect(size.width, size.height)

const [hovered, setHovered] = useState(false)

const [clicked, setClicked] = useState(Array(content.length).fill(false))
const [videos] = useState(() => {
return content.reduce((p, c) => {
Expand Down Expand Up @@ -67,6 +76,8 @@ export function Stack({ width = 6, height = 4, distance = 8, content = [] }) {
</Text>
)}
<Text
onPointerEnter={() => setHovered(true)}
onPointerLeave={() => setHovered(false)}
font={c.titleFont}
fontSize={c.titleFontSize}
letterSpacing={0.1}
Expand All @@ -78,6 +89,43 @@ export function Stack({ width = 6, height = 4, distance = 8, content = [] }) {
{c.title}
<meshStandardMaterial color='white' />
</Text>
<dom.In>
<ThemeProvider theme={createTheme()}>
<SoundsProvider
sounds={createSounds({
shared: { volume: 1, disabled: false }, // Shared sound settings
players: {
// The player settings
click: {
// With the name the player is created
sound: { src: ['/sound/click.mp3'] } // The settings to pass to Howler
},
typing: {
sound: { src: ['/sound/type.mp3'] },
settings: { oneAtATime: true } // The custom app settings
},
deploy: {
sound: { src: ['/sound/assemble.mp3'] },
settings: { oneAtATime: true }
}
}
})}>
{hovered && (
<Arwes className='h-fit w-[20%] !left-[60%] !top-[25%]'>
<Project animate header={c.cardTitle} headerSize='h6' className='p-[10px]'>
{(anim) => (
<p>
<Words animate show={anim.entered} className='text-xs'>
{c.description}
</Words>
</p>
)}
</Project>
</Arwes>
)}
</SoundsProvider>
</ThemeProvider>
</dom.In>
</Box>
</Flex>
)}
Expand Down
11 changes: 11 additions & 0 deletions src/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,15 @@
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, helvetica neue, helvetica, ubuntu, roboto, noto,
segoe ui, arial, sans-serif;
}
header[class*="Arwes"] {
padding: 5px;
text-align: center;
}
header[class*="Arwes"] > h1 {
font-size: 10px;
}
div[class*="Arwes-main"]{
overflow-y: clip;
position: relative;
}
}

0 comments on commit 9cbdc34

Please sign in to comment.