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

removing .renew-banner className and styles, using notification block… #174

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions edsdme/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ function setUpPage() {
redirectLoggedinPartner();
updateIMSConfig();
await preloadResources(CONFIG.locales, miloLibs);
const { loadArea, setConfig, getConfig, loadBlock } = await import(`${miloLibs}/utils/utils.js`);
const { loadArea, setConfig, getConfig } = await import(`${miloLibs}/utils/utils.js`);

setConfig({ ...CONFIG, miloLibs });
await getRenewBanner(getConfig, loadBlock);
await getRenewBanner(getConfig);
await loadArea();
partnerIsSignedIn();
if (partnerIsSignedIn()) {
Expand Down
12 changes: 3 additions & 9 deletions edsdme/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export function isRenew() {
return { accountStatus, daysNum };
}

export async function getRenewBanner(getConfig, loadBlock) {
export async function getRenewBanner(getConfig) {
const renew = isRenew();
if (!renew) return;
const { accountStatus, daysNum } = renew;
Expand All @@ -223,16 +223,10 @@ export async function getRenewBanner(getConfig, loadBlock) {
const componentData = data.replace('$daysNum', daysNum);
const parser = new DOMParser();
const doc = parser.parseFromString(componentData, 'text/html');
const aside = doc.querySelector('.aside');
aside.classList.add('renew-banner');
const block = doc.querySelector('.notification');

const div = document.createElement('div');
div.style.position = 'sticky';
div.style.top = '64px';
div.style.zIndex = 1;

await loadBlock(aside);
div.appendChild(aside);
div.appendChild(block);

const main = document.querySelector('main');
if (main) main.insertBefore(div, main.firstChild);
Expand Down
31 changes: 0 additions & 31 deletions edsdme/styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,6 @@
*
*
*/

/* renew banner */
.aside.notification.renew-banner .foreground.container,
.aside.notification.extra-small.renew-banner .foreground.container {
padding-top: 14px;
padding-bottom: 14px;
}

.aside.notification.renew-banner .foreground.container .text,
.aside.notification.extra-small.renew-banner .foreground.container .text {
justify-content: space-between;
align-items: flex-start;
gap: 32px;
flex-wrap: nowrap;
}

@media screen and (max-width: 600px) {
.aside.notification.renew-banner .foreground.container .text,
.aside.notification.extra-small.renew-banner .foreground.container .text {
display: flex;
flex-wrap: wrap;
gap: 24px;
}
}

.aside.renew-banner .foreground.container .text .body-m {
margin-bottom: 0;
font-size: 16px;
font-weight: bold;
}

.personalization-hide {
display: none;
}
15 changes: 7 additions & 8 deletions test/scripts/utils.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,12 @@ describe('Test utils.js', () => {
const getConfig = () => ({ locale: '' });
global.fetch = jest.fn(() => Promise.resolve({
ok: true,
text: () => Promise.resolve('<div class="aside">Test</div>'),
text: () => Promise.resolve('<div class="notification">Test</div>'),
}));

const main = document.createElement('main');
document.body.appendChild(main);
await getRenewBanner(getConfig, jest.fn());
const banner = document.querySelector('.renew-banner');
await getRenewBanner(getConfig);
const banner = document.querySelector('.notification');
expect(banner).toBeTruthy();
});
it('Don\'t show renew banner', async () => {
Expand All @@ -356,13 +355,13 @@ describe('Test utils.js', () => {
const getConfig = () => ({ locale: '' });
global.fetch = jest.fn(() => Promise.resolve({
ok: true,
text: () => Promise.resolve('<div class="aside">Test</div>'),
text: () => Promise.resolve('<div class="notification">Test</div>'),
}));

const main = document.createElement('main');
document.body.appendChild(main);
await getRenewBanner(getConfig, jest.fn());
const banner = document.querySelector('.renew-banner');
await getRenewBanner(getConfig);
const banner = document.querySelector('.notification');
expect(banner).toBeFalsy();
});
it('Renew banner fetch error', async () => {
Expand All @@ -381,7 +380,7 @@ describe('Test utils.js', () => {
global.fetch = jest.fn(() => Promise.resolve({ ok: false }));
const main = document.createElement('main');
document.body.appendChild(main);
expect(await getRenewBanner(getConfig, jest.fn())).toEqual(null);
expect(await getRenewBanner(getConfig)).toEqual(null);
});
it('Update ims config if user is signed in', () => {
jest.useFakeTimers();
Expand Down
Loading