From 3aea21d982539ea3f2adbbd7502f86270911c558 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Sat, 7 Aug 2021 19:36:51 +0200 Subject: [PATCH] refactor: further optimizations (#1335) * refactor(accessibility): axe/language - added lang attribute element must have a lang attribute: The element does not have a lang attribute more information: https://dequeuniversity.com/rules/axe/4.2/html-has-lang * chore: replaced individual random function by the one provided as a utility * chore: prettier code formatting * chore: prettier code formatting * chore: eslint feedback * chore: reverted those previously incorrectly checked in files * docs: removed incorrect sentence out of #1313 I've added that documentation entry with #1313, but sadly missed to remove that incorrect sentence that belongs to another section on that page. --- .../src/html/partials/base-template.html | 9 +++-- .../uikit-workshop/src/scripts/actions/app.js | 40 +++++++++---------- .../src/scripts/components/panels-viewer.js | 5 +-- .../scripts/components/pl-nav/src/NavList.js | 3 +- .../scripts/components/pl-search/pl-search.js | 3 +- .../lit-components/pl-viewport/pl-viewport.js | 3 +- 6 files changed, 31 insertions(+), 32 deletions(-) diff --git a/packages/uikit-workshop/src/html/partials/base-template.html b/packages/uikit-workshop/src/html/partials/base-template.html index 1bd7a332d..5f47c91a7 100755 --- a/packages/uikit-workshop/src/html/partials/base-template.html +++ b/packages/uikit-workshop/src/html/partials/base-template.html @@ -2,7 +2,10 @@ {{# descBlockExists }}
{{# isPatternView }} @@ -83,9 +86,7 @@

Annotations

  • {{ title }}

    -
    - {{{ comment }}} -
    +
    {{{ comment }}}
  • diff --git a/packages/uikit-workshop/src/scripts/actions/app.js b/packages/uikit-workshop/src/scripts/actions/app.js index 16ed551bb..c3e335a22 100644 --- a/packages/uikit-workshop/src/scripts/actions/app.js +++ b/packages/uikit-workshop/src/scripts/actions/app.js @@ -9,17 +9,15 @@ export const UPDATE_CURRENT_URL = 'UPDATE_CURRENT_URL'; export const UPDATE_CURRENT_PATTERN = 'UPDATE_CURRENT_PATTERN'; export const IS_VIEWALL_PAGE = 'IS_VIEWALL_PAGE'; -export const updateCurrentPattern = (currentPattern) => ( - dispatch, - getState -) => { - if (getState().app.currentPattern !== currentPattern) { - dispatch({ - type: UPDATE_CURRENT_PATTERN, - currentPattern, - }); - } -}; +export const updateCurrentPattern = + (currentPattern) => (dispatch, getState) => { + if (getState().app.currentPattern !== currentPattern) { + dispatch({ + type: UPDATE_CURRENT_PATTERN, + currentPattern, + }); + } + }; export const updateCurrentUrl = (currentUrl) => (dispatch, getState) => { if (getState().app.currentUrl !== currentUrl) { @@ -75,17 +73,15 @@ export const updateDrawerState = (opened) => (dispatch, getState) => { } }; -export const updateDrawerAnimationState = (drawerIsAnimating) => ( - dispatch, - getState -) => { - if (getState().app.drawerIsAnimating !== drawerIsAnimating) { - dispatch({ - type: UPDATE_DRAWER_ANIMATION_STATE, - drawerIsAnimating, - }); - } -}; +export const updateDrawerAnimationState = + (drawerIsAnimating) => (dispatch, getState) => { + if (getState().app.drawerIsAnimating !== drawerIsAnimating) { + dispatch({ + type: UPDATE_DRAWER_ANIMATION_STATE, + drawerIsAnimating, + }); + } + }; export const updateDrawerHeight = (height) => (dispatch, getState) => { if (getState().app.drawerHeight !== height) { diff --git a/packages/uikit-workshop/src/scripts/components/panels-viewer.js b/packages/uikit-workshop/src/scripts/components/panels-viewer.js index 289102f5f..08d0f27db 100644 --- a/packages/uikit-workshop/src/scripts/components/panels-viewer.js +++ b/packages/uikit-workshop/src/scripts/components/panels-viewer.js @@ -177,9 +177,8 @@ export const panelsViewer = { template = document.getElementById(panel.templateID); templateCompiled = Hogan.compile(template.innerHTML); templateRendered = templateCompiled.render(patternData); - const normalizedCode = normalizeWhitespace.normalize( - templateRendered - ); + const normalizedCode = + normalizeWhitespace.normalize(templateRendered); normalizedCode.replace(/[\r\n]+/g, '\n\n'); const highlightedCode = Prism.highlight( normalizedCode, diff --git a/packages/uikit-workshop/src/scripts/components/pl-nav/src/NavList.js b/packages/uikit-workshop/src/scripts/components/pl-nav/src/NavList.js index 0c364a4be..80cb246ca 100644 --- a/packages/uikit-workshop/src/scripts/components/pl-nav/src/NavList.js +++ b/packages/uikit-workshop/src/scripts/components/pl-nav/src/NavList.js @@ -3,12 +3,13 @@ import { NavToggle } from './NavToggle'; import { NavLink } from './NavLink'; import { NavItem } from './NavItem'; import { NavButton } from './NavButton'; +import { getRandom } from '../../../utils'; export const NavList = (props) => { const { children, category, categoryName, elem } = props; const reorderedChildren = []; - const random = Math.random().toString().substr(2); + const random = getRandom(10000000, 99999999); const nonViewAllItems = elem.noViewAll ? children.filter((item) => !item.isDocPattern) diff --git a/packages/uikit-workshop/src/scripts/components/pl-search/pl-search.js b/packages/uikit-workshop/src/scripts/components/pl-search/pl-search.js index 46d049a4f..a00a1f8be 100644 --- a/packages/uikit-workshop/src/scripts/components/pl-search/pl-search.js +++ b/packages/uikit-workshop/src/scripts/components/pl-search/pl-search.js @@ -242,7 +242,8 @@ class Search extends BaseComponent { return (
    diff --git a/packages/uikit-workshop/src/scripts/lit-components/pl-viewport/pl-viewport.js b/packages/uikit-workshop/src/scripts/lit-components/pl-viewport/pl-viewport.js index 342f31035..79f6a9cf1 100644 --- a/packages/uikit-workshop/src/scripts/lit-components/pl-viewport/pl-viewport.js +++ b/packages/uikit-workshop/src/scripts/lit-components/pl-viewport/pl-viewport.js @@ -387,7 +387,8 @@ class IFrame extends BaseLitComponent { * Workaround to avoiding an infinite loop (if using srcdoc) which breaks the ability to * hit the back button if you hit a 404 */ - this.iframe.contentWindow.document.body.innerHTML = this.iframe404Fallback; + this.iframe.contentWindow.document.body.innerHTML = + this.iframe404Fallback; } }, 100); }