Plugin Settings: fix text overflow for long plugin names (#2383)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
f21db5cb01
commit
d6507947f5
|
@ -21,7 +21,7 @@ import "./addonCard.css";
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import { Badge } from "@components/Badge";
|
import { Badge } from "@components/Badge";
|
||||||
import { Switch } from "@components/Switch";
|
import { Switch } from "@components/Switch";
|
||||||
import { Text } from "@webpack/common";
|
import { Text, useRef } from "@webpack/common";
|
||||||
import type { MouseEventHandler, ReactNode } from "react";
|
import type { MouseEventHandler, ReactNode } from "react";
|
||||||
|
|
||||||
const cl = classNameFactory("vc-addon-");
|
const cl = classNameFactory("vc-addon-");
|
||||||
|
@ -42,6 +42,8 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AddonCard({ disabled, isNew, name, infoButton, footer, author, enabled, setEnabled, description, onMouseEnter, onMouseLeave }: Props) {
|
export function AddonCard({ disabled, isNew, name, infoButton, footer, author, enabled, setEnabled, description, onMouseEnter, onMouseLeave }: Props) {
|
||||||
|
const titleRef = useRef<HTMLDivElement>(null);
|
||||||
|
const titleContainerRef = useRef<HTMLDivElement>(null);
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cl("card", { "card-disabled": disabled })}
|
className={cl("card", { "card-disabled": disabled })}
|
||||||
|
@ -51,7 +53,21 @@ export function AddonCard({ disabled, isNew, name, infoButton, footer, author, e
|
||||||
<div className={cl("header")}>
|
<div className={cl("header")}>
|
||||||
<div className={cl("name-author")}>
|
<div className={cl("name-author")}>
|
||||||
<Text variant="text-md/bold" className={cl("name")}>
|
<Text variant="text-md/bold" className={cl("name")}>
|
||||||
{name}{isNew && <Badge text="NEW" color="#ED4245" />}
|
<div ref={titleContainerRef} className={cl("title-container")}>
|
||||||
|
<div
|
||||||
|
ref={titleRef}
|
||||||
|
className={cl("title")}
|
||||||
|
onMouseOver={() => {
|
||||||
|
const title = titleRef.current!;
|
||||||
|
const titleContainer = titleContainerRef.current!;
|
||||||
|
|
||||||
|
title.style.setProperty("--offset", `${titleContainer.clientWidth - title.scrollWidth}px`);
|
||||||
|
title.style.setProperty("--duration", `${Math.max(0.5, (title.scrollWidth - titleContainer.clientWidth) / 7)}s`);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{name}
|
||||||
|
</div>
|
||||||
|
</div>{isNew && <Badge text="NEW" color="#ED4245" />}
|
||||||
</Text>
|
</Text>
|
||||||
{!!author && (
|
{!!author && (
|
||||||
<Text variant="text-md/normal" className={cl("author")}>
|
<Text variant="text-md/normal" className={cl("author")}>
|
||||||
|
|
|
@ -62,3 +62,36 @@
|
||||||
.vc-addon-author::before {
|
.vc-addon-author::before {
|
||||||
content: "by ";
|
content: "by ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vc-addon-title-container {
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
height: 1.25em;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-addon-title {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes vc-addon-title {
|
||||||
|
0% {
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
transform: translateX(var(--offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-addon-title:hover {
|
||||||
|
overflow: visible;
|
||||||
|
animation: vc-addon-title var(--duration) linear infinite;
|
||||||
|
}
|
||||||
|
|
|
@ -462,6 +462,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
name: "Oleh Polisan",
|
name: "Oleh Polisan",
|
||||||
id: 242305263313485825n
|
id: 242305263313485825n
|
||||||
},
|
},
|
||||||
|
HAHALOSAH: {
|
||||||
|
name: "HAHALOSAH",
|
||||||
|
id: 903418691268513883n
|
||||||
|
},
|
||||||
GabiRP: {
|
GabiRP: {
|
||||||
name: "GabiRP",
|
name: "GabiRP",
|
||||||
id: 507955112027750401n
|
id: 507955112027750401n
|
||||||
|
|
Loading…
Reference in a new issue