1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-10-31 07:11:47 +09:00

refactor(frontend): use css module

This commit is contained in:
syuilo 2023-05-19 14:08:51 +09:00
parent f68008b002
commit 56d4658b36

View File

@ -1,19 +1,19 @@
<template> <template>
<div class="tivcixzd" :class="{ done: closed || isVoted }"> <div :class="{ [$style.done]: closed || isVoted }">
<ul> <ul :class="$style.choices">
<li v-for="(choice, i) in note.poll.choices" :key="i" :class="{ voted: choice.voted }" @click="vote(i)"> <li v-for="(choice, i) in note.poll.choices" :key="i" :class="[$style.choice, { [$style.voted]: choice.voted }]" @click="vote(i)">
<div class="backdrop" :style="{ 'width': `${showResult ? (choice.votes / total * 100) : 0}%` }"></div> <div :class="$style.bg" :style="{ 'width': `${showResult ? (choice.votes / total * 100) : 0}%` }"></div>
<span> <span :class="$style.fg">
<template v-if="choice.isVoted"><i class="ti ti-check"></i></template> <template v-if="choice.isVoted"><i class="ti ti-check" style="margin-right: 4px; color: var(--accent);"></i></template>
<Mfm :text="choice.text" :plain="true"/> <Mfm :text="choice.text" :plain="true"/>
<span v-if="showResult" class="votes">({{ i18n.t('_poll.votesCount', { n: choice.votes }) }})</span> <span v-if="showResult" style="margin-left: 4px; opacity: 0.7;">({{ i18n.t('_poll.votesCount', { n: choice.votes }) }})</span>
</span> </span>
</li> </li>
</ul> </ul>
<p v-if="!readOnly"> <p v-if="!readOnly" :class="$style.info">
<span>{{ i18n.t('_poll.totalVotes', { n: total }) }}</span> <span>{{ i18n.t('_poll.totalVotes', { n: total }) }}</span>
<span> · </span> <span> · </span>
<a v-if="!closed && !isVoted" @click="showResult = !showResult">{{ showResult ? i18n.ts._poll.vote : i18n.ts._poll.showResult }}</a> <a v-if="!closed && !isVoted" style="color: inherit;" @click="showResult = !showResult">{{ showResult ? i18n.ts._poll.vote : i18n.ts._poll.showResult }}</a>
<span v-if="isVoted">{{ i18n.ts._poll.voted }}</span> <span v-if="isVoted">{{ i18n.ts._poll.voted }}</span>
<span v-else-if="closed">{{ i18n.ts._poll.closed }}</span> <span v-else-if="closed">{{ i18n.ts._poll.closed }}</span>
<span v-if="remaining > 0"> · {{ timer }}</span> <span v-if="remaining > 0"> · {{ timer }}</span>
@ -86,67 +86,51 @@ const vote = async (id) => {
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" module>
.tivcixzd { .choices {
> ul { display: block;
display: block; margin: 0;
margin: 0; padding: 0;
padding: 0; list-style: none;
list-style: none; }
> li { .choice {
display: block; display: block;
position: relative; position: relative;
margin: 4px 0; margin: 4px 0;
padding: 4px; padding: 4px;
//border: solid 0.5px var(--divider); //border: solid 0.5px var(--divider);
background: var(--accentedBg); background: var(--accentedBg);
border-radius: 4px; border-radius: 4px;
overflow: clip; overflow: clip;
cursor: pointer; cursor: pointer;
}
> .backdrop { .bg {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
height: 100%; height: 100%;
background: var(--accent); background: var(--accent);
background: linear-gradient(90deg,var(--buttonGradateA),var(--buttonGradateB)); background: linear-gradient(90deg,var(--buttonGradateA),var(--buttonGradateB));
transition: width 1s ease; transition: width 1s ease;
} }
> span { .fg {
position: relative; position: relative;
display: inline-block; display: inline-block;
padding: 3px 5px; padding: 3px 5px;
background: var(--panel); background: var(--panel);
border-radius: 3px; border-radius: 3px;
}
> i { .info {
margin-right: 4px; color: var(--fg);
color: var(--accent); }
}
> .votes { .done {
margin-left: 4px; .choice {
opacity: 0.7; cursor: default;
}
}
}
}
> p {
color: var(--fg);
a {
color: inherit;
}
}
&.done {
> ul > li {
cursor: default;
}
} }
} }
</style> </style>