groundfloor-react-ui 1.0.20 → 1.0.21

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,5 +1,5 @@
1
- import React, { useState, useEffect, useRef } from 'react';
2
1
  import PropTypes from 'prop-types';
2
+ import React, { useEffect, useRef, useState } from 'react';
3
3
  import styled, { css, useTheme } from 'styled-components';
4
4
  import defaultThemeColor from '../constants/defaultThemeColor';
5
5
 
@@ -8,185 +8,200 @@ import defaultThemeColor from '../constants/defaultThemeColor';
8
8
  */
9
9
 
10
10
  const StyledBreadcrumb = styled.div`
11
- background: transparent;
12
- color: ${({ theme, variant }) => theme.variant[variant]};
13
- font-size: ${({ isPrimary }) => isPrimary ? '16px' : '14px'};
14
- display: flex;
15
- align-items: center;
16
-
17
- ${({ isWrap }) => {
18
- if (isWrap) {
19
- return css`
20
- width: ${({ block }) => block ? 'auto' : 'fit-content'};
21
- flex-wrap: wrap;
22
- visibility: visible;
23
- `
24
- } else {
25
- return css`
26
- border: 1px solid transparent;
27
- overflow-x: auto;
28
- overflow-y: hidden;
29
- visibility: ${({ isBreadcrumbVisible }) => isBreadcrumbVisible ? 'visible' : 'hidden'};
30
- /* Hide scrollbar for Chrome, Safari and Opera */
31
- &::-webkit-scrollbar {
32
- display: none;
33
- }
34
- /* Hide scrollbar for IE, Edge and Firefox */
35
- &-ms-overflow-style: none; /* IE and Edge */
36
- scrollbar-width: none; /* Firefox */
37
- `
11
+ background: transparent;
12
+ color: ${({ theme, variant }) => theme.variant[variant]};
13
+ font-size: ${({ isPrimary }) => (isPrimary ? '16px' : '14px')};
14
+ display: flex;
15
+ align-items: center;
16
+
17
+ ${({ isWrap }) => {
18
+ if (isWrap) {
19
+ return css`
20
+ width: ${({ block }) => (block ? 'auto' : 'fit-content')};
21
+ flex-wrap: wrap;
22
+ visibility: visible;
23
+ `;
24
+ } else {
25
+ return css`
26
+ border: 1px solid transparent;
27
+ overflow-x: auto;
28
+ overflow-y: hidden;
29
+ visibility: ${({ isBreadcrumbVisible }) =>
30
+ isBreadcrumbVisible ? 'visible' : 'hidden'};
31
+ /* Hide scrollbar for Chrome, Safari and Opera */
32
+ &::-webkit-scrollbar {
33
+ display: none;
38
34
  }
39
- }};
40
-
41
- .breadcrumb-icon svg path {
42
- fill: ${({ theme, variant }) => theme.variant[variant]};
35
+ /* Hide scrollbar for IE, Edge and Firefox */
36
+ &-ms-overflow-style: none; /* IE and Edge */
37
+ scrollbar-width: none; /* Firefox */
38
+ `;
43
39
  }
40
+ }};
44
41
 
45
- .breadcrumb-icon-separator svg path {
46
- fill: ${({ theme, variantSeparator }) => theme.variant[variantSeparator]};
47
- }
42
+ .breadcrumb-icon svg path {
43
+ fill: ${({ theme, variant }) => theme.variant[variant]};
44
+ }
48
45
 
49
- .breadcrumb-icon-separator {
50
- margin: 0 ${({ isPrimary }) => isPrimary ? '12px' : '7px'};
51
- }
46
+ .breadcrumb-icon-separator svg path {
47
+ fill: ${({ theme, variantSeparator }) => theme.variant[variantSeparator]};
48
+ }
49
+
50
+ .breadcrumb-icon-separator {
51
+ margin: 0 ${({ isPrimary }) => (isPrimary ? '12px' : '7px')};
52
+ }
52
53
  `;
53
54
 
54
55
  const StyledCombo = styled.div`
55
- display: flex;
56
- flex-wrap: nowrap;
56
+ display: flex;
57
+ flex-wrap: nowrap;
57
58
  `;
58
59
 
59
60
  const StyledItem = styled.div`
60
- cursor: ${({ href }) => href ? 'pointer' : 'default'};
61
- list-style: none;
62
- color: ${({ theme, variant }) => theme.variant[variant]};
63
- white-space: nowrap;
64
- max-width: 15ch;
65
- white-space: nowrap;
66
- overflow: hidden;
67
- text-overflow: ellipsis;
68
-
69
- &:hover {
70
- text-decoration: ${({ href }) => href ? 'underline' : 'none'};
71
- }
61
+ cursor: ${({ href }) => (href ? 'pointer' : 'default')};
62
+ list-style: none;
63
+ color: ${({ theme, variant }) => theme.variant[variant]};
64
+ white-space: nowrap;
65
+ max-width: 15ch;
66
+ white-space: nowrap;
67
+ overflow: hidden;
68
+ text-overflow: ellipsis;
69
+
70
+ &:hover {
71
+ text-decoration: ${({ href }) => (href ? 'underline' : 'none')};
72
+ }
72
73
  `;
73
74
 
74
- export const Breadcrumb = ({ wrap, block, style, variant, variantSeparator, appLogo, separator, items, onClick, isPrimary, ...props }) => {
75
- const theme = useTheme() || defaultThemeColor;
76
-
77
- const breadcrumbRef = useRef(null)
78
-
79
- const [isBreadcrumbVisible, setIsBreadcrumbVisible] = useState(undefined);
80
-
81
- const handleWindowResize = () => {
82
- if (breadcrumbRef?.current?.scrollWidth < breadcrumbRef?.current?.offsetWidth) {
83
- setIsBreadcrumbVisible(true)
84
- } else {
85
- setIsBreadcrumbVisible(false)
86
- }
75
+ export const Breadcrumb = ({
76
+ wrap,
77
+ block,
78
+ style,
79
+ variant,
80
+ variantSeparator,
81
+ appLogo,
82
+ separator,
83
+ items,
84
+ onClick,
85
+ isPrimary,
86
+ ...props
87
+ }) => {
88
+ const activeTheme = useTheme() || defaultThemeColor;
89
+
90
+ const breadcrumbRef = useRef(null);
91
+
92
+ const [isBreadcrumbVisible, setIsBreadcrumbVisible] = useState(undefined);
93
+
94
+ const handleWindowResize = () => {
95
+ if (
96
+ breadcrumbRef?.current?.scrollWidth < breadcrumbRef?.current?.offsetWidth
97
+ ) {
98
+ setIsBreadcrumbVisible(true);
99
+ } else {
100
+ setIsBreadcrumbVisible(false);
87
101
  }
88
-
89
- useEffect(() => {
90
- handleWindowResize();
91
- }, [items])
92
-
93
- //On component mount add event listener
94
- useEffect(() => {
95
- if (!wrap) {
96
- // Monitor the width of the viewPort to adjust the text of the arrow accordingly
97
- window.addEventListener("resize", handleWindowResize);
98
- return () => (window.removeEventListener("resize", handleWindowResize));
99
- }
100
- }, [])
101
-
102
- const list = (items) ? items.map((item, i) => {
103
- return (
104
- <StyledCombo key={item.label} >
105
- {(i === 0 && !appLogo) ? null : (<div className="breadcrumb-icon-separator">{separator}</div>)}
106
- <StyledItem onClick={() => { if (item.href) onClick(item.href) }} variant={variant} href={item.href} title={item.label}>
107
- {/* If label longer than 15chs trim it by css */}
108
- {item.label}
109
- </StyledItem>
110
- </StyledCombo>
111
- )
112
- }) : (null)
113
-
114
- return (
115
- <StyledBreadcrumb
116
- isWrap={wrap}
117
- ref={!wrap ? breadcrumbRef : null}
118
- isBreadcrumbVisible={isBreadcrumbVisible}
119
- block={block}
102
+ };
103
+
104
+ useEffect(() => {
105
+ handleWindowResize();
106
+ }, [items]);
107
+
108
+ //On component mount add event listener
109
+ useEffect(() => {
110
+ if (!wrap) {
111
+ // Monitor the width of the viewPort to adjust the text of the arrow accordingly
112
+ window.addEventListener('resize', handleWindowResize);
113
+ return () => window.removeEventListener('resize', handleWindowResize);
114
+ }
115
+ }, []);
116
+
117
+ const list = items
118
+ ? items.map((item, i) => {
119
+ return (
120
+ <StyledCombo key={item.label}>
121
+ {i === 0 && !appLogo ? null : (
122
+ <div className='breadcrumb-icon-separator'>{separator}</div>
123
+ )}
124
+ <StyledItem
125
+ theme={activeTheme}
126
+ onClick={() => {
127
+ if (item.href) onClick(item.href);
128
+ }}
120
129
  variant={variant}
121
- variantSeparator={variantSeparator}
122
- style={style}
123
- isPrimary={isPrimary}
124
- {...props}
125
- >
126
- {appLogo && (<div className="breadcrumb-icon">{appLogo}</div>)}
127
- {list}
128
- </StyledBreadcrumb>
129
- )
130
+ href={item.href}
131
+ title={item.label}
132
+ >
133
+ {/* If label longer than 15chs trim it by css */}
134
+ {item.label}
135
+ </StyledItem>
136
+ </StyledCombo>
137
+ );
138
+ })
139
+ : null;
140
+
141
+ return (
142
+ <StyledBreadcrumb
143
+ theme={activeTheme}
144
+ isWrap={wrap}
145
+ ref={!wrap ? breadcrumbRef : null}
146
+ isBreadcrumbVisible={isBreadcrumbVisible}
147
+ block={block}
148
+ variant={variant}
149
+ variantSeparator={variantSeparator}
150
+ style={style}
151
+ isPrimary={isPrimary}
152
+ {...props}
153
+ >
154
+ {appLogo && <div className='breadcrumb-icon'>{appLogo}</div>}
155
+ {list}
156
+ </StyledBreadcrumb>
157
+ );
130
158
  };
131
159
 
132
160
  Breadcrumb.propTypes = {
133
- /**
134
- * Color of text. primary-1, 2, error, etc.
135
- */
136
- variant: PropTypes.string,
137
- /**
138
- * Color of separator. primary-1, 2, error, etc.
139
- */
140
- variantSeparator: PropTypes.string,
141
- /**
142
- * Click handler
143
- */
144
- onClick: PropTypes.func,
145
- /**
146
- * Optional Icon element with app icon
147
- */
148
- appLogo: PropTypes.any,
149
- /**
150
- * Optional Icon element with separator icon
151
- */
152
- separator: PropTypes.any,
153
- /**
154
- * List of the elements of breadcramb
155
- */
156
- items: PropTypes.array,
157
- /**
158
- * Optional width selector
159
- */
160
- block: PropTypes.bool,
161
- /**
162
- * Theme object
163
- */
164
- theme: PropTypes.object,
165
- /**
166
- * If true wrap items when shrink else hide
167
- */
168
- wrap: PropTypes.bool,
169
- /**
170
- * If true bigger font and margin, if false it means secondary breadcrum with smaller font and less margin
171
- */
172
- isPrimary: PropTypes.bool,
161
+ /**
162
+ * Color of text. primary-1, 2, error, etc.
163
+ */
164
+ variant: PropTypes.string,
165
+ /**
166
+ * Color of separator. primary-1, 2, error, etc.
167
+ */
168
+ variantSeparator: PropTypes.string,
169
+ /**
170
+ * Click handler
171
+ */
172
+ onClick: PropTypes.func,
173
+ /**
174
+ * Optional Icon element with app icon
175
+ */
176
+ appLogo: PropTypes.any,
177
+ /**
178
+ * Optional Icon element with separator icon
179
+ */
180
+ separator: PropTypes.any,
181
+ /**
182
+ * List of the elements of breadcramb
183
+ */
184
+ items: PropTypes.array,
185
+ /**
186
+ * Optional width selector
187
+ */
188
+ block: PropTypes.bool,
189
+
190
+ /**
191
+ * If true wrap items when shrink else hide
192
+ */
193
+ wrap: PropTypes.bool,
194
+ /**
195
+ * If true bigger font and margin, if false it means secondary breadcrum with smaller font and less margin
196
+ */
197
+ isPrimary: PropTypes.bool,
173
198
  };
174
199
 
175
- StyledBreadcrumb.defaultProps = {
176
- theme: defaultThemeColor,
177
- }
178
-
179
- StyledItem.defaultProps = {
180
- theme: defaultThemeColor,
181
- }
182
-
183
200
  Breadcrumb.defaultProps = {
184
- theme: defaultThemeColor,
185
- variant: 'neutral-2',
186
- variantSeparator: 'neutral-3',
187
- block: false,
188
- onClick: undefined,
189
- wrap: false,
190
- isPrimary: true
191
- };
192
-
201
+ variant: 'neutral-2',
202
+ variantSeparator: 'neutral-3',
203
+ block: false,
204
+ onClick: undefined,
205
+ wrap: false,
206
+ isPrimary: true,
207
+ };
@@ -1,64 +1,71 @@
1
- import React, { forwardRef } from 'react';
2
1
  import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
2
+ import React, { forwardRef } from 'react';
3
+ import styled, { useTheme } from 'styled-components';
4
4
  import defaultStyles from '../constants/defaultStyle';
5
+ import defaultThemeColor from '../constants/defaultThemeColor';
5
6
 
6
7
  const CardWrapper = styled.div`
7
- //Set the styles from the default styles object
8
- ${({ theme, type }) => {
9
- if (theme) {
8
+
9
+ color: ${({ activeTheme }) => activeTheme.textColor};
10
+ padding-top: 25px;
11
+ padding-bottom: 25px;
12
+ padding-left: 32px;
13
+ padding-right: 32px;
14
+ background-color: ${({ activeTheme }) => activeTheme.bgColor};
15
+ width: inherit;
16
+ border-radius: 5px;
17
+ box-shadow: 0px 5px 37px rgba(56, 66, 100, 0.0880136);
18
+ border-color: ${({ activeTheme }) => activeTheme.border};
19
+ transition: all .5s ease .95ms !important;
20
+
21
+ //Set the styles from the default styles object
22
+ ${({ inBuiltCss, type }) => {
23
+ if (inBuiltCss) {
10
24
  let tempObj = {};
11
- if (theme[type]) {
12
- for (const property in theme[type]) {
13
- tempObj[property] = theme[type][property]
14
- delete theme.common[property]
25
+ if (inBuiltCss[type]) {
26
+ for (const property in inBuiltCss[type]) {
27
+ tempObj[property] = inBuiltCss[type][property];
28
+ delete inBuiltCss.common[property];
15
29
  }
16
- for (const property in theme['common']) {
17
- tempObj[property] = theme['common'][property]
30
+ for (const property in inBuiltCss['common']) {
31
+ tempObj[property] = inBuiltCss['common'][property];
18
32
  }
19
33
  }
20
34
  return tempObj;
21
35
  }
22
36
  }}
23
-
24
- // custom styles
37
+
38
+ // custom styles
25
39
  ${({ customStyles }) => customStyles}
26
40
  `;
27
41
 
28
- CardWrapper.defaultProps = {
29
- theme: defaultStyles
30
- }
42
+ export const CardRef = forwardRef(({ type, header, content, ...props }, ref) => {
43
+ const activeTheme = useTheme() || defaultThemeColor;
31
44
 
32
- export const CardRef = forwardRef(({ type, theme, header, content, ...props }, ref) => {
33
45
  return (
34
- <CardWrapper theme={defaultStyles} type={'card'} {...props} ref={ref}>
46
+ <CardWrapper
47
+ inBuiltCss={defaultStyles}
48
+ activeTheme={activeTheme}
49
+ {...props}
50
+ ref={ref}
51
+ >
35
52
  {header}
36
53
  {content}
37
54
  </CardWrapper>
38
- )
39
- })
55
+ );
56
+ });
40
57
 
41
58
  CardRef.propTypes = {
42
- /**
43
- * theme Object
44
- */
45
- theme: PropTypes.object,
46
59
  /**
47
60
  * the type of the element
48
- */
61
+ */
49
62
  type: PropTypes.string,
50
63
  /**
51
- * header of the card
64
+ * header of the card
52
65
  */
53
66
  header: PropTypes.any,
54
67
  /**
55
68
  * the content of the card
56
- */
69
+ */
57
70
  content: PropTypes.any,
58
- }
59
-
60
- CardRef.defaultProps = {
61
- theme: defaultStyles,
62
- type: 'card',
63
- }
64
-
71
+ };
@@ -1,6 +1,6 @@
1
- import React from "react";
2
1
  import PropTypes from 'prop-types';
3
- import styled, { css } from 'styled-components';
2
+ import React from "react";
3
+ import styled from 'styled-components';
4
4
  import defaultStyles from '../constants/defaultStyle';
5
5
 
6
6
  /**
@@ -26,68 +26,59 @@ import defaultStyles from '../constants/defaultStyle';
26
26
 
27
27
  const StyledContainer = styled.div`
28
28
  //Set the styles from the default styles object
29
- ${({ theme, type, drawerOpen, customStyles }) => {
30
- if (theme) {
31
- let tempObj = {};
32
- if (theme[type]) {
33
- for (const property in theme['common']) {
34
- tempObj[property] = theme['common'][property]
35
- }
36
- for (const property in theme[type]) {
37
- delete theme.common[property]
38
- tempObj[property] = theme[type][property]
39
- }
40
- if (drawerOpen) {
41
- tempObj = { ...tempObj, ...theme['drawer-open'] }
42
- } else {
43
- tempObj = { ...tempObj, ...theme['drawer-close'] }
44
- }
45
- }
46
- return { ...tempObj, ...customStyles };
29
+ ${({ inBuiltCss, type, drawerOpen, customStyles }) => {
30
+ if (inBuiltCss) {
31
+ let tempObj = {};
32
+ if (inBuiltCss[type]) {
33
+ for (const property in inBuiltCss['common']) {
34
+ tempObj[property] = inBuiltCss['common'][property]
35
+ }
36
+ for (const property in inBuiltCss[type]) {
37
+ delete inBuiltCss.common[property]
38
+ tempObj[property] = inBuiltCss[type][property]
39
+ }
40
+ if (drawerOpen) {
41
+ tempObj = { ...tempObj, ...inBuiltCss['drawer-open'] }
42
+ } else {
43
+ tempObj = { ...tempObj, ...inBuiltCss['drawer-close'] }
47
44
  }
48
- }}
45
+ }
46
+ return { ...tempObj, ...customStyles };
47
+ }
48
+ }}
49
49
  `;
50
50
 
51
51
  export const Drawer = ({
52
- theme,
53
- customStyles,
54
- drawerOpen,
55
- children,
56
- ...props
52
+ customStyles,
53
+ drawerOpen,
54
+ children,
55
+ ...props
57
56
  }) => {
58
57
 
59
58
 
60
- // return ReactDom.createPortal(
61
- return (
62
- <StyledContainer
63
- theme={theme}
64
- customStyles={customStyles}
65
- type={'drawer'}
66
- drawerOpen={drawerOpen}
67
- {...props}
68
- >
69
- {children}
70
- </StyledContainer>
59
+ // return ReactDom.createPortal(
60
+ return (
61
+ <StyledContainer
62
+ inBuiltCss={defaultStyles}
63
+ customStyles={customStyles}
64
+ type={'drawer'}
65
+ drawerOpen={drawerOpen}
66
+ {...props}
67
+ >
68
+ {children}
69
+ </StyledContainer>
71
70
 
72
- );
71
+ );
73
72
  };
74
73
 
75
74
  Drawer.propTypes = {
76
- /**
77
- * Theme object
78
- */
79
- theme: PropTypes.object,
80
- /**
81
- * Custom style object
82
- */
83
- customStyles: PropTypes.object,
84
- /**
85
- * Boolean value to to open and close the drawer
86
- */
87
- drawerOpen: PropTypes.bool,
88
- };
89
-
90
- Drawer.defaultProps = {
91
- theme: defaultStyles,
92
- };
93
75
 
76
+ /**
77
+ * Custom style object
78
+ */
79
+ customStyles: PropTypes.object,
80
+ /**
81
+ * Boolean value to to open and close the drawer
82
+ */
83
+ drawerOpen: PropTypes.bool,
84
+ };
@@ -1,24 +1,24 @@
1
- import React, { useState, useEffect, useRef } from "react";
2
1
  import PropTypes from 'prop-types';
2
+ import React, { useEffect, useRef, useState } from "react";
3
3
  import styled from 'styled-components';
4
4
  import defaultStyles from '../constants/defaultStyle';
5
5
 
6
6
  const ImageLayout = styled.img`
7
7
  //Set the styles from the default styles object
8
- ${({ theme, type, size, customStyles }) => {
9
- if (theme) {
8
+ ${({ inBuiltCss, type, size, customStyles }) => {
9
+ if (inBuiltCss) {
10
10
  let tempObj = {};
11
- if (theme[type]) {
12
- for (const property in theme['common']) {
13
- tempObj[property] = theme['common'][property]
11
+ if (inBuiltCss[type]) {
12
+ for (const property in inBuiltCss['common']) {
13
+ tempObj[property] = inBuiltCss['common'][property]
14
14
  }
15
- for (const property in theme[type]) {
16
- tempObj[property] = theme[type][property]
17
- delete theme.common[property]
15
+ for (const property in inBuiltCss[type]) {
16
+ tempObj[property] = inBuiltCss[type][property]
17
+ delete inBuiltCss.common[property]
18
18
  }
19
- for (const property in theme[`${type}${size}`]) {
20
- tempObj[property] = theme[`${type}${size}`][property]
21
- delete theme.common[property]
19
+ for (const property in inBuiltCss[`${type}${size}`]) {
20
+ tempObj[property] = inBuiltCss[`${type}${size}`][property]
21
+ delete inBuiltCss.common[property]
22
22
  }
23
23
  }
24
24
  return { ...tempObj, ...customStyles };
@@ -26,7 +26,7 @@ const ImageLayout = styled.img`
26
26
  }}
27
27
  `;
28
28
 
29
- export const Image = ({ theme, customStyles, type, size, alt, src, handleImageStatus, ...props }) => {
29
+ export const Image = ({ customStyles, type, size, alt, src, handleImageStatus, ...props }) => {
30
30
 
31
31
  const [imageStatus, setImageStatus] = useState("loading");
32
32
 
@@ -58,7 +58,7 @@ export const Image = ({ theme, customStyles, type, size, alt, src, handleImageSt
58
58
  return (
59
59
  <ImageLayout
60
60
  {...props}
61
- theme={theme}
61
+ inBuiltCss={defaultStyles}
62
62
  customStyles={customStyles}
63
63
  type={type}
64
64
  alt={alt}
@@ -70,10 +70,7 @@ export const Image = ({ theme, customStyles, type, size, alt, src, handleImageSt
70
70
  }
71
71
 
72
72
  Image.propTypes = {
73
- /**
74
- * Theme props
75
- */
76
- theme: PropTypes.object,
73
+
77
74
  /**
78
75
  * Custom style object
79
76
  */
@@ -102,11 +99,9 @@ Image.propTypes = {
102
99
  }
103
100
 
104
101
  Image.defaultProps = {
105
- theme: defaultStyles,
106
102
  customStyles: null,
107
103
  type: 'image',
108
104
  alt: 'image alternative',
109
105
  src: null,
110
106
  handleImageStatus: null
111
- }
112
-
107
+ }