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

πŸ› : [BUGFIX] Layout issue with new Gainers/Losers trend widget if LLD is in French or German #6932

Merged
merged 3 commits into from
May 27, 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/empty-elephants-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": patch
---

There was a Layout issue with new Gainers/Losers trend widget if LLD is in French or German
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback } from "react";
import React, { useCallback, useRef } from "react";
import { useTranslation } from "react-i18next";
import { AccountLike, ValueChange } from "@ledgerhq/types-live";
import { Unit } from "@ledgerhq/types-cryptoassets";
Expand All @@ -13,6 +13,8 @@ import { setTrackingSource } from "~/renderer/analytics/TrackPage";
import { useHistory } from "react-router-dom";
import { useFeature } from "@ledgerhq/live-common/featureFlags/index";
import { Text } from "@ledgerhq/react-ui";
import PilldDaysSelect from "../PillsDaysSelect";
import { useResize } from "~/renderer/hooks/useResize";

type BalanceSinceProps = {
valueChange: ValueChange;
Expand Down Expand Up @@ -135,13 +137,18 @@ export default function BalanceInfos({ totalBalance, valueChange, isAvailable, u
pathname: "/swap",
});
}, [history]);

const ref = useRef<HTMLDivElement>(null);
const { width } = useResize(ref);

return (
<Box flow={5}>
<Box flow={5} ref={ref}>
<Box horizontal alignItems="center" justifyContent="space-between">
<Text variant="h3Inter" fontWeight="semiBold">
{t("dashboard.header")}
</Text>
<PillsDaysCount />

{width <= 500 ? <PilldDaysSelect /> : <PillsDaysCount />}
</Box>
<Box horizontal>
<BalanceTotal
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React, { useMemo } from "react";
import { PortfolioRangeOption, useTimeRange } from "~/renderer/actions/settings";
import Select from "~/renderer/components/Select";

type ChangeArgs = { value: PortfolioRangeOption; label: string };

const PilldDaysSelect: React.FC = () => {
const [selected, onChange, options] = useTimeRange();

const mappedOptions = useMemo(
() =>
options.map(option => ({
label: option.label,
value: option,
})),
[options],
);

const mappedSelected = useMemo(() => {
const current = options.find(o => o.key === selected) ?? options[0];
return {
label: current.label,
value: current,
};
}, [options, selected]);

const avoidEmptyValue = (option?: ChangeArgs | null) => option && onChange(option.value);

return (
<Select
isSearchable={false}
small
minWidth={90}
onChange={avoidEmptyValue}
renderSelected={(item: { label: unknown }) => item && item.label}
value={mappedSelected}
options={mappedOptions}
/>
);
};

export default PilldDaysSelect;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { selectedTimeRangeSelector } from "~/renderer/reducers/settings";
const primary = "primary.c80";
const neutral = "neutral.c70";

const RESPONSIVE_WIDTH = 275;
const RESPONSIVE_WIDTH = 330;

export function MarketPerformanceWidgetHeader({ onChangeOrder, order }: HeaderProps) {
const { t } = useTranslation();
Expand Down
Loading