Skip to content

Commit 6dfb2db

Browse files
authored
Add banner image (#206)
* Add banner image * Export BannerImage
1 parent 049ffbf commit 6dfb2db

File tree

6 files changed

+68
-4
lines changed

6 files changed

+68
-4
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@code4ro/taskforce-fe-components",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"private": false,
55
"sideEffects": false,
66
"dependencies": {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from "react";
2+
import { BannerImage } from "./banner-image";
3+
4+
export default { title: "Banner Image" };
5+
6+
export const Default = () => (
7+
<BannerImage
8+
link="https://code4.ro"
9+
image={
10+
{src: "https://stirioficiale.ro/storage/imagine principala_ROVACCINARE.png"}
11+
}
12+
/>
13+
);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from "react";
2+
import PropTypes from "prop-types";
3+
4+
export const BannerImage = ({ image: {src, alt, title}, link }) => {
5+
return (
6+
<div>
7+
{link ?
8+
<a href={link} target="_blank" rel="noopener noreferrer">
9+
<img src={src} alt={alt} title={title}/>
10+
</a>
11+
:
12+
<img src={src} alt={alt} title={title}/>
13+
}
14+
</div>
15+
);
16+
};
17+
18+
BannerImage.propTypes = {
19+
image: PropTypes.shape({
20+
src: PropTypes.string.isRequired,
21+
alt: PropTypes.string,
22+
title: PropTypes.string
23+
}).isRequired,
24+
link: PropTypes.string
25+
};
26+
27+
BannerImage.defaultProps = {
28+
link: null
29+
}
30+
31+

src/components/instruments/instruments.stories.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react";
22
import { Instruments } from "./instruments";
33
import { InstrumentsItem } from "../instruments-item/instruments-item";
4+
import { BannerImage } from "../banner-image/banner-image";
45

56
export default { title: "Instruments" };
67

@@ -9,6 +10,15 @@ const showMessage = () => alert("Hello, friend.");
910
export const grid = () => (
1011
<Instruments layout="grid">
1112
<section>
13+
<BannerImage
14+
link="https://vaccinare-covid.gov.ro/"
15+
image={{
16+
src:
17+
"https://stirioficiale.ro/storage/imagine principala_ROVACCINARE.png",
18+
alt: "#ROVACCINARE",
19+
title: "#ROVACCINARE"
20+
}}
21+
/>
1222
<InstrumentsItem
1323
color="yellow"
1424
title="Instalează-ți add-on-ul de depistat știrile false"
@@ -17,15 +27,15 @@ export const grid = () => (
1727
color="blue"
1828
title="Instalează-ți add-on-ul de depistat știrile false"
1929
/>
30+
</section>
31+
<section>
2032
<InstrumentsItem
2133
color="green"
2234
title="Stiri oficiale si informații la zi"
2335
content="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Elit, duis pretium."
2436
ctaText="Cele mai noi informații oficiale"
2537
onClick={showMessage}
2638
/>
27-
</section>
28-
<section>
2939
<InstrumentsItem
3040
color="red"
3141
title="Vrei să ajuți. Intră aici"
@@ -55,6 +65,15 @@ export const grid = () => (
5565

5666
export const oneColumn = () => (
5767
<Instruments layout="column">
68+
<BannerImage
69+
link="https://vaccinare-covid.gov.ro/"
70+
image={{
71+
src:
72+
"https://stirioficiale.ro/storage/imagine principala_ROVACCINARE.png",
73+
alt: "#ROVACCINARE",
74+
title: "#ROVACCINARE"
75+
}}
76+
/>
5877
<InstrumentsItem
5978
color="green"
6079
title="Instalează-ți add-on-ul de depistat știrile false"

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export { Hero } from "./components/hero/hero";
2222
export { IncubatedBy } from "./components/incubated-by/incubated-by";
2323

2424
export { Banner } from "./components/banner/banner";
25+
export { BannerImage } from "./components/banner-image/banner-image";
2526

2627
export { Instruments } from "./components/instruments/instruments";
2728
export { InstrumentsItem } from "./components/instruments-item/instruments-item";

0 commit comments

Comments
 (0)