forked from smartcontractkit/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/91 layout hero #103
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
Feat/91 layout hero #103
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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.
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,45 @@ | ||
| --- | ||
| import { buttonVariants, Typography } from "@chainlink/blocks" | ||
| import styles from "./LayoutHero.module.css" | ||
|
|
||
| interface Props { | ||
| title: string | ||
| description: string | ||
| buttons: Array<{ | ||
| label: string | ||
| link: string | ||
| }> | ||
| image: string | ||
| } | ||
|
|
||
| const { title, description, buttons = [], image } = Astro.props as Props | ||
| --- | ||
|
|
||
| <section class={styles.layoutHero}> | ||
| <div class={styles.heroContentWrapper}> | ||
| <div class={styles.heroContent}> | ||
| <h2 class={styles.heroTitle}>{title}</h2> | ||
| <Typography variant="body-s" color="muted">{description}</Typography> | ||
| <div class={styles.heroButtons}> | ||
| { | ||
| buttons.map((button, index) => ( | ||
| <a | ||
| href={button.link} | ||
| class={buttonVariants({ | ||
| variant: index === 0 ? "primary" : "tertiary", | ||
| size: "sm", | ||
| })} | ||
| > | ||
| {button.label} | ||
| </a> | ||
| )) | ||
| } | ||
| </div> | ||
| </div> | ||
| <div class={styles.heroImage}> | ||
| <img src={image} alt={title} /> | ||
| </div> | ||
| </div> | ||
|
|
||
| <img class={styles.heroBackgroundImg} src="/images/ccip/ccip-hero-bg.png" /> | ||
| </section> | ||
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,64 @@ | ||
| .layoutHero { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: var(--space-8x); | ||
| margin: 0 auto; | ||
| background-color: var(--gray-100); | ||
| position: relative; | ||
| width: 100%; | ||
| height: 345px; | ||
| border-left: 1px solid var(--border); | ||
| border-right: 1px solid var(--border); | ||
| border-bottom: 1px solid var(--border); | ||
| } | ||
|
|
||
| .heroContent { | ||
| display: flex; | ||
| flex-direction: column; | ||
| padding-left: 55px; | ||
| width: 100%; | ||
| height: 100%; | ||
| justify-content: center; | ||
| max-width: 540px; | ||
| } | ||
|
|
||
| .heroContentWrapper { | ||
| display: flex; | ||
| position: relative; | ||
| z-index: 2; | ||
| width: 100%; | ||
| height: 100%; | ||
| } | ||
|
|
||
| .heroBackgroundImg { | ||
| position: absolute; | ||
| right: 0; | ||
| z-index: 1; | ||
| } | ||
| .heroTitle { | ||
| font-size: 3rem; | ||
| line-height: 50px; | ||
| color: var(--gray-950); | ||
| margin-bottom: var(--space-3x); | ||
| letter-spacing: -0.48px; | ||
| font-weight: 400; | ||
| } | ||
|
|
||
| .heroButtons { | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| gap: var(--space-4x); | ||
| margin-top: var(--space-8x); | ||
| } | ||
|
|
||
| .heroImage { | ||
| display: flex; | ||
| position: absolute; | ||
| bottom: 35px; | ||
| right: 0; | ||
| } | ||
|
|
||
| .heroImage img { | ||
| max-width: 100%; | ||
| height: auto; | ||
| } |
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,84 @@ | ||
| # LayoutHero Component | ||
|
|
||
| ## What is it? | ||
|
|
||
| The LayoutHero component is a reusable hero section that displays a title, description, call-to-action buttons, and an optional image. It's perfect for landing pages or the top of important pages where you want to grab attention and guide users to take action. | ||
|
|
||
| ## How to Use It | ||
|
|
||
| ### Basic Usage | ||
|
|
||
| To use the LayoutHero component in your page, you'll need to import it and provide some information: | ||
|
|
||
| ```astro | ||
| --- | ||
| import { LayoutHero } from "@components" | ||
| --- | ||
|
|
||
| <LayoutHero | ||
| title="Welcome to Our Documentation" | ||
| description="Learn how to build amazing applications with our platform" | ||
| buttons={[ | ||
| { label: "Get Started", link: "/quickstart" }, | ||
| { label: "View Documentation", link: "/docs" }, | ||
| ]} | ||
| image="/images/hero-image.png" | ||
| /> | ||
| ``` | ||
|
|
||
| ### What Each Part Does | ||
|
|
||
| **title** (Required) | ||
|
|
||
| - This is the main heading that appears at the top | ||
| - Make it clear and attention-grabbing | ||
| - Example: "Welcome to Chainlink Docs" | ||
|
|
||
| **description** (Required) | ||
|
|
||
| - A short paragraph explaining what this page or section is about | ||
| - Keep it concise but informative | ||
| - Example: "Learn how to connect your smart contracts to real-world data" | ||
|
|
||
| **buttons** (Required) | ||
|
|
||
| - An array of buttons that link to other pages | ||
| - Each button needs two things: | ||
| - `label`: The text shown on the button | ||
| - `link`: Where the button takes you when clicked | ||
| - The first button will be blue (primary action) | ||
| - The second button will be white (secondary action) | ||
| - You can have 0, 1, or 2 buttons | ||
|
|
||
| **image** (Required) | ||
|
|
||
| - The path to an image file you want to display | ||
| - The image appears on the right side on larger screens | ||
| - Below the text on mobile devices | ||
| - Example: "/images/my-hero-image.png" | ||
|
|
||
| ## Examples | ||
|
|
||
| ### With Only One Button | ||
|
|
||
| ```astro | ||
| <LayoutHero | ||
| title="Start Building Today" | ||
| description="Get started with our comprehensive guides and tutorials" | ||
| buttons={[{ label: "Get Started", link: "/quickstart" }]} | ||
| /> | ||
| ``` | ||
|
|
||
| ### With Image and Two Buttons | ||
|
|
||
| ```astro | ||
| <LayoutHero | ||
| title="CCIP Cross-Chain Protocol" | ||
| description="Send tokens and messages across blockchains securely and reliably" | ||
| buttons={[ | ||
| { label: "Try CCIP", link: "/ccip/getting-started" }, | ||
| { label: "Learn More", link: "/ccip/concepts" }, | ||
| ]} | ||
| image="/images/ccip-hero.png" | ||
| /> | ||
| ``` |
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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not be using a block button?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way that they look to be used in the UI is as links. Being semantically correct, should we not use anchors with button styling (for navigating) rather than buttons? I think doing would be inconsequential compared to doing it this way. let me know what you think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you said is actually correct, but the solution for that is different.
The "button component" as an "asChild" property, that will allow it to use the Child element: https://blocks.chain.link/?path=/docs/blocks-button--docs
So for example if I do
<BlockButton asChild><a></a></BlockButton>It will not render the Button but just apply the style to the Anchor tag!
(this is a common practice also in shadCn)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! That results in less code too so I will do it that way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bug with the component where it won't render when using asChild because of returning multiple react children. Tried to briefly troubleshoot, but even their example doesn't work