-
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.
Styling for 'medias' component, supporting 1 or 2 images. DDFFORM-73
- Loading branch information
Showing
6 changed files
with
150 additions
and
6 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
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,40 @@ | ||
import { ComponentStory, ComponentMeta } from "@storybook/react"; | ||
import { withDesign } from "storybook-addon-designs"; | ||
import Medias from "./Medias"; | ||
import ImageCredited from "../image-credited/ImageCredited"; | ||
|
||
export default { | ||
title: "Library / Medias", | ||
component: Medias, | ||
decorators: [withDesign], | ||
argTypes: { | ||
items: { | ||
// Disabling controls, as the different variations are added already. | ||
control: false, | ||
}, | ||
}, | ||
parameters: { | ||
design: { | ||
type: "figma", | ||
url: "https://www.figma.com/file/Zx9GrkFA3l4ISvyZD2q0Qi/Designsystem?type=design&node-id=7477-39100&mode=design&t=SREzD6mFi3A15ap4-4", | ||
}, | ||
}, | ||
} as ComponentMeta<typeof Medias>; | ||
|
||
const Template: ComponentStory<typeof Medias> = (args) => <Medias {...args} />; | ||
|
||
export const Multiple = Template.bind({}); | ||
Multiple.args = { | ||
items: [ | ||
<ImageCredited | ||
src="https://i.imgur.com/0Fis99n.jpeg" | ||
description="Happy dog is Happy" | ||
/>, | ||
<ImageCredited src="https://i.imgur.com/KYhYZkp.jpeg" />, | ||
], | ||
}; | ||
|
||
export const Single = Template.bind({}); | ||
Single.args = { | ||
items: [<ImageCredited src="https://i.imgur.com/KYhYZkp.jpeg" />], | ||
}; |
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,31 @@ | ||
import { FC, ReactNode } from "react"; | ||
import clsx from "clsx"; | ||
|
||
type MediasProps = { | ||
items: ReactNode[]; | ||
}; | ||
|
||
const Medias: FC<MediasProps> = ({ items }) => { | ||
const classes = clsx("medias", { | ||
"medias--multiple": items.length > 1, | ||
"medias--single": items.length <= 1, | ||
}); | ||
|
||
return ( | ||
<div className={classes}> | ||
{items.map((item, index) => { | ||
const itemClasses = clsx("medias__item", { | ||
"medias__item--last": index === items.length - 1, | ||
}); | ||
|
||
return ( | ||
<div key={index} className={itemClasses}> | ||
{item} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Medias; |
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,68 @@ | ||
$_medias-breakpoint: 550px; | ||
|
||
.medias__item { | ||
width: 100%; | ||
box-sizing: border-box; | ||
|
||
img { | ||
width: 100%; | ||
height: auto; | ||
aspect-ratio: 33 / 25; | ||
object-fit: cover; | ||
} | ||
} | ||
|
||
.medias--single { | ||
max-width: $layout__max-width--single-media; | ||
margin: auto; | ||
|
||
.medias__item { | ||
padding: 0 $s-md; | ||
} | ||
} | ||
|
||
@include media-query($_medias-breakpoint) { | ||
.medias--multiple { | ||
display: grid; | ||
grid-gap: 8%; | ||
grid-template-columns: auto 40%; | ||
} | ||
|
||
.medias__item { | ||
width: 100%; | ||
min-width: 250px; | ||
} | ||
|
||
.medias__item--last { | ||
margin-top: 4rem; | ||
} | ||
} | ||
|
||
@include media-query($_medias-breakpoint, "max-width") { | ||
.medias--multiple { | ||
.medias__item { | ||
max-width: 330px; | ||
padding-right: $s-lg; | ||
} | ||
.medias__item--last { | ||
max-width: 300px; | ||
margin-top: $s-md; | ||
margin-left: auto; | ||
padding-left: $s-lg; | ||
padding-right: 0; | ||
} | ||
} | ||
} | ||
|
||
.medias--multiple { | ||
max-width: $layout__max-width--multiple-medias; | ||
//max-width: 900px; | ||
margin: auto; | ||
|
||
.medias__item--last { | ||
img { | ||
aspect-ratio: 1 / 1; | ||
object-fit: cover; | ||
} | ||
} | ||
} |
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