Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing pr #52

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2c469e8
mwpw-155030 - authorable pagination type
draganalilly021 Jul 26, 2024
9701383
MWPW-155065 PartnerCards fallback for invalid thumbnail images
richardhand Jul 29, 2024
9680317
Merge pull request #48 from adobecom/mwpw-155065-invalid-thumbnail-fa…
richardhand-fortedigital Jul 30, 2024
9b0433d
Merge branch 'stage' into mwpw-155030-authorable-pagination
draganatrajkovic Jul 30, 2024
4f29637
newsCardsStyles path
draganatrajkovic Jul 30, 2024
19b639c
Merge pull request #47 from adobecom/mwpw-155030-authorable-pagination
draganatrajkovic Jul 30, 2024
040581c
MWPW-151240: Preloaded resources to improve performance
zagi25 Jul 24, 2024
f887235
Merge branch 'stage' into MWPW-151240-performance-improvement
zagi25 Jul 31, 2024
47abc76
MWPW-151240: Resolve merge conflicts and update tests
zagi25 Jul 31, 2024
eb37f9a
MWPW-151240: Fixed language and country bug
zagi25 Aug 1, 2024
4e1dd4f
mwpw-155030 - do not display empty li el as sort/filter item
draganalilly021 Aug 5, 2024
0334798
Merge pull request #53 from adobecom/mwpw-155030-authored-empty-li
draganatrajkovic Aug 6, 2024
a57a201
MWPW-151240: Moved caasUrl logic to utils.js
zagi25 Aug 9, 2024
726b5ac
MWPW-156259: Arbitrary bug fix
zagi25 Aug 9, 2024
0e77f29
Merge pull request #51 from adobecom/MWPW-151240-performance-improvement
zagi25 Aug 9, 2024
0ce6550
MWPW-157066 - sort drop behind profile drop
draganalilly021 Aug 21, 2024
67db9fe
Merge pull request #54 from adobecom/mwpw-157066-sort-behind-profile-…
draganatrajkovic Aug 23, 2024
04ed9bc
Update run-nala.yml
cod17828 Aug 26, 2024
40f8e8f
Merge pull request #55 from adobecom/cod17828-patch-6
zagi25 Aug 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
1 change: 1 addition & 0 deletions .github/workflows/run-nala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ jobs:
prRepo: ${{ github.event.pull_request.head.repo.name }}
prBranch: ${{ github.event.pull_request.head.ref }}
prBaseBranch: ${{ github.event.pull_request.base.ref }}
HLX_API_KEY: ${{ secrets.HLX_API_KEY }}
92 changes: 1 addition & 91 deletions eds/blocks/knowledge-base-overview/KnowledgeBaseOverview.js
Original file line number Diff line number Diff line change
@@ -1,93 +1,3 @@
import { getLibs } from '../../scripts/utils.js';
import { numericPaginationStyles } from '../../components/PartnerCardsStyles.js';
import PartnerCardsWithDateFilter from '../../components/PartnerCardsWithDateFilter.js';

const miloLibs = getLibs();
const { html, css, repeat } = await import(`${miloLibs}/deps/lit-all.min.js`);

export default class KnowledgeBaseOverview extends PartnerCardsWithDateFilter {
static properties = {
...PartnerCardsWithDateFilter.properties,
totalPages: { type: Number },
};

constructor() {
super();
this.totalPages = 0;
this.useStageCaasEndpoint = true;
}

static styles = [
PartnerCardsWithDateFilter.styles,
css`${numericPaginationStyles}`,
];

get paginationList() {
if (!this.cards.length) return;

const min = 1;
this.totalPages = Math.ceil(this.cards.length / this.cardsPerPage);

const pagesNumArray = Array.from({ length: this.totalPages }, (_, i) => i + min);
return html`${repeat(
pagesNumArray,
(pageNum) => pageNum,
(pageNum) => html`<button
class="page-btn ${this.paginationCounter === pageNum ? 'selected' : ''}"
@click="${() => this.handlePageNum(pageNum)}"
aria-label="${this.blockData.localizedText['{{page}}']} ${pageNum}">
${pageNum}
</button>`,
)}`;
}

get pagination() {
return html`
<div class="pagination-pages-list">
<button class="pagination-prev-btn ${this.paginationCounter === 1 || !this.paginatedCards?.length ? 'disabled' : ''}" @click="${this.handlePrevPage}" aria-label="${this.blockData.localizedText['{{previous-page}}']}">
${this.blockData.localizedText['{{prev}}']}</button>
${this.paginationList}
<button class="pagination-next-btn ${this.paginationCounter === this.totalPages || !this.paginatedCards?.length ? 'disabled' : ''}" @click="${this.handleNextPage}" aria-label="${this.blockData.localizedText['{{next-page}}']}">
${this.blockData.localizedText['{{next}}']}</button>
</div>
`;
}

get cardsCounter() {
const lastElOrderNum = super.cardsCounter;
const { orderNum: firstElOrderNum } = this.paginatedCards[0];
return `${firstElOrderNum} - ${lastElOrderNum}`;
}

handleActions() {
super.handleActions();
this.updatePaginatedCards();
}

updatePaginatedCards() {
const startIndex = (this.paginationCounter - 1) * this.cardsPerPage;
const endIndex = this.paginationCounter * this.cardsPerPage;
this.paginatedCards = this.cards.slice(startIndex, endIndex);
}

handlePageNum(pageNum) {
if (this.paginationCounter !== pageNum) {
this.paginationCounter = pageNum;
this.handleActions();
}
}

handlePrevPage() {
if (this.paginationCounter > 1) {
this.paginationCounter -= 1;
this.handleActions();
}
}

handleNextPage() {
if (this.paginationCounter < this.totalPages) {
this.paginationCounter += 1;
this.handleActions();
}
}
}
export default class KnowledgeBaseOverview extends PartnerCardsWithDateFilter {}
15 changes: 12 additions & 3 deletions eds/blocks/knowledge-base-overview/knowledge-base-overview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getLibs, replaceText, getConfig, populateLocalizedTextFromListItems } from '../../scripts/utils.js';
import { getCaasUrl, getLibs } from '../../scripts/utils.js';
import { replaceText, getConfig, populateLocalizedTextFromListItems } from '../utils/utils.js';
import KnowledgeBaseOverview from './KnowledgeBaseOverview.js';

function declareKnowledgeBaseOverview() {
Expand Down Expand Up @@ -33,6 +34,7 @@ export default async function init(el) {
'{{last-6-months}}': 'Last 6 months',
'{{next}}': 'Next',
'{{next-page}}': 'Next Page',
'{{load-more}}': 'Load more',
'{{no-results-description}}': 'Try checking your spelling or broadening your search.',
'{{no-results-title}}': 'No Results Found',
'{{of}}': 'Of',
Expand Down Expand Up @@ -69,13 +71,20 @@ export default async function init(el) {
],
};

const block = {
el,
name: 'knowledge-base-overview',
collectionTag: '"caas:adobe-partners/collections/knowledge-base"',
ietf: config.locale.ietf
}

const blockData = {
localizedText,
tableData: el.children,
dateFilter,
cardsPerPage: 12,
ietf: config.locale.ietf,
collectionTags: '"caas:adobe-partners/collections/knowledge-base"',
pagination: 'default',
caasUrl: getCaasUrl(block)
};

const app = document.createElement('knowledge-base-overview');
Expand Down
34 changes: 1 addition & 33 deletions eds/blocks/partner-news/PartnerNews.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,3 @@
import { getLibs } from '../../scripts/utils.js';
import { loadMorePaginationStyles } from '../../components/PartnerCardsStyles.js';
import PartnerCardsWithDateFilter from '../../components/PartnerCardsWithDateFilter.js';

const miloLibs = getLibs();
const { html, css } = await import(`${miloLibs}/deps/lit-all.min.js`);

export default class PartnerNews extends PartnerCardsWithDateFilter {
static styles = [
PartnerCardsWithDateFilter.styles,
css`${loadMorePaginationStyles}`,
];

get pagination() {
if (this.cards.length === this.paginatedCards.length) {
return '';
}
return html`<button class="load-more-btn" @click="${this.handleLoadMore}" aria-label="${this.blockData.localizedText['{{load-more}}']}">${this.blockData.localizedText['{{load-more}}']}</button>`;
}

handleActions() {
super.handleActions();
this.updatePaginatedCards();
}

updatePaginatedCards() {
const countPages = this.paginationCounter * this.cardsPerPage;
this.paginatedCards = this.cards.slice(0, countPages);
}

handleLoadMore() {
this.paginationCounter += 1;
this.handleActions();
}
}
export default class PartnerNews extends PartnerCardsWithDateFilter {}
19 changes: 16 additions & 3 deletions eds/blocks/partner-news/partner-news.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getLibs, replaceText, getConfig, populateLocalizedTextFromListItems } from '../../scripts/utils.js';
import { getCaasUrl, getLibs } from '../../scripts/utils.js';
import { replaceText, getConfig, populateLocalizedTextFromListItems } from '../utils/utils.js';
import PartnerNews from './PartnerNews.js';

function declarePartnerNews() {
Expand Down Expand Up @@ -32,10 +33,15 @@ export default async function init(el) {
'{{filters}}': 'Filters',
'{{last-90-days}}': 'Last 90 days',
'{{load-more}}': 'Load more',
'{{next}}': 'Next',
'{{next-page}}': 'Next Page',
'{{no-results-description}}': 'Try checking your spelling or broadening your search.',
'{{no-results-title}}': 'No Results Found',
'{{of}}': 'Of',
'{{page}}': 'Page',
'{{prev}}': 'Prev',
'{{previous-month}}': 'Previous month',
'{{previous-page}}': 'Previous Page',
'{{results}}': 'Results',
'{{search}}': 'Search',
'{{show-all}}': 'Show all',
Expand Down Expand Up @@ -65,13 +71,20 @@ export default async function init(el) {
],
};

const block = {
el,
name: 'partner-news',
collectionTag: '"caas:adobe-partners/collections/news"',
ietf: config.locale.ietf
}

const blockData = {
localizedText,
tableData: el.children,
dateFilter,
cardsPerPage: 12,
ietf: config.locale.ietf,
collectionTags: '"caas:adobe-partners/collections/news"',
pagination: 'load-more',
caasUrl: getCaasUrl(block)
};

const app = document.createElement('partner-news');
Expand Down
20 changes: 20 additions & 0 deletions eds/blocks/utils/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { setLibs } from '../../scripts/utils.js';

const miloLibs = setLibs('/libs');

const { createTag, localizeLink, getConfig } = await import(`${miloLibs}/utils/utils.js`);

export { createTag, localizeLink, getConfig };
const { replaceText } = await import(`${miloLibs}/features/placeholders.js`);
export { replaceText };

export function populateLocalizedTextFromListItems(el, localizedText) {
const liList = Array.from(el.querySelectorAll('li'));
liList.forEach((liEl) => {
const liInnerText = liEl.innerText;
if (!liInnerText) return;
let liContent = liInnerText.trim().toLowerCase().replace(/ /g, '-');
if (liContent.endsWith('_default')) liContent = liContent.slice(0, -8);
localizedText[`{{${liContent}}}`] = liContent;
});
}
44 changes: 0 additions & 44 deletions eds/components/NewsCard.js

This file was deleted.

Loading
Loading