design: distinguish multi/single choice polls with shapes
This commit is contained in:
1 file changed
+30
-1
@@ -91,6 +91,7 @@
|
|||||||
{@const percentage = Math.floor(
|
{@const percentage = Math.floor(
|
||||||
(choice.num_votes / totalVotes || 0) * 100,
|
(choice.num_votes / totalVotes || 0) * 100,
|
||||||
)}
|
)}
|
||||||
|
{@const multi = post.poll.mode != 'single'}
|
||||||
<li
|
<li
|
||||||
class="relative z-10 overflow-hidden has-disabled:pointer-events-none"
|
class="relative z-10 overflow-hidden has-disabled:pointer-events-none"
|
||||||
role="progressbar"
|
role="progressbar"
|
||||||
@@ -113,7 +114,7 @@
|
|||||||
<label
|
<label
|
||||||
class="px-4 py-2 w-full text-left flex flex-row gap-2 items-center"
|
class="px-4 py-2 w-full text-left flex flex-row gap-2 items-center"
|
||||||
>
|
>
|
||||||
{#if post.poll.mode == 'single'}
|
{#if !multi}
|
||||||
<input
|
<input
|
||||||
class="appearance-none absolute inset-0 cursor-pointer w-full h-full peer"
|
class="appearance-none absolute inset-0 cursor-pointer w-full h-full peer"
|
||||||
name="poll={post.id}"
|
name="poll={post.id}"
|
||||||
@@ -132,6 +133,11 @@
|
|||||||
disabled={!canVote}
|
disabled={!canVote}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
<div
|
||||||
|
class={['choice-indicator', multi ? 'rounded-md' : 'rounded-full']}
|
||||||
|
>
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
<div class={['choice-text', 'text-slate-600 dark:text-zinc-400']}>
|
<div class={['choice-text', 'text-slate-600 dark:text-zinc-400']}>
|
||||||
{choice.choice_text}
|
{choice.choice_text}
|
||||||
</div>
|
</div>
|
||||||
@@ -178,6 +184,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.choice-indicator {
|
||||||
|
width: calc(var(--spacing) * 5);
|
||||||
|
height: calc(var(--spacing) * 5);
|
||||||
|
background: var(--color-slate-100);
|
||||||
|
display: inline-grid;
|
||||||
|
place-items: center;
|
||||||
|
|
||||||
|
@variant dark {
|
||||||
|
background: var(--color-zinc-800);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
input:checked ~ .choice-indicator > div {
|
||||||
|
width: calc(var(--spacing) * 4);
|
||||||
|
height: calc(var(--spacing) * 4);
|
||||||
|
border-radius: inherit;
|
||||||
|
background: var(--color-primary-900);
|
||||||
|
|
||||||
|
@variant dark {
|
||||||
|
background: var(--color-primary-100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
li:has(label:focus-within) {
|
li:has(label:focus-within) {
|
||||||
border: 1px solid --alpha(var(--color-primary-900) / 50%);
|
border: 1px solid --alpha(var(--color-primary-900) / 50%);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user