mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-23 08:39:24 -05:00
fix(unreadBadgeCount): use div (#153)
* fix(unreadBadgeCount): use div * add self to devs
This commit is contained in:
parent
2156bc1576
commit
8ae70c490c
2 changed files with 32 additions and 25 deletions
|
@ -8,7 +8,7 @@ import "./styles.css";
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs, EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findStoreLazy } from "@webpack";
|
import { findStoreLazy } from "@webpack";
|
||||||
import { ReadStateStore, useStateFromStores } from "@webpack/common";
|
import { ReadStateStore, useStateFromStores } from "@webpack/common";
|
||||||
|
@ -18,28 +18,15 @@ import { JSX } from "react";
|
||||||
const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore");
|
const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore");
|
||||||
const JoinedThreadsStore = findStoreLazy("JoinedThreadsStore");
|
const JoinedThreadsStore = findStoreLazy("JoinedThreadsStore");
|
||||||
|
|
||||||
function NumberBadge({ color, className, count }) {
|
function NumberBadge({ className, count, width }) {
|
||||||
return <svg
|
// To whoever used svgs here,
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
// Please. svgs bad and buggy unless used as an icon
|
||||||
width="24"
|
return <div
|
||||||
height="24"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="none"
|
|
||||||
className={className}
|
className={className}
|
||||||
|
style={{ width: width }}
|
||||||
>
|
>
|
||||||
<circle cx="12" cy="12" r="10" fill={color} />
|
{count}
|
||||||
<text
|
</div>;
|
||||||
x="50%"
|
|
||||||
y="50%"
|
|
||||||
textAnchor="middle"
|
|
||||||
fontSize="10"
|
|
||||||
fill="white"
|
|
||||||
fontWeight="bold"
|
|
||||||
dy=".3em"
|
|
||||||
>
|
|
||||||
{count}
|
|
||||||
</text>
|
|
||||||
</svg>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
|
@ -63,7 +50,7 @@ const settings = definePluginSettings({
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "UnreadCountBadge",
|
name: "UnreadCountBadge",
|
||||||
authors: [Devs.Joona],
|
authors: [Devs.Joona, EquicordDevs.Panniku],
|
||||||
description: "Shows unread message count badges on channels in the channel list",
|
description: "Shows unread message count badges on channels in the channel list",
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
|
@ -109,16 +96,20 @@ export default definePlugin({
|
||||||
|
|
||||||
if (!settings.store.showOnMutedChannels && (UserGuildSettingsStore.isChannelMuted(channel.guild_id, channel.id) || JoinedThreadsStore.isMuted(channel.id)))
|
if (!settings.store.showOnMutedChannels && (UserGuildSettingsStore.isChannelMuted(channel.guild_id, channel.id) || JoinedThreadsStore.isMuted(channel.id)))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
// Im not sure if the "dot" ever appends, hence why the css is almost left unmodified for these classes
|
||||||
const className = `vc-unreadCountBadge${whiteDot ? "-dot" : ""}${channel.threadMetadata ? "-thread" : ""}`;
|
const className = `vc-unreadCountBadge${whiteDot ? "-dot" : ""}${channel.threadMetadata ? "-thread" : ""}`;
|
||||||
return (
|
return (
|
||||||
<NumberBadge
|
<NumberBadge
|
||||||
color="var(--brand-500)"
|
className={"vc-unreadCountBadge " + className}
|
||||||
className={className}
|
|
||||||
count={
|
count={
|
||||||
unreadCount > 99 && settings.store.notificationCountLimit
|
unreadCount > 99 && settings.store.notificationCountLimit
|
||||||
? "+99"
|
? "+99"
|
||||||
: unreadCount
|
: unreadCount
|
||||||
}
|
}
|
||||||
|
width={
|
||||||
|
unreadCount > 10 ? 22 : 16
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, { noop: true }),
|
}, { noop: true }),
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
.unreadCountBadge {
|
.vc-unreadCountBadge {
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: 16px;
|
||||||
|
min-height: 16px;
|
||||||
|
min-width: 16px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
background-color: var(--brand-500);
|
||||||
|
color: var(--white);
|
||||||
|
font-size: 12px;
|
||||||
|
font-family: var(--font-display);
|
||||||
|
border-radius: 8px;
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
|
line-height: 1.33;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-unreadCountBadge-dot {
|
.vc-unreadCountBadge-dot {
|
||||||
|
|
Loading…
Add table
Reference in a new issue