Skip to content

Commit

Permalink
Website: small UI tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
quietbits committed Oct 19, 2023
1 parent 4a991c1 commit d17ba4b
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 4 deletions.
18 changes: 14 additions & 4 deletions @stellar/design-system-website/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,16 @@ strong {
font-weight: 600;
}

p {
font-size: 1rem;
}

p,
ul,
ol {
line-height: 1.6;
}

.container {
font-size: 14px;
}

/* Table */
table {
display: table;
Expand Down Expand Up @@ -252,3 +252,13 @@ nav > .menu__list > li > .menu__list-item-collapsible .menu__link {
.table-of-contents__link:hover {
color: var(--ifm-menu-color-active);
}

/* Cards */

.card.padding--lg {
padding: 1rem !important;
}

.card h2 {
margin-bottom: 0.75rem;
}
87 changes: 87 additions & 0 deletions @stellar/design-system-website/src/theme/DocCard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React from "react";
import clsx from "clsx";
// eslint-disable-next-line import/no-unresolved
import Link from "@docusaurus/Link";
import {
findFirstCategoryLink,
useDocById,
} from "@docusaurus/theme-common/internal";
// import isInternalUrl from "@docusaurus/isInternalUrl";
// eslint-disable-next-line import/no-unresolved
import { translate } from "@docusaurus/Translate";
import styles from "./styles.module.css";
function CardContainer({ href, children }) {
return (
<Link
href={href}
className={clsx("card padding--lg", styles.cardContainer)}
>
{children}
</Link>
);
}
function CardLayout({ href, icon, title, description }) {
return (
<CardContainer href={href}>
<h2 className={clsx("text--truncate", styles.cardTitle)} title={title}>
{icon} {title}
</h2>
{description && (
<p
className={clsx("text--truncate", styles.cardDescription)}
title={description}
>
{description}
</p>
)}
</CardContainer>
);
}
function CardCategory({ item }) {
const href = findFirstCategoryLink(item);
// Unexpected: categories that don't have a link have been filtered upfront
if (!href) {
return null;
}
return (
<CardLayout
href={href}
icon={null}
title={item.label}
description={
item.description ??
translate(
{
message: "{count} items",
id: "theme.docs.DocCard.categoryDescription",
description:
"The default description for a category card in the generated index about how many items this category includes",
},
{ count: item.items.length },
)
}
/>
);
}
function CardLink({ item }) {
// const icon = isInternalUrl(item.href) ? '📄️' : '🔗';
const doc = useDocById(item.docId ?? undefined);
return (
<CardLayout
href={item.href}
icon={null}
title={item.label}
description={item.description ?? doc?.description}
/>
);
}
export default function DocCard({ item }) {
switch (item.type) {
case "link":
return <CardLink item={item} />;
case "category":
return <CardCategory item={item} />;
default:
throw new Error(`unknown item type ${JSON.stringify(item)}`);
}
}
27 changes: 27 additions & 0 deletions @stellar/design-system-website/src/theme/DocCard/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.cardContainer {
--ifm-link-color: var(--ifm-color-emphasis-800);
--ifm-link-hover-color: var(--ifm-color-emphasis-700);
--ifm-link-hover-decoration: none;

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

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

.cardContainer *:last-child {
margin-bottom: 0;
}

.cardTitle {
font-size: 1.2rem;
}

.cardDescription {
font-size: 0.8rem;
}

0 comments on commit d17ba4b

Please sign in to comment.