Skip to content

fix: replace direct CSS import with CSS-in-JS styling#1

Merged
idelvall merged 1 commit into
mainfrom
fix/css-in-js-styling
Jun 22, 2026
Merged

fix: replace direct CSS import with CSS-in-JS styling#1
idelvall merged 1 commit into
mainfrom
fix/css-in-js-styling

Conversation

@idelvall

Copy link
Copy Markdown
Member

Summary

  • Grafana's plugin validator rejected v1.0.0 with code-rules-no-direct-css-imports — a direct import './styles.css' in src/panel/TextDiffPanel.tsx.
  • Moved all rules from styles.css into emotion CSS-in-JS via useStyles2, and render the diff as React elements (using cx for added/removed lines) instead of building an HTML string for dangerouslySetInnerHTML — which also removes the manual escapeHtml helper.
  • Deleted src/panel/styles.css and bumped the plugin to 1.0.1.

Validation

  • npm run typecheck, npm run lint, npm run build, and npm run test:ci all pass.
  • Ran the full Grafana plugin validator (grafana/plugin-validator-cli) against a built zip + source: exits 0, and code-rules now reports "no code rules violations found". Only the expected unsigned-plugin warning and an optional sponsorship-link recommendation remain.
  • Deployed 1.0.1 to local Grafana and confirmed the panel registers and renders, with zero styles.css references in the served module.js.

Test plan

  • Open a dashboard with the Text Diff panel; confirm added/removed/context lines render correctly.
  • Confirm the "No data" hint shows for an empty/invalid query.

Made with Cursor

Grafana's plugin validator rejects direct CSS imports
(code-rules-no-direct-css-imports). Move the rules from styles.css into
emotion CSS-in-JS via useStyles2, and render the diff as React elements
instead of injecting an HTML string through dangerouslySetInnerHTML
(which also removes the need for manual HTML escaping). Bump to 1.0.1.

Co-authored-by: Cursor <cursoragent@cursor.com>
@idelvall idelvall merged commit bf9ab06 into main Jun 22, 2026
2 of 3 checks passed
@github-actions

Copy link
Copy Markdown

Bundle Size Changes

Hello! 👋 This comment was generated by a Github Action to help you and reviewers understand the impact of your PR on frontend bundle sizes.

Whenever this PR is updated, this comment will update to reflect the latest changes.

EntryPoint Size % Diff
module 11.02 KB (-4.99 KB) -31.18%
Files Total bundle size % Diff
7 202.04 KB (-4.87 KB) -2.35%
View detailed bundle information

Added

No assets were added

Removed

No assets were removed

Bigger

Name Size % Diff
CHANGELOG.md 321 Bytes (+127 Bytes) +65.46%

Smaller

Name Size % Diff
module.js 11.02 KB (-4.99 KB) -31.18%
View module information

Added

No modules were added

Removed

Name Size % Diff
style-loader 0 Bytes (-5.84 KB) -100.00%
css-loader 0 Bytes (-4.44 KB) -100.00%
./panel/styles.css 0 Bytes (-1.14 KB) -100.00%

Bigger

Name Size % Diff
./panel/TextDiffPanel.tsx 2.81 KB (+603 Bytes) +26.53%

Smaller

No modules were smaller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant