Skip to content

Commit

Permalink
fireflies
Browse files Browse the repository at this point in the history
  • Loading branch information
lassejaco committed Jan 2, 2024
1 parent 54aac40 commit 99921f0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
15 changes: 8 additions & 7 deletions devcon/src/components/common/page-hero/PageHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export const PageHero = (props: PageHeroProps) => {
if (props.background) {
style.backgroundImage = `url(${props.background})`
style.backgroundSize = 'cover'
style['-webkit-mask-image'] =
'-webkit-gradient(linear, left 90%, left bottom, from(rgba(0,0,0,1)), to(rgba(0,0,0,0)))'
}

let className = `${css['hero']} margin-bottom`
Expand Down Expand Up @@ -145,13 +147,12 @@ export const PageHero = (props: PageHeroProps) => {

return (
<div id="page-hero" className={className} style={style}>
{/* {props.heroBackground && (
<div className="absolute w-full h-full">
<Image className="h-full w-full object-cover" src={props.heroBackground} alt="Hero background"></Image>
</div>
)} */}

<div className="section">
<div className="section relative h-[50vh]">
{/* {props.heroBackground && (
<div className="absolute w-full h-full">
<Image className="h-full w-full object-contain" src={props.heroBackground} alt="Hero background"></Image>
</div>
)} */}
{/* add to section: h-[50vh] <-- for when bg image is set */}
<div className={css['info']}>
<PathNavigation {...props} />
Expand Down
2 changes: 2 additions & 0 deletions devcon/src/components/common/page-hero/page-hero.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
&.custom-background {
border-bottom: none;

mask-image: linear-gradient(from right, black, transparent);

.path {
// Might be problematic depending on image colors
color: white;
Expand Down
18 changes: 13 additions & 5 deletions devcon/src/components/domain/index/hero/dc7/fireflies.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ class Animation {
return canvas
}

stop = () => {
window.cancelAnimationFrame(this.animationFrameId)
window.removeEventListener('resize', this.resize)
}

draw = () => {
var drawer = this.draw.bind(this)

this.redraw()
window.requestAnimationFrame(drawer)
this.animationFrameId = window.requestAnimationFrame(drawer)
}

redraw = () => {
Expand Down Expand Up @@ -83,7 +88,7 @@ class Firefly {
}

flicker = () => {
if (this.opacity >= 1 || this.opacity <= 0.001) {
if (this.opacity >= 1 || this.opacity <= 0.5) {
this.flare = !this.flare
}

Expand All @@ -104,15 +109,18 @@ function setOpacity(color, opacity) {

export const Fireflies = props => {
React.useEffect(() => {
new Animation(`#${props.id}`, {
const animation = new Animation(`#${props.id}`, {
count: 75,
color: 'rgba(236, 196, 94, 1)',
// color: 'rgba(236, 196, 255, 1)',
speed: 0.2,
radius: 2,
radius: 2.5,
...props.settings,
})

// Cleanup function
return () => {
animation.stop()
}
// new Animation(`#${props.id}`, {
// count: 30,
// color: 'rgba(255, 248, 0, 1)',
Expand Down
8 changes: 5 additions & 3 deletions devcon/src/pages/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@
}

.background-text {
* {
background: rgba(255, 255, 255, 0.7);
}
background: rgba(255, 255, 255, 0.2);
border-radius: 16px;
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
border: 1px solid rgba(255, 255, 255, 0.3)
}

0 comments on commit 99921f0

Please sign in to comment.