summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/components/mfm.ts6
-rw-r--r--src/client/style.scss63
-rw-r--r--src/mfm/language.ts2
-rw-r--r--src/mfm/to-html.ts6
-rw-r--r--src/mfm/to-string.ts4
5 files changed, 69 insertions, 12 deletions
diff --git a/src/client/components/mfm.ts b/src/client/components/mfm.ts
index 7e4fec2848..e1216614a6 100644
--- a/src/client/components/mfm.ts
+++ b/src/client/components/mfm.ts
@@ -131,6 +131,12 @@ export default defineComponent({
}, genEl(token.children));
}
+ case 'shake': {
+ return h('span', {
+ style: this.$store.state.device.animatedMfm ? 'display: inline-block; animation: anime-shake 0.5s ease infinite;' : 'display: inline-block;'
+ }, genEl(token.children));
+ }
+
case 'url': {
return [h(MkUrl, {
key: Math.random(),
diff --git a/src/client/style.scss b/src/client/style.scss
index be9e373291..07abbe0814 100644
--- a/src/client/style.scss
+++ b/src/client/style.scss
@@ -499,19 +499,58 @@ hr {
100% { transform: translateY(0); }
}
-// const gen = () => `translate(${Math.floor(Math.random() * 24) - 12}px, ${Math.floor(Math.random() * 24) - 12}px)`
+// const val = () => `translate(${Math.floor(Math.random() * 20) - 10}px, ${Math.floor(Math.random() * 20) - 10}px)`;
+// let css = '';
+// for (let i = 0; i <= 100; i += 5) { css += `${i}% { transform: ${val()} }\n`; }
@keyframes anime-twitch {
- 0% { transform: translate(0px, -9px); }
- 10% { transform: translate(5px, -11px); }
- 20% { transform: translate(-12px, 2px); }
- 30% { transform: translate(10px, 4px); }
- 40% { transform: translate(0px, 9px); }
- 50% { transform: translate(-6px, 2px); }
- 60% { transform: translate(-7px, 7px); }
- 70% { transform: translate(14px, 7px); }
- 80% { transform: translate(-5px, 10px); }
- 90% { transform: translate(3px, -3px); }
- 100% { transform: translate(10px, 8px); }
+ 0% { transform: translate(7px, -2px) }
+ 5% { transform: translate(-3px, 1px) }
+ 10% { transform: translate(-7px, -1px) }
+ 15% { transform: translate(0px, -1px) }
+ 20% { transform: translate(-8px, 6px) }
+ 25% { transform: translate(-4px, -3px) }
+ 30% { transform: translate(-4px, -6px) }
+ 35% { transform: translate(-8px, -8px) }
+ 40% { transform: translate(4px, 6px) }
+ 45% { transform: translate(-3px, 1px) }
+ 50% { transform: translate(2px, -10px) }
+ 55% { transform: translate(-7px, 0px) }
+ 60% { transform: translate(-2px, 4px) }
+ 65% { transform: translate(3px, -8px) }
+ 70% { transform: translate(6px, 7px) }
+ 75% { transform: translate(-7px, -2px) }
+ 80% { transform: translate(-7px, -8px) }
+ 85% { transform: translate(9px, 3px) }
+ 90% { transform: translate(-3px, -2px) }
+ 95% { transform: translate(-10px, 2px) }
+ 100% { transform: translate(-2px, -6px) }
+}
+
+// const val = () => `translate(${Math.floor(Math.random() * 6) - 3}px, ${Math.floor(Math.random() * 6) - 3}px) rotate(${Math.floor(Math.random() * 24) - 12}deg)`;
+// let css = '';
+// for (let i = 0; i <= 100; i += 5) { css += `${i}% { transform: ${val()} }\n`; }
+@keyframes anime-shake {
+ 0% { transform: translate(-3px, -1px) rotate(-8deg) }
+ 5% { transform: translate(0px, -1px) rotate(-10deg) }
+ 10% { transform: translate(1px, -3px) rotate(0deg) }
+ 15% { transform: translate(1px, 1px) rotate(11deg) }
+ 20% { transform: translate(-2px, 1px) rotate(1deg) }
+ 25% { transform: translate(-1px, -2px) rotate(-2deg) }
+ 30% { transform: translate(-1px, 2px) rotate(-3deg) }
+ 35% { transform: translate(2px, 1px) rotate(6deg) }
+ 40% { transform: translate(-2px, -3px) rotate(-9deg) }
+ 45% { transform: translate(0px, -1px) rotate(-12deg) }
+ 50% { transform: translate(1px, 2px) rotate(10deg) }
+ 55% { transform: translate(0px, -3px) rotate(8deg) }
+ 60% { transform: translate(1px, -1px) rotate(8deg) }
+ 65% { transform: translate(0px, -1px) rotate(-7deg) }
+ 70% { transform: translate(-1px, -3px) rotate(6deg) }
+ 75% { transform: translate(0px, -2px) rotate(4deg) }
+ 80% { transform: translate(-2px, -1px) rotate(3deg) }
+ 85% { transform: translate(1px, -3px) rotate(-10deg) }
+ 90% { transform: translate(1px, 0px) rotate(3deg) }
+ 95% { transform: translate(-2px, 0px) rotate(-3deg) }
+ 100% { transform: translate(2px, 1px) rotate(2deg) }
}
@keyframes anime-tada {
diff --git a/src/mfm/language.ts b/src/mfm/language.ts
index f334301d12..61d6422558 100644
--- a/src/mfm/language.ts
+++ b/src/mfm/language.ts
@@ -77,6 +77,7 @@ export const mfmLanguage = P.createLanguage({
r.jump,
r.flip,
r.twitch,
+ r.shake,
r.inlineCode,
r.mathInline,
r.mention,
@@ -124,6 +125,7 @@ export const mfmLanguage = P.createLanguage({
jump: r => P.regexp(/<jump>(.+?)<\/jump>/, 1).map(x => createTree('jump', r.inline.atLeast(1).tryParse(x), {})),
flip: r => P.regexp(/<flip>(.+?)<\/flip>/, 1).map(x => createTree('flip', r.inline.atLeast(1).tryParse(x), {})),
twitch: r => P.regexp(/<twitch>(.+?)<\/twitch>/, 1).map(x => createTree('twitch', r.inline.atLeast(1).tryParse(x), {})),
+ shake: r => P.regexp(/<shake>(.+?)<\/shake>/, 1).map(x => createTree('shake', r.inline.atLeast(1).tryParse(x), {})),
center: r => r.startOfLine.then(P.regexp(/<center>([\s\S]+?)<\/center>/, 1).map(x => createTree('center', r.inline.atLeast(1).tryParse(x), {}))),
inlineCode: () => P.regexp(/`([^ยด\n]+?)`/, 1).map(x => createLeaf('inlineCode', { code: x })),
mathBlock: r => r.startOfLine.then(P.regexp(/\\\[([\s\S]+?)\\\]/, 1).map(x => createLeaf('mathBlock', { formula: x.trim() }))),
diff --git a/src/mfm/to-html.ts b/src/mfm/to-html.ts
index d58bf386e8..36680e374e 100644
--- a/src/mfm/to-html.ts
+++ b/src/mfm/to-html.ts
@@ -73,6 +73,12 @@ export function toHtml(tokens: MfmForest | null, mentionedRemoteUsers: IMentione
return el;
},
+ shake(token) {
+ const el = doc.createElement('i');
+ appendChildren(token.children, el);
+ return el;
+ },
+
flip(token) {
const el = doc.createElement('span');
appendChildren(token.children, el);
diff --git a/src/mfm/to-string.ts b/src/mfm/to-string.ts
index a6e2a9916c..6b8dcf2c39 100644
--- a/src/mfm/to-string.ts
+++ b/src/mfm/to-string.ts
@@ -52,6 +52,10 @@ export function toString(tokens: MfmForest | null, opts?: RestoreOptions): strin
return `<twitch>${appendChildren(token.children, opts)}</twitch>`;
},
+ shake(token, opts) {
+ return `<shake>${appendChildren(token.children, opts)}</shake>`;
+ },
+
flip(token, opts) {
return `<flip>${appendChildren(token.children, opts)}</flip>`;
},