Skip to content

Commit

Permalink
make linter a bit more happy
Browse files Browse the repository at this point in the history
  • Loading branch information
halamix2 committed Jun 23, 2024
1 parent 5c1324e commit f09c2bc
Show file tree
Hide file tree
Showing 20 changed files with 447 additions and 427 deletions.
22 changes: 21 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,32 @@ require('@rushstack/eslint-patch/modern-module-resolution')

module.exports = {
root: true,
'extends': [
extends: [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript',
'@vue/eslint-config-prettier/skip-formatting'
],
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-shadow': 'error',
'one-var': 'error',
/*
* 'require-await': 'off',
* '@typescript-eslint/require-await': 'error',
*/
'func-style': 'error',
eqeqeq: 'error',
'max-lines-per-function': 'error',
'max-statements': 'error',
'@typescript-eslint/no-use-before-define': 'error',
'no-warning-comments': 'warn',
'max-lines': 'error',
'multiline-comment-style': 'error',
'prefer-const': 'error',
'no-eq-null': 'error'
//no-magic-numbers
},
parserOptions: {
ecmaVersion: 'latest'
}
Expand Down
8 changes: 5 additions & 3 deletions e2e/dummy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'

// See here how to get started:
// https://playwright.dev/docs/intro
/*
* See here how to get started:
* https://playwright.dev/docs/intro
*/
test('visits the app root url', async ({ page }) => {
await page.goto('/')
await expect(page.locator('div.v-toolbar-title__placeholder')).toContainText('GPST')
Expand Down
74 changes: 40 additions & 34 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { defineConfig, devices } from '@playwright/test'
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
// Require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
Expand All @@ -22,7 +22,7 @@ export default defineConfig({
timeout: 5000
},
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
forbidOnly: Boolean(process.env.CI),
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
Expand All @@ -40,7 +40,7 @@ export default defineConfig({
trace: 'on-first-retry',

/* Only on CI systems run the tests headless */
headless: !!process.env.CI
headless: Boolean(process.env.CI)
},

/* Configure projects for major browsers */
Expand All @@ -57,44 +57,50 @@ export default defineConfig({
...devices['Desktop Firefox']
}
}
// {
// name: 'webkit',
// use: {
// ...devices['Desktop Safari']
// }
// }
/*
* {
* name: 'webkit',
* use: {
* ...devices['Desktop Safari']
* }
* }
*/

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: {
// ...devices['Pixel 5'],
// },
// },
// {
// name: 'Mobile Safari',
// use: {
// ...devices['iPhone 12'],
// },
// },
/*
* {
* name: 'Mobile Chrome',
* use: {
* ...devices['Pixel 5'],
* },
* },
* {
* name: 'Mobile Safari',
* use: {
* ...devices['iPhone 12'],
* },
* },
*/

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: {
// channel: 'msedge',
// },
// },
// {
// name: 'Google Chrome',
// use: {
// channel: 'chrome',
// },
// },
/*
* {
* name: 'Microsoft Edge',
* use: {
* channel: 'msedge',
* },
* },
* {
* name: 'Google Chrome',
* use: {
* channel: 'chrome',
* },
* },
*/
],

/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',
// OutputDir: 'test-results/',

/* Run your local dev server before starting the tests */
webServer: {
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { RouterView } from 'vue-router'
// import HeaderItem from './components/HeaderItem.vue'
// Import HeaderItem from './components/HeaderItem.vue'
const appVersion = import.meta.env.PACKAGE_VERSION
</script>

Expand Down
141 changes: 66 additions & 75 deletions src/components/CanvasItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,74 @@ import { onMounted, ref } from 'vue'
import type { Ref } from 'vue'
const props = defineProps<{
canvasWidth: number
canvasHeight: number
title: string
}>()
const emit = defineEmits<{
canvasContext: [canvas: HTMLCanvasElement]
updateBackground: [file: string]
updateScale: [scale: number]
updatePos: [left: number, top: number]
updateRotation: [rotation: number]
}>()
const canvasDragged = ref(false)
const canvasModel: Ref<HTMLCanvasElement | null> = ref(null)
// TODO remove after testing
const sumX = ref(0)
const sumY = ref(0)
function canvasDrop(e: DragEvent) {
if (e.dataTransfer!.items && e.dataTransfer!.items.length == 1) {
//emit('string', e.dataTransfer!.items[0])
let reader = new FileReader()
reader.onloadend = function () {
emit('updateBackground', reader.result as string)
canvasWidth: number
canvasHeight: number
title: string
}>(),
emit = defineEmits<{
canvasContext: [canvas: HTMLCanvasElement]
updateBackground: [file: string]
updateScale: [scale: number]
updatePos: [left: number, top: number]
updateRotation: [rotation: number]
}>(),
canvasDragged = ref(false),
canvasModel: Ref<HTMLCanvasElement | null> = ref(null),
// TODO: remove after testing
sumX = ref(0),
sumY = ref(0),
canvasDrop = function (e: DragEvent) {
if (e.dataTransfer!.items && e.dataTransfer!.items.length === 1) {
//Emit('string', e.dataTransfer!.items[0])
const reader = new FileReader()
reader.onloadend = function () {
emit('updateBackground', reader.result as string)
}
reader.readAsDataURL(e.dataTransfer!.items[0].getAsFile()!)
}
reader.readAsDataURL(e.dataTransfer!.items[0].getAsFile()!)
}
}
function canvasWheel(e: WheelEvent) {
if (e.deltaY > 0) {
emit('updateScale', -0.02)
} else {
emit('updateScale', 0.02)
}
}
function canvasMouseDown(e: MouseEvent) {
if ((e.buttons & 1) == 1) {
canvasDragged.value = true
canvasModel.value!.classList.add('cursor-grabbing')
canvasModel.value!.classList.remove('cursor-grab')
}
// wheel button
if (((e.buttons >> 2) & 1) == 1) {
emit('updateRotation', 90)
}
}
function windowMouseUp(e: MouseEvent) {
if (canvasModel.value != null && (e.buttons & 1) == 0) {
canvasDragged.value = false
sumX.value = 0
sumY.value = 0
canvasModel.value!.classList.remove('cursor-grabbing')
canvasModel.value!.classList.add('cursor-grab')
}
}
function windowMouseMove(e: MouseEvent) {
if (canvasDragged.value) {
sumX.value += e.movementX
sumY.value += e.movementY
emit('updatePos', e.movementX, e.movementY)
},
canvasWheel = function (e: WheelEvent) {
if (e.deltaY > 0) {
emit('updateScale', -0.02)
} else {
emit('updateScale', 0.02)
}
},
canvasMouseDown = function (e: MouseEvent) {
if ((e.buttons & 1) === 1) {
canvasDragged.value = true
canvasModel.value!.classList.add('cursor-grabbing')
canvasModel.value!.classList.remove('cursor-grab')
}
// Wheel button
if (((e.buttons >> 2) & 1) === 1) {
emit('updateRotation', 90)
}
},
windowMouseUp = function (e: MouseEvent) {
if (canvasModel.value !== null && (e.buttons & 1) === 0) {
canvasDragged.value = false
sumX.value = 0
sumY.value = 0
canvasModel.value!.classList.remove('cursor-grabbing')
canvasModel.value!.classList.add('cursor-grab')
}
},
windowMouseMove = function (e: MouseEvent) {
if (canvasDragged.value) {
sumX.value += e.movementX
sumY.value += e.movementY
emit('updatePos', e.movementX, e.movementY)
}
},
savePNG = function () {
const data = canvasModel.value!.toDataURL('image/png'),
a = document.createElement('a')
a.download = `${props.title}.png`
a.href = data
a.click()
console.info(`Zapis do pliku${props.title}.png`)
}
}
function savePNG() {
const data = canvasModel.value!.toDataURL('image/png')
let a = document.createElement('a')
a.download = props.title + '.png'
a.href = data
a.click()
console.info('Zapis do pliku' + props.title + '.png')
}
// TODO this might break if the button is lifted outside of a browser window, oh well
onMounted(() => {
Expand Down
Loading

0 comments on commit f09c2bc

Please sign in to comment.