-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This component contains a required link and title. It can be used with a description and a background image to enhance visual appeal. The title field is a `ReactNode` where the `<u>` (underlined) tag has a custom underline SVG placed beneath it.
- Loading branch information
1 parent
26b6bb0
commit 8017f32
Showing
7 changed files
with
192 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
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 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,53 @@ | ||
import { ComponentStory, ComponentMeta } from "@storybook/react"; | ||
import { withDesign } from "storybook-addon-designs"; | ||
import Banner from "./Banner"; | ||
import ImageCredited from "../image-credited/ImageCredited"; | ||
|
||
export default { | ||
title: "Library / Banner", | ||
component: Banner, | ||
decorators: [withDesign], | ||
parameters: { | ||
design: { | ||
type: "figma", | ||
url: "https://www.figma.com/design/Zx9GrkFA3l4ISvyZD2q0Qi/Designsystem?node-id=446-6957&t=IWAOniAbcjV2y2Hf-4", | ||
}, | ||
}, | ||
argTypes: { | ||
image: { | ||
defaultValue: ( | ||
<ImageCredited | ||
src="https://images.unsplash.com/photo-1531058020387-3be344556be6?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxfDB8MXxyYW5kb218MHx8ZXZlbnR8fHx8fHwxNzAyOTEwMzE0&ixlib=rb-4.0.3&q=8 | ||
0&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=1080" | ||
/> | ||
), | ||
}, | ||
title: { | ||
name: "Title", | ||
defaultValue: "Hvad skal jeg <u>høre?</u>", | ||
control: { type: "text" }, | ||
}, | ||
description: { | ||
name: "Description", | ||
defaultValue: | ||
"Om du er dedikeret musiknørd eller moderat musikinteresseret, så er dette siden til dig. Her kan du finde anbefalinger, digitale musikmagasiner, nyheder, musiklitteratur og meget mere.", | ||
control: { type: "text" }, | ||
}, | ||
}, | ||
} as ComponentMeta<typeof Banner>; | ||
|
||
const Template: ComponentStory<typeof Banner> = (args) => <Banner {...args} />; | ||
|
||
export const Default = Template.bind({}); | ||
|
||
export const NoImage = Template.bind({}); | ||
NoImage.args = { | ||
title: "Title <u>uden</u> billede", | ||
image: undefined, | ||
}; | ||
|
||
export const NoDescription = Template.bind({}); | ||
NoDescription.args = { | ||
title: "Banner <u>uden</u> beskrivelse", | ||
description: undefined, | ||
}; |
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,40 @@ | ||
import { FC, ReactNode } from "react"; | ||
import clsx from "clsx"; | ||
import MediaContainer from "../media-container/MediaContainer"; | ||
import { ReactComponent as ArrowLargeRight } from "../Arrows/icon-arrow-ui/icon-arrow-ui-large-right.svg"; | ||
|
||
type BannerType = { | ||
title: string; | ||
image?: ReactNode; | ||
description?: string; | ||
}; | ||
|
||
const Banner: FC<BannerType> = ({ image, title, description }) => { | ||
return ( | ||
<a href="#" className="banner"> | ||
{image && ( | ||
<div className="banner-visual"> | ||
<MediaContainer media={image} /> | ||
</div> | ||
)} | ||
<div | ||
className={clsx("banner-content arrow__hover--right-large", { | ||
"banner-content--no-image": !image, | ||
})} | ||
> | ||
<h2 | ||
className="banner-content__title" | ||
// We need to be able to replicate our WYSIWYG field in Drupal that makes it possible to underline (<u>) words. | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={{ __html: title }} | ||
/> | ||
{description && ( | ||
<p className="banner-content__description">{description}</p> | ||
)} | ||
<ArrowLargeRight /> | ||
</div> | ||
</a> | ||
); | ||
}; | ||
|
||
export default Banner; |
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,66 @@ | ||
@mixin banner-height { | ||
height: 500px; | ||
@include media-query__medium { | ||
height: 810px; | ||
} | ||
} | ||
|
||
@mixin banner-text-margin { | ||
margin-bottom: $s-md; | ||
@include media-query__medium { | ||
margin-bottom: $s-xl; | ||
} | ||
} | ||
|
||
.banner { | ||
@include layout-container($layout__max-width--large, 0); | ||
@include banner-height; | ||
display: grid; | ||
grid-template-rows: 1fr auto 1fr; | ||
text-decoration: none; | ||
} | ||
|
||
.banner-content { | ||
padding: $s-xl; | ||
max-width: 375px; | ||
background-color: white; | ||
grid-row: 2; | ||
grid-column: 1; | ||
|
||
@include media-query__medium { | ||
padding: $s-2xl; | ||
max-width: 575px; | ||
margin-left: 250px; | ||
} | ||
|
||
&--no-image { | ||
max-width: unset; | ||
background-color: unset; | ||
margin-left: unset; | ||
text-align: center; | ||
} | ||
} | ||
|
||
.banner-content__title { | ||
@include typography($typo__h1); | ||
@include underlined-title; | ||
@include banner-text-margin; | ||
} | ||
|
||
.banner-content__description { | ||
@include typography($typo__body-medium); | ||
@include banner-text-margin; | ||
color: $color__global-grey; | ||
} | ||
|
||
.banner-visual { | ||
grid-row: 1 / -1; | ||
grid-column: 1; | ||
|
||
// Todo: can this be done in drupal? | ||
img { | ||
@include banner-height; | ||
object-fit: cover; | ||
object-position: center; | ||
} | ||
} |
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