From a98a7ed8f4fd0afc2626bb0c88d21a2d12d002f0 Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt Date: Thu, 22 Aug 2024 02:49:54 +0200 Subject: [PATCH 1/7] Update Button styles --- .vscode/settings.json | 3 +- .../SpanScalingInsightCard/index.tsx | 1 + .../common/InsightCard/ActionButton/index.tsx | 38 +++ .../common/InsightCard/ActionButton/types.ts | 13 + .../insightCards/common/InsightCard/index.tsx | 208 ++++++------ .../insightCards/common/InsightCard/styles.ts | 10 +- .../insightCards/common/InsightCard/types.ts | 9 + .../common/IssueCompactCard/index.tsx | 2 +- .../Insights/Issues/IssuesFilter/index.tsx | 2 +- .../InstallationWizard/InstallStep/index.tsx | 3 +- .../EnvironmentInstructionsPanel/styles.ts | 6 +- src/components/common/v3/JiraButton/index.tsx | 107 +++--- src/components/common/v3/JiraButton/types.ts | 6 +- .../common/v3/NewButton/NewButton.stories.tsx | 23 +- src/components/common/v3/NewButton/index.tsx | 60 ++-- src/components/common/v3/NewButton/styles.ts | 317 +++++++----------- src/components/common/v3/NewButton/types.ts | 6 +- .../NewIconButton/NewIconButton.stories.tsx | 16 +- .../common/v3/NewIconButton/index.tsx | 21 +- .../common/v3/NewIconButton/styles.ts | 251 +++++--------- .../common/v3/NewIconButton/types.ts | 3 +- 21 files changed, 543 insertions(+), 562 deletions(-) create mode 100644 src/components/Insights/InsightsCatalog/InsightsPage/insightCards/common/InsightCard/ActionButton/index.tsx create mode 100644 src/components/Insights/InsightsCatalog/InsightsPage/insightCards/common/InsightCard/ActionButton/types.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 3c80beaa0..5386dcb55 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,8 @@ "editor.defaultFormatter": "esbenp.prettier-vscode", "stylelint.validate": ["typescript"], "cSpell.words": [ - "Checkmark", + "borderless", + "checkmark", "digma", "digmathon", "digmo", diff --git a/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/SpanScalingInsightCard/index.tsx b/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/SpanScalingInsightCard/index.tsx index 9a655ce06..8be7dad73 100644 --- a/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/SpanScalingInsightCard/index.tsx +++ b/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/SpanScalingInsightCard/index.tsx @@ -75,6 +75,7 @@ export const SpanScalingInsightCard = ({ ticketLink={insight.ticketLink} isHintEnabled={isJiraHintEnabled && i === 0} insightType={insight.type} + type={"icon"} /> ]; diff --git a/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/common/InsightCard/ActionButton/index.tsx b/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/common/InsightCard/ActionButton/index.tsx new file mode 100644 index 000000000..ca0039c06 --- /dev/null +++ b/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/common/InsightCard/ActionButton/index.tsx @@ -0,0 +1,38 @@ +import { isUndefined } from "../../../../../../../../typeGuards/isUndefined"; +import { NewButton } from "../../../../../../../common/v3/NewButton"; +import { NewIconButton } from "../../../../../../../common/v3/NewIconButton"; +import { Tooltip } from "../../../../../../../common/v3/Tooltip"; +import { ActionButtonProps } from "./types"; + +export const ActionButton = ({ + type, + icon, + label, + title, + onClick, + isDisabled +}: ActionButtonProps) => { + if (type === "icon") { + return ( + + + + ); + } + + return ( + + + + ); +}; diff --git a/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/common/InsightCard/ActionButton/types.ts b/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/common/InsightCard/ActionButton/types.ts new file mode 100644 index 000000000..c9ca96128 --- /dev/null +++ b/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/common/InsightCard/ActionButton/types.ts @@ -0,0 +1,13 @@ +import { ComponentType, ReactNode } from "react"; +import { IconProps } from "../../../../../../../common/icons/types"; + +export type ActionButtonType = "icon" | "regular"; + +export interface ActionButtonProps { + type?: ActionButtonType; + icon: ComponentType; + label: string; + title?: ReactNode; + onClick: () => void; + isDisabled?: boolean; +} diff --git a/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/common/InsightCard/index.tsx b/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/common/InsightCard/index.tsx index f1566b831..3a4da011f 100644 --- a/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/common/InsightCard/index.tsx +++ b/src/components/Insights/InsightsCatalog/InsightsPage/insightCards/common/InsightCard/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from "react"; +import { Fragment, useEffect, useState } from "react"; import { useGlobalStore } from "../../../../../../../containers/Main/stores/useGlobalStore"; import { usePrevious } from "../../../../../../../hooks/usePrevious"; import { isString } from "../../../../../../../typeGuards/isString"; @@ -11,21 +11,21 @@ import { HistogramIcon } from "../../../../../../common/icons/16px/HistogramIcon import { PinIcon } from "../../../../../../common/icons/16px/PinIcon"; import { RecheckIcon } from "../../../../../../common/icons/16px/RecheckIcon"; import { CrossIcon } from "../../../../../../common/icons/CrossIcon"; -import { Button } from "../../../../../../common/v3/Button"; -import { BaseButtonProps } from "../../../../../../common/v3/Button/types"; import { JiraButton } from "../../../../../../common/v3/JiraButton"; -import { Tooltip } from "../../../../../../common/v3/Tooltip"; +import { NewButton } from "../../../../../../common/v3/NewButton"; import { trackingEvents } from "../../../../../tracking"; import { isEndpointInsight, isSpanInsight } from "../../../../../typeGuards"; import { InsightStatus } from "../../../../../types"; import { IssueCompactCard } from "../IssueCompactCard"; +import { ActionButton } from "./ActionButton"; +import { ActionButtonType } from "./ActionButton/types"; import { InsightHeader } from "./InsightHeader"; import { ProductionAffectionBar } from "./ProductionAffectionBar"; import { RecalculateBar } from "./RecalculateBar"; import { useDismissal } from "./hooks/useDismissal"; import { useMarkingAsRead } from "./hooks/useMarkingAsRead"; import * as s from "./styles"; -import { InsightCardProps } from "./types"; +import { Action, InsightCardProps } from "./types"; const HIGH_CRITICALITY_THRESHOLD = 0.8; @@ -208,132 +208,143 @@ export const InsightCard = ({ ); } - const renderActions = () => { - const buttonsToRender: { - tooltip: string; - button: React.ComponentType; - }[] = []; - - if ( - isMarkAsReadButtonEnabled && - insight.isReadable && - insight.isRead === false - ) { - buttonsToRender.push({ - tooltip: "Mark as read", - button: (btnProps) => ( -