1
|
1 |
|
import "./styles.css"; |
2
|
|
|
|
3
|
|
|
import { ContainerComponent } from "./types"; |
4
|
|
|
|
5
|
1 |
|
import { buildComponent } from "../../../utils"; |
6
|
1 |
|
import classNames from "classnames"; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* A simple but smart container, enhanced with modular-ui common props and animations (if enabled) |
10
|
|
|
* |
11
|
|
|
* @since 3.0.0 |
12
|
|
|
* |
13
|
|
|
* @param wrapper component type. The Container component can wrap a content inside different components (by now, ) |
14
|
|
|
* @param children content to render inside Container |
15
|
|
|
* @param animated if `true`, the Container will be showed with a fade-in effect |
16
|
|
|
* @param {string} className `common modular-ui prop` - custom className (to better customize it) |
17
|
|
|
* @param {boolean} unstyled `common modular-ui prop` - Style/unstyle component (to better customize it) |
18
|
|
|
* @param {string} id `common modular-ui prop` - `data-id` parameter (for testing purpose, to easily find the component into the DOM) |
19
|
|
|
* @param {boolean} dark `common modular-ui prop` - Enable/disable dark mode |
20
|
|
|
* @param {boolean} hide `common modular-ui prop` - Hide/show component |
21
|
|
|
* @param {boolean} shadow `common modular-ui prop` - Enable/disable shadow behind component (to better customize it) |
22
|
|
|
* |
23
|
|
|
* @example <caption>Example Container usage</caption> |
24
|
|
|
* import { render } from "react-dom"; |
25
|
|
|
* import { Container } from '@cianciarusocataldo/modular-ui'; |
26
|
|
|
* |
27
|
|
|
* render(<Container animated dark> Example content </Container>, document.getElementById("root")); |
28
|
|
|
* |
29
|
|
|
* @see https://cianciarusocataldo.github.io/modular-ui/components/molecules/Container |
30
|
|
|
* |
31
|
|
|
* @author Cataldo Cianciaruso <https://github.com/CianciarusoCataldo> |
32
|
|
|
* |
33
|
|
|
* @copyright 2022 Cataldo Cianciaruso |
34
|
|
|
*/ |
35
|
1 |
|
const Container: ContainerComponent = ({ |
36
|
19 |
|
children, |
37
|
19 |
|
wrapper, |
38
|
19 |
|
animated, |
39
|
19 |
|
...commonProps |
40
|
|
|
}) => |
41
|
19 |
|
buildComponent({ |
42
|
|
|
name: "modular-container", |
43
|
|
|
Component: children, |
44
|
|
|
commonProps: { |
45
|
|
|
...commonProps, |
46
|
|
|
className: classNames(commonProps.className, { |
47
|
|
|
animated: animated && !commonProps.hide, |
48
|
|
|
}), |
49
|
|
|
}, |
50
|
|
|
wrapper, |
51
|
|
|
}); |
52
|
|
|
|
53
|
|
|
export default Container; |
54
|
|
|
|