Skip to content

Commit

Permalink
feat: add poweredby mdx component
Browse files Browse the repository at this point in the history
  • Loading branch information
jeangovil committed Jun 6, 2023
1 parent 7af63d0 commit a993258
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@use '../../../css/utils';
@use '../../../css/lsd';

.mdx-powered-by {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 0 1rem;
}

.mdx-powered-by__card {
display: flex;
flex-direction: column;
align-items: flex-start;
padding: 1.5rem 0;
}

.mdx-powered-by__logo {
height: 40px;
width: auto;
}

.mdx-powered-by__name {
margin-top: 1rem;
}

.mdx-powered-by__description {
margin-top: 1.5rem;
}

.mdx-powered-by__link {
margin-top: 1.5rem;
width: 100%;

button {
width: 100%;

& > span {
display: block;
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
}
}

@include utils.responsive('lg', 'down') {
.mdx-powered-by {
grid-template-columns: 1fr;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { Button, PickIcon, Typography } from '@acid-info/lsd-react'
import { useColorMode } from '@docusaurus/theme-common'
import React from 'react'
import './PoweredBy.scss'

export type PoweredByItem = {
logoSrc?: string
logoSrcDark?: string
name?: React.ReactNode
description?: React.ReactNode
link?: string
linkLabel?: string
}

export type PoweredByProps = React.HTMLProps<HTMLDivElement> & {
items?: PoweredByItem[]
}

export const PoweredBy: React.FC<PoweredByProps> = ({
items = [],
...props
}) => {
const { colorMode } = useColorMode()

return (
<div className="mdx-powered-by">
{items.map((item, index) => {
const logoSrc = item.logoSrc ?? item.logoSrcDark

return (
<div key={index} className="mdx-powered-by__card">
{logoSrc && (
<img
alt={typeof item.name === 'string' ? item.name : ''}
className="mdx-powered-by__logo"
src={
(colorMode === 'dark' ? item.logoSrcDark : item.logoSrc) ??
logoSrc
}
/>
)}
<Typography
component="span"
variant="h5"
className="mdx-powered-by__name"
>
{item.name}
</Typography>
<Typography
variant="subtitle1"
className="mdx-powered-by__description"
>
{item.description}
</Typography>
{item.link && (
<a
href={item.link}
target="_blank"
className="mdx-powered-by__link"
>
<Button size="large" variant="outlined">
<Typography variant="label1" component="span">
{item.linkLabel ?? <>Visit {item.name}</>}
</Typography>
<span>
<PickIcon color="primary" />
</span>
</Button>
</a>
)}
</div>
)
})}
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './PoweredBy'
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export * from './HeroDescription'
export * from './HeroInfo'
export * from './HeroModel'
export * from './HeroTitle'
export * from './PoweredBy'
export * from './ScrollToBottom'
export * from './Showcase'

0 comments on commit a993258

Please sign in to comment.