Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(theme-classic): clean up CSS of doc cards #6950

Merged
merged 13 commits into from
Mar 25, 2022
21 changes: 12 additions & 9 deletions packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@ function CardContainer({
href,
children,
}: {
href?: string;
href: string;
children: ReactNode;
}): JSX.Element {
const className = clsx(
'card margin-bottom--lg padding--lg',
styles.cardContainer,
href && styles.cardContainerLink,
);
return href ? (
<Link href={href} className={className}>
{children}
</Link>
) : (
<div className={className}>{children}</div>
return (
<article className="col col--6">
<Link href={href} className={className}>
{children}
</Link>
</article>
);
}

Expand All @@ -49,7 +48,11 @@ function CardLayout({
icon: ReactNode;
title: string;
description?: string;
}): JSX.Element {
}): JSX.Element | null {
if (!href) {
lex111 marked this conversation as resolved.
Show resolved Hide resolved
return null;
}

return (
<CardContainer href={href}>
<h2 className={clsx('text--truncate', styles.cardTitle)} title={title}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,25 @@
*/

.cardContainer {
height: 8rem;
color: var(--ifm-color-emphasis-800);
--ifm-link-color: var(--ifm-color-emphasis-800);
--ifm-link-hover-color: var(--ifm-color-emphasis-800);
--ifm-link-hover-color: var(--ifm-color-emphasis-700);
--ifm-link-hover-decoration: none;

/* box-shadow: var(--ifm-global-shadow-lw); */
box-shadow: 0 1.5px 3px 0 rgb(0 0 0 / 15%);
border: 1px solid var(--ifm-color-emphasis-200);
transition: box-shadow var(--ifm-transition-fast) ease,
background-color var(--ifm-transition-fast) ease;
transition: all var(--ifm-transition-fast) ease;
transition-property: border, box-shadow;
}

.cardContainer.cardContainerLink:hover {
/* box-shadow: var(--ifm-global-shadow-md); */
box-shadow: 0 4px 8px 0 rgb(0 0 0 / 20%);
}

[data-theme='dark'] .cardContainer.cardContainerLink:hover {
--ifm-card-background-color: #2d2d2d; /* original, non-hovered color is #242526 */
}

.cardContainer:not(.cardContainerLink) {
cursor: not-allowed;
.cardContainer:hover {
border-color: var(--ifm-color-primary);
box-shadow: 0 3px 6px 0 rgb(0 0 0 / 20%);
}

.cardTitle {
font-size: 1.2rem;
min-height: 1.2rem;
}

.cardDescription {
font-size: 0.8rem;
min-height: 0.8rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export default function DocCardList({
return (
<div className="row">
{items.map((item, index) => (
<article key={index} className="col col--6">
lex111 marked this conversation as resolved.
Show resolved Hide resolved
<DocCard item={item} />
</article>
<DocCard key={index} item={item} />
))}
</div>
);
Expand Down