@taruvi/navkit 0.0.22 → 0.0.24
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/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -43,25 +43,24 @@ const NavkitContent = () => {
|
|
|
43
43
|
</Box>
|
|
44
44
|
<Box component={"div"} sx={styles.rightSection}>
|
|
45
45
|
<Shortcuts showChat={setShowChat} onMenuToggle={() => setShowShortcutsMenu(!showShortcutsMenu)} />
|
|
46
|
-
{isUserAuthenticated && userData && <Profile userData={userData} onClick={() => setShowProfileMenu(!showProfileMenu)} />}
|
|
47
46
|
<Box
|
|
48
47
|
onClick={() => {
|
|
49
|
-
if (isUserAuthenticated
|
|
48
|
+
if (isUserAuthenticated) {
|
|
50
49
|
setShowAppLauncher(!showAppLauncher);
|
|
51
50
|
}
|
|
52
51
|
}}
|
|
53
52
|
onMouseEnter={() => {
|
|
54
|
-
if (isUserAuthenticated
|
|
53
|
+
if (isUserAuthenticated) {
|
|
55
54
|
setIsAppLauncherHovered(true);
|
|
56
55
|
}
|
|
57
56
|
}}
|
|
58
57
|
onMouseLeave={() => setIsAppLauncherHovered(false)}
|
|
59
58
|
sx={{
|
|
60
59
|
...styles.appLauncherContainer,
|
|
61
|
-
cursor: isUserAuthenticated
|
|
60
|
+
cursor: isUserAuthenticated ? "pointer" : "default",
|
|
62
61
|
}}
|
|
63
62
|
>
|
|
64
|
-
{(isAppLauncherHovered || showAppLauncher) && isUserAuthenticated
|
|
63
|
+
{(isAppLauncherHovered || showAppLauncher) && isUserAuthenticated ? (
|
|
65
64
|
<Box sx={styles.appLauncherHover}>
|
|
66
65
|
<FontAwesomeIcon icon={["fas", "th"]} style={styles.appLauncherIcon} />
|
|
67
66
|
<Typography sx={styles.appLauncherText}>Apps</Typography>
|
|
@@ -70,11 +69,12 @@ const NavkitContent = () => {
|
|
|
70
69
|
<Box component="img" src={taruviLogo} sx={styles.appLauncherLogo} />
|
|
71
70
|
)}
|
|
72
71
|
</Box>
|
|
72
|
+
{isUserAuthenticated && userData && <Profile userData={userData} onClick={() => setShowProfileMenu(!showProfileMenu)} />}
|
|
73
73
|
</Box>
|
|
74
74
|
</Toolbar>
|
|
75
75
|
</AppBar>
|
|
76
76
|
|
|
77
|
-
{showAppLauncher && isUserAuthenticated &&
|
|
77
|
+
{showAppLauncher && isUserAuthenticated && (
|
|
78
78
|
<Box>
|
|
79
79
|
<AppLauncher />
|
|
80
80
|
</Box>
|
package/src/NavkitContext.tsx
CHANGED
|
@@ -109,7 +109,7 @@ export const NavkitProvider = ({ children, client, onThemeChange }: NavkitProvid
|
|
|
109
109
|
const transformedApps: AppData[] = (appsResponse?.data || []).map?.((app: any) => ({
|
|
110
110
|
id: app.slug,
|
|
111
111
|
appname: app.display_name || app.name,
|
|
112
|
-
icon: app.icon || "
|
|
112
|
+
icon: app.icon || "",
|
|
113
113
|
url: app.url
|
|
114
114
|
}))
|
|
115
115
|
startTransition(() => {
|
|
@@ -3,7 +3,7 @@ import type { AppData } from "../../types"
|
|
|
3
3
|
import Search from "../Search/Search"
|
|
4
4
|
import { Card, Box, Grid, Typography } from "@mui/material"
|
|
5
5
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
|
6
|
-
import type
|
|
6
|
+
import { findIconDefinition, library, type IconName } from "@fortawesome/fontawesome-svg-core"
|
|
7
7
|
import { useNavigation } from "../../NavkitContext"
|
|
8
8
|
import { getAppLauncherStyles } from "./AppLauncher.styles"
|
|
9
9
|
|
|
@@ -12,6 +12,11 @@ const isIconUrl = (icon: string): boolean => {
|
|
|
12
12
|
return icon.startsWith('http://') || icon.startsWith('https://') || icon.startsWith('/')
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
const isValidFaIcon = (icon: string): boolean => {
|
|
16
|
+
const iconName = icon.replace('fa-', '') as IconName
|
|
17
|
+
return !!findIconDefinition({ prefix: 'fas', iconName }) || !!findIconDefinition({ prefix: 'far', iconName })
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
const AppLauncher = () => {
|
|
16
21
|
const { navigateToUrl, appsList, themeMode } = useNavigation()
|
|
17
22
|
const styles = getAppLauncherStyles(themeMode)
|
|
@@ -32,12 +37,12 @@ const AppLauncher = () => {
|
|
|
32
37
|
return (
|
|
33
38
|
<Card sx={styles.container}>
|
|
34
39
|
<Search appsList={appsList} onSearchChange={handleSearchChange} />
|
|
35
|
-
{filteredApps && filteredApps.length > 0
|
|
40
|
+
{filteredApps && filteredApps.length > 0 ? (
|
|
36
41
|
<Box sx={styles.scrollContainer}>
|
|
37
|
-
<Grid container spacing={
|
|
42
|
+
<Grid container spacing={0}>
|
|
38
43
|
{filteredApps.map((app) => {
|
|
39
44
|
return (
|
|
40
|
-
<Grid size={
|
|
45
|
+
<Grid size={2} key={app.id}>
|
|
41
46
|
<Box
|
|
42
47
|
sx={styles.appItem}
|
|
43
48
|
onClick={() => handleAppClick(app)}
|
|
@@ -55,18 +60,22 @@ const AppLauncher = () => {
|
|
|
55
60
|
objectFit: 'contain'
|
|
56
61
|
}}
|
|
57
62
|
/>
|
|
58
|
-
) : (
|
|
63
|
+
) : app.icon && isValidFaIcon(app.icon) ? (
|
|
59
64
|
<FontAwesomeIcon
|
|
60
65
|
icon={["fas", app.icon.replace('fa-', '') as IconName]}
|
|
61
66
|
style={styles.iconStyle}
|
|
62
67
|
/>
|
|
68
|
+
) : (
|
|
69
|
+
<Typography sx={{ fontSize: '1.25rem', fontWeight: 600 }}>
|
|
70
|
+
{app.appname?.charAt(0).toUpperCase()}
|
|
71
|
+
</Typography>
|
|
63
72
|
)}
|
|
64
73
|
</Box>
|
|
65
74
|
<Typography
|
|
66
75
|
variant="body2"
|
|
67
76
|
sx={styles.appName}
|
|
68
77
|
>
|
|
69
|
-
{app?.appname?.length >
|
|
78
|
+
{app?.appname?.length > 40 ? `${app.appname.substring(0, 40)}...` : app.appname}
|
|
70
79
|
</Typography>
|
|
71
80
|
</Box>
|
|
72
81
|
</Grid>
|
|
@@ -74,6 +83,12 @@ const AppLauncher = () => {
|
|
|
74
83
|
})}
|
|
75
84
|
</Grid>
|
|
76
85
|
</Box>
|
|
86
|
+
) : (
|
|
87
|
+
<Box sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', padding: '40px 16px' }}>
|
|
88
|
+
<Typography sx={{ color: styles.appName?.color || '#9e9e9e', fontSize: '0.875rem' }}>
|
|
89
|
+
No apps available
|
|
90
|
+
</Typography>
|
|
91
|
+
</Box>
|
|
77
92
|
)}
|
|
78
93
|
</Card>
|
|
79
94
|
)
|