-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from Atnic/feature/card
feat: add card component
- Loading branch information
Showing
7 changed files
with
254 additions
and
460 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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# @jala-banyu/card | ||
|
||
## 4.1.0 | ||
|
||
### Minor Changes | ||
|
||
- Initial version of Card | ||
|
||
## 4.0.0 | ||
|
||
### Patch Changes | ||
|
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,35 @@ | ||
import React, {forwardRef} from "react"; | ||
import {HTMLBanyuProps} from "@jala-banyu/system"; | ||
import {clsx} from "@jala-banyu/shared-utils"; | ||
|
||
import {useCardContext} from "./card-context"; | ||
|
||
type CardTitleProps = HTMLBanyuProps<"div"> & { | ||
startButton?: React.ReactNode; | ||
title: string; | ||
subtitle?: string; | ||
}; | ||
|
||
const CardTitle = forwardRef<"div", CardTitleProps>((props, ref) => { | ||
const {as, className} = props; | ||
const Component = as || "div"; | ||
const domRef = ref; | ||
|
||
const {slots, classNames} = useCardContext(); | ||
const headerTitleStyles = clsx(classNames?.headerTitle, className); | ||
const headerSubtitleStyles = clsx(classNames?.headerSubtitle, className); | ||
|
||
return ( | ||
<Component ref={domRef} className="flex items-center justify-between gap-2 w-full"> | ||
{props.startButton} | ||
<div className="flex-1 flex-col"> | ||
<h2 className={slots.headerTitle?.({class: headerTitleStyles})}>{props.title}</h2> | ||
<p className={slots.headerSubtitle?.({class: headerSubtitleStyles})}>{props.subtitle}</p> | ||
</div> | ||
</Component> | ||
); | ||
}); | ||
|
||
CardTitle.displayName = "Banyu.CardTitle"; | ||
|
||
export default CardTitle; |
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
Oops, something went wrong.