beem-component 1.4.5 → 1.4.8

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.
@@ -1,159 +0,0 @@
1
- import React, { useEffect, useCallback, useState } from "react";
2
- import { Clear } from "@material-ui/icons";
3
- import styled from "styled-components";
4
- import { BmBgGrey45, BmPrimaryBlack, BmPrimaryWhite } from "../colors";
5
- import { BmIcons } from "../iconStyles";
6
-
7
- const { Provider, Consumer } = React.createContext();
8
-
9
- export const Overlay = styled.div`
10
- position: fixed;
11
- top: 0;
12
- left: 0;
13
- z-index: 9999;
14
- width: 100%;
15
- height: 100%;
16
- background-color: ${BmBgGrey45};
17
- }
18
- `;
19
- export const ModalContent = styled.div`
20
- display: flex;
21
- flex-direction: column;
22
- border-radius: 0.25rem;
23
- padding: 1rem;
24
- margin: auto;
25
- background: ${BmPrimaryWhite};
26
- width: ${({ size }) => {
27
- if (size) {
28
- console.log({ size });
29
- if (size === "small") return "21.429rem";
30
- if (size === "default") return "35.714rem";
31
- if (size === "large") return "57.143rem";
32
- if (size === "xlarge") return "81.429rem";
33
- return size;
34
- }
35
- return "35.714rem";
36
- }};
37
- > *:not(:last-child) {
38
- margin-bottom: 1rem;
39
- }
40
- `;
41
-
42
- export const ModalWrapper = styled.div`
43
- z-index: 9999;
44
- overflow-x: auto;
45
- overflow-y: auto;
46
- outline: 0;
47
- position: fixed;
48
- height: auto;
49
- top: ${({ centered }) => {
50
- if (centered) {
51
- return "50%";
52
- }
53
- return "10%";
54
- }};
55
- left: 50%;
56
- transform: translate(-50%, -50%);
57
- `;
58
-
59
- export const HeaderWrapper = styled.div`
60
- display: flex;
61
- flex-direction: row;
62
- justify-content: space-between;
63
- padding: 1.143rem 0rem;
64
- `;
65
-
66
- export const HeaderText = styled.h2`
67
- text-align: center;
68
- display: flex;
69
- color: ${BmPrimaryBlack};
70
- margin-left: auto;
71
- `;
72
-
73
- export const Close = styled.div`
74
- display: flex;
75
- justify-content: flex-end;
76
- margin-left: auto;
77
- `;
78
-
79
- export const BmModal = ({
80
- children,
81
- show,
82
- size,
83
- centered,
84
- setShowModals,
85
- ...rest
86
- }) => {
87
- const [toggle, setToggle] = useState(show);
88
- useEffect(() => {
89
- setToggle(show);
90
- }, [show]);
91
- return (
92
- <>
93
- {toggle && (
94
- <>
95
- <Overlay />
96
- <ModalWrapper showModal={show} centered={centered}>
97
- <Provider value={{ toggle, setToggle, size, show }}>
98
- <ModalContent size={size} {...rest}>
99
- {children}
100
- </ModalContent>
101
- </Provider>
102
- </ModalWrapper>
103
- </>
104
- )}
105
- </>
106
- );
107
- };
108
-
109
- const ModalHeader = styled.div`
110
- display: flex;
111
- flex-direction: row;
112
- justify-content: space-between;
113
- `;
114
-
115
- BmModal.Header = ({
116
- children,
117
- leadingIcon,
118
- trailingIcon,
119
- size,
120
- closeButton,
121
- show,
122
- ...rest
123
- }) => {
124
- return (
125
- <Consumer>
126
- {(value) => (
127
- <>
128
- <ModalHeader {...rest}>
129
- {JSON.stringify(value)}
130
- {children}
131
- {closeButton && (
132
- <BmIcons
133
- size="xlarge"
134
- icon={<Clear />}
135
- onClick={() =>
136
- value.setToggle(!value.toggle)
137
- }
138
- {...rest}
139
- />
140
- )}
141
- </ModalHeader>
142
- </>
143
- )}
144
- </Consumer>
145
- );
146
- };
147
-
148
- BmModal.Body = styled.div`
149
- display: flex;
150
- flex-direction: column;
151
- justify-content: space-between;
152
- `;
153
-
154
- BmModal.Footer = styled.div`
155
- display: flex;
156
- justify-content: space-between;
157
- `;
158
-
159
- export default BmModal;