Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #222 from studiopress/update/pluginade/0.0.3
Browse files Browse the repository at this point in the history
Update to Pluginade 0.0.3
  • Loading branch information
johnstonphilip authored Jan 29, 2024
2 parents 151a279 + a6eaa76 commit 7653a93
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 11 deletions.
38 changes: 38 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"extends": [
"plugin:@wordpress/eslint-plugin/recommended"
],
"globals": {
"beforeEach": "readonly",
"describe": "readonly",
"expect": "readonly",
"it": "readonly",
"jest": "readonly",
"test": "readonly"
},
"settings": {
"jsdoc": {
"mode": "typescript"
},
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
},
"rules": {
"react/jsx-no-target-blank": "off"
},
"overrides": [
{
"files": [ "*.ts", "*.tsx" ],
"rules": {
"jsdoc/require-param": "off",
"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off",
"no-unused-vars": "off",
"no-undef": "off"
}
}
]
}
2 changes: 1 addition & 1 deletion pluginade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Set this to the version of pluginade-scripts you want to use.
# For a list of available versions, see https://github.com/pluginade/pluginade-scripts/tags
pluginadeversion="0.0.2";
pluginadeversion="0.0.3-beta-8";

# Change the following variables to your plugin's namespace and textdomain:
textdomain="pattern-manager";
Expand Down
4 changes: 2 additions & 2 deletions wp-modules/app/js/src/components/App/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ html body.toplevel_page_pattern-manager {

.components-notice__content {
margin-right: 0;

span {
margin-left: 2px;
text-decoration: none;
Expand Down Expand Up @@ -439,4 +439,4 @@ input[type="checkbox"]:checked::before {
.pm-nav ul li ul li {
clear: both;
width: 100%;
}
}
2 changes: 1 addition & 1 deletion wp-modules/app/js/src/components/Patterns/PatternGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function PatternGrid( {
patterns,
siteUrl,
}: Props ) {
useForceRerender( [ patterns ] );
useForceRerender( patterns );

return (
<>
Expand Down
7 changes: 4 additions & 3 deletions wp-modules/app/js/src/hooks/useForceRerender.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { useLayoutEffect, useState } from '@wordpress/element';
import type { Patterns } from '../types';

type WindowDimensions = [ number, number ];

/** Re-render the calling component when the window is resized or dependencies update. */
export default function useForceRerender< T extends unknown >(
dependencies: T[]
dependencies: Patterns
) {
const [ , setForceUpdate ] = useState< T[] | WindowDimensions >();

useLayoutEffect( () => {
setForceUpdate( dependencies );
setForceUpdate( [ window.innerWidth, window.innerHeight ] );

function updateSizeAndRerender() {
setForceUpdate( [ window.innerWidth, window.innerHeight ] );
Expand All @@ -18,5 +19,5 @@ export default function useForceRerender< T extends unknown >(
window.addEventListener( 'resize', updateSizeAndRerender );
return () =>
window.removeEventListener( 'resize', updateSizeAndRerender );
}, [ ...dependencies ] );
}, [ dependencies ] );
}
2 changes: 1 addition & 1 deletion wp-modules/app/js/src/hooks/useLazyRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function useLazyRender< T extends Element >(
return () => {
observer.disconnect();
};
}, [ lazyContainerRef ] );
}, [ lazyContainerRef, observerOptions ] );

return {
lazyIsIntersecting:
Expand Down
3 changes: 3 additions & 0 deletions wp-modules/editor/js/src/components/Toggles/ModalToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export default function ModalToggle( {
if ( isDisabled && isChecked ) {
handleChangeMulti( false, 'blockTypes', blockTypeForModal );
}
// Disable eslint for exhaustive-deps as handleChangeMulti
// is a stable function and does not need to be included in the dependency array.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ isDisabled, isChecked, blockTypeForModal ] );

return (
Expand Down
3 changes: 3 additions & 0 deletions wp-modules/editor/js/src/hooks/usePatternData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export default function usePatternData( postMeta: PostMeta ) {
) {
updatePostMeta( 'postTypes', filteredPostTypes );
}
// We can ignore this because updatePostMeta is always created fresh on every render.
// NOTE: make sure that other dependencies required are added in the future, as the linter could miss them here.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
postMeta.postTypes,
templatePartBlockTypeSelected,
Expand Down
3 changes: 3 additions & 0 deletions wp-modules/editor/js/src/hooks/useSave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export default function useSave(
if ( isSavingPost ) {
updatePatternNames();
}
// We can ignore this because updatePatternNames is always created fresh on every render.
// NOTE: make sure that other dependencies required are added in the future, as the linter could miss them here.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ isSavingPost ] );

async function updatePatternNames() {
Expand Down
2 changes: 1 addition & 1 deletion wp-modules/editor/js/src/utils/flatUnorderedEquals.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** Check if two flat arrays are loosely equal. */
export default function flatUnorderedEquals<
T extends string | number | boolean
T extends string | number | boolean,
>( arrayA: T[], arrayB: T[] ) {
arrayA.sort();
arrayB.sort();
Expand Down
2 changes: 1 addition & 1 deletion wp-modules/editor/js/src/utils/getCustomCategories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { PostMeta } from '../types';
* Human readable labels are used for the return array.
*/
export default function getCustomCategories<
T extends { label: string; value: string; pm_custom?: boolean }
T extends { label: string; value: string; pm_custom?: boolean },
>( selections: PostMeta[ 'categories' ], categoryOptions: T[] ) {
return categoryOptions.reduce(
( acc: PostMeta[ 'customCategories' ], category ) => {
Expand Down
2 changes: 1 addition & 1 deletion wp-modules/editor/js/src/utils/getSelectedOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function getSelectedOptions<
label: string;
name?: string;
value?: string;
}
},
>( selections: string[], availableOptions: T[], optionKey: keyof T ) {
return selections
.reduce(
Expand Down

0 comments on commit 7653a93

Please sign in to comment.