diff --git a/CHANGELOG.md b/CHANGELOG.md
index 316d25c..2a36ea3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@
- Added theme object, notifySuccess & notifyError (#270)
- Update dependencies and Actions (#271)
- Replace custom code parameters with Code Parameters Builder (#285)
+- Update CSS class for the Panel instead of a Row (#272)
## 4.3.0 (2023-12-25)
diff --git a/package-lock.json b/package-lock.json
index 5e0d623..71050a9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -69,7 +69,7 @@
"webpack-livereload-plugin": "^3.0.2"
},
"engines": {
- "node": ">=18"
+ "node": ">=20"
}
},
"node_modules/@aashutoshrathi/word-wrap": {
diff --git a/package.json b/package.json
index 8e2b9c7..6bce8dd 100644
--- a/package.json
+++ b/package.json
@@ -62,7 +62,7 @@
"webpack-livereload-plugin": "^3.0.2"
},
"engines": {
- "node": ">=18"
+ "node": ">=20"
},
"license": "Apache-2.0",
"name": "marcusolsson-dynamictext-panel",
diff --git a/src/components/Text/Text.test.tsx b/src/components/Text/Text.test.tsx
index 9b16a5f..1861a37 100644
--- a/src/components/Text/Text.test.tsx
+++ b/src/components/Text/Text.test.tsx
@@ -56,34 +56,6 @@ describe('Text', () => {
expect(screen.getByTestId(TEST_IDS.text.content)).toHaveTextContent('Test default content');
});
- it('Should apply styles', async () => {
- const styles = `
- color: red;
- `;
- const replaceVariables = jest.fn((str: string) => str);
- const props: Props = {
- data: {} as any,
- options: {
- ...DEFAULT_OPTIONS,
- content: 'Test content',
- defaultContent: 'Test default content',
- renderMode: RenderMode.EVERY_ROW,
- styles,
- },
- timeRange: {} as any,
- timeZone: '',
- replaceVariables,
- eventBus: {} as any,
- };
-
- render();
-
- expect(replaceVariables).toHaveBeenCalledWith(styles);
-
- expect(screen.getByTestId(TEST_IDS.text.content)).toBeInTheDocument();
- expect(screen.getByTestId(TEST_IDS.text.content)).toHaveStyle({ color: 'red' });
- });
-
describe('After Render Function', () => {
it('Should run after render function', async () => {
const eventBus = {
diff --git a/src/components/Text/Text.tsx b/src/components/Text/Text.tsx
index e1ffb00..c547909 100644
--- a/src/components/Text/Text.tsx
+++ b/src/components/Text/Text.tsx
@@ -1,4 +1,4 @@
-import { css, cx } from '@emotion/css';
+import { cx } from '@emotion/css';
import {
AlertErrorPayload,
AlertPayload,
@@ -105,13 +105,7 @@ export const Text: React.FC = ({
* Styles
*/
const styles = useStyles2(getStyles);
- const className = cx(
- styles.highlight,
- styles.frame,
- css`
- ${options.styles ? replaceVariables(options.styles) : ''}
- `
- );
+ const className = cx(styles.highlight, styles.frame, 'dt-row');
/**
* Events
diff --git a/src/components/TextPanel/TextPanel.test.tsx b/src/components/TextPanel/TextPanel.test.tsx
index c4a7d82..95f993b 100644
--- a/src/components/TextPanel/TextPanel.test.tsx
+++ b/src/components/TextPanel/TextPanel.test.tsx
@@ -159,6 +159,47 @@ describe('Panel', () => {
expect(streamSubscribe).toHaveBeenCalled();
});
+ it('Should apply css for component', async () => {
+ const streamSubscribe = jest.fn(() => ({
+ unsubscribe: jest.fn(),
+ }));
+
+ const eventBus = {
+ getStream: jest.fn(() => ({
+ subscribe: streamSubscribe,
+ })),
+ };
+
+ const replaceVariables = jest.fn((str: string) => str);
+
+ await act(async () =>
+ render(
+ getComponent({
+ options: {
+ ...defaultOptions,
+ defaultContent: 'hello',
+ styles: '.styles-test{}; .dt-row{color:red}',
+ },
+ replaceVariables,
+ data: { series: [] } as any,
+ eventBus: eventBus as any,
+ id: 5,
+ })
+ )
+ );
+
+ expect(replaceVariables).toHaveBeenCalledWith('.styles-test{}; .dt-row{color:red}');
+
+ const panel = screen.getByTestId(TEST_IDS.panel.root);
+ expect(panel).toBeInTheDocument();
+
+ const rowClass = panel.querySelectorAll('.dt-row');
+ expect(rowClass.length).toBeGreaterThan(0);
+
+ expect(screen.getByTestId(TEST_IDS.text.content)).toBeInTheDocument();
+ expect(screen.getByTestId(TEST_IDS.text.content)).toHaveStyle({ color: 'red' });
+ });
+
describe('Helpers execution', () => {
const helpers = `
const subscription = eventBus.subscribe('event', () => {});
diff --git a/src/components/TextPanel/TextPanel.tsx b/src/components/TextPanel/TextPanel.tsx
index 2092989..5a9ae72 100644
--- a/src/components/TextPanel/TextPanel.tsx
+++ b/src/components/TextPanel/TextPanel.tsx
@@ -118,6 +118,9 @@ export const TextPanel: React.FC = ({