From d48786971b1805aa8a07698f41b4094ae8848e4f Mon Sep 17 00:00:00 2001 From: schmelczerandras Date: Thu, 24 Sep 2020 14:16:45 +0200 Subject: [PATCH] Reformat code --- .eslintrc.json | 55 +++++++++-------- .prettierrc | 1 + src/framework/container-page.ts | 4 +- src/framework/events/event-handler.ts | 4 +- src/framework/helper/get-height.ts | 2 +- src/framework/helper/mix-colors.ts | 6 +- src/framework/helper/random.ts | 4 +- src/framework/helper/sum.ts | 2 +- src/framework/page-element.ts | 3 +- .../primitives/implementations/anchor.ts | 6 +- .../primitives/implementations/image.ts | 5 +- .../primitives/implementations/video.ts | 4 +- src/framework/styles/dark-mode/dark-mode.ts | 3 +- src/page/background/animation.ts | 5 +- src/page/background/background.ts | 58 +++++++----------- src/page/background/blob.ts | 8 +-- src/page/image-viewer/image-viewer.ts | 4 +- src/page/theme-switcher/theme-switcher.ts | 9 +-- src/static/icons/fullscreen.svg | 1 + src/static/icons/play-button.svg | 11 ++++ src/static/media/sdf2d.jpg | Bin 0 -> 35516 bytes src/styles.scss | 12 ++-- 22 files changed, 85 insertions(+), 122 deletions(-) create mode 100644 src/static/icons/fullscreen.svg create mode 100644 src/static/icons/play-button.svg create mode 100644 src/static/media/sdf2d.jpg diff --git a/.eslintrc.json b/.eslintrc.json index f934a2b..8275ed8 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,28 +1,29 @@ { - "root": true, - "env": { - "browser": true, - "es2020": true - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "prettier", - "prettier/@typescript-eslint" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 11, - "sourceType": "module" - }, - "plugins": ["unused-imports", "@typescript-eslint", "prettier"], - "rules": { - "prettier/prettier": "error", - "no-unused-vars": "off", - "unused-imports/no-unused-imports-ts": "error", - "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }], - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/explicit-module-boundary-types": "off" - } - } \ No newline at end of file + "root": true, + "env": { + "browser": true, + "es2020": true + }, + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "prettier", + "prettier/@typescript-eslint" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 11, + "sourceType": "module" + }, + "plugins": ["unused-imports", "@typescript-eslint", "prettier"], + "rules": { + "prettier/prettier": "error", + "no-unused-vars": "off", + "unused-imports/no-unused-imports-ts": "error", + "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }], + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/explicit-module-boundary-types": "off", + "@typescript-eslint/no-non-null-assertion": "off" + } +} diff --git a/.prettierrc b/.prettierrc index ea2afbe..c5193f3 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,7 @@ { "trailingComma": "es5", "tabWidth": 2, + "printWidth": 90, "singleQuote": true, "endOfLine": "lf" } diff --git a/src/framework/container-page.ts b/src/framework/container-page.ts index 4a803b8..8300d48 100644 --- a/src/framework/container-page.ts +++ b/src/framework/container-page.ts @@ -4,9 +4,7 @@ import { OnLoadEvent } from './events/concrete-events/on-load-event'; export class ContainerPage extends PageElement { public constructor(rootElement: HTMLElement, children: Array) { - children - .filter(e => e.element) - .forEach(e => rootElement.appendChild(e.element)); + children.filter(e => e.element).forEach(e => rootElement.appendChild(e.element)); super(rootElement, children); } diff --git a/src/framework/events/event-handler.ts b/src/framework/events/event-handler.ts index ac22f9b..e33f294 100644 --- a/src/framework/events/event-handler.ts +++ b/src/framework/events/event-handler.ts @@ -26,9 +26,7 @@ export abstract class EventHandler { return event; } - public handleOnPageThemeChangedEvent( - event: OnPageThemeChangedEvent - ): OptionalEvent { + public handleOnPageThemeChangedEvent(event: OnPageThemeChangedEvent): OptionalEvent { return event; } } diff --git a/src/framework/helper/get-height.ts b/src/framework/helper/get-height.ts index ddd4c90..26d0582 100644 --- a/src/framework/helper/get-height.ts +++ b/src/framework/helper/get-height.ts @@ -1,6 +1,6 @@ export const getHeight = (e: HTMLElement): number => { // ignores margin collapse - const computedStyle = window.getComputedStyle(e); + const computedStyle = getComputedStyle(e); return ( e.clientHeight + parseInt(computedStyle.marginTop) + diff --git a/src/framework/helper/mix-colors.ts b/src/framework/helper/mix-colors.ts index 2f89fd1..e63712a 100644 --- a/src/framework/helper/mix-colors.ts +++ b/src/framework/helper/mix-colors.ts @@ -1,11 +1,7 @@ export type hex = string; export type rgb = [number, number, number]; -export const mixColors = ( - hexColorA: hex, - hexColorB: hex, - quantityA: number -): hex => { +export const mixColors = (hexColorA: hex, hexColorB: hex, quantityA: number): hex => { const colorA = hexToRGB(hexColorA); const colorB = hexToRGB(hexColorB); diff --git a/src/framework/helper/random.ts b/src/framework/helper/random.ts index d7f51ff..d2b1028 100644 --- a/src/framework/helper/random.ts +++ b/src/framework/helper/random.ts @@ -7,9 +7,7 @@ export class Random { public get next(): number { // result is in [0, 1) - return ( - ((2 ** 31 - 1) & (this.seed = Math.imul(48271, this.seed))) / 2 ** 31 - ); + return ((2 ** 31 - 1) & (this.seed = Math.imul(48271, this.seed))) / 2 ** 31; } public choose(list: Array): T { diff --git a/src/framework/helper/sum.ts b/src/framework/helper/sum.ts index 3fbd934..4e9a940 100644 --- a/src/framework/helper/sum.ts +++ b/src/framework/helper/sum.ts @@ -1,2 +1,2 @@ export const sum = (list: ArrayLike): number => - Array.prototype.reduce.call(list, (a, sum) => a + sum, 0); + Array.prototype.reduce.call(list, (a: number, sum: number) => a + sum, 0); diff --git a/src/framework/page-element.ts b/src/framework/page-element.ts index 2fa941b..4a76e89 100644 --- a/src/framework/page-element.ts +++ b/src/framework/page-element.ts @@ -5,8 +5,7 @@ import { Event } from './events/event'; import { OnLoadEvent } from './events/concrete-events/on-load-event'; import { OptionalEvent } from './events/optional-event'; -export abstract class PageElement extends EventHandler - implements EventBroadcaster { +export abstract class PageElement extends EventHandler implements EventBroadcaster { protected eventBroadcaster: EventBroadcaster; protected constructor( diff --git a/src/framework/primitives/implementations/anchor.ts b/src/framework/primitives/implementations/anchor.ts index e885a76..bf5192e 100644 --- a/src/framework/primitives/implementations/anchor.ts +++ b/src/framework/primitives/implementations/anchor.ts @@ -2,10 +2,7 @@ import { Primitive } from '../primitive'; import { html, url } from '../../model/misc'; export class Anchor implements Primitive { - public constructor( - private readonly href: url, - private readonly text: string - ) {} + public constructor(private readonly href: url, private readonly text: string) {} public toHTML(): html { return ` @@ -14,6 +11,7 @@ export class Anchor implements Primitive { rel="noreferrer" target="_blank" >${this.text} +
`; } } diff --git a/src/framework/primitives/implementations/image.ts b/src/framework/primitives/implementations/image.ts index f098344..acc4623 100644 --- a/src/framework/primitives/implementations/image.ts +++ b/src/framework/primitives/implementations/image.ts @@ -26,10 +26,7 @@ export class Image implements Primitive { return ( this.image.images .slice(0, -1) - .map( - d => - `(max-width: ${d.width / Image.IMAGE_SCREEN_RATIO}px) ${d.width}px,` - ) + .map(d => `(max-width: ${d.width / Image.IMAGE_SCREEN_RATIO}px) ${d.width}px,`) .join('\n') + `\n${last(this.image.images).width}px` ); } diff --git a/src/framework/primitives/implementations/video.ts b/src/framework/primitives/implementations/video.ts index f4a83cd..32ab7dc 100644 --- a/src/framework/primitives/implementations/video.ts +++ b/src/framework/primitives/implementations/video.ts @@ -11,9 +11,7 @@ export class Video implements Primitive { public toHTML(container = false): string { return ` ${container ? `
` : ''} -