Skip to content

Commit d4f2607

Browse files
LaurentClaesclaude
andcommitted
Fix @import CSS ordering warning in styleguide Code component
Same approach as the ThemeProvider fix: replace Emotion CSS @import with a <link> element for Roboto Mono font. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b37987b commit d4f2607

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

  • packages/styleguide/app/components

packages/styleguide/app/components/Code.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import sv from '@drawbotics/drylus-style-vars';
2-
import { css, cx, injectGlobal } from 'emotion';
2+
import { css, cx } from 'emotion';
33
import Highlight, { defaultProps } from 'prism-react-renderer';
44
import React from 'react';
55

66
import theme from '../utils/code-theme';
77

8-
injectGlobal`
9-
@import url('https://fonts.googleapis.com/css?family=Roboto+Mono');
10-
`;
8+
const ROBOTO_MONO_URL = 'https://fonts.googleapis.com/css?family=Roboto+Mono';
9+
if (typeof document !== 'undefined' && !document.querySelector(`link[href="${ROBOTO_MONO_URL}"]`)) {
10+
const link = document.createElement('link');
11+
link.rel = 'stylesheet';
12+
link.href = ROBOTO_MONO_URL;
13+
document.head.appendChild(link);
14+
}
1115

1216
const styles = {
1317
codeWrapper: css`

0 commit comments

Comments
 (0)