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
10 changes: 8 additions & 2 deletions src/components/Insights/common/InsightCard/KeyValue/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { ForwardedRef, forwardRef } from "react";
import * as s from "./styles";
import { KeyValueProps } from "./types";

export const KeyValue = (props: KeyValueProps) => {
const KeyValueComponent = (
props: KeyValueProps,
ref: ForwardedRef<HTMLDivElement>
) => {
return (
<s.Container>
<s.Container className={props.className} ref={ref}>
<s.Key>{props.label}</s.Key>
<s.Value>{props.children}</s.Value>
</s.Container>
);
};

export const KeyValue = forwardRef(KeyValueComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { ReactNode } from "react";
export interface KeyValueProps {
label: ReactNode;
children: ReactNode;
className?: string;
}
4 changes: 2 additions & 2 deletions src/components/Insights/common/InsightCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ export const InsightCard = (props: InsightCardProps) => {
tooltip: "Open Trace",
button: (btnProps) => (
<Button
{...btnProps}
icon={TraceIcon}
label={"Trace"}
onClick={() => props.onGoToTrace && props.onGoToTrace()}
{...btnProps}
/>
)
});
Expand Down Expand Up @@ -184,7 +184,7 @@ export const InsightCard = (props: InsightCardProps) => {
{secondary.map((Secondary) => {
return (
<Tooltip key={Secondary.tooltip} title={Secondary.tooltip}>
<Secondary.button buttonType="tertiary" label={undefined} />
<Secondary.button buttonType="tertiary" label={undefined} />
</Tooltip>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Tag } from "../../../../common/v3/Tag";
import { InsightCard } from "../../InsightCard";
import { ColumnsContainer } from "../../InsightCard/ColumnsContainer";
import { KeyValue } from "../../InsightCard/KeyValue";
import { Description } from "../styles";
import * as s from "./styles";
import { SlowEndpointInsightProps } from "./types";

Expand All @@ -20,12 +19,12 @@ export const SlowEndpointInsight = (props: SlowEndpointInsightProps) => {
content={
<s.ContentContainer>
<ColumnsContainer>
<Description>
<s.DescriptionColumn label="Description">
{`On average requests are slower than other endpoints by ${roundTo(
diff,
2
)}%`}
</Description>
</s.DescriptionColumn>
<KeyValue label={"Slower by"}>
<Tag content={getDurationString(props.insight.median)} />
</KeyValue>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import styled from "styled-components";
import { KeyValue } from "../../InsightCard/KeyValue";

export const ContentContainer = styled.div`
padding: 8px 0;
display: flex;
`;

export const DescriptionColumn = styled(KeyValue)`
flex-grow: 2;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export const TrafficInsight = (props: TrafficInsightProps) => {
content={
<s.ContentContainer>
<ColumnsContainer>
<s.Description>{getDescription(props.insight.type)}</s.Description>
<s.DescriptionColumn label="Description">
{getDescription(props.insight.type)}
</s.DescriptionColumn>
<KeyValue label={"Duration"}>
<Tag content={`${valueString}/min`} />
</KeyValue>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import styled from "styled-components";
import { caption1RegularTypography } from "../../../../common/App/typographies";
import { KeyValue } from "../../InsightCard/KeyValue";

export const ContentContainer = styled.div`
gap: 24px;
padding: 8px 0;
display: flex;
`;

export const Description = styled.div`
color: ${({ theme }) => theme.colors.v3.text.secondary};
${caption1RegularTypography}
export const DescriptionColumn = styled(KeyValue)`
flex-grow: 2;
`;