@asaleh37/ui-base 25.9.1 → 25.9.3
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.
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/common/Login.tsx +101 -75
- package/src/main.tsx +5 -1
- package/src/redux/features/common/AppInfoSlice.ts +6 -0
package/package.json
CHANGED
|
@@ -16,10 +16,13 @@ import { UserSessionActions } from "../../redux/features/common/UserSessionSlice
|
|
|
16
16
|
import {
|
|
17
17
|
DARK_THEME_INITIAL_MAIN_COLOR,
|
|
18
18
|
DARK_THEME_INITIAL_SECANDARY_COLOR,
|
|
19
|
+
LIGHT_THEME_INITIAL_MAIN_COLOR,
|
|
20
|
+
LIGHT_THEME_INITIAL_SECANDARY_COLOR,
|
|
19
21
|
} from "../../util";
|
|
22
|
+
import { AppInfo } from "../../redux/features/common/AppInfoSlice";
|
|
20
23
|
|
|
21
24
|
const Login: React.FC = () => {
|
|
22
|
-
const appInfo = useSelector((state: any) => state.AppInfo.value);
|
|
25
|
+
const appInfo: AppInfo = useSelector((state: any) => state.AppInfo.value);
|
|
23
26
|
const [username, setUsername] = useState("");
|
|
24
27
|
const [password, setPassword] = useState("");
|
|
25
28
|
const [isLoginInProcess, setIsLoginInProcess] = useState(false);
|
|
@@ -89,15 +92,22 @@ const Login: React.FC = () => {
|
|
|
89
92
|
},
|
|
90
93
|
},
|
|
91
94
|
palette: {
|
|
92
|
-
mode: "dark",
|
|
95
|
+
mode: appInfo?.loginScreenStyle?.themeMode || "dark",
|
|
93
96
|
primary: {
|
|
94
97
|
main:
|
|
95
|
-
appInfo
|
|
98
|
+
appInfo?.loginScreenStyle?.themeMode === "light"
|
|
99
|
+
? appInfo.appTheme?.light?.primaryColor ||
|
|
100
|
+
LIGHT_THEME_INITIAL_MAIN_COLOR
|
|
101
|
+
: appInfo.appTheme?.dark?.primaryColor ||
|
|
102
|
+
DARK_THEME_INITIAL_MAIN_COLOR,
|
|
96
103
|
},
|
|
97
104
|
secondary: {
|
|
98
105
|
main:
|
|
99
|
-
appInfo
|
|
100
|
-
|
|
106
|
+
appInfo?.loginScreenStyle?.themeMode === "light"
|
|
107
|
+
? appInfo.appTheme?.light?.secondaryColor ||
|
|
108
|
+
LIGHT_THEME_INITIAL_SECANDARY_COLOR
|
|
109
|
+
: appInfo.appTheme?.dark?.secondaryColor ||
|
|
110
|
+
DARK_THEME_INITIAL_SECANDARY_COLOR,
|
|
101
111
|
},
|
|
102
112
|
},
|
|
103
113
|
});
|
|
@@ -137,85 +147,101 @@ const Login: React.FC = () => {
|
|
|
137
147
|
|
|
138
148
|
return (
|
|
139
149
|
<ThemeProvider theme={loginTheme}>
|
|
140
|
-
<
|
|
150
|
+
<Box
|
|
141
151
|
sx={{
|
|
142
|
-
|
|
143
|
-
height: "100vh",
|
|
152
|
+
minHeight: "100vh", // full page height
|
|
144
153
|
width: "100%",
|
|
145
|
-
|
|
154
|
+
display: "flex",
|
|
146
155
|
alignItems: "center",
|
|
147
156
|
justifyContent: "center",
|
|
157
|
+
background: appInfo?.loginScreenStyle?.backgroundColor,
|
|
158
|
+
backgroundImage: `url('/${appInfo?.loginScreenStyle?.backgroundImageNameInPublicFolder}')`,
|
|
159
|
+
backgroundRepeat: "no-repeat",
|
|
160
|
+
backgroundSize: "cover", // 🔥 makes it responsive
|
|
161
|
+
backgroundPosition: "center", // keeps it centered
|
|
148
162
|
}}
|
|
149
163
|
>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
<Typography
|
|
164
|
+
<Paper
|
|
165
|
+
sx={{
|
|
166
|
+
display: "flex",
|
|
167
|
+
width: "fit-content",
|
|
168
|
+
padding: 2,
|
|
169
|
+
height: "fit-content",
|
|
170
|
+
borderRadius: 5,
|
|
171
|
+
alignItems: "center",
|
|
172
|
+
justifyContent: "center",
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
175
|
+
{UserSessionState.isAuthenticated == false ? (
|
|
176
|
+
<Box
|
|
164
177
|
sx={{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}}
|
|
170
|
-
variant="caption"
|
|
171
|
-
color="textSecondary"
|
|
172
|
-
>
|
|
173
|
-
V.{appInfo.appVersion}
|
|
174
|
-
</Typography>
|
|
175
|
-
<TextField
|
|
176
|
-
label="username"
|
|
177
|
-
sx={{ width: 300, m: 1 }}
|
|
178
|
-
value={username}
|
|
179
|
-
onChange={(event) => {
|
|
180
|
-
setUsername(event.target.value);
|
|
181
|
-
}}
|
|
182
|
-
onKeyDown={(event) => {
|
|
183
|
-
if (event.key === "Enter") {
|
|
184
|
-
handleLogin();
|
|
185
|
-
}
|
|
186
|
-
}}
|
|
187
|
-
/>
|
|
188
|
-
<TextField
|
|
189
|
-
label="password"
|
|
190
|
-
sx={{ width: 300, m: 1 }}
|
|
191
|
-
value={password}
|
|
192
|
-
type="password"
|
|
193
|
-
onChange={(event) => {
|
|
194
|
-
setPassword(event.target.value);
|
|
195
|
-
}}
|
|
196
|
-
onKeyDown={(event) => {
|
|
197
|
-
if (event.key === "Enter") {
|
|
198
|
-
handleLogin();
|
|
199
|
-
}
|
|
178
|
+
display: "flex",
|
|
179
|
+
flexDirection: "column",
|
|
180
|
+
alignItems: "center",
|
|
181
|
+
justifyContent: "center",
|
|
200
182
|
}}
|
|
201
|
-
/>
|
|
202
|
-
<Button
|
|
203
|
-
loading={isLoginInProcess}
|
|
204
|
-
onClick={handleLogin}
|
|
205
|
-
variant="contained"
|
|
206
|
-
color="primary"
|
|
207
|
-
sx={{ m: 1 }}
|
|
208
183
|
>
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
184
|
+
<img src={appInfo?.appLogo} width={150} height={150} />
|
|
185
|
+
<Typography sx={{ m: 1 }} variant="h4" color="textSecondary">
|
|
186
|
+
{appInfo?.appName}
|
|
187
|
+
</Typography>
|
|
188
|
+
<Typography
|
|
189
|
+
sx={{
|
|
190
|
+
paddingRight: 1,
|
|
191
|
+
width: "100%",
|
|
192
|
+
textAlign: "right",
|
|
193
|
+
fontSize: 10,
|
|
194
|
+
}}
|
|
195
|
+
variant="caption"
|
|
196
|
+
color="textSecondary"
|
|
197
|
+
>
|
|
198
|
+
V.{appInfo.appVersion}
|
|
199
|
+
</Typography>
|
|
200
|
+
<TextField
|
|
201
|
+
label="username"
|
|
202
|
+
sx={{ width: 300, m: 1 }}
|
|
203
|
+
value={username}
|
|
204
|
+
onChange={(event) => {
|
|
205
|
+
setUsername(event.target.value);
|
|
206
|
+
}}
|
|
207
|
+
onKeyDown={(event) => {
|
|
208
|
+
if (event.key === "Enter") {
|
|
209
|
+
handleLogin();
|
|
210
|
+
}
|
|
211
|
+
}}
|
|
212
|
+
/>
|
|
213
|
+
<TextField
|
|
214
|
+
label="password"
|
|
215
|
+
sx={{ width: 300, m: 1 }}
|
|
216
|
+
value={password}
|
|
217
|
+
type="password"
|
|
218
|
+
onChange={(event) => {
|
|
219
|
+
setPassword(event.target.value);
|
|
220
|
+
}}
|
|
221
|
+
onKeyDown={(event) => {
|
|
222
|
+
if (event.key === "Enter") {
|
|
223
|
+
handleLogin();
|
|
224
|
+
}
|
|
225
|
+
}}
|
|
226
|
+
/>
|
|
227
|
+
<Button
|
|
228
|
+
loading={isLoginInProcess}
|
|
229
|
+
onClick={handleLogin}
|
|
230
|
+
variant="contained"
|
|
231
|
+
color="primary"
|
|
232
|
+
sx={{ m: 1 }}
|
|
233
|
+
>
|
|
234
|
+
login
|
|
235
|
+
</Button>
|
|
236
|
+
</Box>
|
|
237
|
+
) : (
|
|
238
|
+
<>
|
|
239
|
+
<CircularProgress sx={{ marginRight: 1 }} />
|
|
240
|
+
<div>You will be redirected shortly ... please wait</div>
|
|
241
|
+
</>
|
|
242
|
+
)}
|
|
243
|
+
</Paper>
|
|
244
|
+
</Box>
|
|
219
245
|
</ThemeProvider>
|
|
220
246
|
);
|
|
221
247
|
};
|
package/src/main.tsx
CHANGED
|
@@ -7,8 +7,12 @@ createRoot(document.getElementById("root")!).render(
|
|
|
7
7
|
enableUINotifications={false}
|
|
8
8
|
appLogo={"/logo.png"}
|
|
9
9
|
appName="UI Base Library"
|
|
10
|
+
loginScreenStyle={{
|
|
11
|
+
themeMode: "light",
|
|
12
|
+
backgroundImageNameInPublicFolder: "bg.jpg",
|
|
13
|
+
}}
|
|
10
14
|
appVersion="0.0"
|
|
11
|
-
authenticationMethod="
|
|
15
|
+
authenticationMethod="APP"
|
|
12
16
|
azureConfiguration={{
|
|
13
17
|
frontEndClientId: "c3bbbdbd-f392-4459-b3dd-2351cb07f924",
|
|
14
18
|
tenantId: "9f136fef-4529-475f-98e6-d271eb04eb00",
|
|
@@ -19,6 +19,11 @@ export type AppInfo = {
|
|
|
19
19
|
ar: { [key: string]: string };
|
|
20
20
|
en: { [key: string]: string };
|
|
21
21
|
};
|
|
22
|
+
loginScreenStyle?: {
|
|
23
|
+
themeMode: "dark" | "light";
|
|
24
|
+
backgroundImageNameInPublicFolder?: string;
|
|
25
|
+
backgroundColor?: string;
|
|
26
|
+
};
|
|
22
27
|
authenticationMethod: "AZURE" | "APP";
|
|
23
28
|
azureConfiguration?: {
|
|
24
29
|
frontEndClientId: string;
|
|
@@ -48,6 +53,7 @@ const initialState: AppInfoProp = {
|
|
|
48
53
|
value: {
|
|
49
54
|
documentTitle: null,
|
|
50
55
|
apiBaseUrl: null,
|
|
56
|
+
authenticationMethod: "APP",
|
|
51
57
|
appName: null,
|
|
52
58
|
appVersion: null,
|
|
53
59
|
appLogo: null,
|