Skip to content

Commit

Permalink
Use the correct font in the help examples
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Oct 1, 2024
1 parent be13e62 commit ae509b3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ui/frontend/HelpExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as actions from './actions';
import { useAppDispatch } from './hooks';

import * as styles from './HelpExample.module.css';
import prismOverrides from './prismjs-overrides.css';
import prismTheme from 'prismjs/themes/prism-okaidia.css';

export interface HelpExampleProps {
Expand All @@ -23,6 +24,7 @@ const HelpExample: React.FC<HelpExampleProps> = ({ code }) => {
</button>
<root.div>
<link href={prismTheme} rel="stylesheet" />
<link href={prismOverrides} rel="stylesheet" />

<Prism language="rust">{code}</Prism>
</root.div>
Expand Down
5 changes: 5 additions & 0 deletions ui/frontend/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ declare module 'prismjs/themes/*.css' {
export default content;
}

declare module '*prismjs-overrides.css' {
const content: string;
export default content;
}

declare module '*.svg' {
const content: string;
export default content;
Expand Down
5 changes: 5 additions & 0 deletions ui/frontend/prismjs-overrides.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
code[class*='language-'],
pre[class*='language-'] {
font-family: 'Source Code Pro', monospace;
font-optical-sizing: auto;
}
7 changes: 6 additions & 1 deletion ui/frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@ module.exports = function(_, argv) {
{
test: /\.css$/,
oneOf: [
// Prism styles as separate files for the shadow DOM
{
test: /prismjs\/themes/,
test: [/prismjs\/themes/, /prismjs-overrides.css$/],
type: 'asset/resource',
},

// Our normal CSS
{
test: /\.module.css$/,
exclude: /node_modules/,
Expand All @@ -112,6 +115,8 @@ module.exports = function(_, argv) {
"postcss-loader",
],
},

// Everything else
{
include: /node_modules/,
use: [
Expand Down

0 comments on commit ae509b3

Please sign in to comment.