-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathmodifiers-banner.tsx
More file actions
35 lines (32 loc) · 911 Bytes
/
modifiers-banner.tsx
File metadata and controls
35 lines (32 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React, { useMemo } from "react";
import { visible } from "@/_components/theme/css-functions";
import { decimalToString } from "@/_lib/remove-non-digits";
import { useTranslations } from "next-intl";
export default function ModifiersBanner({
patternScale,
}: {
patternScale?: number;
}) {
const t = useTranslations("OverlayCanvas");
const hidden = useMemo(() => {
if (!patternScale || patternScale === 1) {
return true;
}
return false;
}, [patternScale]);
const text = useMemo(() => {
if (patternScale && patternScale !== 1) {
return t.rich("scaled", {
scale: () => decimalToString(patternScale, 2),
scaleP: () => decimalToString(patternScale * 100, 1),
});
}
}, [patternScale]);
return (
<div
className={`${visible(!hidden)} h-6 bg-amber-700 w-full text-center font-bold opacity-80`}
>
{text}
</div>
);
}