Skip to content

Commit fff5a6b

Browse files
slorberclaude
andauthored
refactor(theme-classic): use the @docusaurus/infima package instead of the npm infima package (#13085)
* refactor(theme-classic): use the @docusaurus/infima package instead of the npm infima package rtlcss now flips Infima like the other CSS, at OnceExit: run alongside the other PostCSS plugins, it missed the var() fallbacks that postcss-preset-env adds in cascade layers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(theme-classic): keep loading the pre-flipped Infima RTL file Moving rtlcss onto Infima gets its own PR: Argos doesn't cover RTL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b81d434 commit fff5a6b

11 files changed

Lines changed: 36 additions & 24 deletions

File tree

‎knip.config.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ const config: KnipConfig = ({
163163
'packages/docusaurus-theme-classic': themePackageConfig({
164164
entry: ['src/nprogress.ts!', 'src/prism-include-languages.ts!'],
165165
ignoreDependencies: [
166-
// Resolved with require.resolve(`infima/...`)
167-
'infima',
166+
// Resolved with require.resolve(`@docusaurus/infima/...`)
167+
'@docusaurus/infima',
168168
// Knip doesn't detect imports in "declare module" blocks
169169
'@docusaurus/mdx-loader',
170170
'utility-types',

‎packages/docusaurus-plugin-css-cascade-layers/src/__tests__/options.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,24 @@ describe('validateOptions', () => {
106106
});
107107
});
108108
});
109+
110+
describe('DEFAULT_OPTIONS', () => {
111+
describe('docusaurus.infima layer', () => {
112+
const isInfima = DEFAULT_OPTIONS.layers!['docusaurus.infima']!;
113+
114+
it.each([
115+
'/repo/packages/docusaurus-infima/dist/infima.css',
116+
'/site/node_modules/@docusaurus/infima/dist/infima.css',
117+
'C:\\site\\node_modules\\@docusaurus\\infima\\dist\\infima.css',
118+
])('matches %s', (filePath) => {
119+
expect(isInfima(filePath)).toBe(true);
120+
});
121+
122+
it.each([
123+
'/site/node_modules/infima/dist/css/default/default.css',
124+
'/site/src/css/custom.css',
125+
])('does not match %s', (filePath) => {
126+
expect(isInfima(filePath)).toBe(false);
127+
});
128+
});
129+
});

‎packages/docusaurus-plugin-css-cascade-layers/src/options.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ function layerFor(...params: string[]) {
2929

3030
// Object order matters, it defines the layer order
3131
const DEFAULT_LAYERS: PluginOptions['layers'] = {
32-
'docusaurus.infima': layerFor('node_modules/infima/dist'),
32+
'docusaurus.infima': layerFor(
33+
'packages/docusaurus-infima/dist',
34+
'node_modules/@docusaurus/infima/dist',
35+
),
3336
'docusaurus.theme-common': layerFor(
3437
'packages/docusaurus-theme-common/lib',
3538
'node_modules/@docusaurus/theme-common/lib',

‎packages/docusaurus-theme-classic/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
},
2222
"dependencies": {
2323
"@docusaurus/core": "workspace:*",
24+
"@docusaurus/infima": "workspace:*",
2425
"@docusaurus/mdx-loader": "workspace:*",
2526
"@docusaurus/module-type-aliases": "workspace:*",
2627
"@docusaurus/plugin-content-blog": "workspace:*",
@@ -35,7 +36,6 @@
3536
"@mdx-js/react": "catalog:",
3637
"clsx": "catalog:",
3738
"copy-text-to-clipboard": "catalog:",
38-
"infima": "catalog:",
3939
"lodash": "catalog:",
4040
"nprogress": "catalog:",
4141
"postcss": "catalog:",

‎packages/docusaurus-theme-classic/src/index.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ import type {Plugin as PostCssPlugin} from 'postcss';
2121
import type {PluginOptions} from '@docusaurus/theme-classic';
2222

2323
function getInfimaCSSFile(direction: string) {
24-
return `infima/dist/css/default/default${
25-
direction === 'rtl' ? '-rtl' : ''
26-
}.css`;
24+
return `@docusaurus/infima/infima${direction === 'rtl' ? '-rtl' : ''}.css`;
2725
}
2826

2927
export default function themeClassic(

‎pnpm-lock.yaml‎

Lines changed: 3 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ catalog:
8383
hast-util-to-estree: ^3.1.3
8484
html-tags: ^5.1.0
8585
image-size: ^2.0.4
86-
infima: 0.2.0-alpha.45
8786
jimp: ^1.6.1
8887
jiti: ^2.7.0
8988
joi: ^18.2.8

‎website/docs/api/plugins/plugin-css-cascade-layers.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Most Docusaurus users configure this plugin through the preset options.
9696
const config = {
9797
layers: {
9898
'docusaurus.infima': (filePath) =>
99-
filePath.includes('/node_modules/infima/dist'),
99+
filePath.includes('/node_modules/@docusaurus/infima/dist'),
100100
'docusaurus.theme-classic': (filePath) =>
101101
filePath.includes('/node_modules/@docusaurus/theme-classic/lib'),
102102
},

‎website/docs/api/plugins/plugin-pwa.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ import CodeBlock from '@theme/CodeBlock';
296296

297297
The `@theme/PwaReloadPopup` component is rendered when a new service worker is waiting to be installed, and we suggest a reload to the user. You can [swizzle](../../swizzling.mdx) this component and implement your own UI. It will receive an `onReload` callback as props, which should be called when the `reload` button is clicked. This will tell the service worker to install the waiting service worker and reload the page.
298298

299-
The default theme includes an implementation for the reload popup and uses [Infima Alerts](https://infima.dev/docs/components/alert).
299+
The default theme includes an implementation for the reload popup and uses [Infima Alerts](/infima/components/alert).
300300

301301
![A screen recording of the reload process. An alert box shows in the bottom right of the window, saying "New content available". After clicking the "Refresh" button, the page's main heading changes from "Introduction" to "PWA :))".](/img/pwa_reload.gif)
302302

‎website/docs/api/themes/theme-configuration.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ export default {
820820

821821
You can set the static Navbar style without disabling the theme switching ability. The selected style will always apply no matter which theme user have selected.
822822

823-
Currently, there are two possible style options: `dark` and `primary` (based on the `--ifm-color-primary` color). You can see the styles preview in the [Infima documentation](https://infima.dev/docs/components/navbar/).
823+
Currently, there are two possible style options: `dark` and `primary` (based on the `--ifm-color-primary` color). You can see the styles preview in the [Infima documentation](/infima/components/navbar).
824824

825825
```js title="docusaurus.config.js"
826826
export default {

0 commit comments

Comments
 (0)