* Fix for long org names on side menu. Now ellipsizes with tooltip if Orgname is over the value set in ellipsize prop. Otherwise functions as before. * added ellipsize prop to index. Fixes #735 20 seems to be a good value that stop org names running onto next line. Tested on Firefox and chrome. Linux debian stretch. Co-authored-by: root <root@rutabaga.groudon>
This commit is contained in:
parent
f615330e17
commit
43c0613fb7
|
|
@ -3,12 +3,15 @@ import { CommonComponentProps, Classes } from "./common";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import Icon, { IconName, IconSize } from "./Icon";
|
import Icon, { IconName, IconSize } from "./Icon";
|
||||||
import Text, { TextType, FontWeight } from "./Text";
|
import Text, { TextType, FontWeight } from "./Text";
|
||||||
|
import TooltipComponent from "components/ads/Tooltip";
|
||||||
|
import { Position } from '@blueprintjs/core/lib/esm/common/position';
|
||||||
|
|
||||||
export type MenuItemProps = CommonComponentProps & {
|
export type MenuItemProps = CommonComponentProps & {
|
||||||
icon?: IconName;
|
icon?: IconName;
|
||||||
text: string;
|
text: string;
|
||||||
label?: ReactNode;
|
label?: ReactNode;
|
||||||
href?: string;
|
href?: string;
|
||||||
|
ellipsize?: number;
|
||||||
onSelect?: () => void;
|
onSelect?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -64,6 +67,19 @@ const IconContainer = styled.span`
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function MenuItem(props: MenuItemProps) {
|
function MenuItem(props: MenuItemProps) {
|
||||||
|
return (
|
||||||
|
props.ellipsize && props.text.length > props.ellipsize ? (
|
||||||
|
<TooltipComponent
|
||||||
|
position={Position.BOTTOM}
|
||||||
|
content={props.text}
|
||||||
|
>
|
||||||
|
<MenuItemContent {...props} />
|
||||||
|
</ TooltipComponent>
|
||||||
|
) : <MenuItemContent {...props} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function MenuItemContent(props: MenuItemProps) {
|
||||||
return (
|
return (
|
||||||
<ItemRow
|
<ItemRow
|
||||||
href={props.href}
|
href={props.href}
|
||||||
|
|
@ -75,7 +91,7 @@ function MenuItem(props: MenuItemProps) {
|
||||||
{props.icon ? <Icon name={props.icon} size={IconSize.LARGE} /> : null}
|
{props.icon ? <Icon name={props.icon} size={IconSize.LARGE} /> : null}
|
||||||
{props.text ? (
|
{props.text ? (
|
||||||
<Text type={TextType.H5} weight={FontWeight.NORMAL}>
|
<Text type={TextType.H5} weight={FontWeight.NORMAL}>
|
||||||
{props.text}
|
{props.ellipsize ? ellipsize(props.ellipsize, props.text) : props.text}
|
||||||
</Text>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
</IconContainer>
|
</IconContainer>
|
||||||
|
|
@ -84,4 +100,8 @@ function MenuItem(props: MenuItemProps) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ellipsize(length: number, text: string) {
|
||||||
|
return text.length > length ? text.slice(0, length).concat(" ...") : text
|
||||||
|
};
|
||||||
|
|
||||||
export default MenuItem;
|
export default MenuItem;
|
||||||
|
|
|
||||||
|
|
@ -246,6 +246,7 @@ function LeftPane() {
|
||||||
key={org.organization.name}
|
key={org.organization.name}
|
||||||
href={`${window.location.pathname}#${org.organization.name}`}
|
href={`${window.location.pathname}#${org.organization.name}`}
|
||||||
text={org.organization.name}
|
text={org.organization.name}
|
||||||
|
ellipsize={20}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</WorkpsacesNavigator>
|
</WorkpsacesNavigator>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user