mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
add custom library header title sizer
This commit is contained in:
@@ -114,12 +114,20 @@ export const LibraryHeader = forwardRef(
|
|||||||
fw={600}
|
fw={600}
|
||||||
isLink
|
isLink
|
||||||
size="md"
|
size="md"
|
||||||
|
style={{}}
|
||||||
to={item.route}
|
to={item.route}
|
||||||
tt="uppercase"
|
tt="uppercase"
|
||||||
>
|
>
|
||||||
{itemTypeString()}
|
{itemTypeString()}
|
||||||
</Text>
|
</Text>
|
||||||
<h1 className={styles.title}>{title}</h1>
|
<h1
|
||||||
|
className={styles.title}
|
||||||
|
style={{
|
||||||
|
fontSize: calculateTitleSize(title),
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</h1>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -128,6 +136,33 @@ export const LibraryHeader = forwardRef(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const calculateTitleSize = (title: string) => {
|
||||||
|
const titleLength = title.length;
|
||||||
|
let baseSize = '3.5dvw';
|
||||||
|
|
||||||
|
if (titleLength > 20) {
|
||||||
|
baseSize = '3dvw';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (titleLength > 30) {
|
||||||
|
baseSize = '2.75dvw';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (titleLength > 40) {
|
||||||
|
baseSize = '2.5dvw';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (titleLength > 50) {
|
||||||
|
baseSize = '2.25dvw';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (titleLength > 60) {
|
||||||
|
baseSize = '2dvw';
|
||||||
|
}
|
||||||
|
|
||||||
|
return `clamp(2rem, ${baseSize}, 3.25rem)`;
|
||||||
|
};
|
||||||
|
|
||||||
interface LibraryHeaderMenuProps {
|
interface LibraryHeaderMenuProps {
|
||||||
favorite?: boolean;
|
favorite?: boolean;
|
||||||
onFavorite?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
onFavorite?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
||||||
|
|||||||
Reference in New Issue
Block a user