generated from abelflopes/lerna-monorepo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add children and actions to banner component
- Loading branch information
1 parent
87cb022
commit 0b866e2
Showing
5 changed files
with
62 additions
and
18 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,15 +1,33 @@ | ||
import React from "react"; | ||
import styles from "./styles/index.module.scss"; | ||
import classNames from "classnames"; | ||
import { Container } from "../container"; | ||
import { ThemeContextProvider } from "@rck/theme"; | ||
|
||
export interface BannerProps extends React.ImgHTMLAttributes<HTMLImageElement> { | ||
children?: never; | ||
export interface BannerProps extends React.HTMLAttributes<HTMLDivElement> { | ||
src: string; | ||
alt?: string; | ||
actions?: React.ReactNode[]; | ||
} | ||
|
||
export const Banner = ({ | ||
className, | ||
src, | ||
alt, | ||
actions, | ||
children, | ||
className, | ||
...otherProps | ||
}: Readonly<BannerProps>): React.ReactElement => ( | ||
<img className={classNames(styles.root, className)} alt={alt} {...otherProps} /> | ||
<ThemeContextProvider | ||
value={{ | ||
inverted: true, | ||
}}> | ||
<div className={classNames(styles.root, className)} {...otherProps}> | ||
<Container spacingY className={styles.container} variation="big"> | ||
{children} | ||
{actions?.length && <div className={styles.actions}>{actions}</div>} | ||
</Container> | ||
<img className={styles.image} alt={alt} src={src} /> | ||
</div> | ||
</ThemeContextProvider> | ||
); |
31 changes: 28 additions & 3 deletions
31
packages/components/all/src/banner/styles/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 |
---|---|---|
@@ -1,9 +1,34 @@ | ||
@import "@rck/theme"; | ||
|
||
.root { | ||
display: flex; | ||
align-items: center; | ||
background-color: get-color("neutral-200"); | ||
display: block; | ||
height: 300px; | ||
object-fit: cover; | ||
width: 100%; | ||
min-height: 300px; | ||
position: relative; | ||
|
||
.container { | ||
position: relative; | ||
z-index: 1; | ||
width: 100%; | ||
} | ||
|
||
.image { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
height: 100%; | ||
width: 100%; | ||
object-fit: cover; | ||
} | ||
|
||
.actions { | ||
display: flex; | ||
gap: get-spacing(1); | ||
|
||
&:not(:only-child) { | ||
margin-top: get-spacing(2); | ||
} | ||
} | ||
} |
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