@taruvi/navkit 0.0.38 → 0.0.40

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,12 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm run dev:*)",
5
+ "WebSearch",
6
+ "Bash(npm run build:*)",
7
+ "Bash(npm install:*)"
8
+ ],
9
+ "deny": [],
10
+ "ask": []
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taruvi/navkit",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "main": "src/App.tsx",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -48,6 +48,6 @@
48
48
  "vitest": "^4.0.18"
49
49
  },
50
50
  "dependencies": {
51
- "@taruvi/sdk": "^1.4.0"
51
+ "@taruvi/sdk": "latest"
52
52
  }
53
53
  }
package/src/App.styles.ts CHANGED
@@ -77,7 +77,7 @@ export const getAppStyles = (mode: ThemeMode) => {
77
77
  overflow: 'hidden',
78
78
  },
79
79
  toolbar: {
80
- backgroundColor: '#004369',
80
+ backgroundColor: '#2B97FF',
81
81
  boxShadow: ' 0px 0px 10px 2px rgba(0, 0, 0, 0.3)',
82
82
  justifyContent: 'space-between',
83
83
  minHeight: dimensions.navHeight,
@@ -106,6 +106,9 @@ export const getAppStyles = (mode: ThemeMode) => {
106
106
  fontWeight: 600,
107
107
  cursor: 'pointer',
108
108
  },
109
+ taruviSpaceLogo: {
110
+ height: '22px',
111
+ },
109
112
  rightSection: {
110
113
  display: 'flex',
111
114
  alignItems: 'center',
package/src/App.tsx CHANGED
@@ -9,10 +9,13 @@ import DraggableResizable from "./components/DraggableResizable";
9
9
  import { getAppStyles } from "./App.styles"
10
10
  import { NavkitProvider, useNavigation } from "./NavkitContext"
11
11
  import taruviLogo from "./assets/logo.svg";
12
+ import taruviLogoWhite from "./assets/taruvi-logo-white.png";
12
13
  import type { Client } from "@taruvi/sdk"
13
14
 
14
15
  const NavkitContent = () => {
15
16
  const { isUserAuthenticated, siteSettings, appSettings, appName, userData, jwtToken, themeMode } = useNavigation();
17
+ const resolvedAppName = appName || appSettings?.displayName
18
+ const showTaruviLogo = !resolvedAppName && !appSettings?.icon
16
19
  const styles = getAppStyles(themeMode)
17
20
  const [showAppLauncher, setShowAppLauncher] = useState<boolean>(false)
18
21
  const [showProfileMenu, setShowProfileMenu] = useState<boolean>(false)
@@ -35,12 +38,18 @@ const NavkitContent = () => {
35
38
  <AppBar position="static" sx={styles.appBar}>
36
39
  <Toolbar sx={styles.toolbar}>
37
40
  <Box component={"a"} href="/" sx={styles.leftSection}>
38
- {appSettings?.icon ? <Box component="img" src={appSettings?.icon} sx={styles.logo} /> : <></>}
39
- {(appName || appSettings?.displayName) &&
40
- <Typography sx={styles.appName} onClick={() => (window.location.href = "/")}>
41
- {(() => { const name = appName || appSettings!.displayName!; return name.length > 40 ? `${name.substring(0, 40)}...` : name })()}
42
- </Typography>
43
- }
41
+ {showTaruviLogo ? (
42
+ <Box component="img" src={taruviLogoWhite} sx={styles.taruviSpaceLogo} />
43
+ ) : (
44
+ <>
45
+ {appSettings?.icon ? <Box component="img" src={appSettings?.icon} sx={styles.logo} /> : <></>}
46
+ {resolvedAppName &&
47
+ <Typography sx={styles.appName} onClick={() => (window.location.href = "/")}>
48
+ {resolvedAppName.length > 40 ? `${resolvedAppName.substring(0, 40)}...` : resolvedAppName}
49
+ </Typography>
50
+ }
51
+ </>
52
+ )}
44
53
  </Box>
45
54
  <Box component={"div"} sx={styles.rightSection}>
46
55
  <Shortcuts showChat={setShowChat} onMenuToggle={() => setShowShortcutsMenu(!showShortcutsMenu)} />
@@ -70,7 +79,7 @@ const NavkitContent = () => {
70
79
  <Box component="img" src={taruviLogo} sx={styles.appLauncherLogo} />
71
80
  )}
72
81
  </Box>
73
- {isUserAuthenticated && userData && <Profile userData={userData} onClick={() => setShowProfileMenu(!showProfileMenu)}/>}
82
+ {isUserAuthenticated && userData && <Profile userData={userData} onClick={() => setShowProfileMenu(!showProfileMenu)} />}
74
83
  </Box>
75
84
  </Toolbar>
76
85
  </AppBar>
@@ -122,4 +131,4 @@ const Navkit = ({ client, getTheme, appName }: NavkitProps) => {
122
131
  )
123
132
  }
124
133
 
125
- export default Navkit
134
+ export default Navkit
@@ -31,7 +31,7 @@ export const NavkitProvider = ({ children, client, onThemeChange, appName }: Nav
31
31
  frontendUrl: '',
32
32
  enableDarkMode: false,
33
33
  })
34
- const appSettings = useRef<AppSettings>({})
34
+ const [appSettings, setAppSettings] = useState<AppSettings>({})
35
35
 
36
36
  const [isDesk, setIsDesk] = useState<boolean>(false)
37
37
  const [appsList, setAppsList] = useState<AppData[]>([])
@@ -87,12 +87,12 @@ export const NavkitProvider = ({ children, client, onThemeChange, appName }: Nav
87
87
  // Fetch app settings to get the app name
88
88
  try {
89
89
  const { data } = appName ? { data: { display_name: appName } } : await new App(client).settings().execute() as { data: { display_name?: string, icon?: string, primary_color?: string, secondary_color?: string } }
90
- appSettings.current = {
90
+ setAppSettings({
91
91
  displayName: data?.display_name,
92
92
  icon: data?.icon,
93
93
  primaryColor: data?.primary_color,
94
94
  secondaryColor: data?.secondary_color
95
- }
95
+ })
96
96
  } catch {
97
97
  // App settings not available, continue without app settings
98
98
  }
@@ -126,7 +126,7 @@ export const NavkitProvider = ({ children, client, onThemeChange, appName }: Nav
126
126
  }
127
127
  }
128
128
 
129
- }, [client])
129
+ }, [appName, client])
130
130
 
131
131
  useLayoutEffect(() => {
132
132
  const init = async () => {
@@ -169,7 +169,7 @@ export const NavkitProvider = ({ children, client, onThemeChange, appName }: Nav
169
169
  }, [themeMode, onThemeChange])
170
170
 
171
171
  return (
172
- <NavigationContext.Provider value={{ navigateToUrl, isDesk, appsList, userData, siteSettings: siteSettings.current, appSettings: appSettings.current, appName, jwtToken, isUserAuthenticated, client, auth, themeMode, toggleTheme }}>
172
+ <NavigationContext.Provider value={{ navigateToUrl, isDesk, appsList, userData, siteSettings: siteSettings.current, appSettings, appName, jwtToken, isUserAuthenticated, client, auth, themeMode, toggleTheme }}>
173
173
  {children}
174
174
  </NavigationContext.Provider>
175
175
  )
@@ -181,4 +181,4 @@ export const useNavigation = () => {
181
181
  throw new Error('useNavigation must be used within a NavkitProvider')
182
182
  }
183
183
  return context
184
- }
184
+ }
@@ -41,7 +41,7 @@ const DraggableResizable = ({
41
41
  y: Math.max(0, Math.min(e.clientY - dragOffset.current.y, window.innerHeight - 50)),
42
42
  })
43
43
  } else if (action.current === 'resize') {
44
- setSize(prev => ({
44
+ setSize(() => ({
45
45
  w: Math.max(minWidth, e.clientX - dragOffset.current.x),
46
46
  h: Math.max(minHeight, e.clientY - dragOffset.current.y),
47
47
  }))
@@ -2,11 +2,11 @@ import { Box, SvgIcon } from '@mui/material'
2
2
  import { getProfileStyles } from './Profile.styles'
3
3
  import { useNavigation } from '../../NavkitContext'
4
4
 
5
- const ProfileIcon = () => (
5
+ const ProfileIcon = ({ color }: { color?: string }) => (
6
6
  <SvgIcon viewBox="0 0 22 22" sx={{ fontSize: 23, display: 'block' }}>
7
- <path d="M10.9921 20.9849C16.511 20.9849 20.9849 16.511 20.9849 10.9921C20.9849 5.4732 16.511 0.999268 10.9921 0.999268C5.47322 0.999268 0.999283 5.4732 0.999283 10.9921C0.999283 16.511 5.47322 20.9849 10.9921 20.9849Z" stroke="#9DE5FD" fill="none" strokeWidth="1.99856" strokeLinecap="round" strokeLinejoin="round"/>
8
- <path d="M10.9921 11.9914C12.6478 11.9914 13.9899 10.6492 13.9899 8.99357C13.9899 7.33791 12.6478 5.99573 10.9921 5.99573C9.33644 5.99573 7.99426 7.33791 7.99426 8.99357C7.99426 10.6492 9.33644 11.9914 10.9921 11.9914Z" stroke="#9DE5FD" fill="none" strokeWidth="1.99856" strokeLinecap="round" strokeLinejoin="round"/>
9
- <path d="M5.99569 19.6479V17.9871C5.99569 17.457 6.20625 16.9487 6.58106 16.5739C6.95586 16.1991 7.4642 15.9885 7.99425 15.9885H13.9899C14.52 15.9885 15.0283 16.1991 15.4031 16.5739C15.7779 16.9487 15.9885 17.457 15.9885 17.9871V19.6479" stroke="#9DE5FD" fill="none" strokeWidth="1.99856" strokeLinecap="round" strokeLinejoin="round"/>
7
+ <path d="M10.9921 20.9849C16.511 20.9849 20.9849 16.511 20.9849 10.9921C20.9849 5.4732 16.511 0.999268 10.9921 0.999268C5.47322 0.999268 0.999283 5.4732 0.999283 10.9921C0.999283 16.511 5.47322 20.9849 10.9921 20.9849Z" stroke={color || "#ffffff"} fill="none" strokeWidth="1.99856" strokeLinecap="round" strokeLinejoin="round"/>
8
+ <path d="M10.9921 11.9914C12.6478 11.9914 13.9899 10.6492 13.9899 8.99357C13.9899 7.33791 12.6478 5.99573 10.9921 5.99573C9.33644 5.99573 7.99426 7.33791 7.99426 8.99357C7.99426 10.6492 9.33644 11.9914 10.9921 11.9914Z" stroke={color || "#ffffff"} fill="none" strokeWidth="1.99856" strokeLinecap="round" strokeLinejoin="round"/>
9
+ <path d="M5.99569 19.6479V17.9871C5.99569 17.457 6.20625 16.9487 6.58106 16.5739C6.95586 16.1991 7.4642 15.9885 7.99425 15.9885H13.9899C14.52 15.9885 15.0283 16.1991 15.4031 16.5739C15.7779 16.9487 15.9885 17.457 15.9885 17.9871V19.6479" stroke={color || "#ffffff"} fill="none" strokeWidth="1.99856" strokeLinecap="round" strokeLinejoin="round"/>
10
10
  </SvgIcon>
11
11
  )
12
12
 
@@ -15,10 +15,11 @@ import type { UserData } from '../../types'
15
15
  interface ProfileProps {
16
16
  userData: UserData
17
17
  onClick: () => void
18
+ iconColor?: string
18
19
  }
19
20
 
20
21
  const Profile = (props: ProfileProps) => {
21
- const { userData, onClick } = props
22
+ const { userData, onClick, iconColor } = props
22
23
  const { themeMode } = useNavigation()
23
24
  const styles = getProfileStyles(themeMode)
24
25
 
@@ -27,7 +28,7 @@ const Profile = (props: ProfileProps) => {
27
28
  {userData.icon_url ? (
28
29
  <Box component="img" src={userData.icon_url} sx={{ width: 23, height: 23, borderRadius: '50%' }} />
29
30
  ) : (
30
- <ProfileIcon />
31
+ <ProfileIcon color={iconColor} />
31
32
  )}
32
33
  </Box>
33
34
  )
@@ -10,7 +10,7 @@ export const shortcutsStyles = {
10
10
  mobileTrigger: {
11
11
  display: { xs: 'flex', md: 'none' },
12
12
  ml: spacing.sm,
13
- color: '#9DE5FD',
13
+ color: '#ffffff',
14
14
  },
15
15
  shortcut: {
16
16
  display: 'flex',
@@ -25,6 +25,6 @@ export const shortcutsStyles = {
25
25
  },
26
26
  iconStyle: {
27
27
  fontSize: '23px',
28
- color: colours.text.secondary,
28
+ color: '#ffffff',
29
29
  },
30
30
  }
@@ -4,9 +4,9 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
4
4
  import { shortcutsStyles } from './Shortcuts.styles'
5
5
  import { useNavigation } from '../../NavkitContext'
6
6
 
7
- const ChatIcon = () => (
7
+ const ChatIcon = ({ color }: { color?: string }) => (
8
8
  <SvgIcon viewBox="-2 -2 24 24" sx={{ fontSize: 23, display: 'block', position: 'relative', top: 2 }}>
9
- <path d="M18 0H2C0.9 0 0 0.9 0 2V20L4 16H18C19.1 16 20 15.1 20 14V2C20 0.9 19.1 0 18 0Z" fill="#9DE5FD"/>
9
+ <path d="M18 0H2C0.9 0 0 0.9 0 2V20L4 16H18C19.1 16 20 15.1 20 14V2C20 0.9 19.1 0 18 0Z" fill={color || "#ffffff"}/>
10
10
  </SvgIcon>
11
11
  )
12
12
 
@@ -14,11 +14,12 @@ interface ShortcutsProps {
14
14
  showChat?: (showChat: boolean) => void
15
15
  onMenuToggle?: () => void
16
16
  triggerRef?: React.RefObject<HTMLButtonElement | null>
17
+ iconColor?: string
17
18
  }
18
19
 
19
20
  const Shortcuts = (props: ShortcutsProps) => {
20
21
 
21
- const { showChat, onMenuToggle, triggerRef } = props
22
+ const { showChat, onMenuToggle, triggerRef, iconColor } = props
22
23
  const { navigateToUrl, siteSettings, isUserAuthenticated } = useNavigation()
23
24
  const shortcuts = siteSettings.shortcuts
24
25
 
@@ -40,7 +41,7 @@ const Shortcuts = (props: ShortcutsProps) => {
40
41
  >
41
42
  <FontAwesomeIcon
42
43
  icon={["far", shortcut.icon] as any}
43
- style={shortcutsStyles.iconStyle}
44
+ style={{ ...shortcutsStyles.iconStyle, ...(iconColor && { color: iconColor }) }}
44
45
  />
45
46
  </Link>
46
47
  ))}
@@ -50,7 +51,7 @@ const Shortcuts = (props: ShortcutsProps) => {
50
51
  onClick={() => showChat?.(true)}
51
52
  sx={shortcutsStyles.shortcut}
52
53
  >
53
- <ChatIcon />
54
+ <ChatIcon color={iconColor} />
54
55
  </Link>
55
56
  }
56
57
  </Box>
@@ -60,11 +61,11 @@ const Shortcuts = (props: ShortcutsProps) => {
60
61
  <IconButton
61
62
  ref={triggerRef}
62
63
  onClick={onMenuToggle}
63
- sx={shortcutsStyles.mobileTrigger}
64
+ sx={{ ...shortcutsStyles.mobileTrigger, ...(iconColor && { color: iconColor }) }}
64
65
  >
65
66
  <FontAwesomeIcon
66
67
  icon={["fas", "ellipsis-v"]}
67
- style={{ ...shortcutsStyles.iconStyle, color: '#9DE5FD' }}
68
+ style={{ ...shortcutsStyles.iconStyle, color: iconColor || '#ffffff' }}
68
69
  />
69
70
  </IconButton>
70
71
  )}