Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/argos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ jobs:
run: pnpm argos:format:text-snapshots
- name: Upload Argos text snapshots
run: pnpm argos:upload:text-snapshots

# pnpm install builds the Infima CSS files
- name: Upload Argos Infima CSS snapshots
run: pnpm argos:upload:infima
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/eslint-plugin/lib/
packages/stylelint-copyright/lib/
packages/docusaurus-infima/dist/

website/changelog

Expand Down
1 change: 1 addition & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"!packages/docusaurus-*/lib/theme/",

"packages/create-docusaurus/templates/*/docusaurus.config.js",
"packages/docusaurus-infima/styles",
"packages/eslint-plugin/lib/",
"packages/stylelint-copyright/lib/",
"__fixtures__",
Expand Down
1 change: 1 addition & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ packages/lqip-loader/lib/
packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/create-docusaurus/lib/*
packages/docusaurus-infima/dist/
packages/create-docusaurus/templates/
website/static/katex/katex.min.css
website/_dogfooding/_asset-tests/badSyntax.css
12 changes: 11 additions & 1 deletion argos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This workspace can be run manually, but is generally run through the [Argos GitH

This workflow runs for `main` and PR branches, and add a commit status to each PR with a visual diff that we can easily inspect.

The workflow execute the 2 main steps below:
The workflow execute the 3 main steps below:

### Screenshots

Expand All @@ -22,6 +22,10 @@ The workflow execute the 2 main steps below:
- Rebuild - this time with HTML unminified/formatted.
- Upload [HTML/CSS/JS files, blog feeds (RSS/Atom/JSON) and the sitemap to also diff them on Argos](https://argos-ci.com/docs/learn/how-to-guides/visual-coverage/compare-non-image-files) using `pnpm argos:upload:text-snapshots`

### Infima CSS

- Upload the CSS files compiled by [`@docusaurus/infima`](../packages/docusaurus-infima) (LTR and RTL) to diff them on Argos, in a separate `infima` build, using `pnpm argos:upload:infima`

## Run manually

Install the Playwright browser once:
Expand All @@ -45,6 +49,12 @@ pnpm argos:format:text-snapshots
pnpm argos:upload:text-snapshots
```

To run the Infima CSS step manually (`pnpm install` already builds the files):

```bash
pnpm argos:upload:infima
```

## How to modify

- Use [./tests/screenshot.spec.ts](./tests/screenshot.spec.ts) to customize the screenshots we take, eventually filter out some useless sitemap pages like versioned docs
Expand Down
1 change: 1 addition & 0 deletions argos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"screenshot": "playwright test",
"upload": "pnpm exec -- argos upload ./screenshots/chromium",
"upload-text-snapshots": "pnpm exec -- argos upload \"../website/build\" --build-name text-snapshots --files styles.css --files \"docs/**/*.html\" --files \"blog/**/*.html\" --files \"**/rss.xml\" --files \"**/atom.xml\" --files \"**/feed.json\" --files sitemap.xml",
"upload-infima": "pnpm exec -- argos upload ../packages/docusaurus-infima/dist --build-name infima --files \"*.css\"",
"report": "playwright show-report"
},
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
"crowdin:upload:website": "crowdin upload sources --config ./crowdin-v2.yaml",
"crowdin:download": "crowdin download --config ./crowdin-v2.yaml",
"crowdin:download:website": "pnpm crowdin:download --language fr --language ko --language pt-BR --language zh-CN --language ja",
"argos": "pnpm argos:build && pnpm argos:screenshot && pnpm argos:build:text-snapshots && pnpm argos:format:text-snapshots && pnpm argos:upload:text-snapshots",
"argos": "pnpm argos:build && pnpm argos:screenshot && pnpm argos:build:text-snapshots && pnpm argos:format:text-snapshots && pnpm argos:upload:text-snapshots && pnpm argos:upload:infima",
"argos:build": "cross-env DOCUSAURUS_ARGOS_BUILD=true pnpm build:website:fast --dev",
"argos:screenshot": "pnpm --filter argos screenshot",
"argos:build:text-snapshots": "cross-env DOCUSAURUS_ARGOS_BUILD=true SKIP_HTML_MINIFICATION=true pnpm build:website:fast --dev --no-minify",
"argos:format:text-snapshots": "node argos/normalizeTextSnapshots.mjs && pnpm format:website:build",
"argos:upload:text-snapshots": "pnpm --filter argos upload-text-snapshots",
"argos:upload:infima": "pnpm --filter argos upload-infima",
"canary": "pnpm canary:bumpVersion && pnpm canary:publish",
"canary:getCoreVersion": "node -p \"require('./packages/docusaurus/package.json').version.split('-')[0]\"",
"canary:version": "echo `pnpm --silent canary:getCoreVersion`-canary-`git rev-list --count HEAD`+`git rev-parse --short HEAD`",
Expand Down
9 changes: 9 additions & 0 deletions packages/docusaurus-infima/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# `@docusaurus/infima`

The Infima CSS framework, an internal package of `@docusaurus/theme-classic`.

Don't depend on it directly: it has no stability guarantee, except for the `--ifm-*` CSS variables and the documented class names. The Infima documentation moves to [docusaurus.io/infima](https://docusaurus.io/infima).

## Origin

The `styles` sources come from the former upstream repository at commit [`87bc1dbf`](https://github.com/facebookincubator/infima/tree/87bc1dbfde5dfb2a70b5ff105b5f2f5ee130c2ab): they are the same as the published `infima@0.2.0-alpha.45` package. `scripts/build.mjs` inlines its [PostCSS preset](https://github.com/facebookincubator/infima/blob/87bc1dbfde5dfb2a70b5ff105b5f2f5ee130c2ab/packages/postcss-preset-infima/index.js).
45 changes: 45 additions & 0 deletions packages/docusaurus-infima/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@docusaurus/infima",
"version": "4.0.0",
"description": "Infima CSS framework, used by the Docusaurus classic theme.",
"sideEffects": [
"*.css"
],
"exports": {
"./infima.css": "./dist/infima.css",
"./infima-rtl.css": "./dist/infima-rtl.css",
"./package.json": "./package.json"
},
"files": [
"dist"
],
"scripts": {
"build": "node scripts/build.mjs"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/meta/docusaurus.git",
"directory": "packages/docusaurus-infima"
},
"license": "MIT",
"devDependencies": {
"postcss": "catalog:",
"postcss-color-mod-function": "catalog:dev",
"postcss-combine-duplicated-selectors": "catalog:dev",
"postcss-each": "catalog:dev",
"postcss-for": "catalog:dev",
"postcss-import": "catalog:dev",
"postcss-mixins": "catalog:dev",
"postcss-nested": "catalog:dev",
"postcss-nested-ancestors": "catalog:dev",
"postcss-preset-env-v7": "catalog:dev",
"postcss-sort-media-queries": "catalog:dev",
"rtlcss": "catalog:"
},
"engines": {
"node": ">=26.13"
}
}
87 changes: 87 additions & 0 deletions packages/docusaurus-infima/scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

// Inlines the upstream postcss-preset-infima and the gulp styles and rtl tasks
// See https://github.com/facebookincubator/infima/blob/87bc1dbfde5dfb2a70b5ff105b5f2f5ee130c2ab/packages/postcss-preset-infima/index.js

import fs from 'node:fs/promises';
import path from 'node:path';
import postcss from 'postcss';
import postcssColorModFunction from 'postcss-color-mod-function';
import postcssCombineDuplicatedSelectors from 'postcss-combine-duplicated-selectors';
import postcssEach from 'postcss-each';
import postcssFor from 'postcss-for';
import postcssImport from 'postcss-import';
import postcssMixins from 'postcss-mixins';
import postcssNested from 'postcss-nested';
import postcssNestedAncestors from 'postcss-nested-ancestors';
import postcssPresetEnv from 'postcss-preset-env-v7';
import postcssSortMediaQueries from 'postcss-sort-media-queries';
import rtlcss from 'rtlcss';

const packageDir = path.dirname(import.meta.dirname);
const entryFile = path.join(packageDir, 'styles/themes/default/default.pcss');
const outputFile = path.join(packageDir, 'dist/infima.css');
const rtlOutputFile = path.join(packageDir, 'dist/infima-rtl.css');

async function main() {
const source = await fs.readFile(entryFile, 'utf8');
const css = await compileInfima(source, entryFile);
await fs.mkdir(path.dirname(outputFile), {recursive: true});
await fs.writeFile(outputFile, css);
await fs.writeFile(rtlOutputFile, rtlcss.process(css));
}

async function compileInfima(source, from) {
const result = await postcss(getPlugins()).process(source, {from});
return result.css;
}

// The plugin order matters
function getPlugins() {
return [
postcssImport,
// TODO postcss-each v1 doesn't seem to be compatible due to color-mod.
// Need to upgrade later
postcssEach,
postcssFor,
postcssMixins({mixins: {transition: transitionMixin}}),
postcssNestedAncestors,
postcssNested,
// color-mod has been removed from the spec, so it's not included in
// preset-env. Using a separate plugin instead. We probably would eventually
// get rid of color-mod
postcssColorModFunction({unresolved: 'ignore'}),
postcssPresetEnv({
stage: 1,
features: {
'custom-properties': false,
},
}),
postcssSortMediaQueries,
postcssCombineDuplicatedSelectors,
];
}

// @mixin transition opacity visibility, var(--ifm-transition-fast), linear;
function transitionMixin(
_mixin,
properties,
duration = 'var(--ifm-transition-fast)',
timing = 'var(--ifm-transition-timing-default)',
) {
if (properties.includes(' ')) {
return {
'transition-property': properties.replace(/\s/g, ', '),
'transition-duration': duration,
'transition-timing-function': timing,
};
}
return {transition: [properties, duration, timing].join(' ')};
}

await main();
32 changes: 32 additions & 0 deletions packages/docusaurus-infima/styles/common/base.pcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

* {
box-sizing: border-box;
}

html {
background-color: var(--ifm-background-color);
color: var(--ifm-font-color-base);
color-scheme: var(--ifm-color-scheme);
font: var(--ifm-font-size-base) / var(--ifm-line-height-base)
var(--ifm-font-family-base);
-webkit-font-smoothing: antialiased;
-webkit-tap-highlight-color: transparent;
text-rendering: optimizelegibility;
text-size-adjust: 100%;
}

body {
margin: 0;
overflow-wrap: break-word;
}

iframe {
border: 0;
color-scheme: auto;
}
54 changes: 54 additions & 0 deletions packages/docusaurus-infima/styles/common/dark-mode.pcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

html[data-theme='dark'] {
--ifm-color-scheme: dark;

--ifm-color-emphasis-0: var(--ifm-color-gray-1000);
--ifm-color-emphasis-100: var(--ifm-color-gray-900);
--ifm-color-emphasis-200: var(--ifm-color-gray-800);
--ifm-color-emphasis-300: var(--ifm-color-gray-700);
--ifm-color-emphasis-400: var(--ifm-color-gray-600);
--ifm-color-emphasis-500: var(--ifm-color-gray-500);
--ifm-color-emphasis-600: var(--ifm-color-gray-400);
--ifm-color-emphasis-700: var(--ifm-color-gray-300);
--ifm-color-emphasis-800: var(--ifm-color-gray-200);
--ifm-color-emphasis-900: var(--ifm-color-gray-100);
--ifm-color-emphasis-1000: var(--ifm-color-gray-0);

--ifm-background-color: #1b1b1d;
--ifm-background-surface-color: #242526;

--ifm-hover-overlay: rgba(255, 255, 255, 0.05);

--ifm-color-content: #e3e3e3;
--ifm-color-content-secondary: rgba(255, 255, 255, 1);

--ifm-breadcrumb-separator-filter: invert(64%) sepia(11%) saturate(0%)
hue-rotate(149deg) brightness(99%) contrast(95%);

--ifm-code-background: rgba(255, 255, 255, 0.1);

--ifm-scrollbar-track-background-color: #444444;
--ifm-scrollbar-thumb-background-color: #686868;
--ifm-scrollbar-thumb-hover-background-color: #7a7a7a;

--ifm-table-stripe-background: rgba(255, 255, 255, 0.07);

--ifm-toc-border-color: var(--ifm-color-emphasis-200);

@each $color in (primary, secondary, success, info, warning, danger) {
--ifm-color-$(color)-contrast-background: color-mod(
var(--ifm-color-$(color)),
shade(var(--ifm-contrast-background-dark-value))
);
--ifm-color-$(color)-contrast-foreground: color-mod(
var(--ifm-color-$(color)),
tint(var(--ifm-contrast-foreground-dark-value))
);
}
}
Loading
Loading