From 8fc254d2db5738e5d370c9f346c8d0d1e31bb9d0 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Tue, 7 Mar 2023 17:59:12 +0100 Subject: [PATCH] feat: abstract BaseCheckbox --- cypress/e2e/project/namespaces.spec.ts | 4 +- .../e2e/project/project-view-table.spec.ts | 4 +- cypress/e2e/task/task.spec.ts | 2 +- src/assets/checkbox.svg | 4 + src/components/base/BaseCheckbox.vue | 53 +++++++ src/components/input/fancycheckbox.story.vue | 71 +++++++++ src/components/input/fancycheckbox.vue | 140 ++++++------------ .../tasks/partials/singleTaskInProject.vue | 2 +- src/directives/cypress.ts | 12 +- src/histoire.setup.ts | 7 +- src/views/project/ProjectGantt.vue | 2 +- src/views/tasks/ShowTasks.vue | 4 +- 12 files changed, 193 insertions(+), 112 deletions(-) create mode 100644 src/assets/checkbox.svg create mode 100644 src/components/base/BaseCheckbox.vue create mode 100644 src/components/input/fancycheckbox.story.vue diff --git a/cypress/e2e/project/namespaces.spec.ts b/cypress/e2e/project/namespaces.spec.ts index 080cf56e9..6ce0d8837 100644 --- a/cypress/e2e/project/namespaces.spec.ts +++ b/cypress/e2e/project/namespaces.spec.ts @@ -120,7 +120,7 @@ describe('Namepaces', () => { .should('not.contain', 'Archived') // Show archived - cy.get('[data-cy="show-archived-check"] label.check span') + cy.get('[data-cy="show-archived-check"] .fancycheckbox__content') .should('be.visible') .click() cy.get('[data-cy="show-archived-check"] input') @@ -129,7 +129,7 @@ describe('Namepaces', () => { .should('contain', 'Archived') // Don't show archived - cy.get('[data-cy="show-archived-check"] label.check span') + cy.get('[data-cy="show-archived-check"] .fancycheckbox__content') .should('be.visible') .click() cy.get('[data-cy="show-archived-check"] input') diff --git a/cypress/e2e/project/project-view-table.spec.ts b/cypress/e2e/project/project-view-table.spec.ts index ce52fb9bf..d468e61c2 100644 --- a/cypress/e2e/project/project-view-table.spec.ts +++ b/cypress/e2e/project/project-view-table.spec.ts @@ -22,10 +22,10 @@ describe('Project View Table', () => { cy.get('.project-table .filter-container .items .button') .contains('Columns') .click() - cy.get('.project-table .filter-container .card.columns-filter .card-content .fancycheckbox .check') + cy.get('.project-table .filter-container .card.columns-filter .card-content .fancycheckbox') .contains('Priority') .click() - cy.get('.project-table .filter-container .card.columns-filter .card-content .fancycheckbox .check') + cy.get('.project-table .filter-container .card.columns-filter .card-content .fancycheckbox') .contains('Done') .click() diff --git a/cypress/e2e/task/task.spec.ts b/cypress/e2e/task/task.spec.ts index ce2ae88bc..9724bc510 100644 --- a/cypress/e2e/task/task.spec.ts +++ b/cypress/e2e/task/task.spec.ts @@ -96,7 +96,7 @@ describe('Task', () => { TaskFactory.create(1) cy.visit('/projects/1/list') - cy.get('.tasks .task .fancycheckbox label.check') + cy.get('.tasks .task .fancycheckbox') .first() .click() cy.get('.global-notification') diff --git a/src/assets/checkbox.svg b/src/assets/checkbox.svg new file mode 100644 index 000000000..2beecfee2 --- /dev/null +++ b/src/assets/checkbox.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/components/base/BaseCheckbox.vue b/src/components/base/BaseCheckbox.vue new file mode 100644 index 000000000..47ba89f6f --- /dev/null +++ b/src/components/base/BaseCheckbox.vue @@ -0,0 +1,53 @@ + + + + + \ No newline at end of file diff --git a/src/components/input/fancycheckbox.story.vue b/src/components/input/fancycheckbox.story.vue new file mode 100644 index 000000000..5de66961f --- /dev/null +++ b/src/components/input/fancycheckbox.story.vue @@ -0,0 +1,71 @@ + + + + \ No newline at end of file diff --git a/src/components/input/fancycheckbox.vue b/src/components/input/fancycheckbox.vue index 43f55b7db..a54491c29 100644 --- a/src/components/input/fancycheckbox.vue +++ b/src/components/input/fancycheckbox.vue @@ -1,66 +1,42 @@ @@ -70,75 +46,51 @@ function check() { padding-right: 5px; padding-top: 3px; - // FIXME: should be a prop &.is-block { + display: block; margin: .5rem .2rem; } } -input[type=checkbox] { - display: none; -} - -.check { - cursor: pointer; - position: relative; - margin: auto; - width: 18px; - height: 18px; - -webkit-tap-highlight-color: transparent; - transform: translate3d(0, 0, 0); -} - -span { +.fancycheckbox__content { font-size: 0.8rem; vertical-align: top; padding-left: .5rem; } -svg { +.fancycheckbox__icon { + --stroke-color: #c8ccd4; position: relative; z-index: 1; - fill: none; - stroke-linecap: round; - stroke-linejoin: round; - stroke: #c8ccd4; - stroke-width: 1.5; + stroke: var(--stroke-color); transform: translate3d(0, 0, 0); transition: all 0.2s ease; -} -.check:hover svg { - stroke: var(--primary); -} - -.is-disabled .check:hover svg { - stroke: #c8ccd4; -} - -path { - stroke-dasharray: 60; - stroke-dashoffset: 0; -} - -polyline { - stroke-dasharray: 22; - stroke-dashoffset: 66; -} - -input[type=checkbox]:checked + .check { - svg { - stroke: var(--primary); + :deep(path) { + // stroke-dasharray: 60; + transition: all 0.2s linear, color 0.2s ease; } + :deep(polyline) { + // stroke-dasharray: 22; + // stroke-dashoffset: 66; + transition: all 0.2s linear, color 0.2s ease; + } +} + +.fancycheckbox:not(:has(input:disabled)):hover .fancycheckbox__icon { + --stroke-color: var(--primary); +} + +.fancycheckbox:has(input:checked) .fancycheckbox__icon:deep() { + --stroke-color: var(--primary); + path { stroke-dashoffset: 60; - transition: all 0.3s linear; } polyline { stroke-dashoffset: 42; - transition: all 0.2s linear; transition-delay: 0.15s; } } diff --git a/src/components/tasks/partials/singleTaskInProject.vue b/src/components/tasks/partials/singleTaskInProject.vue index 668c59c12..96d4bf3e1 100644 --- a/src/components/tasks/partials/singleTaskInProject.vue +++ b/src/components/tasks/partials/singleTaskInProject.vue @@ -6,7 +6,7 @@ > diff --git a/src/directives/cypress.ts b/src/directives/cypress.ts index 31092cc31..418b8adec 100644 --- a/src/directives/cypress.ts +++ b/src/directives/cypress.ts @@ -6,13 +6,11 @@ declare global { } } -const cypressDirective: Directive = { - mounted(el, {value}) { - if ( - (window.Cypress || import.meta.env.DEV) && - value - ) { - el.setAttribute('data-cy', value) +const cypressDirective = >{ + mounted(el, {arg, value}) { + const testingId = arg || value + if ((window.Cypress || import.meta.env.DEV) && testingId) { + el.setAttribute('data-cy', testingId) } }, beforeUnmount(el) { diff --git a/src/histoire.setup.ts b/src/histoire.setup.ts index 1abc88c6f..17fafeff5 100644 --- a/src/histoire.setup.ts +++ b/src/histoire.setup.ts @@ -1,4 +1,4 @@ -import { defineSetupVue3 } from '@histoire/plugin-vue' +import {defineSetupVue3} from '@histoire/plugin-vue' import {i18n} from './i18n' // import './histoire.css' // Import global CSS @@ -6,18 +6,21 @@ import './styles/global.scss' import {createPinia} from 'pinia' +import cypress from '@/directives/cypress' + import FontAwesomeIcon from '@/components/misc/Icon' import XButton from '@/components/input/button.vue' import Modal from '@/components/misc/modal.vue' import Card from '@/components/misc/card.vue' - export const setupVue3 = defineSetupVue3(({ app }) => { // Add Pinia store const pinia = createPinia() app.use(pinia) app.use(i18n) + app.directive('cy', cypress) + app.component('icon', FontAwesomeIcon) app.component('XButton', XButton) app.component('modal', Modal) diff --git a/src/views/project/ProjectGantt.vue b/src/views/project/ProjectGantt.vue index c45bc247b..43409d475 100644 --- a/src/views/project/ProjectGantt.vue +++ b/src/views/project/ProjectGantt.vue @@ -22,7 +22,7 @@ Reset - + {{ $t('project.gantt.showTasksWithoutDates') }} diff --git a/src/views/tasks/ShowTasks.vue b/src/views/tasks/ShowTasks.vue index 960f36aea..fb55c4890 100644 --- a/src/views/tasks/ShowTasks.vue +++ b/src/views/tasks/ShowTasks.vue @@ -11,10 +11,10 @@ - + {{ $t('task.show.noDates') }} - + {{ $t('task.show.overdue') }}