Skip to content

Commit

Permalink
refactor: further optimizations (pattern-lab#1335)
Browse files Browse the repository at this point in the history
* refactor(accessibility): axe/language - added lang attribute

<html> element must have a lang attribute: The <html> 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 pattern-lab#1313

I've added that documentation entry with pattern-lab#1313, but sadly missed to remove that incorrect sentence that belongs to another section on that page.
  • Loading branch information
mfranzke authored Aug 7, 2021
1 parent 9ddcc21 commit 3aea21d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 32 deletions.
9 changes: 5 additions & 4 deletions packages/uikit-workshop/src/html/partials/base-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
{{# descBlockExists }}

<div
class="pl-c-pattern-info__panel pl-c-pattern-info__panel--info pl-js-pattern-info"
class="
pl-c-pattern-info__panel pl-c-pattern-info__panel--info
pl-js-pattern-info
"
>
{{# isPatternView }}
<!-- extra info for modal view -->
Expand Down Expand Up @@ -83,9 +86,7 @@ <h2 class="pl-c-annotations__title">Annotations</h2>
<li class="pl-c-annotations__item">
<h3 class="pl-c-annotations__item-title">{{ title }}</h3>

<div class="pl-c-annotations__item-body">
{{{ comment }}}
</div>
<div class="pl-c-annotations__item-body">{{{ comment }}}</div>
<!--end pl-c-annotations__item-body-->
</li>
<!--end pl-c-annotations__item-->
Expand Down
40 changes: 18 additions & 22 deletions packages/uikit-workshop/src/scripts/actions/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ class Search extends BaseComponent {
return (
<div
className={classNames('pl-c-typeahead__input-wrapper', {
[`pl-c-typeahead__input-wrapper--with-clear-button`]: shouldShowClearButton,
[`pl-c-typeahead__input-wrapper--with-clear-button`]:
shouldShowClearButton,
})}
>
<input {...inputProps} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 3aea21d

Please sign in to comment.