datastake-daf 0.6.596 → 0.6.598

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.
@@ -0,0 +1,268 @@
1
+ import styled, { createGlobalStyle } from "styled-components";
2
+ import { MOBILE_WIDTH, TABLET_WIDTH } from "datastake-daf/src/constants/Style";
3
+
4
+ // Global styles for portaled elements (dropdowns, modals, etc.)
5
+ export const GlobalNavbarStyles = createGlobalStyle`
6
+ .language-select-popup {
7
+ .ant-select-dropdown {
8
+ padding: 4px;
9
+ background: #ffffff;
10
+ border-radius: 8px;
11
+ box-shadow: 0px 12px 16px -4px rgba(16, 24, 40, 0.08),
12
+ 0px 4px 6px -2px rgba(16, 24, 40, 0.03);
13
+ border: none !important;
14
+ }
15
+
16
+ .ant-select-item {
17
+ border-radius: 6px;
18
+ padding: 8px 12px;
19
+ min-height: 40px;
20
+ transition: all 0.2s ease;
21
+
22
+ &:hover {
23
+ background-color: #265a80;
24
+
25
+ .language-option span {
26
+ color: #ffffff;
27
+ }
28
+ }
29
+
30
+ &.ant-select-item-option-selected {
31
+ background-color: #265a80;
32
+ color: #ffffff;
33
+
34
+ .language-option span {
35
+ color: #ffffff;
36
+ }
37
+ }
38
+
39
+ .language-option {
40
+ display: flex;
41
+ align-items: center;
42
+ gap: 8px;
43
+
44
+ .flag-icon {
45
+ width: 20px;
46
+ height: 14px;
47
+ border-radius: 2px;
48
+ }
49
+
50
+ span {
51
+ font-size: 14px;
52
+ font-weight: 500;
53
+ color: #344054;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ `;
59
+
60
+ const style = styled.div`
61
+ font-family: Outfit;
62
+
63
+ .btns {
64
+ display: flex;
65
+ gap: 12px;
66
+ }
67
+
68
+ .d-container {
69
+ width: 80vw;
70
+ margin-left: auto;
71
+ margin-right: auto;
72
+
73
+ @media (max-width: 1440px) {
74
+ width: 85vw;
75
+ }
76
+
77
+ @media (${TABLET_WIDTH}) {
78
+ width: calc(100vw - 4.6rem);
79
+ }
80
+ }
81
+
82
+ .flex-c {
83
+ display: flex;
84
+ flex-direction: column;
85
+ }
86
+
87
+ .jus-c {
88
+ justify-content: center;
89
+ }
90
+
91
+ .d-navbar {
92
+ box-shadow: 0px 12px 16px -4px rgba(16, 24, 40, 0.08), 0px 4px 6px -2px rgba(16, 24, 40, 0.03);
93
+ position: fixed;
94
+ top: 0;
95
+ left: 0;
96
+ right: 0;
97
+ background-color: white;
98
+ z-index: 1000;
99
+ width: 100%;
100
+ height: 80px;
101
+ display: flex;
102
+ align-items: center;
103
+
104
+ @media (${TABLET_WIDTH}) {
105
+ height: 72px;
106
+ }
107
+
108
+ @media (${MOBILE_WIDTH}) {
109
+ height: 64px;
110
+ }
111
+
112
+ .main-cont {
113
+ display: flex;
114
+ align-items: center;
115
+ justify-content: space-between;
116
+ width: 100%;
117
+ height: 100%;
118
+ padding: 0 80px;
119
+
120
+ @media (max-width: 1200px) {
121
+ padding: 0 32px;
122
+ }
123
+
124
+ @media (${TABLET_WIDTH}) {
125
+ padding: 0 24px;
126
+ }
127
+
128
+ @media (${MOBILE_WIDTH}) {
129
+ padding: 0 16px;
130
+ }
131
+
132
+ .left {
133
+ display: flex;
134
+ align-items: center;
135
+ height: 100%;
136
+
137
+ .navbar-logo {
138
+ cursor: pointer;
139
+ height: 30px;
140
+ width: auto;
141
+ object-fit: contain;
142
+
143
+ @media (${MOBILE_WIDTH}) {
144
+ height: 32px;
145
+ }
146
+ }
147
+
148
+ img {
149
+ cursor: pointer;
150
+ height: 40px;
151
+ width: auto;
152
+ object-fit: contain;
153
+
154
+ @media (${MOBILE_WIDTH}) {
155
+ height: 32px;
156
+ }
157
+ }
158
+ }
159
+
160
+ .right {
161
+ display: flex;
162
+ gap: 1rem;
163
+ align-items: center;
164
+
165
+ .language-select {
166
+ min-width: 100px;
167
+
168
+ .ant-select-selector {
169
+ padding: 8px 12px !important;
170
+ height: auto !important;
171
+ border: none !important;
172
+
173
+ .ant-select-selection-item {
174
+ padding: 0 !important;
175
+ line-height: none !important;
176
+ &:hover{
177
+ background-color: transparent !important;
178
+ border: none !important;
179
+ }
180
+ }
181
+ }
182
+
183
+ .ant-select-arrow {
184
+ color: #667085;
185
+ display: flex;
186
+ align-items: center;
187
+ height: 80%;
188
+ }
189
+ }
190
+
191
+ .language-option {
192
+ display: flex;
193
+ align-items: center;
194
+ gap: 8px;
195
+
196
+ .flag-icon {
197
+ width: 20px;
198
+ height: 15px;
199
+ object-fit: cover;
200
+ border-radius: 2px;
201
+ }
202
+
203
+ span {
204
+ font-size: 14px;
205
+ font-weight: 500;
206
+ color: #344054;
207
+ }
208
+ }
209
+
210
+ .ant-btn {
211
+ font-size: 14px;
212
+ padding: 6px 0;
213
+ text-align: center;
214
+ width: 70px;
215
+
216
+ @media (${MOBILE_WIDTH}) {
217
+ padding: 3px 0;
218
+ }
219
+ }
220
+
221
+ @media (max-width: 1070px) {
222
+ gap: 1rem;
223
+ }
224
+ }
225
+ }
226
+ }
227
+
228
+ &.bordered {
229
+ .d-navbar {
230
+ position: relative;
231
+ box-shadow: unset;
232
+ border-bottom: 1px solid var(--base-gray-40);
233
+ }
234
+ }
235
+
236
+ .tazama-extra {
237
+ &.mobile {
238
+ display: none;
239
+ }
240
+
241
+ @media (${MOBILE_WIDTH}) {
242
+ &.mobile {
243
+ display: flex;
244
+ }
245
+
246
+ &.desktop {
247
+ display: none;
248
+ }
249
+ }
250
+
251
+ .nav-extra {
252
+ position: fixed;
253
+ top: 0;
254
+ left: 0;
255
+ height: 100dvh;
256
+ width: 100%;
257
+ background: white;
258
+ margin-left: -100%;
259
+ transition: 0.4s margin-left;
260
+
261
+ &.toggled {
262
+ margin-left: 0;
263
+ }
264
+ }
265
+ }
266
+ `;
267
+
268
+ export default style;
@@ -0,0 +1,146 @@
1
+ /* eslint-disable react/prop-types */
2
+ import React, { useEffect, useMemo, useRef, useState } from "react"
3
+ import { formatClassname } from '../../../../../helpers/ClassesHelper.js';
4
+ import Style from "./style";
5
+
6
+ function useOutsideAlerter({ ref, secondRef, onOutside = () => { } }) {
7
+ useEffect(() => {
8
+ function handleClickOutside(event) {
9
+ if (ref.current && !ref.current.contains(event.target)
10
+ && secondRef.current && !secondRef.current.contains(event.target)) {
11
+ onOutside();
12
+ }
13
+ }
14
+
15
+ document.addEventListener("mousedown", handleClickOutside);
16
+ return () => {
17
+ document.removeEventListener("mousedown", handleClickOutside);
18
+ };
19
+ }, [ref]);
20
+ }
21
+
22
+ const Options = ({
23
+ values = [],
24
+ onChange = () => { },
25
+ value = '',
26
+ setToggled = () => { },
27
+ toggled = false,
28
+ secondRef = {},
29
+ }) => {
30
+ const ref = useRef();
31
+ useOutsideAlerter({ ref, secondRef, onOutside: () => setToggled(false) });
32
+
33
+ return (
34
+ <div
35
+ className={formatClassname(['select-options', !toggled && 'not-toggled'])}
36
+ ref={ref}
37
+ >
38
+ {values.map((val) => (
39
+ <div
40
+ className={formatClassname(['value', val.value === value && 'active-value'])}
41
+ key={val.value}
42
+ onClick={() => onChange(val.value)}
43
+ >
44
+ {val.label}
45
+ </div>
46
+ ))}
47
+ </div>
48
+ );
49
+ }
50
+
51
+ let timeout = null;
52
+
53
+ export const Select = ({
54
+ bordered,
55
+ values = [],
56
+ defaultValue = '',
57
+ onChange = () => { },
58
+ }) => {
59
+ const ref = useRef();
60
+ const [value, setValue] = useState(defaultValue);
61
+ const [toggled, setToggled] = useState(false);
62
+ const [visible, setVisible] = useState(false);
63
+
64
+ useEffect(() => {
65
+ setValue(defaultValue);
66
+ }, [defaultValue]);
67
+
68
+ const valueLabel = useMemo(() => {
69
+ if (value === 'en') {
70
+ return (
71
+ <div className="country-cont flex-r">
72
+ <div className="flex-c jus-c">
73
+ <img src="/assets/images/countries/gb.png" alt="" />
74
+ </div>
75
+ <div className="flex-c jus-c">
76
+ <span>EN</span>
77
+ </div>
78
+ </div>
79
+ );
80
+ }
81
+
82
+ if (value === 'sp') {
83
+ return (
84
+ <div className="country-cont flex-r">
85
+ <div className="flex-c jus-c">
86
+ <img src="/assets/images/countries/sp.png" alt="" />
87
+ </div>
88
+ <div className="flex-c jus-c">
89
+ <span>ES</span>
90
+ </div>
91
+ </div>
92
+ );
93
+ }
94
+
95
+ return (
96
+ <div className="country-cont flex-r">
97
+ <div className="flex-c jus-c">
98
+ <img src="/assets/images/countries/fr.png" alt="" />
99
+ </div>
100
+ <div className="flex-c jus-c">
101
+ <span>FR</span>
102
+ </div>
103
+ </div>
104
+ );
105
+ }, [values, value]);
106
+
107
+ useEffect(() => {
108
+ if (toggled) {
109
+ setVisible(true);
110
+ } else {
111
+ timeout = setTimeout(() => setVisible(false), 300);
112
+ }
113
+ return () => {
114
+ if (timeout) {
115
+ clearTimeout(timeout);
116
+ timeout = null;
117
+ }
118
+ }
119
+ }, [toggled]);
120
+
121
+ return (
122
+ <Style>
123
+ <div
124
+ className={formatClassname(['select-navbar', bordered && 'bordered'])}
125
+ onClick={() => setToggled((p) => !p)}
126
+ ref={ref}
127
+ >
128
+ <div>{valueLabel}</div>
129
+ </div>
130
+ {visible && (
131
+ <Options
132
+ value={value}
133
+ secondRef={ref}
134
+ values={values}
135
+ toggled={toggled}
136
+ onChange={(val) => {
137
+ setValue(val);
138
+ setToggled(false);
139
+ onChange(val);
140
+ }}
141
+ setToggled={setToggled}
142
+ />
143
+ )}
144
+ </Style>
145
+ );
146
+ }
@@ -0,0 +1,122 @@
1
+ import styled from "styled-components";
2
+ import { MOBILE_WIDTH, TABLET_WIDTH } from "datastake-daf/src/constants/Style";
3
+
4
+ const Style = styled.div`
5
+ display: flex;
6
+ flex-direction: column;
7
+ justify-content: center;
8
+ position: relative;
9
+
10
+ .flex-r {
11
+ display: flex;
12
+ }
13
+
14
+ .flex-c {
15
+ display: flex;
16
+ flex-direction: column;
17
+
18
+ img {
19
+ border-radius: 50%;
20
+ margin-top: -2px;
21
+ }
22
+ }
23
+
24
+ .justify-center {
25
+ justify-content: center;
26
+ }
27
+
28
+ .select-navbar {
29
+ padding: 0 .75rem;
30
+
31
+ div {
32
+ width: 4.625rem;
33
+ user-select: none;
34
+ font-size: .875rem;
35
+ font-weight: 500;
36
+ text-align: center;
37
+ color: #193E61;
38
+ cursor: pointer;
39
+ }
40
+
41
+ .country-cont {
42
+ justify-content: center;
43
+ gap: 0.6rem;
44
+
45
+ .flex-c {
46
+ width: fit-content;
47
+ }
48
+
49
+ img {
50
+ width: 18px;
51
+ height: 18px;
52
+ }
53
+
54
+ span {
55
+ color: $gray-100;
56
+ font-size: 14px;
57
+ }
58
+ }
59
+
60
+ &.bordered {
61
+ .country-cont {
62
+ img {
63
+ width: 14px;
64
+ height: 14px;
65
+ border-radius: 100%;
66
+ }
67
+ }
68
+ }
69
+ }
70
+
71
+ .select-options {
72
+ position: absolute;
73
+ width: 100%;
74
+ top: 55px;
75
+ left: 0;
76
+ background-color: white;
77
+ border-radius: 8px;
78
+ box-shadow: 0px 12px 16px -4px rgba(16, 24, 40, 0.08), 0px 4px 6px -2px rgba(16, 24, 40, 0.03);
79
+ padding: .75rem 0;
80
+ z-index: 100;
81
+ animation: .3s fade forwards;
82
+
83
+ &.not-toggled {
84
+ animation: .3s fadeOut forwards;
85
+ }
86
+
87
+ @media (${TABLET_WIDTH}) {
88
+ top: 50px;
89
+ }
90
+
91
+ @media (${MOBILE_WIDTH}) {
92
+ top: 3.5rem;
93
+ }
94
+
95
+ .value {
96
+ padding: .75rem 0rem;
97
+ margin: 0 .75rem;
98
+ text-align: center;
99
+ font-size: 1rem;
100
+ font-weight: 500;
101
+ cursor: pointer;
102
+ user-select: none;
103
+
104
+ &.active-value {
105
+ background-color: #265A80;
106
+ color: white;
107
+ }
108
+ }
109
+ }
110
+
111
+ @keyframes fade {
112
+ 0% { opacity: 0; }
113
+ 100% { opacity: 1; }
114
+ }
115
+
116
+ @keyframes fadeOut {
117
+ 0% { opacity: 1; }
118
+ 100% { opacity: 0; }
119
+ }
120
+ `;
121
+
122
+ export default Style;
@@ -0,0 +1,87 @@
1
+ import React from "react";
2
+ import AuthNavbar from "./components/Navbar/index.jsx";
3
+ import { formatClassname } from "../../../helpers/ClassesHelper.js";
4
+ import Style from './style';
5
+
6
+ const AuthLayout = ({
7
+ children,
8
+ StyleComponent,
9
+ t = (key) => key,
10
+ title = "Welcome Back",
11
+ subTitle = "Please introduce yourself",
12
+ logo,
13
+ appName = "default",
14
+ containerClassName = "",
15
+ leftClassName = "",
16
+ rightClassName = "",
17
+ rightImgClassName = "",
18
+ rightImageUrl,
19
+ additionalContent,
20
+ showTopHeader = true,
21
+ showLanguageSelector = true,
22
+ updateLanguage,
23
+ showBack = false,
24
+ onBack,
25
+ backLabel = "Back",
26
+ defaultValue = "en",
27
+ }) => {
28
+ const Wrapper = StyleComponent || "div";
29
+ const wrapperClassName = formatClassname([
30
+ "auth-layout",
31
+ appName,
32
+ containerClassName,
33
+ ]);
34
+
35
+ return (
36
+
37
+
38
+ <>
39
+ {showTopHeader && (
40
+ <AuthNavbar
41
+ logo={logo}
42
+ appName={appName}
43
+ showLanguageSelector={showLanguageSelector}
44
+ updateLanguage={updateLanguage}
45
+ showBack={showBack}
46
+ onBack={onBack}
47
+ backLabel={backLabel}
48
+ defaultValue={defaultValue}
49
+ />
50
+ )}
51
+ <Style>
52
+ <div className="main-cont">
53
+ <div className={formatClassname(["d-cont left", leftClassName])}>
54
+ <div className="main">
55
+ {logo && (
56
+ <div className="left-logo">
57
+ <img src={logo} alt={`${appName} logo`} />
58
+ </div>
59
+ )}
60
+ <div className="left-header">
61
+ {title && <h2>{t(title)}</h2>}
62
+ {subTitle && (
63
+ <p>{typeof subTitle === "string" ? t(subTitle) : subTitle}</p>
64
+ )}
65
+ </div>
66
+ {children}
67
+ {additionalContent}
68
+ </div>
69
+ </div>
70
+
71
+ <div
72
+ className={formatClassname(["d-cont right", rightClassName])}
73
+ style={
74
+ rightImageUrl
75
+ ? { backgroundImage: `url(${rightImageUrl})`, backgroundSize: "cover" }
76
+ : {}
77
+ }
78
+ >
79
+ <div className={formatClassname(["right-img", rightImgClassName])} />
80
+ </div>
81
+ </div>
82
+ </Style>
83
+ </>
84
+ );
85
+ };
86
+
87
+ export default AuthLayout;