Skip to content

Commit ca5f69b

Browse files
committed
fix: use a custom mdx compiler
1 parent ed79556 commit ca5f69b

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

knip.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {compile} from '@mdx-js/mdx';
12
import type {KnipConfig} from 'knip';
23

34
const productionEntryPoints = [
@@ -60,7 +61,15 @@ const config: KnipConfig = {
6061
'!static/app/stories/*.{js,mjs,ts,tsx}!',
6162
],
6263
compilers: {
63-
mdx: true,
64+
mdx: async text => {
65+
const result = await compile(text, {
66+
providerImportSource: '@mdx-js/react',
67+
jsx: true,
68+
outputFormat: 'program',
69+
});
70+
71+
return String(result);
72+
},
6473
},
6574
rules: {
6675
binaries: 'off',

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
"@eslint/eslintrc": "^3.3.0",
183183
"@eslint/js": "^9.22.0",
184184
"@mdx-js/loader": "^3.1.0",
185+
"@mdx-js/mdx": "^3.1.0",
185186
"@pmmmwh/react-refresh-webpack-plugin": "0.5.16",
186187
"@sentry/jest-environment": "6.0.0",
187188
"@sentry/profiling-node": "9.16.1",

static/app/styles/colors.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import ExternalLink from 'sentry/components/links/externalLink';
1212
import Panel from 'sentry/components/panels/panel';
1313
import PanelItem from 'sentry/components/panels/panelItem';
1414
import {IconCheckmark, IconClose} from 'sentry/icons';
15-
import {ThemeToggle, SideBySide} from 'sentry/stories';
15+
import * as Storybook from 'sentry/stories';
1616
import {space} from 'sentry/styles/space';
1717

1818
export const GRAY_PALETTES = [
@@ -66,7 +66,7 @@ export const FixedWidth = styled('div')`
6666
max-width: 800px;
6767
`;
6868

69-
export const SideBySideUl = styled('ul')`
69+
export const SideBySide = styled('ul')`
7070
list-style-type: none;
7171
margin: 0;
7272
padding: 0;
@@ -158,7 +158,7 @@ export const ColorPalette = ({name, palette}) => {
158158
const theme = useTheme();
159159

160160
return (
161-
<SideBySideUl>
161+
<SideBySide>
162162
{palette.map((section, i) => {
163163
return (
164164
<li key={`${name}-${i}`}>
@@ -179,7 +179,7 @@ export const ColorPalette = ({name, palette}) => {
179179
</li>
180180
);
181181
})}
182-
</SideBySideUl>
182+
</SideBySide>
183183
);
184184
}
185185

@@ -201,9 +201,9 @@ Here are the recommended use cases:
201201
- **Gray 200:** borders around large elements (cards, panels, dialogs, tables).
202202
- **Gray 100:** dividers and borders around small elements (buttons, form inputs). */}
203203

204-
<ThemeToggle>
204+
<Storybook.ThemeToggle>
205205
<ColorPalette name="grays" palette={GRAY_PALETTES} />
206-
</ThemeToggle>
206+
</Storybook.ThemeToggle>
207207

208208
## Accent Colors
209209

@@ -229,9 +229,9 @@ Each hue comes in 4 levels: 400 (dark), 300 (full opacity), 200 (medium opacity)
229229
- **The 200 level** has medium opacity, useful for borders and dividers.
230230
- **The 100 level** has very low opacity, useful as background fills.
231231

232-
<ThemeToggle>
232+
<Storybook.ThemeToggle>
233233
<ColorPalette name="levels" palette={LEVELS_PALETTES} />
234-
</ThemeToggle>
234+
</Storybook.ThemeToggle>
235235

236236
## Accessibility
237237

@@ -245,7 +245,7 @@ In Sentry's color palette, only Gray 300 and above satisfy the contrast requirem
245245

246246
Accent colors in the 300 series, except for Yellow 300, satisfy the contrast requirement for large text.
247247

248-
<SideBySide>
248+
<Storybook.SideBySide>
249249
<ExampleCard
250250
imgSrc={DoContrast}
251251
text="Use Gray 300 and above for normal text"
@@ -264,15 +264,15 @@ Accent colors in the 300 series, except for Yellow 300, satisfy the contrast req
264264
imgSrc={DontAccentColors}
265265
text="Use accent colors in the 100 or 200 series for any text"
266266
/>
267-
</SideBySide>
267+
</Storybook.SideBySide>
268268

269269
### Separation
270270

271271
Color can be an effective way to visually separate elements in the user interface. However, not all users see color in the same way. Some are color-blind and cannot reliably differentiate one color from another. Some have color filters on their screens, like Night Shift in MacOS. Others are in bright environments with high levels of glare, reducing their ability to see color clearly.
272272

273273
As such, color is an unreliable way to separate elements. Whenever possible, provide additional visual cues like icons, text labels, line type (solid, dashed, dotted),… to further reinforce the separation.
274274

275-
<SideBySide>
275+
<Storybook.SideBySide>
276276
<ExampleCard
277277
imgSrc={DoDifferentiation}
278278
text="Provide additional visual encoding (e.g. line type) besides color to differentiate elements"
@@ -282,4 +282,4 @@ As such, color is an unreliable way to separate elements. Whenever possible, pro
282282
imgSrc={DontDifferentiation}
283283
text="Use color as the only way to differentiate elements"
284284
/>
285-
</SideBySide>
285+
</Storybook.SideBySide>

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2044,7 +2044,7 @@
20442044
"@mdx-js/mdx" "^3.0.0"
20452045
source-map "^0.7.0"
20462046

2047-
"@mdx-js/mdx@^3.0.0":
2047+
"@mdx-js/mdx@^3.0.0", "@mdx-js/mdx@^3.1.0":
20482048
version "3.1.0"
20492049
resolved "https://registry.yarnpkg.com/@mdx-js/mdx/-/mdx-3.1.0.tgz#10235cab8ad7d356c262e8c21c68df5850a97dc3"
20502050
integrity sha512-/QxEhPAvGwbQmy1Px8F899L5Uc2KZ6JtXwlCgJmjSTBedwOZkByYcBG4GceIGPXRDsmfxhHazuS+hlOShRLeDw==

0 commit comments

Comments
 (0)