Skip to content
Snippets Groups Projects
Commit 8e7fb9b6 authored by Max Frederiksen's avatar Max Frederiksen
Browse files

CE-3632: MR comments

parent 23bddcf8
No related branches found
No related tags found
1 merge request!223CE-3632: Autocomplete and EllipsisText
Pipeline #219907 passed
...@@ -4,42 +4,35 @@ import { ...@@ -4,42 +4,35 @@ import {
TypographyProps, TypographyProps,
TooltipProps TooltipProps
} from "@mui/material"; } from "@mui/material";
import { EmptyValue } from "../EmptyValue";
export interface EllipsisTextProps { export interface EllipsisTextProps {
title?: string;
disableTooltip?: boolean;
TypographyProps?: TypographyProps; TypographyProps?: TypographyProps;
TooltipProps?: TooltipProps; TooltipProps?: TooltipProps;
children: string; children?: string;
} }
export const EllipsisText = ({ export const EllipsisText = ({
title,
disableTooltip = false,
TypographyProps, TypographyProps,
TooltipProps, TooltipProps,
children children
}: EllipsisTextProps) => { }: EllipsisTextProps) => {
const renderedText = (
<Typography
noWrap
{...TypographyProps}
>
{children}
</Typography>
);
if (disableTooltip) {
return renderedText;
}
return ( return (
<Tooltip <Tooltip
title={title ?? children} title={children}
arrow arrow
{...TooltipProps} {...TooltipProps}
> >
{renderedText} {children ? (
<Typography
noWrap
{...TypographyProps}
>
{children}
</Typography>
) : (
<EmptyValue />
)}
</Tooltip> </Tooltip>
); );
}; };
...@@ -52,7 +52,6 @@ Default.args = { ...@@ -52,7 +52,6 @@ Default.args = {
TypographyProps: { TypographyProps: {
variant: "body2" variant: "body2"
}, },
disableTooltip: false,
TooltipProps: { TooltipProps: {
placement: "right-end" placement: "right-end"
} }
...@@ -60,14 +59,16 @@ Default.args = { ...@@ -60,14 +59,16 @@ Default.args = {
const ExternalLinkTemplate = ({ children, ...props }: EllipsisTextProps) => { const ExternalLinkTemplate = ({ children, ...props }: EllipsisTextProps) => {
return ( return (
<Container> <MemoryRouter>
<ExternalLink <Container>
to="https://europeanspallationsource.se/" <ExternalLink
label={children} to="https://europeanspallationsource.se/"
> label={children}
<EllipsisText {...props}>{children}</EllipsisText> >
</ExternalLink> <EllipsisText {...props}>{children}</EllipsisText>
</Container> </ExternalLink>
</Container>
</MemoryRouter>
); );
}; };
......
...@@ -57,16 +57,6 @@ const Template = ({ loading, ...args }: AutocompleteProps) => { ...@@ -57,16 +57,6 @@ const Template = ({ loading, ...args }: AutocompleteProps) => {
); );
}; };
export const Default = (args: typeof Autocomplete) => ( export const Default = () => <Template loading={false} />;
<Template
loading={false}
{...args}
/>
);
export const Loading = (args: typeof Autocomplete) => ( export const Loading = () => <Template loading />;
<Template
loading
{...args}
/>
);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment