Skip to content

Commit 00bd4bd

Browse files
committed
chore: moved style loading to main instance constructor
1 parent 2e413c2 commit 00bd4bd

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/helper/style-loader.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*!
2+
* Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import '../styles/styles.scss';
7+
8+
export class StyleLoader {
9+
private static instance: StyleLoader | undefined;
10+
private constructor () {
11+
12+
}
13+
14+
public static getInstance (): StyleLoader {
15+
if (StyleLoader.instance === undefined) {
16+
StyleLoader.instance = new StyleLoader();
17+
}
18+
19+
return StyleLoader.instance;
20+
}
21+
22+
public destroy = (): void => {
23+
StyleLoader.instance = undefined;
24+
};
25+
}

src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import { FeedbackForm } from './components/feedback-form/feedback-form';
3737
import { MynahUITabsStore } from './helper/tabs-store';
3838
import { Config } from './helper/config';
3939
import { marked, Tokens } from 'marked';
40-
import './styles/styles.scss';
4140
import { generateUID } from './helper/guid';
4241
import { NoTabs } from './components/no-tabs';
4342
import { copyToClipboard } from './helper/chat-item';
@@ -46,6 +45,7 @@ import { serializeHtml, serializeMarkdown } from './helper/serialize-chat';
4645
import { Sheet } from './components/sheet';
4746
import { DetailedListSheet, DetailedListSheetProps } from './components/detailed-list/detailed-list-sheet';
4847
import { MynahUIDataStore } from './helper/store';
48+
import { StyleLoader } from './helper/style-loader';
4949

5050
export { generateUID } from './helper/guid';
5151
export {
@@ -313,6 +313,7 @@ export class MynahUI {
313313
private readonly chatWrappers: Record<string, ChatWrapper> = {};
314314

315315
constructor (props: MynahUIProps) {
316+
StyleLoader.getInstance();
316317
// Apply global fix for marked listitem content is not getting parsed.
317318
marked.use({
318319
renderer: {

0 commit comments

Comments
 (0)