mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-21 15:48:52 -05:00
feat(wigglyText): Updates
* feat(wigglyText): upsert * Fix Import Formatting --------- Co-authored-by: thororen <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
parent
2f6700192f
commit
3035edf256
2 changed files with 115 additions and 56 deletions
|
@ -8,8 +8,11 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import { makeRange } from "@components/PluginSettings/components";
|
import { makeRange } from "@components/PluginSettings/components";
|
||||||
import { EquicordDevs } from "@utils/constants";
|
import { EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { Text } from "@webpack/common";
|
||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
|
|
||||||
|
import ExampleWiggle from "./ui/components/ExampleWiggle";
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
intensity: {
|
intensity: {
|
||||||
type: OptionType.SLIDER,
|
type: OptionType.SLIDER,
|
||||||
|
@ -18,22 +21,6 @@ const settings = definePluginSettings({
|
||||||
default: 4,
|
default: 4,
|
||||||
stickToMarkers: true,
|
stickToMarkers: true,
|
||||||
onChange: () => updateStyles()
|
onChange: () => updateStyles()
|
||||||
},
|
|
||||||
direction: {
|
|
||||||
type: OptionType.SELECT,
|
|
||||||
description: "Swing direction",
|
|
||||||
options: [{
|
|
||||||
label: "Circle",
|
|
||||||
value: "xy",
|
|
||||||
default: true
|
|
||||||
}, {
|
|
||||||
label: "Horizontal",
|
|
||||||
value: "x",
|
|
||||||
}, {
|
|
||||||
label: "Vertical",
|
|
||||||
value: "y"
|
|
||||||
}],
|
|
||||||
onChange: () => updateStyles()
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -42,56 +29,103 @@ const dirMap = {
|
||||||
y: "1.2s wiggle-wavy-y linear infinite"
|
y: "1.2s wiggle-wavy-y linear infinite"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const classMap = [
|
||||||
|
{
|
||||||
|
chars: ["<", ">"],
|
||||||
|
className: "wiggle-inner-x",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
chars: ["^", "^"],
|
||||||
|
className: "wiggle-inner-y",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
chars: [")", "("],
|
||||||
|
className: "wiggle-inner-xy"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
let styles: HTMLStyleElement;
|
let styles: HTMLStyleElement;
|
||||||
const updateStyles = () => {
|
const updateStyles = () => {
|
||||||
const inten = Vencord.Settings.plugins.WigglyText.intensity + "px";
|
const inten = Vencord.Settings.plugins.WigglyText.intensity + "px";
|
||||||
const dir = Vencord.Settings.plugins.WigglyText.direction as string;
|
|
||||||
styles.textContent = `
|
styles.textContent = `
|
||||||
.wiggly-inner {
|
.wiggle-example {
|
||||||
animation: ${dir.split("").map(dir => dirMap[dir]).join(", ")};
|
list-style-type: disc;
|
||||||
position: relative;
|
list-style-position: outside;
|
||||||
top: 0;
|
margin: 4px 0 0 16px;
|
||||||
left: 0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes wiggle-wavy-x {
|
.wiggle-example li {
|
||||||
from {
|
white-space: break-spaces;
|
||||||
left: -${inten};
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
.wiggle-inner {
|
||||||
left: ${inten};
|
position: relative;
|
||||||
}
|
top: 0;
|
||||||
}
|
left: 0;
|
||||||
|
|
||||||
@keyframes wiggle-wavy-y {
|
&.wiggle-inner-x {
|
||||||
0% {
|
animation: ${dirMap.x};
|
||||||
top: 0;
|
}
|
||||||
animation-timing-function: ease-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
25% {
|
&.wiggle-inner-y {
|
||||||
top: -${inten};
|
animation: ${dirMap.y};
|
||||||
animation-timing-function: ease-in;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
50% {
|
&.wiggle-inner-xy {
|
||||||
top: 0;
|
animation: ${dirMap.x}, ${dirMap.y};
|
||||||
animation-timing-function: ease-out;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
75% {
|
@keyframes wiggle-wavy-x {
|
||||||
top: ${inten};
|
from {
|
||||||
animation-timing-function: ease-in;
|
left: -${inten};
|
||||||
}
|
}
|
||||||
}`;
|
|
||||||
|
to {
|
||||||
|
left: ${inten};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes wiggle-wavy-y {
|
||||||
|
0% {
|
||||||
|
top: 0;
|
||||||
|
animation-timing-function: ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
25% {
|
||||||
|
top: -${inten};
|
||||||
|
animation-timing-function: ease-in;
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
top: 0;
|
||||||
|
animation-timing-function: ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
75% {
|
||||||
|
top: ${inten};
|
||||||
|
animation-timing-function: ease-in;
|
||||||
|
}
|
||||||
|
}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "WigglyText",
|
name: "WigglyText",
|
||||||
description: "Adds a new markdown formatting that makes text ~wiggly~",
|
description: "Adds a new markdown formatting that makes text wiggly.",
|
||||||
authors: [EquicordDevs.nexpid],
|
authors: [EquicordDevs.nexpid],
|
||||||
settings,
|
settings,
|
||||||
|
settingsAboutComponent: () => (
|
||||||
|
<Text>
|
||||||
|
You can make text wiggle with the following:<br />
|
||||||
|
<ul className="wiggle-example">
|
||||||
|
<li><ExampleWiggle wiggle="x">left and right</ExampleWiggle> by typing <code><~text~></code></li>
|
||||||
|
<li><ExampleWiggle wiggle="y">up and down</ExampleWiggle> by typing <code>^~text~^</code></li>
|
||||||
|
<li><ExampleWiggle wiggle="xy">in a circle</ExampleWiggle> by typing <code>)~text~(</code></li>
|
||||||
|
</ul>
|
||||||
|
</Text>
|
||||||
|
),
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: "parseToAST:",
|
find: "parseToAST:",
|
||||||
|
@ -104,16 +138,21 @@ export default definePlugin({
|
||||||
|
|
||||||
wigglyRule: {
|
wigglyRule: {
|
||||||
order: 24,
|
order: 24,
|
||||||
match: (source: string) => source.match(/^~([\s\S]+?)~(?!_)/),
|
match: (source: string) => classMap.map(({ chars }) => source.match(new RegExp(`^(\\${chars[0]})~([\\s\\S]+?)~(\\${chars[1]})(?!_)`))).find(x => x !== null),
|
||||||
parse: (
|
parse: (
|
||||||
capture: RegExpMatchArray,
|
capture: RegExpMatchArray,
|
||||||
transform: (...args: any[]) => any,
|
transform: (...args: any[]) => any,
|
||||||
state: any
|
state: any
|
||||||
) => ({
|
) => {
|
||||||
content: transform(capture[1], state),
|
const className = classMap.find(({ chars }) => chars[0] === capture[1] && chars[1] === capture[3])?.className ?? "";
|
||||||
}),
|
|
||||||
|
return {
|
||||||
|
content: transform(capture[2], state),
|
||||||
|
className
|
||||||
|
};
|
||||||
|
},
|
||||||
react: (
|
react: (
|
||||||
data: { content: any[]; },
|
data: { content: any[]; className: string; },
|
||||||
output: (...args: any[]) => ReactNode[]
|
output: (...args: any[]) => ReactNode[]
|
||||||
) => {
|
) => {
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
|
@ -129,7 +168,7 @@ export default definePlugin({
|
||||||
children[j] = child.split("").map((x, i) => (
|
children[j] = child.split("").map((x, i) => (
|
||||||
<span key={i}>
|
<span key={i}>
|
||||||
<span
|
<span
|
||||||
className="wiggly-inner"
|
className={`wiggle-inner ${data.className}`}
|
||||||
style={{
|
style={{
|
||||||
animationDelay: `${((offset++) * 25) % 1200}ms`,
|
animationDelay: `${((offset++) * 25) % 1200}ms`,
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default function ExampleWiggle({ wiggle, children }: { wiggle: "x" | "y" | "xy", children: string; }) {
|
||||||
|
return children.split("").map((x, i) => (
|
||||||
|
<span key={i}>
|
||||||
|
<span
|
||||||
|
className={`wiggle-inner wiggle-inner-${wiggle}`}
|
||||||
|
style={{
|
||||||
|
animationDelay: `${(i * 25) % 1200}ms`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{x}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
));
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue