-
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 9b943b1
Showing
5 changed files
with
164 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.
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,52 @@ | ||
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/file/Zx9GrkFA3l4ISvyZD2q0Qi/Designsystem?type=design&node-id=7477-39243&mode=dev", | ||
}, | ||
}, | ||
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>", | ||
}, | ||
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,33 @@ | ||
import { FC, ReactNode } from "react"; | ||
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 arrow__hover--right-large"> | ||
{image && ( | ||
<div className="banner-visual"> | ||
<MediaContainer media={image} /> | ||
</div> | ||
)} | ||
<div className="banner-content"> | ||
<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 }} | ||
/> | ||
<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,75 @@ | ||
@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; | ||
} | ||
} | ||
|
||
.banner-content__title { | ||
@include typography($typo__h1); | ||
@include banner-text-margin; | ||
|
||
u { | ||
position: relative; | ||
text-decoration: none; | ||
|
||
&::after { | ||
content: ""; | ||
position: absolute; | ||
bottom: -5px; | ||
left: 0; | ||
width: 100%; | ||
height: 10px; | ||
background-size: 100% 100%; | ||
// Underlined icon from public/icons/basic/icon-underlined.svg | ||
background-image: url("data:image/svg+xml,%3Csvg width='101' height='7' viewBox='0 0 101 7' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.88867 6C36.7022 -0.286878 63.0591 0.988901 99.1109 1.35819' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A"); | ||
} | ||
} | ||
} | ||
|
||
.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; | ||
} | ||
} |