Skip to content

Commit

Permalink
Themes: Remove old pattern directory theme
Browse files Browse the repository at this point in the history
  • Loading branch information
ryelle committed Dec 17, 2024
1 parent 7208ff5 commit 76fd1bd
Show file tree
Hide file tree
Showing 134 changed files with 50 additions and 8,234 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"workspaces": [
"public_html/wp-content/plugins/pattern-creator",
"public_html/wp-content/plugins/pattern-directory",
"public_html/wp-content/themes/pattern-directory",
"public_html/wp-content/themes/wporg-pattern-directory-2024"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ import { __, _x, sprintf } from '@wordpress/i18n';
import { Button } from '@wordpress/components';

/**
* Theme dependencies
*/
// eslint-disable-next-line import/no-unresolved -- imported via alias in webpack.config.js.
import getPaginationList from 'themes/pattern-directory/utils/get-pagination-list';

/*
* Note: forked from theme, `pattern-directory/src/components/pattern-grid/pagination.js`
* Internal dependencies
*/
import { getPaginationList } from './utils';

export default function OpenversePagination( { currentPage = 1, onNavigation, totalPages } ) {
if ( ! totalPages || totalPages <= 1 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,51 @@ export async function fetchImages( { searchTerm, page = 1 } ) {
throw error;
}
}

/**
* Get the collapsed list of page numbers for a given range of pages, used to paginate queries.
*
* This will return an array of page numbers (1, 2, 3, etc) for a given length (number of pages). If there are
* less than 5 pages (inclusive), it will return 1 through 5. If there are more, it will collapse between the
* start and end with an ellipsis. If the current page is in the middle, it will add pages to the middle.
*
* See test/get-pagination-list.js for examples.
*
* @param {number} length The total number of pages.
* @param {?number} current The current page, used to output extra pages if necessary. Default 1.
* @return {Array.<number|string>} Array of numbers and … used to display pagination links.
*/
export function getPaginationList( length, current = 1 ) {
const range = Array.from( { length }, ( val, i ) => i + 1 );
const list = [];
if ( length <= 5 ) {
return range;
}
list.push( ...range.slice( 0, 2 ) );
if ( current >= 2 && current <= length - 1 ) {
list.push( ...range.slice( current - 2, current + 1 ) );
}
list.push( ...range.slice( -2 ) );

return (
list
// Remove duplicates.
.filter( ( value, i, a ) => a.indexOf( value ) === i )
// Add in … where there's a jump larger than 1.
.reduce( ( acc, value, i, a ) => {
if ( i === 0 ) {
acc.push( value );
return acc;
}
const diff = Math.abs( a[ i ] - a[ i - 1 ] );
if ( diff === 0 ) {
return acc;
}
if ( diff > 1 ) {
acc.push( '…' );
}
acc.push( value );
return acc;
}, [] )
);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const path = require( 'path' );
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );

const config = {
Expand All @@ -8,13 +7,6 @@ const config = {
library: [ 'wp', 'patternCreator' ],
libraryTarget: 'window',
},
resolve: {
...defaultConfig.resolve,
alias: {
...defaultConfig.resolve.alias,
'themes/pattern-directory': path.resolve( __dirname, '../../themes/pattern-directory/src/' ),
},
},
};

module.exports = config;
39 changes: 0 additions & 39 deletions public_html/wp-content/themes/pattern-directory/404.php

This file was deleted.

150 changes: 0 additions & 150 deletions public_html/wp-content/themes/pattern-directory/Gruntfile.js

This file was deleted.

22 changes: 0 additions & 22 deletions public_html/wp-content/themes/pattern-directory/README.md

This file was deleted.

46 changes: 0 additions & 46 deletions public_html/wp-content/themes/pattern-directory/css/README.md

This file was deleted.

This file was deleted.

Loading

0 comments on commit 76fd1bd

Please sign in to comment.