forked from smartcontractkit/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/93 layout tutorials #104
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
dc3b24d
add tutorial foundation
tyrelchambers 247a27c
Add tutorial components
tyrelchambers 8d3a66e
add README
tyrelchambers df85835
support N number of columns and add arrow icon
tyrelchambers 3260710
Update index.astro
tyrelchambers f681b91
remove unused import
tyrelchambers be5128b
Update GridCard.module.css
tyrelchambers 98818b0
change how we add borders
tyrelchambers 6ba9de7
make grid responsive
tyrelchambers 59daf7d
Merge branch 'dev-3.0' into feat/93-layout-tutorials
Zelig880 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,41 @@ | ||
| .card { | ||
| display: flex; | ||
| background: var(--color-background); | ||
| padding: var(--space-6x); | ||
| align-items: start; | ||
| gap: var(--space-6x); | ||
|
|
||
| &:hover .cardFooter { | ||
| opacity: 1; | ||
| } | ||
| } | ||
|
|
||
| .card:hover { | ||
| background-color: var(--muted); | ||
| } | ||
|
|
||
| .cardFooter { | ||
| opacity: 0; | ||
| margin-top: auto; | ||
| /* enforcing a width */ | ||
| min-width: 16px; | ||
| } | ||
|
|
||
| .cardFooter img { | ||
| width: 10px; | ||
| height: 10px; | ||
| } | ||
|
|
||
| .cardTitle { | ||
| font-size: 16px; | ||
| font-weight: 525; | ||
| color: var(--foreground); | ||
| margin-bottom: var(--space-2x); | ||
| } | ||
|
|
||
| .cardDescription { | ||
| color: var(--color-text-secondary); | ||
| font-size: 0.9375rem; | ||
| line-height: 1.6; | ||
| margin: 0; | ||
| } |
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,41 @@ | ||
| import { Typography } from "@chainlink/blocks" | ||
| import styles from "./GridCard.module.css" | ||
|
|
||
| export interface GridItem { | ||
| title: string | ||
| description: string | ||
| link: string | ||
| columns?: number | ||
| index?: number | ||
| } | ||
|
|
||
| export const GridCard = ({ title, description, link, columns = 3, index = 0 }: GridItem) => { | ||
| // Calculate position in grid | ||
| const row = Math.floor(index / columns) | ||
| const col = index % columns | ||
| const isFirstRow = row === 0 | ||
| const isFirstColumn = col === 0 | ||
|
|
||
| // Dynamic border styles | ||
| const borderStyle: React.CSSProperties = { | ||
| borderTop: isFirstRow ? "1px solid var(--border)" : undefined, | ||
| borderLeft: isFirstColumn ? "1px solid var(--border)" : undefined, | ||
| borderRight: "1px solid var(--border)", | ||
| borderBottom: "1px solid var(--border)", | ||
| } | ||
|
|
||
| return ( | ||
| <a href={link} className={styles.card} style={borderStyle}> | ||
| <div> | ||
| <h3 className={styles.cardTitle}>{title}</h3> | ||
tyrelchambers marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <Typography variant="body-s" style={{ lineHeight: "24px" }}> | ||
| {description} | ||
| </Typography> | ||
| </div> | ||
|
|
||
| <div className={styles.cardFooter}> | ||
| <img src="/assets/icons/upper-right-arrow.svg" alt="arrow" /> | ||
| </div> | ||
| </a> | ||
| ) | ||
| } | ||
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,17 @@ | ||
| import { GridCard, GridItem } from "./GridCard.tsx" | ||
| import styles from "./TabGrid.module.css" | ||
|
|
||
| interface ItemGridProps { | ||
| links: GridItem[] | ||
| columns?: number | ||
| } | ||
|
|
||
| export const ItemGrid = ({ links, columns = 3 }: ItemGridProps) => { | ||
| return ( | ||
| <div className={styles.grid} style={{ gridTemplateColumns: `repeat(${columns}, 1fr)` }}> | ||
| {links.map((link, index) => ( | ||
| <GridCard key={`${link.title}-${index}`} {...link} columns={columns} index={index} /> | ||
tyrelchambers marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ))} | ||
| </div> | ||
| ) | ||
| } | ||
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,89 @@ | ||
| # TabGrid Component | ||
|
|
||
| A tabbed interface for displaying grid items organized by category. | ||
|
|
||
| ## What is this? | ||
|
|
||
| The TabGrid component displays a collection of items in a clean, organized layout with tabs. Each tab represents a category of items (like "EVM" or "Solana"), and clicking on a tab shows the relevant items as clickable cards. | ||
|
|
||
| This component is useful when you have multiple items and want to group them by topic or category, making it easier for users to find what they need. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```tsx | ||
| import { TabGrid } from "@components/TabGrid/TabGrid" | ||
| ;<TabGrid | ||
| header="Tutorials" | ||
| tabs={[ | ||
| { | ||
| name: "Getting Started", | ||
| links: [ | ||
| { | ||
| title: "Quick Start Guide", | ||
| description: "Learn the basics in 5 minutes", | ||
| link: "/docs/quickstart", | ||
| }, | ||
| { | ||
| title: "Installation", | ||
| description: "Set up your development environment", | ||
| link: "/docs/installation", | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| name: "Advanced", | ||
| links: [ | ||
| { | ||
| title: "Architecture Overview", | ||
| description: "Understand the system design", | ||
| link: "/docs/architecture", | ||
| }, | ||
| ], | ||
| }, | ||
| ]} | ||
| /> | ||
| ``` | ||
|
|
||
| ## How to set it up | ||
|
|
||
| The component requires a `tabs` prop, which is an array of tab objects. Each tab object contains: | ||
|
|
||
| - A **name** (the label shown on the tab button) | ||
| - A list of **links** (the items shown when that tab is active) | ||
|
|
||
| Each grid item needs three pieces of information: | ||
|
|
||
| - **title** - The name of the item | ||
| - **description** - A short sentence explaining what the item covers | ||
| - **link** - The URL where the item can be found | ||
|
|
||
| ## Props Reference | ||
|
|
||
| ### `TabGrid` | ||
|
|
||
| | Prop | Type | Required | Description | | ||
| | --------- | -------- | -------- | ------------------------------------------------- | | ||
| | `header` | `string` | Yes | The heading text displayed above the tabs | | ||
| | `tabs` | `Tab[]` | Yes | List of tabs, each containing a category of items | | ||
| | `columns` | `number` | No | Number of columns in the grid (defaults to 2) | | ||
|
|
||
| ### `Tab` | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | -------- | ------------ | -------- | -------------------------------------------------------- | | ||
| | `name` | `string` | Yes | The label displayed on the tab (e.g., "Getting Started") | | ||
| | `links` | `GridItem[]` | Yes | The list of items to show when this tab is selected | | ||
|
|
||
| ### `GridItem` | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | ------------- | -------- | -------- | -------------------------------------------- | | ||
| | `title` | `string` | Yes | The item's heading | | ||
| | `description` | `string` | Yes | A brief explanation of what users will learn | | ||
| | `link` | `string` | Yes | The URL path to the item page | | ||
|
|
||
| ## Components | ||
|
|
||
| - **TabGrid** - Main container with tabs and header | ||
| - **ItemGrid** - Grid layout for item cards | ||
| - **GridCard** - Individual item card with hover effects |
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,45 @@ | ||
| .grid { | ||
| display: grid; | ||
| } | ||
|
|
||
| .tutorialHeader { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| margin-bottom: var(--space-8x); | ||
| } | ||
|
|
||
| .tabsTrigger { | ||
| height: 32px; | ||
| padding: var(--space-1x) var(--space-2x); | ||
| justify-content: center; | ||
| align-items: center; | ||
| border-radius: var(--space-2x); | ||
| background-color: var(--pill); | ||
| border: 1px solid var(--pill-border); | ||
| } | ||
|
|
||
| .tabsTrigger:hover { | ||
| background-color: var(--pill-hover); | ||
| } | ||
|
|
||
| .tabsTrigger[data-state="active"] { | ||
| background-color: var(--pill-active); | ||
| border-color: var(--pill-active); | ||
|
|
||
| & p { | ||
| color: var(--pill-active-foreground); | ||
| } | ||
| } | ||
|
|
||
| .tabsList { | ||
| display: flex; | ||
| gap: var(--space-2x); | ||
| border-bottom: 0; | ||
| } | ||
|
|
||
| @media (max-width: 768px) { | ||
| .grid { | ||
| grid-template-columns: 1fr; | ||
| } | ||
| } |
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,40 @@ | ||
| import styles from "./TabGrid.module.css" | ||
| import { GridItem } from "./GridCard.tsx" | ||
| import { ItemGrid } from "./ItemGrid.tsx" | ||
| import { Tabs, TabsContent, TabsList, TabsTrigger, Typography } from "@chainlink/blocks" | ||
|
|
||
| export interface Tab { | ||
| name: string | ||
| links: GridItem[] | ||
| } | ||
|
|
||
| interface TabGridProps { | ||
| tabs: Tab[] | ||
| header: string | ||
| columns?: number | ||
| } | ||
|
|
||
| export const TabGrid = ({ tabs, header, columns }: TabGridProps) => { | ||
| return ( | ||
| <Tabs defaultValue={tabs[0].name}> | ||
| <header className={styles.tutorialHeader}> | ||
| <Typography variant="h2">{header}</Typography> | ||
| <TabsList className={styles.tabsList}> | ||
| {tabs.map((tab) => ( | ||
| <TabsTrigger key={tab.name} value={tab.name} className={styles.tabsTrigger}> | ||
| <Typography variant="body-s">{tab.name}</Typography> | ||
tyrelchambers marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </TabsTrigger> | ||
| ))} | ||
| </TabsList> | ||
| </header> | ||
|
|
||
| {tabs.map((tab) => ( | ||
| <TabsContent key={tab.name} value={tab.name}> | ||
| <div className={styles.tutorialSection}> | ||
| <ItemGrid links={tab.links} columns={columns} /> | ||
| </div> | ||
| </TabsContent> | ||
| ))} | ||
| </Tabs> | ||
| ) | ||
| } | ||
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
Oops, something went wrong.
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.