-
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.
feat: implement LogoCarousel component
- Loading branch information
Showing
4 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
packages/logos-docusaurus-theme/src/client/components/mdx/LogoCarousel/LogoCarousel.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,33 @@ | ||
@use '../../../css/utils'; | ||
@use '../../../css/lsd'; | ||
|
||
.mdx-logo-carousel { | ||
.mdx-section-header__title { | ||
flex-basis: 100%; | ||
} | ||
|
||
.mdx-section-header__extra { | ||
margin-left: auto; | ||
} | ||
|
||
.mdx-logo-carousel__inner { | ||
margin-top: 100px; | ||
} | ||
|
||
.mdx-logo-carousel__item { | ||
flex-shrink: 0; | ||
} | ||
|
||
.mdx-logo-carousel__logo { | ||
height: 86px; | ||
width: auto; | ||
} | ||
} | ||
|
||
@include utils.responsive('lg', 'down') { | ||
.mdx-logo-carousel { | ||
.mdx-logo-carousel__inner { | ||
margin-top: 64px; | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/logos-docusaurus-theme/src/client/components/mdx/LogoCarousel/LogoCarousel.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,64 @@ | ||
import { Typography } from '@acid-info/lsd-react' | ||
import ThemedImage from '@theme/ThemedImage' | ||
import clsx from 'clsx' | ||
import React, { useRef } from 'react' | ||
import './LogoCarousel.scss' | ||
import { Grid, SectionHeader } from '..' | ||
import { ScrollButtons } from '../ScrollButtons' | ||
import { useHydrated } from '../../../lib/useHydrated' | ||
|
||
export type LogoCarouselProps = Omit< | ||
React.HTMLAttributes<HTMLDivElement>, | ||
'title' | ||
> & { | ||
title?: React.ReactNode | ||
items?: { | ||
title?: string | ||
logoSrc?: string | ||
logoSrcDark?: string | ||
}[] | ||
} | ||
|
||
export const LogoCarousel: React.FC<LogoCarouselProps> = ({ | ||
title, | ||
className, | ||
items = [], | ||
children, | ||
...props | ||
}) => { | ||
const hydrated = useHydrated() | ||
const ref = useRef<HTMLDivElement>(null) | ||
const containerRef = useRef<HTMLElement | null>(null) | ||
|
||
if (typeof window !== 'undefined' && hydrated && !containerRef.current) { | ||
containerRef.current = | ||
ref.current?.querySelector('.mdx-grid__content') ?? null | ||
|
||
console.log(containerRef.current, ref.current) | ||
} | ||
|
||
return ( | ||
<div ref={ref} className={clsx(className, 'mdx-logo-carousel')} {...props}> | ||
<SectionHeader title={title}> | ||
<ScrollButtons containerRef={containerRef} /> | ||
</SectionHeader> | ||
<Grid | ||
className="mdx-logo-carousel__inner" | ||
xs={{ wrap: false, gap: '96px', scrollButtons: false }} | ||
> | ||
{items.map((item) => ( | ||
<Grid.Item className="mdx-logo-carousel__item"> | ||
<ThemedImage | ||
className="mdx-logo-carousel__logo" | ||
title={item.title} | ||
sources={{ | ||
dark: item.logoSrcDark ?? item.logoSrc ?? '', | ||
light: item.logoSrc ?? item.logoSrcDark ?? '', | ||
}} | ||
/> | ||
</Grid.Item> | ||
))} | ||
</Grid> | ||
</div> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
packages/logos-docusaurus-theme/src/client/components/mdx/LogoCarousel/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 './LogoCarousel' |
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