Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | 117x 117x 117x 117x | import { DateTime } from 'luxon';
import { Plugin } from '../model/plugin';
import { Ref } from '../model/ref';
import { Mod } from '../model/tag';
export const voteUpPlugin: Plugin = {
tag: 'plugin/user/vote/up',
name: $localize`⬆️ Vote Up`,
config: {
mod: $localize`⬆️ Voting`,
type: 'plugin',
experimental: true,
generated: $localize`Generated by jasper-ui ${DateTime.now().toISO()}`,
description: $localize`Activates built-in voting support and allows users to upvote Refs.`,
sorts: [
{ sort: 'plugins->plugin/user/vote:top', label: '❤️ top', title: $localize`Total activity` },
{ sort: 'plugins->plugin/user/vote:decay', label: '🔥️ hot', title: $localize`Decaying score` },
],
filters: [
{ user: 'plugin/user/vote', label: $localize`⬆️ voted`, title: $localize`My voted Refs`, group: $localize`Lists ☰` },
],
// language=CSS
css: `.voting {
display: flex;
flex-direction: column;
justify-content: space-around;
max-height: 56px;
margin-right: 10px;
* {
cursor: pointer;
transition: transform 100ms ease-in-out, filter 100ms ease-in-out;
filter: grayscale(1);
&:hover {
filter: grayscale(1) brightness(1.1);
}
&:active {
transform: scale(0.9);
filter: grayscale(1) brightness(0.7) blur(0.1px);
}
}
.vote-up.on {
transform: scale(1.5);
filter: hue-rotate(180deg);
&:hover {
filter: brightness(1.1) hue-rotate(180deg);
}
&:active {
transform: scale(0.9);
filter: brightness(0.7) blur(0.1px) hue-rotate(180deg);
}
}
.vote-down.on {
transform: scale(1.2);
filter: hue-rotate(0);
&:hover {
filter: brightness(1.1);
}
&:active {
transform: scale(0.9);
filter: brightness(0.7) blur(0.1px);
}
}
.vote-up::before {
content: '⬆️';
}
.vote-down::before {
content: '⬇️';
}
}`
},
};
export const voteDownPlugin: Plugin = {
tag: 'plugin/user/vote/down',
name: $localize`⬇️ Vote Down`,
config: {
mod: $localize`⬆️ Voting`,
type: 'plugin',
experimental: true,
generated: $localize`Generated by jasper-ui ${DateTime.now().toISO()}`,
description: $localize`Allows users to downvote Refs. Required upvote plugin to be installed.`,
sorts: [
{ sort: 'plugins->plugin/user/vote:score', label: '📈️ score', title: $localize`Total score` },
],
},
};
export function score(ref: Ref) {
let score = 0;
if (ref.metadata?.plugins?.['plugin/user/vote/up']) {
score += ref.metadata?.plugins['plugin/user/vote/up'];
}
if (ref.metadata?.plugins?.['plugin/user/vote/down']) {
score -= ref.metadata?.plugins['plugin/user/vote/down'];
}
return score;
}
export const voteMod: Mod = {
plugin: [
voteUpPlugin,
voteDownPlugin,
],
};
|