Web: Files: Templates: added navigation badge

This commit is contained in:
Nikita Gopienko 2024-05-17 17:12:54 +03:00
parent 7fd2505a6d
commit a013cf146d
6 changed files with 40 additions and 3 deletions

View File

@ -205,5 +205,6 @@
"AddAdminByNameOrEmail": "Add admin by name or email", "AddAdminByNameOrEmail": "Add admin by name or email",
"RoomTemplate": "Room template", "RoomTemplate": "Room template",
"RoomTemplateDescription": "Use this template to quickly create a new room.", "RoomTemplateDescription": "Use this template to quickly create a new room.",
"TemplateOwner": "Template owner" "TemplateOwner": "Template owner",
"Template": "Template"
} }

View File

@ -987,6 +987,8 @@ const SectionHeaderContent = (props) => {
? t("Files:ShareRoom") ? t("Files:ShareRoom")
: null; : null;
const badgeLabel = isTemplatesFolder ? t("Files:Template") : "";
return ( return (
<Consumer key="header"> <Consumer key="header">
{(context) => ( {(context) => (
@ -1054,6 +1056,7 @@ const SectionHeaderContent = (props) => {
onNavigationButtonClick={onNavigationButtonClick} onNavigationButtonClick={onNavigationButtonClick}
tariffBar={<TariffBar />} tariffBar={<TariffBar />}
showNavigationButton={!!showNavigationButton} showNavigationButton={!!showNavigationButton}
badgeLabel={badgeLabel}
/> />
</div> </div>
)} )}

View File

@ -248,6 +248,14 @@ const StyledContainer = styled.div<{
grid-template-columns: ${(props) => grid-template-columns: ${(props) =>
props.isRootFolder ? "auto 1fr" : "29px auto 1fr"}; props.isRootFolder ? "auto 1fr" : "29px auto 1fr"};
} }
.title-block-badge {
margin-left: 8px;
div {
background-color: ${(props) => props.theme.catalog.header.iconFill};
}
}
`; `;
const StyledInfoPanelToggleColorThemeWrapper = styled(ColorTheme)<{ const StyledInfoPanelToggleColorThemeWrapper = styled(ColorTheme)<{
@ -482,6 +490,14 @@ const StyledTextContainer = styled.div<{
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
`}; `};
.title-block-badge {
div {
${(props) =>
props.isRootFolderTitle &&
`background-color: ${props.theme.navigation.rootFolderTitleColor}`};
}
}
`; `;
const StyledHeading = styled(Heading)<{ isRootFolderTitle: boolean }>` const StyledHeading = styled(Heading)<{ isRootFolderTitle: boolean }>`

View File

@ -82,6 +82,7 @@ const Navigation = ({
onNavigationButtonClick, onNavigationButtonClick,
tariffBar, tariffBar,
showNavigationButton, showNavigationButton,
badgeLabel,
...rest ...rest
}: INavigationProps) => { }: INavigationProps) => {
const [isOpen, setIsOpen] = React.useState(false); const [isOpen, setIsOpen] = React.useState(false);
@ -177,6 +178,7 @@ const Navigation = ({
isRootFolder={isRootFolder} isRootFolder={isRootFolder}
onClick={toggleDropBox} onClick={toggleDropBox}
isRootFolderTitle={false} isRootFolderTitle={false}
badgeLabel={!showRootFolderNavigation ? badgeLabel : ""}
/> />
</div> </div>
); );
@ -197,6 +199,7 @@ const Navigation = ({
isRootFolder={isRootFolder} isRootFolder={isRootFolder}
isRootFolderTitle isRootFolderTitle
onClick={onTextClick} onClick={onTextClick}
badgeLabel={badgeLabel}
/> />
{navigationTitleNode} {navigationTitleNode}

View File

@ -104,6 +104,7 @@ export interface ITextProps {
isRootFolderTitle: boolean; isRootFolderTitle: boolean;
onClick: () => void; onClick: () => void;
className?: string; className?: string;
badgeLabel?: string;
} }
export interface INavigationLogoProps { export interface INavigationLogoProps {
@ -201,4 +202,5 @@ export interface INavigationProps {
onNavigationButtonClick?: () => void; onNavigationButtonClick?: () => void;
tariffBar: React.ReactElement; tariffBar: React.ReactElement;
showNavigationButton: boolean; showNavigationButton: boolean;
badgeLabel?: string;
} }

View File

@ -25,6 +25,7 @@
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
import React from "react"; import React from "react";
import { Badge } from "../../badge";
import { import {
StyledArrowIcon, StyledArrowIcon,
@ -42,6 +43,7 @@ const Text = ({
isOpen, isOpen,
isRootFolderTitle, isRootFolderTitle,
onClick, onClick,
badgeLabel,
...rest ...rest
}: ITextProps) => { }: ITextProps) => {
return ( return (
@ -58,9 +60,19 @@ const Text = ({
> >
{title} {title}
</StyledHeading> </StyledHeading>
{badgeLabel && (
<Badge
className="title-block-badge"
label={badgeLabel}
fontSize="9px"
padding="2px 5px"
fontWeight={700}
borderRadius="50px"
noHover
isHovered={false}
/>
)}
{isRootFolderTitle && <StyledArrowIcon />} {isRootFolderTitle && <StyledArrowIcon />}
{!isRootFolderTitle && !isRootFolder ? ( {!isRootFolderTitle && !isRootFolder ? (
isOpen ? ( isOpen ? (
<StyledExpanderDownIconRotate /> <StyledExpanderDownIconRotate />