Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ export interface ActionButtonProps {
title?: ReactNode;
onClick: () => void;
isDisabled?: boolean;
className?: string;
tooltip?: ReactNode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ export const InsightHeader = ({
)}
<s.Title>
{insightTypeInfo?.label}
{insightTypeInfo?.description && (
<s.TitleInfo title={<insightTypeInfo.description />} />
)}
{lastUpdateTimer && (
<s.Description>
Updated:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Meta, StoryObj } from "@storybook/react";
import { InsightsInfo } from ".";

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
const meta: Meta<typeof InsightsInfo> = {
title: "Insights/InsightsCatalog/InsightsPage/InsightsInfo",
component: InsightsInfo,
parameters: {
// More on how to position stories at: https://storybook.js.org/docs/react/configure/story-layout
layout: "fullscreen"
}
};

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
isOpen: true,
description: () => (
<>
This area significantly slows down the entire request and takes up at
least 30% of the request time. You should consider making this code
asynchronous or otherwise optimize it.
</>
)
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { InsightsInfoProps } from "./types";

import { openURLInDefaultBrowser } from "../../../../../../../../utils/actions/openURLInDefaultBrowser";
import { sendUserActionTrackingEvent } from "../../../../../../../../utils/actions/sendUserActionTrackingEvent";
import { CrossIcon } from "../../../../../../../common/icons/12px/CrossIcon";
import { trackingEvents } from "../../../../../../tracking";
import * as s from "./styles";

export const InsightsInfo = ({
isOpen,
children,
description: Description,
documentationLink,
onClose
}: InsightsInfoProps) => {
const handleOpenDocsClick = () => {
if (!documentationLink) {
return;
}

sendUserActionTrackingEvent(trackingEvents.INSIGHTS_INFO_OPEN_DOCS_CLICKED);
openURLInDefaultBrowser(documentationLink);
onClose();
};

const handleCloseClick = () => {
sendUserActionTrackingEvent(trackingEvents.INSIGHTS_INFO_OPEN_DOCS_CLICKED);
onClose();
};

return (
<s.InfoTooltip
isOpen={isOpen}
onDismiss={onClose}
isDisabled={!Description}
placement="top"
title={
<s.Container>
<s.Header>
<s.CloseButton
onClick={handleCloseClick}
icon={(props) => <CrossIcon {...props} size={12} />}
size={"small"}
buttonType="secondaryBorderless"
></s.CloseButton>
</s.Header>
<s.Content>
<s.Description>{Description && <Description />}</s.Description>
{documentationLink && (
<s.StyledLink onClick={handleOpenDocsClick}>
Open Docs
</s.StyledLink>
)}
</s.Content>
</s.Container>
}
hideArrow={true}
fullWidth={true}
>
{children}
</s.InfoTooltip>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import styled from "styled-components";
import {
footnoteRegularTypography,
subscriptRegularTypography
} from "../../../../../../../common/App/typographies";
import { Link } from "../../../../../../../common/v3/Link";
import { NewIconButton } from "../../../../../../../common/v3/NewIconButton";
import { Tooltip } from "../../../../../../../common/v3/Tooltip";

export const CloseButton = styled(NewIconButton)`
display: flex;
background: none;
border: none;
cursor: pointer;
padding: 0;
`;

export const Container = styled.div`
display: flex;
flex-direction: column;
border-radius: 4px;
`;

export const Header = styled.div`
display: flex;
align-items: center;
justify-content: end;
height: 20px;
`;

export const Description = styled.div`
${footnoteRegularTypography}
color: ${({ theme }) => theme.colors.v3.text.secondary};
`;

export const Content = styled.div`
display: flex;
flex-direction: column;
gap: 8px;
padding: 0 12px 12px;
`;

export const StyledLink = styled(Link)`
${subscriptRegularTypography}
text-decoration: underline;
padding: 4px 0;
`;

export const InfoTooltip = styled(Tooltip)`
max-width: 256px;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ReactElement } from "react";

export interface InsightsInfoProps {
isOpen?: boolean;
children: ReactElement;
description?: () => JSX.Element;
onClose: () => void;
documentationLink?: string | null;
}
Loading