Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usage of hopper icon in metric score #798

Merged
merged 5 commits into from
Apr 17, 2024
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
5 changes: 5 additions & 0 deletions .changeset/khaki-glasses-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@igloo-ui/metric": patch
---

Fixed Metric Score Icon size
9 changes: 6 additions & 3 deletions packages/Metric/src/Metric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import cx from "classnames";
import { useButton, type AriaButtonProps, FocusRing } from "react-aria";

import HelpSolid from "@igloo-ui/icons/dist/HelpSolid";
import Help from "@igloo-ui/icons/dist/Help";
import Alignment from "@igloo-ui/icons/dist/Alignment";
import Checkmark from "@igloo-ui/icons/dist/Checkmark";

import { QuestionIcon } from "@hopper-ui/icons-react16";

import Tooltip from "@igloo-ui/tooltip";
import Score from "./Score";

Expand Down Expand Up @@ -54,6 +55,8 @@ const Metric: React.FunctionComponent<MetricProps> = ({
return document.documentElement.getAttribute("data-brand") ?? "igloo";
};

const isWorkleap = getBrand() === "workleap";

const { buttonProps } = useButton(rest, btnRef);

const classes = cx("ids-metric", className, {
Expand Down Expand Up @@ -106,8 +109,8 @@ const Metric: React.FunctionComponent<MetricProps> = ({
>
{tooltip && appearance !== "selected" && (
<Tooltip content={tooltip}>
{getBrand() === "workleap" ? (
<Help size="small" />) : <HelpSolid size="small" />}
{isWorkleap ? (
<QuestionIcon size="sm" />) : <HelpSolid size="small" />}
</Tooltip>
)}
{type !== "subMetric" && appearance === "selected" && (
Expand Down
55 changes: 39 additions & 16 deletions packages/Metric/src/Score.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import cx from "classnames";

import ArrowUp from "@igloo-ui/icons/dist/ArrowUp";
import ArrowDown from "@igloo-ui/icons/dist/ArrowDown";
import { ArrowUpIcon, ArrowDownIcon } from "@hopper-ui/icons-react16";
fraincs marked this conversation as resolved.
Show resolved Hide resolved

import { useLocalizedStringFormatter, useLocale } from "@igloo-ui/provider";
import intlMessages from "./intl";

Expand All @@ -25,6 +27,16 @@ export interface ScoreProps extends React.ComponentProps<"div"> {
value?: number | null;
}

const sizeMap = {
small: "sm",
medium: "md",
large: "lg"
} as const;

const getBrand = (): string => {
return document.documentElement.getAttribute("data-brand") ?? "igloo";
};

const Score: React.FunctionComponent<ScoreProps> = ({
arrowSize = "small",
className,
Expand All @@ -36,6 +48,25 @@ const Score: React.FunctionComponent<ScoreProps> = ({
}: ScoreProps) => {
const stringFormatter = useLocalizedStringFormatter(intlMessages);
const { locale } = useLocale();

const isWorkleap = getBrand() === "workleap";

const arrowPositiveClass = cx("ids-score__arrow", "ids-score__arrow--positive", {
"ids-score__arrow--selected": isSelected
});

const arrowNegativeClass = cx("ids-score__arrow", "ids-score__arrow--negative", {
"ids-score__arrow--selected": isSelected
});

const ArrowUpIconElement = isWorkleap ?
<ArrowUpIcon className={arrowPositiveClass} size={sizeMap[arrowSize]} /> :
<ArrowUp className={arrowPositiveClass} size={arrowSize} />;

const ArrowDownIconElement = isWorkleap ?
<ArrowDownIcon className={arrowNegativeClass} size={sizeMap[arrowSize]} /> :
<ArrowDown className={arrowNegativeClass} size={arrowSize} />;

if (!isVariation && (value === undefined || value === null)) {
return <span
className={cx("ids-score", className, {
Expand All @@ -53,28 +84,20 @@ const Score: React.FunctionComponent<ScoreProps> = ({
if (forceDecimal) {
displayValue = metricValue.toFixed(1);
}

const arrow = isNegative ? (
<ArrowDown
size={arrowSize}
className={cx("ids-score__arrow", "ids-score__arrow--negative", {
"ids-score__arrow--selected": isSelected
})}
/>
ArrowDownIconElement
) : (
<ArrowUp
size={arrowSize}
className={cx("ids-score__arrow", "ids-score__arrow--positive", {
"ids-score__arrow--selected": isSelected
})}
/>
ArrowUpIconElement
);
let postFix = absoluteValue === 1 ?
` ${stringFormatter.format("pt")}` :

let postFix = absoluteValue === 1 ?
` ${stringFormatter.format("pt")}` :
` ${stringFormatter.format("pts")}`;

if (locale === "fr-CA") {
postFix = absoluteValue === 1 || absoluteValue === 0 ?
` ${stringFormatter.format("pt")}` :
postFix = absoluteValue === 1 || absoluteValue === 0 ?
` ${stringFormatter.format("pt")}` :
` ${stringFormatter.format("pts")}`;
}

Expand Down
Loading