Updated Checkbox component (#5329)

Signed-off-by: Alexander Platov <alexander.platov@hardcoreeng.com>
This commit is contained in:
Alexander Platov 2024-04-12 06:41:16 +03:00 committed by GitHub
parent 1410607117
commit 0baf9026d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 139 additions and 147 deletions

View File

@ -21,7 +21,7 @@
export let circle: boolean = false
export let kind: 'default' | 'primary' | 'positive' | 'negative' | 'todo' = 'default'
export let color: string | undefined = undefined
export let readonly = false
export let readonly: boolean = false
const dispatch = createEventDispatcher()
@ -43,168 +43,186 @@
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
<label class="checkbox {size} {kind}" class:circle class:readonly class:checked on:click|stopPropagation>
<label
style:--checkbox-color={color ?? 'var(--global-accent-TextColor)'}
class="checkbox-container {size} {kind} {symbol}"
class:colored={color !== undefined}
class:circle
class:readonly
class:checked
on:click|stopPropagation
>
<input class="chBox" disabled={readonly} type="checkbox" bind:checked on:change|capture={handleValueChanged} />
<svg class="checkSVG" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" style:color>
{#if kind === 'todo'}
{#if readonly}
<path
class="todo-readonly"
d="M15.735 10.049A8 8 0 0 0 16 8a8 8 0 0 0-.408-2.528 1 1 0 0 0-.725 1.16 7 7 0 0 1 0 2.735 1 1 0 0 0 .725 1.161q.079-.237.143-.48m-.58 1.532a1 1 0 0 0-1.333.308 7.05 7.05 0 0 1-1.933 1.933 1 1 0 0 0-.308 1.334 8.03 8.03 0 0 0 3.575-3.575m-4.627 4.011a1 1 0 0 0-1.16-.725 7 7 0 0 1-2.735 0 1 1 0 0 0-1.161.725A8 8 0 0 0 8 16a8 8 0 0 0 2.528-.408m-6.109-.436a1 1 0 0 0-.308-1.334 7.05 7.05 0 0 1-1.933-1.933 1 1 0 0 0-1.334-.308 8.03 8.03 0 0 0 3.575 3.575M.408 10.528a1 1 0 0 0 .725-1.16 7 7 0 0 1 0-2.735 1 1 0 0 0-.725-1.161A8 8 0 0 0 0 8a8 8 0 0 0 .408 2.528M.844 4.42a1 1 0 0 0 1.334-.308 7 7 0 0 1 1.933-1.933A1 1 0 0 0 4.42.844a8 8 0 0 0-.864.503A8.04 8.04 0 0 0 .845 4.42M5.472.408a1 1 0 0 0 1.16.725 7 7 0 0 1 2.735 0 1 1 0 0 0 1.161-.725A8 8 0 0 0 8 0a8 8 0 0 0-2.528.408m6.109.436a1 1 0 0 0 .308 1.334 7.05 7.05 0 0 1 1.933 1.933 1 1 0 0 0 1.334.308 8 8 0 0 0-.504-.864 8.04 8.04 0 0 0-3.071-2.71"
/>
{:else}
<circle class="todo-circle" cx="8" cy="8" r="7.5" />
<path
class="todo-check"
d="M11.585 5.54c.22.22.22.576 0 .795l-4.312 4.313a.56.56 0 0 1-.796 0L4.415 8.585a.563.563 0 0 1 .795-.795l1.665 1.664L10.79 5.54c.22-.22.576-.22.795 0"
/>
{/if}
{:else if checked}
{#if symbol === 'minus'}
<rect
class="check"
class:primary={kind === 'primary'}
class:positive={kind === 'positive'}
class:negative={kind === 'negative'}
x="4"
y="7.4"
width="8"
height="1.2"
/>
{:else}
<polygon
class="check"
class:primary={kind === 'primary'}
class:positive={kind === 'positive'}
class:negative={kind === 'negative'}
points="7.3,11.5 4,8.3 5,7.4 7.3,9.7 11.8,5.1 12.7,6.1 "
/>
{/if}
{/if}
</svg>
<div class="checkSVG" />
</label>
<style lang="scss">
.checkbox {
flex-shrink: 0;
display: inline-flex;
.checkbox-container {
display: flex;
justify-content: center;
align-items: center;
background-color: var(--theme-button-hovered);
border: 1px solid var(--theme-checkbox-border);
border-radius: 0.25rem;
flex-shrink: 0;
.checkSVG {
position: relative;
&::after {
position: absolute;
inset: 0;
}
}
&:not(.readonly):hover {
cursor: pointer;
}
&.small {
&.default,
&.primary,
&.positive,
&.negative {
.checkSVG {
background-color: var(--theme-button-hovered);
border: 1px solid var(--theme-checkbox-border);
&::after {
background-color: var(--theme-checkbox-color);
}
}
&.check .checkSVG::after {
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' style='enable-background:new 0 0 14 14' xml:space='preserve'%3E%3Cpath d='M6 10.2 2.7 7l1-.9L6 8.4l4.5-4.6.9 1z'/%3E%3C/svg%3E%0A");
}
&.minus .checkSVG::after {
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' style='enable-background:new 0 0 14 14' xml:space='preserve'%3E%3Cpath d='M3 6.4h8v1.2H3z'/%3E%3C/svg%3E%0A");
}
&.small .checkSVG {
width: 0.875rem;
height: 0.875rem;
}
&.medium {
&.medium .checkSVG {
width: 1rem;
height: 1rem;
}
&.large {
&.large .checkSVG {
width: 1.25rem;
height: 1.25rem;
}
&.circle {
&.circle .checkSVG {
width: 1rem;
height: 1rem;
border-radius: 50%;
}
& {
&.checked {
&:not(.circle) .checkSVG {
border-radius: 0.25rem;
}
&.checked .checkSVG {
background-color: var(--theme-checkbox-bg-color);
&::after {
content: '';
}
}
&.readonly {
&.readonly .checkSVG {
background-color: var(--theme-checkbox-disabled);
}
}
&.default.readonly,
&.primary,
&.positive,
&.negative {
.checkSVG::after {
background-color: var(--primary-button-color);
}
}
&.primary {
.checkSVG {
border-color: var(--primary-button-default);
&:not(.readonly).checked {
}
&:not(.readonly).checked .checkSVG {
background-color: var(--primary-button-default);
}
}
&.positive {
.checkSVG {
border-color: var(--positive-button-default);
&:not(.readonly).checked {
}
&:not(.readonly).checked .checkSVG {
background-color: var(--positive-button-default);
}
}
&.negative {
.checkSVG {
border-color: var(--negative-button-default);
&:not(.readonly).checked {
}
&:not(.readonly).checked .checkSVG {
background-color: var(--negative-button-default);
}
}
&.todo {
width: var(--global-extra-small-Size);
height: var(--global-extra-small-Size);
border: none;
border-radius: 50%;
background-color: transparent;
.checkSVG {
height: var(--global-min-Size);
width: var(--global-min-Size);
border: 1px solid var(--global-tertiary-TextColor);
border-radius: 50%;
&::after {
background-color: var(--global-tertiary-TextColor);
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' style='enable-background:new 0 0 16 16' xml:space='preserve'%3E%3Cpath d='M11.6 5.5c.2.2.2.6 0 .8l-4.3 4.3c-.2.2-.6.2-.8 0l-2.1-2c-.2-.2-.2-.6 0-.8.2-.2.6-.2.8 0l1.7 1.7 3.9-3.9c.2-.3.6-.3.8-.1z' style='fill-rule:evenodd;clip-rule:evenodd;fill:%23072790'/%3E%3C/svg%3E%0A");
}
}
&:focus-within {
border-radius: 0.25rem;
box-shadow: 0 0 0 0.125rem var(--global-focus-inset-BorderColor);
outline: 0.125rem solid var(--global-focus-BorderColor);
outline-offset: 0.125rem;
.checkSVG {
.todo-check {
visibility: visible;
}
}
}
&:not(.readonly):hover {
background-color: var(--button-secondary-hover-BackgroundColor);
.checkSVG {
.todo-check {
visibility: visible;
}
}
}
&:not(.readonly):hover,
&.checked {
.checkSVG {
color: var(--global-accent-TextColor);
.checkSVG::after {
content: '';
}
}
&.colored .checkSVG {
border-color: var(--checkbox-color);
.todo-circle {
fill: currentColor;
}
.todo-check {
visibility: visible;
fill: var(--global-subtle-BackgroundColor);
&::after {
background-color: var(--checkbox-color);
}
}
&.readonly .checkSVG,
&.checked .checkSVG {
border: none;
}
.checkSVG {
height: var(--global-min-Size);
width: var(--global-min-Size);
border-radius: 50%;
color: var(--global-tertiary-TextColor);
.todo-readonly {
fill: currentColor;
&.readonly {
.checkSVG::before {
position: absolute;
content: '';
inset: 0;
background-color: var(--global-tertiary-TextColor);
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' style='enable-background:new 0 0 16 16' xml:space='preserve'%3E%3Cpath d='M15.3 11.4c-.5-.2-1.1-.1-1.4.3-.1.1-.1.2-.2.2-.5.7-1.2 1.4-1.9 1.8-.4.3-.6 1-.3 1.4 1.6-.7 2.9-2 3.8-3.7zM.4 10.5c.6-.2.9-.7.8-1.2-.1-.4-.1-.9-.1-1.3s0-.9.1-1.3c.1-.5-.2-1-.8-1.2-.3.9-.4 1.8-.4 2.6s.1 1.6.4 2.4zm3.5 3.2c-.7-.5-1.3-1.1-1.8-1.8-.3-.4-1-.6-1.4-.3.7 1.5 2 2.8 3.5 3.6.4-.6.3-1.2-.3-1.5zm5.3 1.1c-.9.1-1.7.1-2.7 0-.5-.1-1.1.2-1.3.8.9.3 1.7.4 2.7.4.9 0 1.7-.1 2.5-.4-.2-.6-.6-.9-1.2-.8zm5.6-8.2c.1.4.1 1 .1 1.5 0 .4 0 .7-.1 1.2s.2 1.1.9 1.2c.2-.8.3-1.6.3-2.4 0-1-.2-1.8-.4-2.7-.6 0-.9.6-.8 1.2zM6.4 1.2h.2c.9-.2 1.7-.2 2.7 0 .5.1 1.1-.2 1.2-.7C9.7.2 8.9 0 8 0 7 0 6.2.1 5.4.4c.1.5.6.8 1 .8zM.9 4.5c.2.1.3.1.5.1.3 0 .6-.2.9-.4l.1-.1c.5-.6 1.1-1.3 1.7-1.7.4-.4.6-1 .3-1.4-1.5.6-2.8 1.9-3.5 3.5zm10.9-2.3.2.1c.6.4 1.3 1.1 1.7 1.7.2.3.5.4.9.4.2 0 .3-.1.5-.1-.7-1.5-2-2.8-3.6-3.5-.3.5-.2 1.1.3 1.4z'/%3E%3C/svg%3E%0A");
z-index: 1;
}
.todo-circle {
stroke: currentColor;
&.colored .checkSVG::before,
&.checked .checkSVG::before {
background-color: var(--checkbox-color);
}
.todo-check {
visibility: hidden;
fill: currentColor;
&.checked .checkSVG::after {
background-color: var(--checkbox-color);
}
}
&.checked:not(.readonly) .checkSVG {
background-color: var(--checkbox-color);
}
&.checked .checkSVG::after {
background-color: var(--global-subtle-BackgroundColor);
}
}
.chBox {
@ -216,35 +234,6 @@
padding: 0;
clip: rect(0 0 0 0);
overflow: hidden;
&:checked + .checkSVG {
& .check {
visibility: visible;
fill: var(--theme-checkbox-color);
&.primary,
&.positive,
&.negative {
fill: var(--primary-button-color);
}
}
}
&:not(:disabled) + .checkSVG {
cursor: pointer;
}
&:disabled + .checkSVG .check {
fill: var(--primary-button-color);
}
}
.checkSVG {
width: 0.875rem;
height: 0.875rem;
.check {
visibility: hidden;
fill: var(--theme-checkbox-color);
}
}
}
</style>

View File

@ -64,24 +64,27 @@ export class TalentDetailsPage extends CommonRecruitingPage {
await this.buttonFinalContact.click()
await this.selectMenuItem(this.page, talentName.finalContactName)
await this.buttonMergeRow.locator('div.flex-center', { hasText: talentName.name }).locator('label.checkbox').click()
await this.buttonMergeRow
.locator('div.flex-center', { hasText: talentName.name })
.locator('label.checkbox-container')
.click()
if (talentName.mergeLocation) {
await this.buttonMergeRow
.locator('div.flex-center', { hasText: talentName.location })
.locator('label.checkbox')
.locator('label.checkbox-container')
.click()
}
if (talentName.mergeTitle) {
await this.buttonMergeRow
.locator('div.flex-center', { hasText: talentName.title })
.locator('label.checkbox')
.locator('label.checkbox-container')
.click()
}
if (talentName.mergeSource) {
await this.buttonMergeRow
.locator('div.flex-center', { hasText: talentName.source })
.locator('label.checkbox')
.locator('label.checkbox-container')
.click()
}