diff --git a/packages/logos-docusaurus-theme/src/client/components/KeepRatio/KeepRatio.module.scss b/packages/logos-docusaurus-theme/src/client/components/KeepRatio/KeepRatio.module.scss new file mode 100644 index 0000000..503d34a --- /dev/null +++ b/packages/logos-docusaurus-theme/src/client/components/KeepRatio/KeepRatio.module.scss @@ -0,0 +1,38 @@ +.root { + position: relative; + display: inline-block; + font-size: 0 !important; + + &.fullWidth { + width: 100%; + height: auto; + } + + &.fullHeight { + width: auto; + height: 100%; + } + + .content { + top: 0; + left: 0; + width: 100%; + height: 100%; + position: absolute; + } + + &:not(.keep) { + .root { + height: auto; + width: auto; + } + + .content { + position: relative; + top: unset; + left: unset; + width: 100%; + height: 100%; + } + } +} diff --git a/packages/logos-docusaurus-theme/src/client/components/KeepRatio/KeepRatio.tsx b/packages/logos-docusaurus-theme/src/client/components/KeepRatio/KeepRatio.tsx new file mode 100644 index 0000000..7ccb107 --- /dev/null +++ b/packages/logos-docusaurus-theme/src/client/components/KeepRatio/KeepRatio.tsx @@ -0,0 +1,77 @@ +import clsx from 'clsx' +import React from 'react' +import styles from './KeepRatio.module.scss' + +export const KeepRatio: React.FC< + React.PropsWithChildren<{ + width: number + height: number + fullWidth?: boolean + fullHeight?: boolean + rootProps?: React.DetailedHTMLProps< + React.HTMLAttributes, + HTMLDivElement + > + contentProps?: React.DetailedHTMLProps< + React.HTMLAttributes, + HTMLDivElement + > + + keep?: boolean + containerWidth?: number | string + containerHeight?: number | string + }> +> = ({ + children, + width, + height, + fullHeight: _fullHeight = false, + fullWidth: _fullWidth = true, + rootProps, + contentProps, + containerWidth, + containerHeight, + keep = true, +}) => { + const fullWidth = !_fullHeight && _fullWidth + const fullHeight = !fullWidth + const ratio = (fullHeight ? height / width : width / height) * 100 + + return ( +
+
+ {children} +
+ {keep && ( + + )} +
+ ) +} diff --git a/packages/logos-docusaurus-theme/src/client/components/KeepRatio/index.ts b/packages/logos-docusaurus-theme/src/client/components/KeepRatio/index.ts new file mode 100644 index 0000000..9a7d0c2 --- /dev/null +++ b/packages/logos-docusaurus-theme/src/client/components/KeepRatio/index.ts @@ -0,0 +1 @@ +export * from './KeepRatio' diff --git a/packages/logos-docusaurus-theme/src/client/components/mdx/ExternalResourceCard/ExternalResourceCard.scss b/packages/logos-docusaurus-theme/src/client/components/mdx/ExternalResourceCard/ExternalResourceCard.scss new file mode 100644 index 0000000..1f0c440 --- /dev/null +++ b/packages/logos-docusaurus-theme/src/client/components/mdx/ExternalResourceCard/ExternalResourceCard.scss @@ -0,0 +1,90 @@ +@use '../../../css/utils'; +@use '../../../css/lsd'; + +.mdx-erc { + display: flex; + flex-direction: row; + align-items: flex-start; + border: 1px solid rgb(var(--lsd-border-primary)); + text-decoration: none !important; + min-height: 144px; +} + +.mdx-erc__icon { + padding: 16px 16px 16px 8px; +} + +.mdx-erc__inner { + flex-grow: 1; + padding: 16px; +} + +.mdx-erc:hover { + .mdx-erc__title { + text-decoration: underline !important; + } +} + +.mdx-erc__logo { + width: 32px !important; + height: 32px !important; + + svg { + width: 32px !important; + height: 32px !important; + } +} + +.mdx-erc__title { + margin-top: 32px; + overflow: hidden; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + max-height: calc(2 * var(--lsd-body1-lineHeight)); +} + +.mdx-erc__description { + margin-top: 8px; +} + +.mdx-erc--with-preview { + display: flex; + flex-direction: column; + + .mdx-erc__preview-image { + width: 100%; + height: 100%; + object-fit: cover; + border-bottom: 1px solid rgb(var(--lsd-border-primary)); + } + + .mdx-erc__icon { + display: none; + } + + .mdx-erc__inner { + padding: 16px; + display: grid; + gap: 0 16px; + grid-template-columns: 32px auto; + grid-template-rows: auto auto; + } + + .mdx-erc__logo { + grid-column: 1; + grid-row: 1 / span 2; + align-self: center; + } + + .mdx-erc__title { + margin-top: 0; + -webkit-line-clamp: 1; + -webkit-box-orient: vertical; + max-height: calc(1 * var(--lsd-body1-lineHeight)); + } + + .mdx-erc__description { + margin-top: 4px; + } +} diff --git a/packages/logos-docusaurus-theme/src/client/components/mdx/ExternalResourceCard/ExternalResourceCard.tsx b/packages/logos-docusaurus-theme/src/client/components/mdx/ExternalResourceCard/ExternalResourceCard.tsx new file mode 100644 index 0000000..2fdaa2b --- /dev/null +++ b/packages/logos-docusaurus-theme/src/client/components/mdx/ExternalResourceCard/ExternalResourceCard.tsx @@ -0,0 +1,83 @@ +import { Typography } from '@acid-info/lsd-react' +import ThemedImage from '@theme/ThemedImage' +import clsx from 'clsx' +import React from 'react' +import { IconExternalLink } from '../../Icon' +import './ExternalResourceCard.scss' +import { KeepRatio } from '../../KeepRatio' + +export type ExternalResourceCardProps = Omit< + React.HTMLProps, + 'title' +> & { + logoSrc?: string + logoSrcDark?: string + title?: React.ReactNode + description?: React.ReactNode + previewSrc?: string + previewSrcDark?: string +} + +export const ExternalResourceCard: React.FC = ({ + title, + logoSrc, + logoSrcDark, + description, + previewSrc, + previewSrcDark, + ...props +}) => { + const withPreview = !!(previewSrc || previewSrcDark) + + return ( + + {withPreview && ( + + + + )} +
+ {(logoSrc || logoSrcDark) && ( + + )} + + {title} + + {description && ( + + {description} + + )} +
+
+ +
+
+ ) +} diff --git a/packages/logos-docusaurus-theme/src/client/components/mdx/ExternalResourceCard/index.ts b/packages/logos-docusaurus-theme/src/client/components/mdx/ExternalResourceCard/index.ts new file mode 100644 index 0000000..da291d3 --- /dev/null +++ b/packages/logos-docusaurus-theme/src/client/components/mdx/ExternalResourceCard/index.ts @@ -0,0 +1 @@ +export * from './ExternalResourceCard' diff --git a/packages/logos-docusaurus-theme/src/client/components/mdx/index.ts b/packages/logos-docusaurus-theme/src/client/components/mdx/index.ts index 0e8796e..6646347 100644 --- a/packages/logos-docusaurus-theme/src/client/components/mdx/index.ts +++ b/packages/logos-docusaurus-theme/src/client/components/mdx/index.ts @@ -3,6 +3,7 @@ export * from './Box' export * from './CallToActionButton' export * from './CallToActionSection' export * from './DocMetadata' +export * from './ExternalResourceCard' export * from './FeatureList' export * from './Grid' export * from './Hero'