-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sidebar): 13451 - also define app name by app id and change icon …
…in tab (#285)
- Loading branch information
Showing
10 changed files
with
107 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
src/features/side_bar/components/AppNameAndIcon/AppNameAndIcon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ActionsBarBTN } from '@konturio/ui-kit'; | ||
import { useAtom } from '@reatom/react'; | ||
import app_config from '~core/app_config'; | ||
import { i18n } from '~core/localization'; | ||
import { currentAppPropertiesResourceAtom } from '~core/shared_state/currentApplication'; | ||
import { transformIconLink } from '~utils/common'; | ||
|
||
type AppNameAndIconProps = { | ||
wrapClassName?: string; | ||
appNameClassName?: string; | ||
isOpen: boolean; | ||
}; | ||
|
||
export function AppNameAndIcon({ | ||
isOpen, | ||
appNameClassName, | ||
wrapClassName, | ||
}: AppNameAndIconProps) { | ||
const [{ data: appParams }] = useAtom(currentAppPropertiesResourceAtom); | ||
const iconPath = | ||
appParams?.sidebarIconUrl && transformIconLink(appParams?.sidebarIconUrl); | ||
|
||
const appIcon = iconPath ? ( | ||
<img src={iconPath} width={24} height={24} alt={i18n.t('sidebar.icon_alt')} /> | ||
) : null; | ||
|
||
return ( | ||
<ActionsBarBTN active={false} iconBefore={appIcon} className={wrapClassName}> | ||
{isOpen ? <span className={appNameClassName}>{appParams?.name}</span> : null} | ||
</ActionsBarBTN> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useEffect } from 'react'; | ||
import { transformIconLink } from '~utils/common'; | ||
|
||
export function useFavicon(iconPath?: string) { | ||
// change tab icon (not expected to work in Safari https://stackoverflow.com/questions/63781987/cant-change-favicon-with-javascript-in-safari) | ||
useEffect(() => { | ||
if (!iconPath) return; | ||
const iconLink = transformIconLink(iconPath); | ||
|
||
const linkElements = document.querySelectorAll( | ||
"link[rel~='icon']", | ||
) as NodeListOf<HTMLLinkElement>; | ||
|
||
linkElements.forEach((linkEl) => { | ||
linkEl.href = iconLink; | ||
}); | ||
}, [iconPath]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters