18 | {React.Children.toArray(children)
19 | .slice(0, stackableIndex + 1)
20 | .map((child: React.ReactElement, index, array) => (
21 |
32 | {child}
33 | {closeIcon}
34 |
35 | ))}
36 |
37 | )
38 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import typescriptPlugin from 'rollup-plugin-typescript2'
2 | import commonjs from '@rollup/plugin-commonjs'
3 | import external from 'rollup-plugin-peer-deps-external'
4 | import postcss from 'rollup-plugin-postcss'
5 | import resolve from '@rollup/plugin-node-resolve'
6 | import url from '@rollup/plugin-url'
7 | import svgr from '@svgr/rollup'
8 | import progress from 'rollup-plugin-progress'
9 | import { sizeSnapshot } from 'rollup-plugin-size-snapshot'
10 | import { terser } from 'rollup-plugin-terser'
11 |
12 | import pkg from './package.json'
13 |
14 | export default {
15 | input: './src/index.tsx',
16 | output: [
17 | {
18 | file: pkg.main,
19 | format: 'cjs',
20 | exports: 'auto',
21 | sourcemap: true
22 | },
23 | {
24 | file: pkg.module,
25 | format: 'es',
26 | exports: 'auto',
27 | sourcemap: true
28 | }
29 | ],
30 | plugins: [
31 | progress(),
32 | external(),
33 | postcss({
34 | inject: true,
35 | modules: {
36 | generateScopedName: 'hm_[local]'
37 | },
38 | autoModules: false
39 | }),
40 | url(),
41 | svgr(),
42 | resolve(),
43 | typescriptPlugin({
44 | rollupCommonJSResolveHack: true,
45 | clean: true
46 | }),
47 | commonjs(),
48 | sizeSnapshot(),
49 | terser()
50 | ]
51 | }
52 |
--------------------------------------------------------------------------------
/src/stories/Modal.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react'
2 | import HyperModal, { ModalStack, ModalStackProps } from '../index'
3 |
4 | export const Modal = () => {
5 | const [index, setIndex] = React.useState(0)
6 | return (
7 |