Skip to content

Commit 80309ca

Browse files
authored
Merge branch 'master' into add-themed-image-component
2 parents db09dd5 + 73f151d commit 80309ca

26 files changed

Lines changed: 533 additions & 2175 deletions

File tree

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"serve:v2:ssl:message": "echo '\n\n\nServing Docusaurus with HTTPS on localhost requires to disable the Chrome security: chrome://flags/#allow-insecure-localhost\n\n\n'",
3030
"serve:v2:ssl:serve": "serve website/build --ssl-cert ./website/.docusaurus/selfsigned.crt --ssl-key ./website/.docusaurus/selfsigned.key",
3131
"changelog": "lerna-changelog",
32-
"postinstall": "yarn build:packages",
32+
"postinstall": "yarn lock:update && yarn build:packages",
3333
"prettier": "prettier --config .prettierrc --write \"**/*.{js,ts}\"",
3434
"prettier:diff": "prettier --config .prettierrc --list-different \"**/*.{js,ts}\"",
3535
"prettier-docs": "prettier --config .prettierrc --write \"**/*.md\"",
@@ -40,7 +40,7 @@
4040
"test": "jest",
4141
"test:build:v2": "./admin/scripts/test-release.sh",
4242
"watch": "yarn lerna run --parallel --no-private watch",
43-
"clear": "yarn workspace docusaurus-2-website clear && yarn lerna exec 'yarn rimraf lib' --ignore docusaurus",
43+
"clear": "yarn workspace docusaurus-2-website clear && yarn lerna exec --ignore docusaurus yarn rimraf lib",
4444
"test:v1Migration:migrate": "rimraf website-1.x-migrated && docusaurus-migrate migrate ./website-1.x ./website-1.x-migrated && sed -i -- 's/docusaurus-1-website/docusaurus-1-website-migrated/g;' website-1.x-migrated/package.json",
4545
"test:v1Migration:start": "yarn workspace docusaurus-1-website-migrated start",
4646
"test:v1Migration:build": "yarn workspace docusaurus-1-website-migrated build",
@@ -51,7 +51,8 @@
5151
"netlify:deployPreview:v1:moveBuild": "mv website-1.x/build/docusaurus website/netlifyDeployPreview/v1",
5252
"netlify:deployPreview:v1-migrated": "yarn test:v1Migration:migrate && yarn netlify:deployPreview:v1-migrated:setBaseUrl && yarn netlify:deployPreview:v1-migrated:build",
5353
"netlify:deployPreview:v1-migrated:setBaseUrl": "sed -i -e 's,\"baseUrl\": \"/\",\"baseUrl\": \"/v1-migrated/\",g' ./website-1.x-migrated/docusaurus.config.js",
54-
"netlify:deployPreview:v1-migrated:build": "yarn workspace docusaurus-1-website-migrated build --out-dir=../website/netlifyDeployPreview/v1-migrated"
54+
"netlify:deployPreview:v1-migrated:build": "yarn workspace docusaurus-1-website-migrated build --out-dir=../website/netlifyDeployPreview/v1-migrated",
55+
"lock:update": "npx yarn-deduplicate"
5556
},
5657
"devDependencies": {
5758
"@babel/cli": "^7.12.1",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
const advancedBasePreset = require('cssnano-preset-advanced');
9+
const postCssCombineDuplicatedSelectors = require('postcss-combine-duplicated-selectors');
10+
const postCssSortMediaQueries = require('postcss-sort-media-queries');
11+
const postCssRemoveOverriddenCustomProperties = require('./src/remove-overridden-custom-properties');
12+
13+
const preset = advancedBasePreset({autoprefixer: {add: true}});
14+
15+
preset.plugins.unshift(
16+
[postCssCombineDuplicatedSelectors, {removeDuplicatedProperties: true}],
17+
[postCssSortMediaQueries],
18+
[postCssRemoveOverriddenCustomProperties],
19+
);
20+
21+
module.exports = preset;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "@docusaurus/cssnano-preset",
3+
"version": "2.0.0-alpha.66",
4+
"description": "Advanced cssnano preset for maximum optimization",
5+
"main": "index.js",
6+
"license": "MIT",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/facebook/docusaurus.git",
10+
"directory": "packages/docusaurus-cssnano-preset"
11+
},
12+
"dependencies": {
13+
"postcss": "^7.0.2",
14+
"postcss-combine-duplicated-selectors": "^9.1.0",
15+
"postcss-sort-media-queries": "^1.7.26",
16+
"cssnano-preset-advanced": "^4.0.7"
17+
},
18+
"devDependencies": {
19+
"to-vfile": "^6.0.0"
20+
}
21+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`remove-overridden-custom-properties overridden custom properties should be removed 1`] = `
4+
":root {
5+
--color-secondary: green;
6+
--color-primary: blue;
7+
--color-header: gray;
8+
}
9+
"
10+
`;
11+
12+
exports[`remove-overridden-custom-properties overridden custom properties with \`!important\` rule should not be removed 1`] = `
13+
":root {
14+
--color-primary: blue;
15+
--color-header: gray !important;
16+
--color-secondary: yellow !important;
17+
}
18+
"
19+
`;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
:root {
2+
--color-primary: red;
3+
--color-secondary: green;
4+
--color-primary: blue;
5+
--color-header: gray !important;
6+
--color-header: black;
7+
--color-secondary: yellow !important;
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:root {
2+
--color-primary: red;
3+
--color-primary: red;
4+
--color-secondary: green;
5+
--color-primary: blue;
6+
--color-header: gray;
7+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
const path = require('path');
9+
const vfile = require('to-vfile');
10+
const postcss = require('postcss');
11+
const postCssRemoveOverriddenCustomProperties = require('../index');
12+
13+
const processFixture = (name) => {
14+
const input = vfile.readSync(
15+
path.join(__dirname, 'fixtures', `${name}.css`),
16+
'utf8',
17+
);
18+
const output = postcss([postCssRemoveOverriddenCustomProperties]).process(
19+
input,
20+
);
21+
22+
return output.css;
23+
};
24+
25+
describe('remove-overridden-custom-properties', () => {
26+
test('overridden custom properties should be removed', () => {
27+
expect(processFixture('normal')).toMatchSnapshot();
28+
});
29+
30+
test('overridden custom properties with `!important` rule should not be removed', () => {
31+
expect(processFixture('important_rule')).toMatchSnapshot();
32+
});
33+
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
const postcss = require('postcss');
9+
10+
/*
11+
This PostCSS plugin will remove duplicate/same custom properties (which are actually overridden ones) **only** from `:root` selector.
12+
13+
Depending on the presence of an `!important` rule in value of custom property, the following actions will happens:
14+
15+
- If the same custom properties do **not** have an `!important` rule, then all of them will be removed except for the last one (which will actually be applied).
16+
- If the same custom properties have at least one `!important` rule, then only those properties that do not have this rule will be removed.
17+
*/
18+
19+
module.exports = postcss.plugin(
20+
'postcss-remove-overridden-custom-properties',
21+
() => {
22+
return (root) => {
23+
root.walkDecls((decl) => {
24+
if (decl.parent.selector !== ':root') {
25+
return;
26+
}
27+
28+
const sameProperties =
29+
decl.parent.nodes.filter((n) => n.prop === decl.prop) || [];
30+
const hasImportantProperties = sameProperties.some((p) =>
31+
p.hasOwnProperty('important'),
32+
);
33+
34+
const overriddenProperties = hasImportantProperties
35+
? sameProperties.filter((p) => !p.hasOwnProperty('important'))
36+
: sameProperties.slice(0, -1);
37+
38+
overriddenProperties.map((p) => p.remove());
39+
});
40+
};
41+
},
42+
);

packages/docusaurus-theme-classic/src/theme/CodeBlock/styles.module.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@
4545
}
4646

4747
.codeBlockTitle:hover + .codeBlockContent .copyButton,
48-
.codeBlockContent:hover > .copyButton {
49-
outline: none;
50-
opacity: 1;
51-
}
52-
48+
.codeBlockContent:hover > .copyButton,
5349
.copyButton:focus {
5450
opacity: 1;
5551
}

packages/docusaurus-theme-classic/src/theme/DocSidebar/styles.module.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,9 @@
107107
width: 24px;
108108
}
109109

110-
/* TODO: Move to Infima */
111110
:global(.menu__list) :global(.menu__list) {
112111
overflow-y: hidden;
113112
will-change: height;
114-
/* Same as "arrow" transition */
115113
transition: height var(--ifm-transition-fast) linear;
116114
}
117115

0 commit comments

Comments
 (0)