Skip to content

Commit

Permalink
fix(web): add ellipsis when workspace name or username is too long (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
mulengawilfred authored Oct 23, 2024
1 parent a6d9dbc commit 5063b21
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 7 deletions.
10 changes: 10 additions & 0 deletions web/src/classic/components/molecules/Common/Header/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,20 @@ const LabelLeft = styled.div`

const LabelWorkspaceName = styled(Text)`
margin-top: 2px;
max-width: 200px;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;

const LabelUserName = styled(Text)`
margin-bottom: 2px;
max-width: 200px;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;

export default HeaderProfile;
13 changes: 11 additions & 2 deletions web/src/classic/components/molecules/Dashboard/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ const Workspace: React.FC<Props> = ({ className, workspace, isPersonal }) => {
<StyledDashboardBlock className={className} grow={5}>
<Content direction="column" justify="space-between">
<WorkspaceHeader align="center" gap={12} wrap="wrap">
<Text size={isSmallWindow ? "m" : "xl"} color={theme.classic.main.text} weight="bold">
<CustomText
size={isSmallWindow ? "m" : "xl"}
color={theme.classic.main.text}
weight="bold">
{name}
{isPersonal && t("'s workspace")}
</Text>
</CustomText>
{policy && (
<Policy
policy={policy}
Expand Down Expand Up @@ -119,4 +122,10 @@ const StyledAvatar = styled(Avatar)`
margin-right: ${metricsSizes["s"]}px;
`;

const CustomText = styled(Text)`
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;

export default Workspace;
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,18 @@ const LinkItem = styled(NavLink)`
}
`;

//
const StyledText = styled(Text)<{ level?: 1 | 2 | 3 }>`
display: block;
display: -webkit-box;
max-width: 100%;
margin: 0 auto;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
padding-left: ${({ level }) =>
level === 3 ? `${metricsSizes["3xl"]}px}` : level === 2 ? `${metricsSizes["l"]}px` : 0};
level === 3 ? `${metricsSizes["3xl"]}px` : level === 2 ? `${metricsSizes["l"]}px` : 0};
`;

const NavigationList = styled.ul`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ const SettingsHeader: React.FC<Props> = ({ title, currentWorkspace, currentProje
return (
<Wrapper>
<Flex gap={12} align="center">
<Text size="xl" color={theme.classic.main.strongText} weight="bold">
<CustomText size="xl" color={theme.classic.main.strongText} weight="bold">
{workspaceName} {workspaceName && (title || currentProject) && " / "}
{currentProject} {currentProject && title && " / "}
{title}
</Text>
</CustomText>
{policy && !currentProject && !title && (
<Policy
policy={policy}
Expand All @@ -64,3 +64,10 @@ export default SettingsHeader;
const Wrapper = styled.div`
padding: ${metricsSizes["l"]}px 0;
`;

const CustomText = styled(Text)`
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ const WorkspaceCell: React.FC<Props> = ({ className, workspace, personal, onSele
direction="column"
justify="space-between"
onClick={() => onSelect?.(workspace)}>
<Text size="xl" color={theme.classic.main.text} otherProperties={{ userSelect: "none" }}>
<CustomText
size="xl"
color={theme.classic.main.text}
otherProperties={{ userSelect: "none" }}>
{workspace.name ? workspace.name : t("No Title Workspace")}
</Text>
</CustomText>
{personal ? (
<Text size="m" color={theme.classic.main.weak}>
{t(
Expand Down Expand Up @@ -71,4 +74,11 @@ const StyleAvatar = styled(Avatar)`
margin-right: ${metricsSizes["s"]}px;
`;

const CustomText = styled(Text)`
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;

export default WorkspaceCell;

0 comments on commit 5063b21

Please sign in to comment.