Skip to content

Commit

Permalink
feat(PAYMENTS-17872): add default styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey-Kornienko-xsolla committed Mar 18, 2024
1 parent c8b36f6 commit 924ef61
Show file tree
Hide file tree
Showing 64 changed files with 1,148 additions and 152 deletions.
33 changes: 27 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"dev": "webpack --mode=development --watch",
"test": "karma start --single-run",
"test:dev": "karma start --auto-watch",
"lint": "eslint \"src/**/*.{ts,tsx}\"",
"lint": "npm run eslint:lint && npm run stylelint:lint",
"eslint:lint": "eslint \"src/**/*.{ts,tsx}\"",
"stylelint:lint": "stylelint \"src/**/*.scss\"",
"prepare": "husky install",
"lib-publish": "npm run build && npm test && npm run lint && npm publish --access public",
"prettier": "prettier --write ./src"
Expand Down Expand Up @@ -47,6 +49,7 @@
"lint-staged": "^14.0.1",
"mini-css-extract-plugin": "^2.7.6",
"prettier": "3.0.2",
"raw-loader": "^4.0.2",
"reflect-metadata": "^0.1.13",
"resolve-url-loader": "^5.0.0",
"sass": "^1.66.1",
Expand Down
Binary file added src/assets/fonts/graphik/Graphik-Bold-Web.eot
Binary file not shown.
Binary file added src/assets/fonts/graphik/Graphik-Bold-Web.ttf
Binary file not shown.
Binary file added src/assets/fonts/graphik/Graphik-Bold-Web.woff
Binary file not shown.
Binary file added src/assets/fonts/graphik/Graphik-Bold-Web.woff2
Binary file not shown.
Binary file added src/assets/fonts/graphik/Graphik-Medium-Web.ttf
Binary file not shown.
Binary file added src/assets/fonts/graphik/Graphik-Medium-Web.woff
Binary file not shown.
Binary file added src/assets/fonts/graphik/Graphik-Medium-Web.woff2
Binary file not shown.
Binary file added src/assets/fonts/graphik/Graphik-Regular-Web.ttf
Binary file not shown.
Binary file added src/assets/fonts/graphik/Graphik-Regular-Web.woff
Binary file not shown.
Binary file not shown.
87 changes: 87 additions & 0 deletions src/assets/fonts/graphik/ttEULA.txt

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/assets/fonts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import './graphik/Graphik-Bold-Web.eot';
import './graphik/Graphik-Bold-Web.ttf';
import './graphik/Graphik-Bold-Web.woff';
import './graphik/Graphik-Bold-Web.woff2';

import './graphik/Graphik-Medium-Web.ttf';
import './graphik/Graphik-Medium-Web.woff';
import './graphik/Graphik-Medium-Web.woff2';

import './graphik/Graphik-Regular-Web.ttf';
import './graphik/Graphik-Regular-Web.woff';
import './graphik/Graphik-Regular-Web.woff2';
3 changes: 3 additions & 0 deletions src/assets/icons/arrow-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/arrow-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/core/customization/themes-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'reflect-metadata';
import { injectable } from 'tsyringe';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { default as styles } from '../../styles/themes/default/secure-styles/style.string-style.scss';
@injectable()
export class ThemesLoader {
public getTheme(): string {
return styles as string;
}
}
3 changes: 3 additions & 0 deletions src/core/customization/themes.map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const themes = {
default: 'default',
};
5 changes: 2 additions & 3 deletions src/features/headless-checkout/environment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// export const headlessCheckoutAppUrl =
// 'https://secure.xsolla.com/headless-checkout';
export const headlessCheckoutAppUrl = 'https://localhost:4200';
export const headlessCheckoutAppUrl =
'https://secure.xsolla.com/headless-checkout';
export const cdnUrl = 'https://cdn3.xsolla.com';
27 changes: 18 additions & 9 deletions src/features/headless-checkout/headless-checkout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getFinanceDetailsHandler } from './post-messages-handlers/get-finance-d
import { FormStatus } from '../../core/status/form-status.enum';
import { noopStub } from '../../tests/stubs/noop.stub';
import { headlessCheckoutAppUrl } from './environment';
import { ThemesLoader } from '../../core/customization/themes-loader';

const mockMessage: Message = {
name: EventName.initPayment,
Expand Down Expand Up @@ -40,6 +41,7 @@ describe('HeadlessCheckout', () => {
let headlessCheckout: HeadlessCheckout;
let postMessagesClient: PostMessagesClient;
let localizeService: LocalizeService;
let themesLoader: ThemesLoader;

// eslint-disable-next-line @typescript-eslint/no-empty-function
const stub = (): void => {};
Expand All @@ -52,7 +54,7 @@ describe('HeadlessCheckout', () => {
origin: headlessCheckoutAppUrl,
data: JSON.stringify({ name: EventName.isReady }),
} as MessageEvent);
}
},
);
postMessagesClient = {
init: stub,
Expand All @@ -64,6 +66,10 @@ describe('HeadlessCheckout', () => {
initDictionaries: async () => Promise.resolve(),
} as unknown as LocalizeService;

themesLoader = {
getTheme: () => 'body { margin: 0;}',
} as unknown as ThemesLoader;

container.clearInstances();

headlessCheckout = container
Expand All @@ -75,6 +81,9 @@ describe('HeadlessCheckout', () => {
.register<LocalizeService>(LocalizeService, {
useValue: localizeService,
})
.register<ThemesLoader>(ThemesLoader, {
useValue: themesLoader,
})
.registerSingleton(HeadlessCheckout)
.resolve(HeadlessCheckout);
});
Expand All @@ -83,7 +92,7 @@ describe('HeadlessCheckout', () => {
const spy = spyOn(postMessagesClient, 'init');
spyOn(windowService.document.body, 'appendChild');
spyOn(windowService.document, 'createElement').and.callFake(
() => new MockIframeElement() as unknown as HTMLIFrameElement
() => new MockIframeElement() as unknown as HTMLIFrameElement,
);
await headlessCheckout.init({ isWebview: false });
expect(spy).toHaveBeenCalled();
Expand All @@ -92,7 +101,7 @@ describe('HeadlessCheckout', () => {
it('Should init localization', () => {
const localizeSpy = spyOn(
localizeService,
'initDictionaries'
'initDictionaries',
).and.resolveTo();

void headlessCheckout.init({ isWebview: false });
Expand All @@ -111,7 +120,7 @@ describe('HeadlessCheckout', () => {
headlessCheckout.events.onCoreEvent(
EventName.initPayment,
mockHandler,
stub
stub,
);
expect(spy).toHaveBeenCalled();
});
Expand All @@ -120,7 +129,7 @@ describe('HeadlessCheckout', () => {
const spy = spyOn(postMessagesClient, 'listen');
spyOn(windowService.document.body, 'appendChild');
spyOn(windowService.document, 'createElement').and.callFake(
() => new MockIframeElement() as unknown as HTMLIFrameElement
() => new MockIframeElement() as unknown as HTMLIFrameElement,
);

await headlessCheckout.init({ isWebview: false });
Expand Down Expand Up @@ -152,7 +161,7 @@ describe('HeadlessCheckout', () => {
await headlessCheckout.getFinanceDetails();
expect(spy).toHaveBeenCalledWith(
{ name: EventName.financeDetails },
getFinanceDetailsHandler
getFinanceDetailsHandler,
);
});

Expand All @@ -173,7 +182,7 @@ describe('HeadlessCheckout', () => {
spyOn(windowService.customElements, 'get').and.returnValue(undefined);
spyOn(windowService.document.body, 'appendChild');
spyOn(windowService.document, 'createElement').and.callFake(
() => new MockIframeElement() as unknown as HTMLIFrameElement
() => new MockIframeElement() as unknown as HTMLIFrameElement,
);

await headlessCheckout.init({ isWebview: false });
Expand All @@ -182,11 +191,11 @@ describe('HeadlessCheckout', () => {

it('Should web components not be redefined', async () => {
spyOn(windowService.customElements, 'get').and.returnValue(
CustomElementMock
CustomElementMock,
);
spyOn(windowService.document.body, 'appendChild');
spyOn(windowService.document, 'createElement').and.callFake(
() => new MockIframeElement() as unknown as HTMLIFrameElement
() => new MockIframeElement() as unknown as HTMLIFrameElement,
);

const spy = spyOn(window.customElements, 'define');
Expand Down
Loading

0 comments on commit 924ef61

Please sign in to comment.