generated from adobecom/milo-college
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from adobecom/stage
MAPC Release 24.7
- Loading branch information
Showing
24 changed files
with
766 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { getLibs } from '../../scripts/utils.js'; | ||
import PartnerCards from '../../components/PartnerCards.js'; | ||
import { searchCardsStyles } from '../search/SearchCardsStyles.js'; | ||
import '../../components/SearchCard.js'; | ||
import { generateRequestForSearchAPI } from '../utils/utils.js'; | ||
|
||
const miloLibs = getLibs(); | ||
const { html, repeat } = await import(`${miloLibs}/deps/lit-all.min.js`); | ||
|
||
export default class Logos extends PartnerCards { | ||
static styles = [ | ||
PartnerCards.styles, | ||
searchCardsStyles, | ||
]; | ||
|
||
constructor() { | ||
super(); | ||
this.contentType = 'all'; | ||
this.contentTypeCounter = { countAll: 0, countAssets: 0, countPages: 0 }; | ||
this.hasResponseData = false; | ||
} | ||
|
||
async fetchData() { | ||
const assetType = { filters: { assetType: ['logoLogotype'] } }; | ||
let apiData; | ||
try { | ||
const response = await generateRequestForSearchAPI( | ||
{ | ||
sort: 'recent', | ||
type: 'asset', | ||
}, | ||
assetType, | ||
); | ||
|
||
if (!response.ok) { | ||
throw new Error(`Error message: ${response.statusText}`); | ||
} | ||
|
||
apiData = await response.json(); | ||
|
||
this.allCards = apiData.cards; | ||
this.cards = apiData.cards; | ||
this.hasResponseData = !!apiData.cards; | ||
} catch (error) { | ||
this.hasResponseData = true; | ||
// eslint-disable-next-line no-console | ||
console.error('There was a problem with your fetch operation:', error); | ||
} | ||
} | ||
|
||
get partnerCards() { | ||
if (this.paginatedCards.length) { | ||
return html`${repeat( | ||
this.paginatedCards, | ||
(card) => card.id, | ||
(card) => html`<search-card class="card-wrapper" .data=${card} .localizedText=${this.blockData.localizedText} .ietf=${this.blockData.ietf}></search-card>`, | ||
)}`; | ||
} | ||
return html`<div class="no-results"> | ||
<strong class="no-results-title">${this.blockData.localizedText['{{no-results-title}}']}</strong> | ||
</div>`; | ||
} | ||
|
||
/* eslint-disable indent */ | ||
render() { | ||
return html` | ||
<div class="partner-cards-content"> | ||
<div class="partner-cards-collection"> | ||
${this.hasResponseData | ||
? this.partnerCards | ||
: html` | ||
<div class="progress-circle-wrapper"> | ||
<sp-theme theme="spectrum" color="light" scale="medium"> | ||
<sp-progress-circle label="Cards loading" indeterminate="" size="l" role="progressbar"></sp-progress-circle> | ||
</sp-theme> | ||
</div> | ||
` | ||
} | ||
</div> | ||
</div> | ||
`; | ||
} | ||
/* eslint-disable indent */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@media (min-width: 900px) { | ||
.section:has(.logos-cards-wrapper.main) { | ||
grid-template-columns: 1fr 3fr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { getLibs } from '../../scripts/utils.js'; | ||
import { replaceText, getConfig, populateLocalizedTextFromListItems } from '../utils/utils.js'; | ||
import Logos from './LogosCards.js'; | ||
|
||
function declareLogos() { | ||
if (customElements.get('logos-cards')) return; | ||
customElements.define('logos-cards', Logos); | ||
} | ||
|
||
async function localizationPromises(localizedText, config) { | ||
return Promise.all(Object.keys(localizedText).map(async (key) => { | ||
const value = await replaceText(key, config); | ||
if (value.length) localizedText[key] = value; | ||
})); | ||
} | ||
|
||
export default async function init(el) { | ||
const miloLibs = getLibs(); | ||
const config = getConfig(); | ||
|
||
const sectionIndex = el.parentNode.getAttribute('data-idx'); | ||
const isMain = el.classList.contains('main'); | ||
|
||
const localizedText = { | ||
'{{no-results-title}}': 'No Results Found', | ||
'{{size}}': 'Size', | ||
'{{last-modified}}': 'Last modified', | ||
}; | ||
|
||
populateLocalizedTextFromListItems(el, localizedText); | ||
|
||
const deps = await Promise.all([ | ||
localizationPromises(localizedText, config), | ||
import(`${miloLibs}/features/spectrum-web-components/dist/theme.js`), | ||
import(`${miloLibs}/features/spectrum-web-components/dist/button.js`), | ||
import(`${miloLibs}/features/spectrum-web-components/dist/progress-circle.js`), | ||
import(`${miloLibs}/features/spectrum-web-components/dist/action-button.js`), | ||
import(`${miloLibs}/features/spectrum-web-components/dist/icons-workflow.js`), | ||
]); | ||
|
||
declareLogos(); | ||
|
||
const blockData = { | ||
localizedText, | ||
tableData: el.children, | ||
ietf: config.locale.ietf, | ||
isMain, | ||
}; | ||
|
||
const app = document.createElement('logos-cards'); | ||
app.className = `logos-cards-wrapper${blockData.isMain ? ' main' : ''}`; | ||
app.blockData = blockData; | ||
app.setAttribute('data-idx', sectionIndex); | ||
el.replaceWith(app); | ||
|
||
await deps; | ||
return app; | ||
} |
Oops, something went wrong.