Fix all Yes/No components (#278)

Signed-off-by: Alexander Platov <sas_lord@mail.ru>
This commit is contained in:
Alexander Platov 2021-10-14 18:52:02 +03:00 committed by GitHub
parent 722298ba78
commit a847d662da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 18 deletions

View File

@ -19,13 +19,13 @@
export let value: boolean | undefined
function getLabel(value: boolean | undefined) {
if (value === true) return 'Да'
if (value === false) return 'Нет'
return 'Неиз'
if (value === true) return 'Yes'
if (value === false) return 'No'
return 'Unkn'
}
</script>
<div class="flex-row-center yesno-container" class:yes={value === true} class:no={value === false} class:unknown={value === undefined} on:click={() => {
<div class="flex-row-center yesno-container" class:yes={value === true} class:no={value === false} on:click={() => {
if (value === true) value = false
else if (value === false) value = undefined
else value = true
@ -51,9 +51,9 @@
user-select: none;
cursor: pointer;
background-color: #77818E;
&.yes { background-color: #60B96E; }
&.no { background-color: #F06C63; }
&.unknown { background-color: #77818E; }
span {
width: 1.6rem;

View File

@ -16,25 +16,31 @@
<script lang="ts">
import { Label } from '@anticrm/ui'
export let state: 'yes' | 'no' | 'unknown'
export let value: boolean | undefined
function getLabel(value: boolean | undefined) {
if (value === true) return 'Yes'
if (value === false) return 'No'
return 'Unkn'
}
</script>
<div class="flex-row-center yesno-container {state}" on:click={() => {
if (state === 'yes') state = 'no'
else if (state === 'no') state = 'unknown'
else state = 'yes'
<div class="flex-row-center yesno-container {value}" on:click={() => {
if (value === true) value = false
else if (value === false) value = undefined
else value = true
}}>
<svg class="svg-small" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<circle class={state} cx="8" cy="8" r="6"/>
{#if state === 'yes'}
<circle cx="8" cy="8" r="6" class:yes={value === true} class:no={value === false} />
{#if value === true}
<polygon fill="#fff" points="7.4,10.9 4.9,8.4 5.7,7.6 7.3,9.1 10.2,5.6 11.1,6.4 "/>
{:else if state === 'no'}
{:else if value === false}
<polygon fill="#fff" points="10.7,6 10,5.3 8,7.3 6,5.3 5.3,6 7.3,8 5.3,10 6,10.7 8,8.7 10,10.7 10.7,10 8.7,8 "/>
{:else}
<path fill="#fff" d="M7.3,9.3h1.3V9c0.1-0.5,0.6-0.9,1.1-1.4c0.4-0.4,0.8-0.9,0.8-1.6c0-1.1-0.8-1.8-2.2-1.8c-1.4,0-2.4,0.8-2.5,2.2 h1.4c0.1-0.6,0.4-1,1-1C8.8,5.4,9,5.7,9,6.2c0,0.4-0.3,0.7-0.7,1.1c-0.5,0.5-1,0.9-1,1.7V9.3z M8,11.6c0.5,0,0.9-0.4,0.9-0.9 c0-0.5-0.4-0.9-0.9-0.9c-0.5,0-0.9,0.4-0.9,0.9C7.1,11.2,7.5,11.6,8,11.6z"/>
{/if}
</svg>
<span><Label label={state} /></span>
<span><Label label={getLabel(value)} /></span>
</div>
<style lang="scss">
@ -43,11 +49,13 @@
user-select: none;
cursor: pointer;
fill: #77818E;
&.yes { fill: #77C07B; }
&.no { fill: #F96E50; }
&.unknown { fill: #77818E; }
span {
margin-left: .25rem;
width: 1.6rem;
text-transform: capitalize;
font-weight: 500;
color: var(--theme-caption-color);

View File

@ -29,7 +29,7 @@
function getLabel(value: boolean | undefined) {
if (value === true) return 'Yes'
if (value === false) return 'No'
return 'Unknown'
return 'Unkn'
}
</script>
@ -41,7 +41,7 @@
onChange(value)
}}>
<svg class="svg-small" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<circle class:yes={value === true} class:no={value === false} class:unknown={value === undefined} cx="8" cy="8" r="6"/>
<circle class:yes={value === true} class:no={value === false} cx="8" cy="8" r="6"/>
{#if value === true}
<polygon fill="#fff" points="7.4,10.9 4.9,8.4 5.7,7.6 7.3,9.1 10.2,5.6 11.1,6.4 "/>
{:else if value === false}
@ -59,11 +59,13 @@
user-select: none;
cursor: pointer;
fill: #77818E;
&.yes { fill: #77C07B; }
&.no { fill: #F96E50; }
&.unknown { fill: #77818E; }
span {
margin-left: .25rem;
width: 1.6rem;
text-transform: capitalize;
font-weight: 500;
color: var(--theme-caption-color);