-
Notifications
You must be signed in to change notification settings - Fork 256
⚓ Refresh glossary categories and doc card formatting #2411
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
Open
JFWooten4
wants to merge
10
commits into
stellar:main
Choose a base branch
from
JFWooten4:723-pt-9
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
46fc03c
📝 Inline Hubble desc
JFWooten4 e3e5c41
Add custom doc card formatting
JFWooten4 865dca4
Add fundamentals category descriptions
JFWooten4 61681e5
📝 Internal consistency
JFWooten4 71c18c3
♿ Screen reader
JFWooten4 3307017
📝 Description fetching
JFWooten4 9dc03d5
⚠️ Actionable errors
JFWooten4 a08d9ab
📝 Clean meta
JFWooten4 6c7e368
🎯 Target ≥elements
JFWooten4 32408f5
SEO nit
JFWooten4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
3 changes: 3 additions & 0 deletions
3
docs/data/analytics/hubble/data-catalog/data-dictionary/bronze/_category_.json
This file contains hidden or 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,3 @@ | ||
| { | ||
| "description": "Raw, untransformed data from the Stellar network. For example, history_contract_events contains all Stellar events." | ||
| } |
3 changes: 3 additions & 0 deletions
3
docs/data/analytics/hubble/data-catalog/data-dictionary/gold/_category_.json
This file contains hidden or 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,3 @@ | ||
| { | ||
| "description": "Curated analytics with friendly aggregate tables. For example, tvl_agg aggregates relevant amounts in Stellar events." | ||
| } |
3 changes: 3 additions & 0 deletions
3
docs/data/analytics/hubble/data-catalog/data-dictionary/silver/_category_.json
This file contains hidden or 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,3 @@ | ||
| { | ||
| "description": "Decoded, transformed, and filtered data. For example, token_transfers_raw contains SEP-41-compliant Stellar events." | ||
| } |
This file contains hidden or 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,9 @@ | ||
| { | ||
| "label": "Smart Contracts", | ||
| "position": 84, | ||
| "link": { | ||
| "type": "doc", | ||
| "id": "learn/fundamentals/contract-development/README" | ||
| }, | ||
| "description": "Dive into Soroban smart-contract concepts, lifecycle guidance, and authorization patterns so you can ship production-ready code on Stellar." | ||
| } |
1 change: 1 addition & 0 deletions
1
docs/learn/fundamentals/contract-development/storage/README.mdx
This file contains hidden or 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
8 changes: 8 additions & 0 deletions
8
docs/learn/fundamentals/contract-development/storage/_category_.json
This file contains hidden or 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,8 @@ | ||
| { | ||
| "label": "Storage", | ||
| "position": 10, | ||
| "link": { | ||
| "type": "doc", | ||
| "id": "learn/fundamentals/contract-development/storage/README" | ||
| } | ||
| } |
This file contains hidden or 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,9 @@ | ||
| { | ||
| "label": "Data Format", | ||
| "position": 85, | ||
| "link": { | ||
| "type": "doc", | ||
| "id": "learn/fundamentals/data-format/README" | ||
| }, | ||
| "description": "Understand Stellar's XDR and JSON encodings so you can inspect transactions, debug payloads, and interchange data with other systems." | ||
| } |
9 changes: 9 additions & 0 deletions
9
docs/learn/fundamentals/stellar-data-structures/_category_.json
This file contains hidden or 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,9 @@ | ||
| { | ||
| "label": "Stellar Data Structures", | ||
| "position": 50, | ||
| "link": { | ||
| "type": "doc", | ||
| "id": "learn/fundamentals/stellar-data-structures/README" | ||
| }, | ||
| "description": "Learn how accounts, assets, contracts, events, and ledgers fit together to describe everything living on the Stellar network." | ||
| } |
This file contains hidden or 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,9 @@ | ||
| { | ||
| "label": "Operations & Transactions", | ||
| "position": 60, | ||
| "link": { | ||
| "type": "doc", | ||
| "id": "learn/fundamentals/transactions/README" | ||
| }, | ||
| "description": "Trace how Stellar transactions bundle operations, flow through the network, and unlock asset transfers or contract calls." | ||
| } |
This file contains hidden or 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
This file contains hidden or 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,170 @@ | ||
| import React, {type ReactNode} from "react"; | ||
| import clsx from "clsx"; | ||
| import Link from "@docusaurus/Link"; | ||
| import { | ||
| useDocById, | ||
| useDocsVersion, | ||
| findFirstSidebarItemLink, | ||
| } from "@docusaurus/plugin-content-docs/client"; | ||
| import type { | ||
| PropSidebarItemCategory, | ||
| PropSidebarItemLink, | ||
| } from "@docusaurus/plugin-content-docs"; | ||
| import { usePluralForm } from "@docusaurus/theme-common"; | ||
| import isInternalUrl from "@docusaurus/isInternalUrl"; | ||
| import { translate } from "@docusaurus/Translate"; | ||
|
|
||
| import type { Props } from "@theme/DocCard"; | ||
| import Heading from "@theme/Heading"; | ||
| import styles from "./styles.module.scss"; | ||
|
|
||
| function useCategoryItemsPlural() { | ||
| const { selectMessage } = usePluralForm(); | ||
| return (count: number) => | ||
| selectMessage( | ||
| count, | ||
| translate( | ||
| { | ||
| message: "1 item|{count} items", | ||
| id: "theme.docs.DocCard.categoryDescription.plurals", | ||
| description: | ||
| "Default description for a category card in the generated index about how many items this category includes", | ||
| }, | ||
| { count }, | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| function getStringCustomProp( | ||
| customProps: PropSidebarItemCategory["customProps"], | ||
| key: string, | ||
| ): string | undefined { | ||
| const value = customProps?.[key]; | ||
| return typeof value === "string" ? value : undefined; | ||
| } | ||
|
|
||
| function getCategoryIndexDocIds(href: string | undefined): string[] { | ||
| if (!href || !isInternalUrl(href)) { | ||
| return []; | ||
| } | ||
|
|
||
| const [pathname] = href.split(/[?#]/); | ||
| const pathSegments = pathname.replace(/^\/+|\/+$/g, "").split("/"); | ||
| const docsSegmentIndex = pathSegments.indexOf("docs"); | ||
| const docPathSegments = | ||
| docsSegmentIndex >= 0 | ||
| ? pathSegments.slice(docsSegmentIndex + 1) | ||
| : pathSegments; | ||
| const docPath = docPathSegments.join("/"); | ||
|
|
||
| return docPath ? [`${docPath}/README`, `${docPath}/index`, docPath] : []; | ||
| } | ||
|
|
||
| function CardContainer({ | ||
| className, | ||
| href, | ||
| children, | ||
| }: { | ||
| className?: string; | ||
| href: string; | ||
| children: ReactNode; | ||
| }): ReactNode { | ||
| const linkProps = isInternalUrl(href) ? { to: href } : { href }; | ||
|
|
||
| return ( | ||
| <Link | ||
| {...linkProps} | ||
| className={clsx("card padding--lg", styles.cardContainer, className)} | ||
| > | ||
| {children} | ||
| </Link> | ||
| ); | ||
| } | ||
|
|
||
| function CardLayout({ | ||
| className, | ||
| href, | ||
| icon, | ||
| title, | ||
| description, | ||
| }: { | ||
| className?: string; | ||
| href: string; | ||
| icon: ReactNode; | ||
| title: string; | ||
| description?: string; | ||
| }): ReactNode { | ||
| return ( | ||
| <CardContainer href={href} className={className}> | ||
| <Heading | ||
| as="h2" | ||
| className={clsx("text--truncate", styles.cardTitle)} | ||
| title={title} | ||
| > | ||
| <span aria-hidden="true">{icon}</span> {title} | ||
| </Heading> | ||
|
JFWooten4 marked this conversation as resolved.
|
||
| {description && ( | ||
| <p | ||
| className={styles.cardDescription} | ||
| title={description} | ||
| > | ||
| {description} | ||
| </p> | ||
| )} | ||
| </CardContainer> | ||
| ); | ||
| } | ||
|
|
||
| function CardCategory({ item }: { item: PropSidebarItemCategory }): ReactNode { | ||
| const href = findFirstSidebarItemLink(item); | ||
| const categoryItemsPlural = useCategoryItemsPlural(); | ||
| const { docs } = useDocsVersion(); | ||
| const categoryIndexDoc = getCategoryIndexDocIds(item.href).find( | ||
| (docId) => docs[docId], | ||
| ); | ||
|
|
||
| if (!href) { | ||
| return null; | ||
| } | ||
|
|
||
| const description = | ||
| item.description ?? | ||
| getStringCustomProp(item.customProps, "description") ?? | ||
| docs[categoryIndexDoc ?? ""]?.description ?? | ||
| categoryItemsPlural(item.items.length); | ||
|
|
||
| return ( | ||
| <CardLayout | ||
| className={item.className} | ||
| href={href} | ||
| icon="🗃️" | ||
| title={item.label} | ||
| description={description} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| function CardLink({ item }: { item: PropSidebarItemLink }): ReactNode { | ||
| const icon = isInternalUrl(item.href) ? "📄" : "🔗"; | ||
| const doc = useDocById(item.docId ?? undefined); | ||
| return ( | ||
| <CardLayout | ||
| className={item.className} | ||
| href={item.href} | ||
| icon={icon} | ||
| title={item.label} | ||
| description={item.description ?? doc?.description} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export default function DocCard({ item }: Props): ReactNode { | ||
| switch (item.type) { | ||
| case "link": | ||
| return <CardLink item={item} />; | ||
| case "category": | ||
| return <CardCategory item={item} />; | ||
| default: | ||
| throw new Error(`Unknown DocCard item type: ${item.type}`); | ||
| } | ||
| } | ||
This file contains hidden or 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,36 @@ | ||
| .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 { | ||
| --card-description-lines: 4; | ||
|
|
||
| font-size: 0.8rem; | ||
| white-space: normal; | ||
| overflow-wrap: anywhere; | ||
| display: -webkit-box; | ||
| -webkit-line-clamp: var(--card-description-lines); | ||
| -webkit-box-orient: vertical; | ||
| max-height: calc(1.8em * var(--card-description-lines)); | ||
| overflow: hidden; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.