-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support Card and LinkCard components (#1512)
Co-authored-by: Timeless0911 <[email protected]>
- Loading branch information
1 parent
2028a38
commit 786acb2
Showing
7 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,6 @@ | ||
--- | ||
'@rspress/theme-default': minor | ||
'@rspress/docs': patch | ||
--- | ||
|
||
feat: support Card and LinkCard components |
This file contains 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 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 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,30 @@ | ||
interface CardProps { | ||
/** | ||
* The title of the card. | ||
*/ | ||
title: React.ReactNode; | ||
/** | ||
* The content to display inside the card. | ||
*/ | ||
content?: React.ReactNode; | ||
/** | ||
* The icon of the card. | ||
*/ | ||
icon?: React.ReactNode; | ||
/** | ||
* The style of the card. | ||
*/ | ||
style?: React.CSSProperties; | ||
} | ||
|
||
export function Card({ content, title, icon, style }: CardProps) { | ||
return ( | ||
<div className="border border-gray-400 rounded-lg p-6" style={style}> | ||
<p className="flex items-center gap-2 mb-4"> | ||
{icon && <div>{icon}</div>} | ||
{title && <span className="text-2xl font-bold">{title}</span>} | ||
</p> | ||
<div className="text-base overflow-auto">{content}</div> | ||
</div> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/theme-default/src/components/LinkCard/index.module.scss
This file contains 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,5 @@ | ||
.link::before { | ||
content: ''; | ||
position: absolute; | ||
inset: 0; | ||
} |
This file contains 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,43 @@ | ||
import styles from './index.module.scss'; | ||
import ArrowRight from '@theme-assets/arrow-right'; | ||
|
||
interface LinkCardProps { | ||
/** | ||
* The URL of the link. | ||
*/ | ||
href: string; | ||
/** | ||
* The title of the link. | ||
*/ | ||
title: string; | ||
/** | ||
* The description of the link. | ||
*/ | ||
description?: React.ReactNode; | ||
/** | ||
* The style of the link card. | ||
*/ | ||
style?: React.CSSProperties; | ||
} | ||
|
||
export function LinkCard(props: LinkCardProps) { | ||
const { href, title, description, style } = props; | ||
|
||
return ( | ||
<div | ||
className="relative border border-gray-400 rounded-lg p-6 flex justify-between items-start hover:border-gray-500 hover:bg-gray-100 transition-all duration-300" | ||
style={style} | ||
> | ||
<div className="flex flex-col"> | ||
<a | ||
href={href} | ||
className={`flex items-center gap-2 mb-4 ${styles.link}`} | ||
> | ||
{title && <span className="text-2xl font-bold">{title}</span>} | ||
</a> | ||
<span className="text-base overflow-auto">{description}</span> | ||
</div> | ||
<ArrowRight /> | ||
</div> | ||
); | ||
} |
This file contains 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