Fix styling conditions for radio select

WIP
This commit is contained in:
Colin Kallemein 2024-11-24 17:15:57 +01:00
parent f7b8c235d8
commit 7d89364104
2 changed files with 16 additions and 11 deletions

View File

@ -151,6 +151,12 @@ button {
} }
} }
.hair-deselect:has(:checked) {
img {
@apply brightness-200;
}
}
.text-pixel { .text-pixel {
@apply text-white font-ui drop-shadow-pixel-black; @apply text-white font-ui drop-shadow-pixel-black;
} }

View File

@ -70,25 +70,24 @@
<div class="flex gap-2 flex-wrap max-h-20 overflow-y-auto scrollbar"> <div class="flex gap-2 flex-wrap max-h-20 overflow-y-auto scrollbar">
<div <div
class="relative flex justify-center items-center bg-gray border border-solid border-gray-500 w-[18px] h-[18px] p-2 rounded-sm hover:bg-gray-500 hover:border-gray-400 focus-visible:outline-none focus-visible:border-gray-300 focus-visible:bg-gray-500" class="hair-deselect relative flex justify-center items-center bg-gray border border-solid border-gray-500 w-[18px] h-[18px] p-2 rounded-sm
:class="{ hover:bg-gray-500 hover:border-gray-400
'bg-cyan': hairs.length == 0, focus-visible:outline-none focus-visible:border-white focus-visible:bg-cyan
}" has-[:checked]:bg-cyan has-[:checked]:border-white"
> >
<img src="/assets/icons/x-button-gray.svg" class="w-4 h-4" alt="Empty button" /> <img src="/assets/icons/x-button-gray.svg" class="w-4 h-4" alt="Empty button" />
<input type="radio" name="hair" @click="selectedHair = null" class="h-full w-full absolute left-0 top-0 m-0 z-10 hover:cursor-pointer focus-visible:outline-offset-0" /> <input type="radio" name="hair" :value="null" v-model="selectedHair" class="h-full w-full absolute left-0 top-0 m-0 z-10 hover:cursor-pointer focus-visible:outline-offset-0" />
</div> </div>
<!-- TODO #255: make radio button so we can set a value, do the same with swatches --> <!-- TODO #255: make radio button so we can set a value, do the same with swatches -->
<div <div
v-for="hair in hairs" v-for="hair in hairs"
class="relative flex justify-center items-center bg-gray border border-solid border-gray-500 w-[18px] h-[18px] p-2 rounded-sm hover:bg-gray-500 hover:border-gray-400 focus-visible:outline-none focus-visible:border-gray-300 focus-visible:bg-gray-500" class="relative flex justify-center items-center bg-gray border border-solid border-gray-500 w-[18px] h-[18px] p-2 rounded-sm
:class="{ hover:bg-gray-500 hover:border-gray-400
'bg-cyan': hair.id === selectedHair?.id, focus-visible:outline-none focus-visible:border-gray-300 focus-visible:bg-gray-500
'bg-gray hover:bg-gray-500': hair.id !== selectedHair?.id has-[:checked]:bg-cyan has-[:checked]:border-white"
}"
> >
<img class="w-4 h-4" :src="config.server_endpoint + '/assets/sprites/' + hair.spriteId + '/front.png'" alt="Hair sprite" /> <img class="w-4 h-4" :src="config.server_endpoint + '/assets/sprites/' + hair.spriteId + '/front.png'" alt="Hair sprite" />
<input type="radio" name="hair" @click="selectedHair = hair" class="h-full w-full absolute left-0 top-0 m-0 z-10 hover:cursor-pointer focus-visible:outline-offset-0" /> <input type="radio" name="hair" :value="hair" v-model="selectedHair" class="h-full w-full absolute left-0 top-0 m-0 z-10 hover:cursor-pointer focus-visible:outline-offset-0" />
</div> </div>
</div> </div>
</div> </div>