react-image-accordion 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc.json +15 -0
- package/.storybook/main.js +11 -0
- package/.storybook/preview.js +9 -0
- package/LICENSE +21 -0
- package/README.md +120 -0
- package/dist/index.es.js +94 -0
- package/dist/index.js +102 -0
- package/package.json +63 -0
- package/rollup.config.js +36 -0
- package/src/.prettierrc +1 -0
- package/src/components/Accordion/App.css +187 -0
- package/src/components/Accordion/React-image-accordion.js +7 -0
- package/src/components/Accordion/UseImageAccordion.js +69 -0
- package/src/components/Accordion/index.js +1 -0
- package/src/index.js +2 -0
- package/src/stories/MockAccordion.json +42 -0
- package/src/stories/UseImageAccordion.stories.js +15 -0
package/.babelrc.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"stories": ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
|
|
3
|
+
"addons": ["@storybook/addon-links", "@storybook/addon-essentials", "@storybook/addon-interactions", "@storybook/addon-mdx-gfm"],
|
|
4
|
+
"framework": {
|
|
5
|
+
name: "@storybook/react-webpack5",
|
|
6
|
+
options: {}
|
|
7
|
+
},
|
|
8
|
+
docs: {
|
|
9
|
+
autodocs: true
|
|
10
|
+
}
|
|
11
|
+
};
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Masoud Naji
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# React Image Accordion
|
|
2
|
+
|
|
3
|
+
A simple and customizable React component that creates an image accordion with smooth animation, inspired by Kevin Powell's tutorial on [YouTube](https://www.youtube.com/watch?v=WJERnXiFFug&t=0s&ab_channel=KevinPowell).
|
|
4
|
+
|
|
5
|
+
The image accordion is a modern design pattern that can be used to display images and accompanying information in an interactive and engaging way. This component makes it easy to incorporate this pattern into your React projects.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
Use the package manager [npm](https://www.npmjs.com/) to install react-image-accordion.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm i react-image-accordion
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
To use the component in your React application, import it and pass the necessary props:
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import ImageAccordion from 'react-image-accordion';
|
|
25
|
+
|
|
26
|
+
function MyComponent() {
|
|
27
|
+
const accordionData = [
|
|
28
|
+
{
|
|
29
|
+
id: 1,
|
|
30
|
+
title: "Boating",
|
|
31
|
+
image: "https://picsum.photos/400/600",
|
|
32
|
+
alt: "first panel image",
|
|
33
|
+
content: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Saepe id numquam ab molestias sint beatae provident possimus doloribus autem repudiandae!",
|
|
34
|
+
svg: "aa (1).svg",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 2,
|
|
38
|
+
title: "Fishing",
|
|
39
|
+
image: "https://picsum.photos/400/600",
|
|
40
|
+
alt: "second panel image",
|
|
41
|
+
content: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Saepe id numquam ab molestias sint beatae provident possimus doloribus autem repudiandae!",
|
|
42
|
+
svg: "aa (2).svg",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 3,
|
|
46
|
+
title: "Swimming",
|
|
47
|
+
image: "https://picsum.photos/400/600",
|
|
48
|
+
alt: "third panel image",
|
|
49
|
+
content: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Saepe id numquam ab molestias sint beatae provident possimus doloribus autem repudiandae!",
|
|
50
|
+
svg: "aa (3).svg",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 4,
|
|
54
|
+
title: "Kayaking",
|
|
55
|
+
image: "https://picsum.photos/400/600",
|
|
56
|
+
alt: "fourth panel image",
|
|
57
|
+
content: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Saepe id numquam ab molestias sint beatae provident possimus doloribus autem repudiandae!",
|
|
58
|
+
svg: "aa (4).svg",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 5,
|
|
62
|
+
title: "Scuba diving",
|
|
63
|
+
image: "https://picsum.photos/400/600",
|
|
64
|
+
alt: "fifth panel image",
|
|
65
|
+
content: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Saepe id numquam ab molestias sint beatae provident possimus doloribus autem repudiandae!",
|
|
66
|
+
svg: "aa (5).svg",
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<ReactImageAccordion
|
|
72
|
+
accordionData: {accordionData}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+

|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+

|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
| Property | type | Default | Description |
|
|
88
|
+
| ---------------- |:-------------:|:----------:|:-----------------------:|
|
|
89
|
+
| accordionData | json data | json file | Source File json |
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## Sample Code
|
|
95
|
+
```React Code
|
|
96
|
+
import MockDocument from "./MOCK_DATA.json";
|
|
97
|
+
import { ReactImageAccordion } from "json-pretty-textarea";
|
|
98
|
+
export const test = () => {
|
|
99
|
+
return (
|
|
100
|
+
<ReactImageAccordion
|
|
101
|
+
accordionData: {MockAccordion}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
***
|
|
109
|
+
## StoryBook Sample
|
|
110
|
+
[StoryBook]https://react-image-accordion.netlify.app/
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
## Contributing
|
|
114
|
+
For major changes, please open an issue first to discuss what you would like to change.
|
|
115
|
+
|
|
116
|
+
Please make sure to update tests as appropriate.
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React$1, { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
function styleInject(css, ref) {
|
|
4
|
+
if ( ref === void 0 ) ref = {};
|
|
5
|
+
var insertAt = ref.insertAt;
|
|
6
|
+
|
|
7
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
8
|
+
|
|
9
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
10
|
+
var style = document.createElement('style');
|
|
11
|
+
style.type = 'text/css';
|
|
12
|
+
|
|
13
|
+
if (insertAt === 'top') {
|
|
14
|
+
if (head.firstChild) {
|
|
15
|
+
head.insertBefore(style, head.firstChild);
|
|
16
|
+
} else {
|
|
17
|
+
head.appendChild(style);
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
head.appendChild(style);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (style.styleSheet) {
|
|
24
|
+
style.styleSheet.cssText = css;
|
|
25
|
+
} else {
|
|
26
|
+
style.appendChild(document.createTextNode(css));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var css_248z = "*,\r\n*::before,\r\n*::after {\r\n box-sizing: border-box;\r\n}\r\n\r\nhtml {\r\n color-scheme: dark;\r\n}\r\n\r\nbody {\r\n display: grid;\r\n justify-content: center;\r\n align-content: center;\r\n min-height: 100vh;\r\n\r\n margin: 0;\r\n font-family: system-ui;\r\n font-size: 1.125rem;\r\n line-height: 1.6;\r\n}\r\n\r\nimg {\r\n max-width: 100%;\r\n display: block;\r\n}\r\n\r\n.wrapper {\r\n max-width: 50rem;\r\n margin-inline: auto;\r\n padding-inline: 1rem;\r\n}\r\n\r\n.accordion {\r\n --_button-size: 3rem;\r\n --_panel-padding: 0.75rem;\r\n --_panel-gap: 1rem;\r\n\r\n display: flex;\r\n flex-direction: column;\r\n gap: 1rem;\r\n}\r\n\r\n@media (min-width: 45em) {\r\n .accordion {\r\n flex-direction: row;\r\n height: 30rem;\r\n }\r\n}\r\n\r\n.accordion * {\r\n margin: 0;\r\n}\r\n\r\n.accordion-panel {\r\n position: relative;\r\n isolation: isolate;\r\n flex-basis: calc((var(--_panel-padding) * 2) + var(--_button-size));\r\n overflow: hidden;\r\n padding: var(--_panel-padding);\r\n padding-right: calc(var(--_panel-padding) * 4);\r\n border-radius: calc(((var(--_panel-padding) * 2) + var(--_button-size)) / 2);\r\n cursor: pointer;\r\n}\r\n\r\n@media (prefers-reduced-motion: no-preference) {\r\n .accordion-panel {\r\n transition: flex-basis 500ms, flex-grow 500ms;\r\n }\r\n}\r\n\r\n.accordion-panel:nth-child(1) {\r\n --_panel-color: red;\r\n}\r\n.accordion-panel:nth-child(2) {\r\n --_panel-color: blue;\r\n}\r\n.accordion-panel:nth-child(3) {\r\n --_panel-color: green;\r\n}\r\n.accordion-panel:nth-child(4) {\r\n --_panel-color: yellow;\r\n}\r\n.accordion-panel:nth-child(5) {\r\n --_panel-color: orange;\r\n}\r\n.accordion-panel:nth-child(6) {\r\n --_panel-color: purple;\r\n}\r\n.accordion-panel:nth-child(7) {\r\n --_panel-color: pink;\r\n}\r\n.accordion-panel:nth-child(8) {\r\n --_panel-color: brown;\r\n}\r\n.accordion-panel:nth-child(9) {\r\n --_panel-color: cyan;\r\n}\r\n.accordion-panel:nth-child(10) {\r\n --_panel-color: magenta;\r\n}\r\n\r\n.accordion-panel:has([aria-expanded=\"true\"]) {\r\n flex-basis: clamp(15rem, 40vh, 20rem);\r\n flex-grow: 1;\r\n}\r\n\r\n.accordion-trigger {\r\n outline: 0 !important;\r\n}\r\n\r\n.accordion-panel:focus-within {\r\n outline: 3px solid var(--_panel-color);\r\n outline-offset: 4px;\r\n}\r\n\r\n.accordion-content > p {\r\n transform: translateY(2rem);\r\n opacity: 0;\r\n margin-left: calc(var(--_button-size) + var(--_panel-gap));\r\n}\r\n\r\n@media (prefers-reduced-motion: no-preference) {\r\n .accordion-panel:has([aria-expanded=\"true\"]) .accordion-content > p {\r\n transition: transform 500ms 500ms, opacity 500ms 500ms;\r\n }\r\n}\r\n\r\n.accordion-panel:has([aria-expanded=\"true\"]) .accordion-content > p {\r\n transform: translateY(0);\r\n opacity: 1;\r\n}\r\n\r\n.accordion-title {\r\n font-size: 1.5rem;\r\n font-weight: 700;\r\n position: relative;\r\n isolation: isolate;\r\n display: grid;\r\n align-items: center;\r\n}\r\n\r\n@media (max-width: 44.999em) {\r\n .accordion-title::after {\r\n content: \"\";\r\n position: absolute;\r\n\r\n left: calc((var(--_panel-gap) + var(--_button-size)) * -1);\r\n width: calc(100% + (var(--_button-size) * 2));\r\n height: var(--_button-size);\r\n background: hsl(0 0% 0% /0.55);\r\n z-index: -1;\r\n border-radius: 100vw;\r\n }\r\n}\r\n\r\n.accordion-image {\r\n position: absolute;\r\n inset: 0;\r\n width: 100%;\r\n height: 100%;\r\n object-fit: cover;\r\n z-index: -1;\r\n transition: filer 500ms;\r\n}\r\n\r\n.accordion-panel:has([aria-expanded=\"true\"]) .accordion-image {\r\n filter: brightness(0.5);\r\n}\r\n.accordion-trigger {\r\n display: flex;\r\n align-items: center;\r\n flex-direction: row-reverse;\r\n gap: var(--_panel-gap);\r\n background: transparent;\r\n border: 0;\r\n padding: 0;\r\n}\r\n.accordion-icon {\r\n fill: var(--_panel-color);\r\n background: hsl(0 0% 0% /0.55);\r\n width: var(--_button-size);\r\n aspect-ratio: 1/1;\r\n padding: 0.75rem;\r\n border-radius: 50%;\r\n z-index: 10;\r\n}\r\n";
|
|
31
|
+
styleInject(css_248z);
|
|
32
|
+
|
|
33
|
+
function UseImageAccordion({
|
|
34
|
+
accordionData
|
|
35
|
+
}) {
|
|
36
|
+
const [activePanel, setActivePanel] = useState(null);
|
|
37
|
+
function toggleAccordion(panelToActivate) {
|
|
38
|
+
setActivePanel(prevPanel => {
|
|
39
|
+
if (prevPanel === panelToActivate) {
|
|
40
|
+
return prevPanel;
|
|
41
|
+
} else {
|
|
42
|
+
return panelToActivate;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
setActivePanel(accordionData[0].id);
|
|
48
|
+
}, []);
|
|
49
|
+
if (!accordionData) return null;
|
|
50
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: "wrapper"
|
|
52
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: "accordion"
|
|
54
|
+
}, accordionData.map(item => /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
key: item.id,
|
|
56
|
+
className: "accordion-panel",
|
|
57
|
+
onClick: () => toggleAccordion(item.id)
|
|
58
|
+
}, /*#__PURE__*/React.createElement("h2", {
|
|
59
|
+
id: item.id
|
|
60
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
61
|
+
type: "button",
|
|
62
|
+
className: "accordion-trigger",
|
|
63
|
+
"aria-controls": "panel1-content",
|
|
64
|
+
"aria-expanded": activePanel === item.id
|
|
65
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
66
|
+
className: "accordion-title",
|
|
67
|
+
id: item.id
|
|
68
|
+
}, "Boating"), /*#__PURE__*/React.createElement("svg", {
|
|
69
|
+
"aria-hidden": "true",
|
|
70
|
+
className: "accordion-icon"
|
|
71
|
+
}, /*#__PURE__*/React.createElement("image", {
|
|
72
|
+
href: item.svg
|
|
73
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
className: "accordion-content",
|
|
75
|
+
id: item.id,
|
|
76
|
+
"aria-labelledby": item.id,
|
|
77
|
+
"aria-hidden": activePanel !== item.id,
|
|
78
|
+
role: "region"
|
|
79
|
+
}, /*#__PURE__*/React.createElement("p", null, item.content), /*#__PURE__*/React.createElement("img", {
|
|
80
|
+
className: "accordion-image",
|
|
81
|
+
src: item.image,
|
|
82
|
+
alt: item.alt
|
|
83
|
+
})))))));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const ReactImageAccordion = ({
|
|
87
|
+
accordionData
|
|
88
|
+
}) => {
|
|
89
|
+
return /*#__PURE__*/React$1.createElement(UseImageAccordion, {
|
|
90
|
+
accordionData: accordionData
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export { ReactImageAccordion };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React$1 = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
|
|
10
|
+
|
|
11
|
+
function styleInject(css, ref) {
|
|
12
|
+
if ( ref === void 0 ) ref = {};
|
|
13
|
+
var insertAt = ref.insertAt;
|
|
14
|
+
|
|
15
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
16
|
+
|
|
17
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
18
|
+
var style = document.createElement('style');
|
|
19
|
+
style.type = 'text/css';
|
|
20
|
+
|
|
21
|
+
if (insertAt === 'top') {
|
|
22
|
+
if (head.firstChild) {
|
|
23
|
+
head.insertBefore(style, head.firstChild);
|
|
24
|
+
} else {
|
|
25
|
+
head.appendChild(style);
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
head.appendChild(style);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (style.styleSheet) {
|
|
32
|
+
style.styleSheet.cssText = css;
|
|
33
|
+
} else {
|
|
34
|
+
style.appendChild(document.createTextNode(css));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var css_248z = "*,\r\n*::before,\r\n*::after {\r\n box-sizing: border-box;\r\n}\r\n\r\nhtml {\r\n color-scheme: dark;\r\n}\r\n\r\nbody {\r\n display: grid;\r\n justify-content: center;\r\n align-content: center;\r\n min-height: 100vh;\r\n\r\n margin: 0;\r\n font-family: system-ui;\r\n font-size: 1.125rem;\r\n line-height: 1.6;\r\n}\r\n\r\nimg {\r\n max-width: 100%;\r\n display: block;\r\n}\r\n\r\n.wrapper {\r\n max-width: 50rem;\r\n margin-inline: auto;\r\n padding-inline: 1rem;\r\n}\r\n\r\n.accordion {\r\n --_button-size: 3rem;\r\n --_panel-padding: 0.75rem;\r\n --_panel-gap: 1rem;\r\n\r\n display: flex;\r\n flex-direction: column;\r\n gap: 1rem;\r\n}\r\n\r\n@media (min-width: 45em) {\r\n .accordion {\r\n flex-direction: row;\r\n height: 30rem;\r\n }\r\n}\r\n\r\n.accordion * {\r\n margin: 0;\r\n}\r\n\r\n.accordion-panel {\r\n position: relative;\r\n isolation: isolate;\r\n flex-basis: calc((var(--_panel-padding) * 2) + var(--_button-size));\r\n overflow: hidden;\r\n padding: var(--_panel-padding);\r\n padding-right: calc(var(--_panel-padding) * 4);\r\n border-radius: calc(((var(--_panel-padding) * 2) + var(--_button-size)) / 2);\r\n cursor: pointer;\r\n}\r\n\r\n@media (prefers-reduced-motion: no-preference) {\r\n .accordion-panel {\r\n transition: flex-basis 500ms, flex-grow 500ms;\r\n }\r\n}\r\n\r\n.accordion-panel:nth-child(1) {\r\n --_panel-color: red;\r\n}\r\n.accordion-panel:nth-child(2) {\r\n --_panel-color: blue;\r\n}\r\n.accordion-panel:nth-child(3) {\r\n --_panel-color: green;\r\n}\r\n.accordion-panel:nth-child(4) {\r\n --_panel-color: yellow;\r\n}\r\n.accordion-panel:nth-child(5) {\r\n --_panel-color: orange;\r\n}\r\n.accordion-panel:nth-child(6) {\r\n --_panel-color: purple;\r\n}\r\n.accordion-panel:nth-child(7) {\r\n --_panel-color: pink;\r\n}\r\n.accordion-panel:nth-child(8) {\r\n --_panel-color: brown;\r\n}\r\n.accordion-panel:nth-child(9) {\r\n --_panel-color: cyan;\r\n}\r\n.accordion-panel:nth-child(10) {\r\n --_panel-color: magenta;\r\n}\r\n\r\n.accordion-panel:has([aria-expanded=\"true\"]) {\r\n flex-basis: clamp(15rem, 40vh, 20rem);\r\n flex-grow: 1;\r\n}\r\n\r\n.accordion-trigger {\r\n outline: 0 !important;\r\n}\r\n\r\n.accordion-panel:focus-within {\r\n outline: 3px solid var(--_panel-color);\r\n outline-offset: 4px;\r\n}\r\n\r\n.accordion-content > p {\r\n transform: translateY(2rem);\r\n opacity: 0;\r\n margin-left: calc(var(--_button-size) + var(--_panel-gap));\r\n}\r\n\r\n@media (prefers-reduced-motion: no-preference) {\r\n .accordion-panel:has([aria-expanded=\"true\"]) .accordion-content > p {\r\n transition: transform 500ms 500ms, opacity 500ms 500ms;\r\n }\r\n}\r\n\r\n.accordion-panel:has([aria-expanded=\"true\"]) .accordion-content > p {\r\n transform: translateY(0);\r\n opacity: 1;\r\n}\r\n\r\n.accordion-title {\r\n font-size: 1.5rem;\r\n font-weight: 700;\r\n position: relative;\r\n isolation: isolate;\r\n display: grid;\r\n align-items: center;\r\n}\r\n\r\n@media (max-width: 44.999em) {\r\n .accordion-title::after {\r\n content: \"\";\r\n position: absolute;\r\n\r\n left: calc((var(--_panel-gap) + var(--_button-size)) * -1);\r\n width: calc(100% + (var(--_button-size) * 2));\r\n height: var(--_button-size);\r\n background: hsl(0 0% 0% /0.55);\r\n z-index: -1;\r\n border-radius: 100vw;\r\n }\r\n}\r\n\r\n.accordion-image {\r\n position: absolute;\r\n inset: 0;\r\n width: 100%;\r\n height: 100%;\r\n object-fit: cover;\r\n z-index: -1;\r\n transition: filer 500ms;\r\n}\r\n\r\n.accordion-panel:has([aria-expanded=\"true\"]) .accordion-image {\r\n filter: brightness(0.5);\r\n}\r\n.accordion-trigger {\r\n display: flex;\r\n align-items: center;\r\n flex-direction: row-reverse;\r\n gap: var(--_panel-gap);\r\n background: transparent;\r\n border: 0;\r\n padding: 0;\r\n}\r\n.accordion-icon {\r\n fill: var(--_panel-color);\r\n background: hsl(0 0% 0% /0.55);\r\n width: var(--_button-size);\r\n aspect-ratio: 1/1;\r\n padding: 0.75rem;\r\n border-radius: 50%;\r\n z-index: 10;\r\n}\r\n";
|
|
39
|
+
styleInject(css_248z);
|
|
40
|
+
|
|
41
|
+
function UseImageAccordion({
|
|
42
|
+
accordionData
|
|
43
|
+
}) {
|
|
44
|
+
const [activePanel, setActivePanel] = React$1.useState(null);
|
|
45
|
+
function toggleAccordion(panelToActivate) {
|
|
46
|
+
setActivePanel(prevPanel => {
|
|
47
|
+
if (prevPanel === panelToActivate) {
|
|
48
|
+
return prevPanel;
|
|
49
|
+
} else {
|
|
50
|
+
return panelToActivate;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
React$1.useEffect(() => {
|
|
55
|
+
setActivePanel(accordionData[0].id);
|
|
56
|
+
}, []);
|
|
57
|
+
if (!accordionData) return null;
|
|
58
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
className: "wrapper"
|
|
60
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
className: "accordion"
|
|
62
|
+
}, accordionData.map(item => /*#__PURE__*/React.createElement("div", {
|
|
63
|
+
key: item.id,
|
|
64
|
+
className: "accordion-panel",
|
|
65
|
+
onClick: () => toggleAccordion(item.id)
|
|
66
|
+
}, /*#__PURE__*/React.createElement("h2", {
|
|
67
|
+
id: item.id
|
|
68
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
69
|
+
type: "button",
|
|
70
|
+
className: "accordion-trigger",
|
|
71
|
+
"aria-controls": "panel1-content",
|
|
72
|
+
"aria-expanded": activePanel === item.id
|
|
73
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
74
|
+
className: "accordion-title",
|
|
75
|
+
id: item.id
|
|
76
|
+
}, "Boating"), /*#__PURE__*/React.createElement("svg", {
|
|
77
|
+
"aria-hidden": "true",
|
|
78
|
+
className: "accordion-icon"
|
|
79
|
+
}, /*#__PURE__*/React.createElement("image", {
|
|
80
|
+
href: item.svg
|
|
81
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
className: "accordion-content",
|
|
83
|
+
id: item.id,
|
|
84
|
+
"aria-labelledby": item.id,
|
|
85
|
+
"aria-hidden": activePanel !== item.id,
|
|
86
|
+
role: "region"
|
|
87
|
+
}, /*#__PURE__*/React.createElement("p", null, item.content), /*#__PURE__*/React.createElement("img", {
|
|
88
|
+
className: "accordion-image",
|
|
89
|
+
src: item.image,
|
|
90
|
+
alt: item.alt
|
|
91
|
+
})))))));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const ReactImageAccordion = ({
|
|
95
|
+
accordionData
|
|
96
|
+
}) => {
|
|
97
|
+
return /*#__PURE__*/React__default["default"].createElement(UseImageAccordion, {
|
|
98
|
+
accordionData: accordionData
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
exports.ReactImageAccordion = ReactImageAccordion;
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-image-accordion",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "Accordion component for React",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.es.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
+
"storybook": "storybook dev -p 6006",
|
|
10
|
+
"build-storybook": "storybook build",
|
|
11
|
+
"build-lib": "rollup -c"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+ssh://git@github.com:masoud-naji/Accordion.git"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"react",
|
|
19
|
+
"accordion",
|
|
20
|
+
"react-accordion",
|
|
21
|
+
"accordion-component",
|
|
22
|
+
"react-accordion-component",
|
|
23
|
+
"react-component",
|
|
24
|
+
"accordion-react-component"
|
|
25
|
+
],
|
|
26
|
+
"author": "Masoud Naji",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/masoud-naji/Accordion"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/masoud-naji/Accordion",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@babel/core": "^7.18.2",
|
|
34
|
+
"@babel/preset-env": "^7.21.4",
|
|
35
|
+
"@babel/preset-react": "^7.18.6",
|
|
36
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
37
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
38
|
+
"@storybook/addon-actions": "^7.0.7",
|
|
39
|
+
"@storybook/addon-essentials": "^7.0.7",
|
|
40
|
+
"@storybook/addon-interactions": "^7.0.7",
|
|
41
|
+
"@storybook/addon-links": "^7.0.7",
|
|
42
|
+
"@storybook/addon-mdx-gfm": "^7.0.7",
|
|
43
|
+
"@storybook/react": "^7.0.7",
|
|
44
|
+
"@storybook/react-webpack5": "^7.0.7",
|
|
45
|
+
"@storybook/testing-library": "^0.1.0",
|
|
46
|
+
"babel-loader": "^8.2.5",
|
|
47
|
+
"react": "^18.1.0",
|
|
48
|
+
"react-dom": "^18.1.0",
|
|
49
|
+
"rollup": "^2.74.1",
|
|
50
|
+
"rollup-plugin-babel": "^4.4.0",
|
|
51
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
52
|
+
"rollup-plugin-postcss": "^3.1.8",
|
|
53
|
+
"storybook": "^7.0.7"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"react": "^18.1.0",
|
|
57
|
+
"react-dom": "^18.1.0"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"rollup-plugin-local-resolve": "^1.0.7",
|
|
61
|
+
"rollup-plugin-terser": "^7.0.2"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import babel from 'rollup-plugin-babel';
|
|
2
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
+
import external from 'rollup-plugin-peer-deps-external';
|
|
4
|
+
import postcss from 'rollup-plugin-postcss';
|
|
5
|
+
import localResolve from 'rollup-plugin-local-resolve';
|
|
6
|
+
// import { terser } from "rollup-plugin-terser";
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
{
|
|
10
|
+
input: 'src/index.js',
|
|
11
|
+
output: [
|
|
12
|
+
{
|
|
13
|
+
file: 'dist/index.js',
|
|
14
|
+
format: 'cjs',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
file: 'dist/index.es.js',
|
|
18
|
+
format: 'es',
|
|
19
|
+
exports: 'named',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
plugins: [
|
|
23
|
+
postcss({
|
|
24
|
+
plugins: []
|
|
25
|
+
}),
|
|
26
|
+
babel({
|
|
27
|
+
exclude: 'node_modules/**',
|
|
28
|
+
presets: ['@babel/preset-react'],
|
|
29
|
+
}),
|
|
30
|
+
external(),
|
|
31
|
+
resolve(),
|
|
32
|
+
localResolve(),
|
|
33
|
+
// terser(),
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
];
|
package/src/.prettierrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
*,
|
|
2
|
+
*::before,
|
|
3
|
+
*::after {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
html {
|
|
8
|
+
color-scheme: dark;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
body {
|
|
12
|
+
display: grid;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
align-content: center;
|
|
15
|
+
min-height: 100vh;
|
|
16
|
+
|
|
17
|
+
margin: 0;
|
|
18
|
+
font-family: system-ui;
|
|
19
|
+
font-size: 1.125rem;
|
|
20
|
+
line-height: 1.6;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
img {
|
|
24
|
+
max-width: 100%;
|
|
25
|
+
display: block;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.wrapper {
|
|
29
|
+
max-width: 50rem;
|
|
30
|
+
margin-inline: auto;
|
|
31
|
+
padding-inline: 1rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.accordion {
|
|
35
|
+
--_button-size: 3rem;
|
|
36
|
+
--_panel-padding: 0.75rem;
|
|
37
|
+
--_panel-gap: 1rem;
|
|
38
|
+
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
gap: 1rem;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@media (min-width: 45em) {
|
|
45
|
+
.accordion {
|
|
46
|
+
flex-direction: row;
|
|
47
|
+
height: 30rem;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.accordion * {
|
|
52
|
+
margin: 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.accordion-panel {
|
|
56
|
+
position: relative;
|
|
57
|
+
isolation: isolate;
|
|
58
|
+
flex-basis: calc((var(--_panel-padding) * 2) + var(--_button-size));
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
padding: var(--_panel-padding);
|
|
61
|
+
padding-right: calc(var(--_panel-padding) * 4);
|
|
62
|
+
border-radius: calc(((var(--_panel-padding) * 2) + var(--_button-size)) / 2);
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
67
|
+
.accordion-panel {
|
|
68
|
+
transition: flex-basis 500ms, flex-grow 500ms;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.accordion-panel:nth-child(1) {
|
|
73
|
+
--_panel-color: red;
|
|
74
|
+
}
|
|
75
|
+
.accordion-panel:nth-child(2) {
|
|
76
|
+
--_panel-color: blue;
|
|
77
|
+
}
|
|
78
|
+
.accordion-panel:nth-child(3) {
|
|
79
|
+
--_panel-color: green;
|
|
80
|
+
}
|
|
81
|
+
.accordion-panel:nth-child(4) {
|
|
82
|
+
--_panel-color: yellow;
|
|
83
|
+
}
|
|
84
|
+
.accordion-panel:nth-child(5) {
|
|
85
|
+
--_panel-color: orange;
|
|
86
|
+
}
|
|
87
|
+
.accordion-panel:nth-child(6) {
|
|
88
|
+
--_panel-color: purple;
|
|
89
|
+
}
|
|
90
|
+
.accordion-panel:nth-child(7) {
|
|
91
|
+
--_panel-color: pink;
|
|
92
|
+
}
|
|
93
|
+
.accordion-panel:nth-child(8) {
|
|
94
|
+
--_panel-color: brown;
|
|
95
|
+
}
|
|
96
|
+
.accordion-panel:nth-child(9) {
|
|
97
|
+
--_panel-color: cyan;
|
|
98
|
+
}
|
|
99
|
+
.accordion-panel:nth-child(10) {
|
|
100
|
+
--_panel-color: magenta;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.accordion-panel:has([aria-expanded="true"]) {
|
|
104
|
+
flex-basis: clamp(15rem, 40vh, 20rem);
|
|
105
|
+
flex-grow: 1;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.accordion-trigger {
|
|
109
|
+
outline: 0 !important;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.accordion-panel:focus-within {
|
|
113
|
+
outline: 3px solid var(--_panel-color);
|
|
114
|
+
outline-offset: 4px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.accordion-content > p {
|
|
118
|
+
transform: translateY(2rem);
|
|
119
|
+
opacity: 0;
|
|
120
|
+
margin-left: calc(var(--_button-size) + var(--_panel-gap));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
124
|
+
.accordion-panel:has([aria-expanded="true"]) .accordion-content > p {
|
|
125
|
+
transition: transform 500ms 500ms, opacity 500ms 500ms;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.accordion-panel:has([aria-expanded="true"]) .accordion-content > p {
|
|
130
|
+
transform: translateY(0);
|
|
131
|
+
opacity: 1;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.accordion-title {
|
|
135
|
+
font-size: 1.5rem;
|
|
136
|
+
font-weight: 700;
|
|
137
|
+
position: relative;
|
|
138
|
+
isolation: isolate;
|
|
139
|
+
display: grid;
|
|
140
|
+
align-items: center;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@media (max-width: 44.999em) {
|
|
144
|
+
.accordion-title::after {
|
|
145
|
+
content: "";
|
|
146
|
+
position: absolute;
|
|
147
|
+
|
|
148
|
+
left: calc((var(--_panel-gap) + var(--_button-size)) * -1);
|
|
149
|
+
width: calc(100% + (var(--_button-size) * 2));
|
|
150
|
+
height: var(--_button-size);
|
|
151
|
+
background: hsl(0 0% 0% /0.55);
|
|
152
|
+
z-index: -1;
|
|
153
|
+
border-radius: 100vw;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.accordion-image {
|
|
158
|
+
position: absolute;
|
|
159
|
+
inset: 0;
|
|
160
|
+
width: 100%;
|
|
161
|
+
height: 100%;
|
|
162
|
+
object-fit: cover;
|
|
163
|
+
z-index: -1;
|
|
164
|
+
transition: filer 500ms;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.accordion-panel:has([aria-expanded="true"]) .accordion-image {
|
|
168
|
+
filter: brightness(0.5);
|
|
169
|
+
}
|
|
170
|
+
.accordion-trigger {
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
flex-direction: row-reverse;
|
|
174
|
+
gap: var(--_panel-gap);
|
|
175
|
+
background: transparent;
|
|
176
|
+
border: 0;
|
|
177
|
+
padding: 0;
|
|
178
|
+
}
|
|
179
|
+
.accordion-icon {
|
|
180
|
+
fill: var(--_panel-color);
|
|
181
|
+
background: hsl(0 0% 0% /0.55);
|
|
182
|
+
width: var(--_button-size);
|
|
183
|
+
aspect-ratio: 1/1;
|
|
184
|
+
padding: 0.75rem;
|
|
185
|
+
border-radius: 50%;
|
|
186
|
+
z-index: 10;
|
|
187
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import "./App.css";
|
|
3
|
+
|
|
4
|
+
function UseImageAccordion({ accordionData }) {
|
|
5
|
+
const [activePanel, setActivePanel] = useState(null);
|
|
6
|
+
|
|
7
|
+
function toggleAccordion(panelToActivate) {
|
|
8
|
+
setActivePanel((prevPanel) => {
|
|
9
|
+
if (prevPanel === panelToActivate) {
|
|
10
|
+
return prevPanel;
|
|
11
|
+
} else {
|
|
12
|
+
return panelToActivate;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setActivePanel(accordionData[0].id);
|
|
19
|
+
}, []);
|
|
20
|
+
|
|
21
|
+
if (!accordionData) return null;
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<div className="wrapper">
|
|
25
|
+
<div className="accordion">
|
|
26
|
+
{accordionData.map((item) => (
|
|
27
|
+
<div
|
|
28
|
+
key={item.id}
|
|
29
|
+
className="accordion-panel"
|
|
30
|
+
onClick={() => toggleAccordion(item.id)}
|
|
31
|
+
>
|
|
32
|
+
<h2 id={item.id}>
|
|
33
|
+
<button
|
|
34
|
+
type="button"
|
|
35
|
+
className="accordion-trigger"
|
|
36
|
+
aria-controls="panel1-content"
|
|
37
|
+
aria-expanded={activePanel === item.id}
|
|
38
|
+
>
|
|
39
|
+
<span className="accordion-title" id={item.id}>
|
|
40
|
+
Boating
|
|
41
|
+
</span>
|
|
42
|
+
<svg aria-hidden="true" className="accordion-icon">
|
|
43
|
+
<image href={item.svg}></image>
|
|
44
|
+
</svg>
|
|
45
|
+
</button>
|
|
46
|
+
</h2>
|
|
47
|
+
<div
|
|
48
|
+
className="accordion-content"
|
|
49
|
+
id={item.id}
|
|
50
|
+
aria-labelledby={item.id}
|
|
51
|
+
aria-hidden={activePanel !== item.id}
|
|
52
|
+
role="region"
|
|
53
|
+
>
|
|
54
|
+
<p>{item.content}</p>
|
|
55
|
+
<img
|
|
56
|
+
className="accordion-image"
|
|
57
|
+
src={item.image}
|
|
58
|
+
alt={item.alt}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
))}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default UseImageAccordion;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./React-image-accordion";
|
package/src/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"title": "Boating",
|
|
4
|
+
"id": 1,
|
|
5
|
+
"image": "https://picsum.photos/400/600",
|
|
6
|
+
"alt": "first panel image",
|
|
7
|
+
"content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Saepe id numquam ab molestias sint beatae provident possimus doloribus autem repudiandae!",
|
|
8
|
+
"svg": "aa (1).svg"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"title": "Fishing",
|
|
12
|
+
"id": 2,
|
|
13
|
+
"image": "https://picsum.photos/400/600",
|
|
14
|
+
"alt": "second panel image",
|
|
15
|
+
"content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Saepe id numquam ab molestias sint beatae provident possimus doloribus autem repudiandae!",
|
|
16
|
+
"svg": "aa (2).svg"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"title": "Swimming",
|
|
20
|
+
"id": 3,
|
|
21
|
+
"image": "https://picsum.photos/400/600",
|
|
22
|
+
"alt": "third panel image",
|
|
23
|
+
"content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Saepe id numquam ab molestias sint beatae provident possimus doloribus autem repudiandae!",
|
|
24
|
+
"svg": "aa (3).svg"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"title": "Kayaking",
|
|
28
|
+
"id": 4,
|
|
29
|
+
"image": "https://picsum.photos/400/600",
|
|
30
|
+
"alt": "fourth panel image",
|
|
31
|
+
"content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Saepe id numquam ab molestias sint beatae provident possimus doloribus autem repudiandae!",
|
|
32
|
+
"svg": "aa (4).svg"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"title": "Scuba diving",
|
|
36
|
+
"id": 5,
|
|
37
|
+
"image": "https://picsum.photos/400/600",
|
|
38
|
+
"alt": "fifth panel image",
|
|
39
|
+
"content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Saepe id numquam ab molestias sint beatae provident possimus doloribus autem repudiandae!",
|
|
40
|
+
"svg": "aa (5).svg"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ReactImageAccordion } from "../components/Accordion";
|
|
3
|
+
import MockAccordion from "./MockAccordion.json";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "React Image Accordion",
|
|
7
|
+
component: ReactImageAccordion,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const Template = (args) => <ReactImageAccordion {...args} />;
|
|
11
|
+
|
|
12
|
+
export const App = Template.bind({});
|
|
13
|
+
App.args = {
|
|
14
|
+
accordionData: MockAccordion,
|
|
15
|
+
};
|