-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
219 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/logos-docusaurus-theme/src/client/components/mdx/Hero/Hero.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
packages/logos-docusaurus-theme/src/client/components/mdx/HeroActions/HeroActions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 3 additions & 7 deletions
10
packages/logos-docusaurus-theme/src/client/components/mdx/HeroInfo/HeroInfo.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
@use '../../../css/utils'; | ||
|
||
.mdx-hero-info { | ||
padding: var(--logos-hero-info-padding-bottom) 0 | ||
var(--logos-hero-info-padding-bottom) 0; | ||
height: var(--logos-hero-info-height); | ||
padding: 32px 0; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
justify-content: end; | ||
|
||
border-bottom: 1px solid rgb(var(--lsd-surface-secondary)); | ||
margin-bottom: calc(100vh - var(--logos-hero-info-height)); | ||
|
||
transition: margin-bottom 0.05s ease-in-out; | ||
} | ||
|
||
.mdx-hero-info--large { | ||
} | ||
|
||
@include utils.responsive('lg', 'down') { | ||
:root { | ||
//--logos-hero-info-height: 340px; | ||
.mdx-hero-info { | ||
padding: 24px 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
packages/logos-docusaurus-theme/src/client/components/mdx/HeroVideo/HeroVideo.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
@use '../../../css/utils'; | ||
|
||
.mdx-hero-video { | ||
display: grid; | ||
grid-template-rows: 1fr; | ||
grid-template-columns: 1fr; | ||
|
||
pointer-events: none; | ||
|
||
--hero-video-scale: 58%; | ||
--hero-video-offset-y: -10%; | ||
--hero-video-scale-mobile: 117.8%; | ||
--hero-video-offset-y-mobile: -10%; | ||
|
||
& > * { | ||
grid-row: 1 / 1; | ||
grid-column: 1 / 1; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
transform: translateY(var(--hero-video-offset-y)); | ||
|
||
max-width: 100%; | ||
height: 100%; | ||
width: auto; | ||
} | ||
|
||
.mdx-hero-video__placeholder { | ||
opacity: 0; | ||
visibility: hidden; | ||
} | ||
|
||
img, | ||
video { | ||
width: 100%; | ||
height: auto; | ||
transform: scale(var(--hero-video-scale)); | ||
margin-left: calc((var(--hero-video-scale) - 100%) * -1); | ||
transform-origin: top left; | ||
} | ||
} | ||
|
||
.mdx-hero-video--loading { | ||
.mdx-hero-video__video { | ||
opacity: 0; | ||
visibility: hidden; | ||
} | ||
|
||
.mdx-hero-video__placeholder { | ||
opacity: 1; | ||
visibility: visible; | ||
} | ||
} | ||
|
||
@include utils.responsive('lg', 'down') { | ||
.mdx-hero-video { | ||
> * { | ||
transform: translateY(var(--hero-video-offset-y-mobile)); | ||
} | ||
|
||
img, | ||
video { | ||
width: 100%; | ||
transform: scale(var(--hero-video-scale-mobile)); | ||
margin-left: calc((var(--hero-video-scale-mobile) - 100%) * -1); | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
packages/logos-docusaurus-theme/src/client/components/mdx/HeroVideo/HeroVideo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import clsx from 'clsx' | ||
import React, { PropsWithChildren, useEffect, useRef, useState } from 'react' | ||
import { makeStyle } from '../../../lib/makeStyle' | ||
import { settle } from '../../../lib/settle' | ||
import { useHero } from '../Hero/Hero.context' | ||
import './HeroVideo.scss' | ||
|
||
export type HeroVideoStyle = { | ||
scale?: string | ||
offsetY?: string | ||
} | ||
|
||
export type HeroVideoProps = PropsWithChildren< | ||
React.HTMLAttributes<HTMLDivElement> | ||
> & { | ||
placeholderSrc: string | ||
desktop?: HeroVideoStyle | ||
mobile?: HeroVideoStyle | ||
} | ||
|
||
export const HeroVideo: React.FC<HeroVideoProps> = ({ | ||
placeholderSrc, | ||
desktop, | ||
mobile, | ||
className, | ||
style = {}, | ||
children, | ||
...props | ||
}) => { | ||
const ctx = useHero() | ||
const ref = useRef<HTMLVideoElement>(null) | ||
const [loading, setLoading] = useState(true) | ||
|
||
const play = async () => { | ||
const el = ref.current | ||
if (!el) return | ||
|
||
await settle(() => el.play()) | ||
} | ||
|
||
const onCanPlay = async () => { | ||
loading && setLoading(false) | ||
await play() | ||
} | ||
|
||
const onEnded = async () => { | ||
await play() | ||
} | ||
|
||
return ( | ||
<> | ||
<div | ||
className={clsx( | ||
className, | ||
'mdx-hero-video', | ||
loading && 'mdx-hero-video--loading', | ||
)} | ||
style={makeStyle( | ||
{ ...style }, | ||
{ | ||
'hero-video-scale': desktop?.scale ?? '58%', | ||
'hero-video-offset-y': desktop?.offsetY ?? '-10%', | ||
'hero-video-scale-mobile': mobile?.scale ?? '117.8%', | ||
'hero-video-offset-y-desktop': mobile?.offsetY ?? '-10%', | ||
}, | ||
)} | ||
{...(props as any)} | ||
> | ||
<div className="mdx-hero-video__placeholder"> | ||
<img src={placeholderSrc} alt="" /> | ||
</div> | ||
<div className="mdx-hero-video__video"> | ||
<video | ||
muted | ||
autoPlay | ||
onEnded={onEnded} | ||
onCanPlay={onCanPlay} | ||
ref={ref} | ||
> | ||
{children} | ||
</video> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
packages/logos-docusaurus-theme/src/client/components/mdx/HeroVideo/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './HeroVideo' |
Oops, something went wrong.