Skip to content

Commit

Permalink
[docs][material-ui] Fixed Google Fonts link for material two-tone ico…
Browse files Browse the repository at this point in the history
…ns in CodeSandbox and Stackblitz (#38247)
  • Loading branch information
ZeeshanTamboli authored Aug 16, 2023
1 parent 85c3c77 commit 2ac3eaa
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
19 changes: 19 additions & 0 deletions docs/src/modules/sandbox/CodeSandbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,23 @@ ReactDOM.createRoot(document.querySelector("#root")!).render(
'<script src="https://cdn.tailwindcss.com"></script>',
);
});

it('should generate the correct stylesheet font link in index.html for Material Two Tones icons', () => {
const raw = `import * as React from 'react';
import Icon from '@mui/material/Icon';
export default function TwoToneIcons() {
return <Icon baseClassName="material-icons-two-tone">add_circle</Icon>;
}
`;

const result = CodeSandbox.createReactApp({
raw,
codeVariant: 'JS',
});

expect(result.files['public/index.html'].content).to.contain(
'https://fonts.googleapis.com/icon?family=Material+Icons+Two+Tone',
);
});
});
6 changes: 5 additions & 1 deletion docs/src/modules/sandbox/CreateReactApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ export const getHtml = ({
title,
language,
codeStyling,
raw,
}: {
title: string;
language: string;
codeStyling?: 'Tailwind' | 'MUI System';
raw?: string;
}) => {
return `<!DOCTYPE html>
<html lang="${language}">
Expand All @@ -23,7 +25,9 @@ export const getHtml = ({
<!-- Icons to support Material Design -->
<link
rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons"
href="https://fonts.googleapis.com/icon?family=Material+Icons${
raw?.includes('material-icons-two-tone') ? '+Two+Tone' : ''
}"
/>${
codeStyling === 'Tailwind'
? `
Expand Down
19 changes: 19 additions & 0 deletions docs/src/modules/sandbox/StackBlitz.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,23 @@ ReactDOM.createRoot(document.querySelector("#root")!).render(
'<script src="https://cdn.tailwindcss.com"></script>',
);
});

it('should generate the correct stylesheet font link in index.html for Material Two Tones icons', () => {
const raw = `import * as React from 'react';
import Icon from '@mui/material/Icon';
export default function TwoToneIcons() {
return <Icon baseClassName="material-icons-two-tone">add_circle</Icon>;
}
`;

const result = StackBlitz.createReactApp({
raw,
codeVariant: 'JS',
});

expect(result.files['index.html']).to.contain(
'https://fonts.googleapis.com/icon?family=Material+Icons+Two+Tone',
);
});
});

0 comments on commit 2ac3eaa

Please sign in to comment.