-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix: OPTIC-2016: Removing AntD reset to aid in UI consistency between page navigations #7420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
eb24047
fix: OPTIC-2016: Removing AntD reset to aid in UI consistency between…
bmartel 7c4fb46
update build to ignore this generated file when applying css prefixing
bmartel bf2c80e
fix the extract script to work as a node_module sourcedep
bmartel b304671
fix Dockerfile to support the extract antd command
bmartel 28bedd4
Merge remote-tracking branch 'origin/develop' into fb-optic-2016
bmartel 43a5547
fix Dockerfile indentation
bmartel b2ca20f
changing package.json of editor and datamanager to avoid version mism…
bmartel 45c9eff
increasing timeout of lsf:serve
bmartel f5f6bf7
commit the resultant antd-no-reset.css file
bmartel e2ea609
revert the change to wait timeout for the lsf:serve command
bmartel 1d5256c
revert change to have Dockerfile run the antd-no-reset generation com…
bmartel 17f0f77
Update .stylelintignore
bmartel d1e4207
fixing the formatting of this file
bmartel 50f366c
Merge branch 'fb-optic-2016' of github.com:HumanSignal/label-studio i…
bmartel dd4714e
Update web/webpack.config.js
bmartel 2b5b074
linting
bmartel d7ce03f
extending the timeout, it was failing because of becoming a couple se…
bmartel 631f389
fix the test server to actually pull in the correct styles
bmartel 3d2e9ad
fix styles in editor standalone test server
bmartel 660b997
make all audio region tests pass
bmartel 83c5efc
fix webaudio regions test
bmartel 6b02183
fix image selected brush test
bmartel 42436a5
fix image zoom tests
bmartel 1b8641b
Merge remote-tracking branch 'origin/develop' into fb-optic-2016
bmartel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
libs/editor/src/assets/styles/_antd-no-reset.scss |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_antd-no-reset.scss |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Extract AntD with no CSS Reset | ||
|
||
This command allows for usage of AntD components without causing style conflicts on global style concerns. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env node | ||
|
||
import "./extract-antd-no-reset.mjs"; |
145 changes: 145 additions & 0 deletions
145
web/tools/extract-antd-no-reset/extract-antd-no-reset.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { fileURLToPath } from "node:url"; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
// Paths | ||
const findNearestNodeModules = (dir) => { | ||
const nodeModulesPath = path.join(dir, "node_modules"); | ||
if (fs.existsSync(nodeModulesPath)) { | ||
return nodeModulesPath; | ||
} | ||
const parentDir = path.dirname(dir); | ||
if (parentDir === dir) { | ||
throw new Error("No node_modules directory found"); | ||
} | ||
return findNearestNodeModules(parentDir); | ||
}; | ||
|
||
const nodeModulesPath = findNearestNodeModules(__dirname); | ||
const sourcePath = path.join(nodeModulesPath, "./antd/dist/antd.css"); | ||
if (!fs.existsSync(sourcePath)) { | ||
throw new Error("Source file not found: " + sourcePath); | ||
} | ||
let targetDirPath = path.join(nodeModulesPath, "@humansignal/editor/src/assets/styles"); | ||
if (!fs.existsSync(targetDirPath)) { | ||
if (fs.existsSync(path.join(__dirname, "../../libs/editor/src/assets/styles"))) { | ||
targetDirPath = path.join(__dirname, "../../libs/editor/src/assets/styles"); | ||
} | ||
} | ||
|
||
const targetPath = path.join(targetDirPath, "./_antd-no-reset.scss"); | ||
|
||
// Read the source file | ||
const sourceContent = fs.readFileSync(sourcePath, "utf8"); | ||
|
||
// Extract header and add our custom comments | ||
const header = `/*! | ||
* | ||
* antd v4.24.15 (without CSS reset) | ||
* | ||
* Copyright 2015-present, Alipay, Inc. | ||
* All rights reserved. | ||
* | ||
* Modified version to exclude global resets | ||
* | ||
*/ | ||
/* stylelint-disable */ | ||
|
||
/* This is a modified version of antd.css that excludes global reset styles */ | ||
`; | ||
|
||
// These are CSS reset selectors we want to remove | ||
const resetSelectors = [ | ||
/^html,\s*body\s*{[\s\S]*?}/m, | ||
/^input::-ms-clear,\s*input::-ms-reveal\s*{[\s\S]*?}/m, | ||
/^\*,\s*\*::before,\s*\*::after\s*{[\s\S]*?}/m, | ||
/^html\s*{[\s\S]*?}/m, | ||
/^@-ms-viewport\s*{[\s\S]*?}/m, | ||
/^body\s*{[\s\S]*?}/m, | ||
/^\[tabindex='-1'\]:focus\s*{[\s\S]*?}/m, | ||
/^hr\s*{[\s\S]*?}/m, | ||
/^h1,\s*h2,\s*h3,\s*h4,\s*h5,\s*h6\s*{[\s\S]*?}/m, | ||
/^p\s*{[\s\S]*?}/m, | ||
/^abbr\[title\],\s*abbr\[data-original-title\]\s*{[\s\S]*?}/m, | ||
/^address\s*{[\s\S]*?}/m, | ||
/^input\[type='text'\],[\s\S]*?textarea\s*{[\s\S]*?}/m, | ||
/^ol,\s*ul,\s*dl\s*{[\s\S]*?}/m, | ||
/^ol ol,[\s\S]*?ul ol\s*{[\s\S]*?}/m, | ||
/^dt\s*{[\s\S]*?}/m, | ||
/^dd\s*{[\s\S]*?}/m, | ||
/^blockquote\s*{[\s\S]*?}/m, | ||
/^dfn\s*{[\s\S]*?}/m, | ||
/^b,\s*strong\s*{[\s\S]*?}/m, | ||
/^small\s*{[\s\S]*?}/m, | ||
/^sub,\s*sup\s*{[\s\S]*?}/m, | ||
/^sub\s*{[\s\S]*?}/m, | ||
/^sup\s*{[\s\S]*?}/m, | ||
/^a\s*{[\s\S]*?}/m, | ||
/^a:hover\s*{[\s\S]*?}/m, | ||
/^a:active\s*{[\s\S]*?}/m, | ||
/^a:active,\s*a:hover\s*{[\s\S]*?}/m, | ||
/^a:focus\s*{[\s\S]*?}/m, | ||
/^a\[disabled\]\s*{[\s\S]*?}/m, | ||
/^pre,\s*code,\s*kbd,\s*samp\s*{[\s\S]*?}/m, | ||
/^pre\s*{[\s\S]*?}/m, | ||
/^figure\s*{[\s\S]*?}/m, | ||
/^img\s*{[\s\S]*?}/m, | ||
/^a,\s*area,[\s\S]*?textarea\s*{[\s\S]*?}/m, | ||
/^table\s*{[\s\S]*?}/m, | ||
/^caption\s*{[\s\S]*?}/m, | ||
/^input,\s*button,[\s\S]*?textarea\s*{[\s\S]*?}/m, | ||
/^button,\s*input\s*{[\s\S]*?}/m, | ||
/^button,\s*select\s*{[\s\S]*?}/m, | ||
/^button,\s*html \[type="button"\],[\s\S]*?\[type="submit"\]\s*{[\s\S]*?}/m, | ||
/^button::-moz-focus-inner,[\s\S]*?\[type='submit'\]::-moz-focus-inner\s*{[\s\S]*?}/m, | ||
/^input\[type='radio'\],\s*input\[type='checkbox'\]\s*{[\s\S]*?}/m, | ||
/^input\[type='date'\],[\s\S]*?input\[type='month'\]\s*{[\s\S]*?}/m, | ||
/^textarea\s*{[\s\S]*?}/m, | ||
/^fieldset\s*{[\s\S]*?}/m, | ||
/^legend\s*{[\s\S]*?}/m, | ||
/^progress\s*{[\s\S]*?}/m, | ||
/^\[type='number'\]::-webkit-inner-spin-button,\s*\[type='number'\]::-webkit-outer-spin-button\s*{[\s\S]*?}/m, | ||
/^\[type='search'\]\s*{[\s\S]*?}/m, | ||
/^\[type='search'\]::-webkit-search-cancel-button,\s*\[type='search'\]::-webkit-search-decoration\s*{[\s\S]*?}/m, | ||
/^::-webkit-file-upload-button\s*{[\s\S]*?}/m, | ||
/^output\s*{[\s\S]*?}/m, | ||
/^summary\s*{[\s\S]*?}/m, | ||
/^template\s*{[\s\S]*?}/m, | ||
/^\[hidden\]\s*{[\s\S]*?}/m, | ||
/^mark\s*{[\s\S]*?}/m, | ||
/^::-moz-selection\s*{[\s\S]*?}/m, | ||
/^::selection\s*{[\s\S]*?}/m, | ||
]; | ||
|
||
// Process the content | ||
let modifiedContent = sourceContent; | ||
|
||
// Remove reset selectors one by one | ||
resetSelectors.forEach((selector) => { | ||
modifiedContent = modifiedContent.replace(selector, ""); | ||
}); | ||
|
||
// Clean up multiple blank lines | ||
modifiedContent = modifiedContent.replace(/\n{3,}/g, "\n\n"); | ||
|
||
// Replace the original header with our custom header | ||
modifiedContent = modifiedContent.replace(/\/\*![\s\S]*?Alipay[\s\S]*?\*\//, header); | ||
|
||
// Remove any other stylelint-disable comments (except the one in our header) | ||
const headerEndPos = modifiedContent.indexOf("/* This is a modified version"); | ||
const contentAfterHeader = modifiedContent.substring(headerEndPos); | ||
const contentWithoutStylelintComments = contentAfterHeader.replace(/\/\* stylelint-disable[\s\S]*?\*\//g, ""); | ||
|
||
// Combine our header with the cleaned content | ||
modifiedContent = modifiedContent.substring(0, headerEndPos) + contentWithoutStylelintComments; | ||
|
||
// Clean up multiple blank lines again after removing comments | ||
modifiedContent = modifiedContent.replace(/\n{3,}/g, "\n\n"); | ||
|
||
// Write the result to the target file | ||
fs.writeFileSync(targetPath, modifiedContent, "utf8"); | ||
|
||
console.log("Generated antd-no-reset.css successfully!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "@humansignal/extract-antd-no-reset", | ||
"version": "0.0.1", | ||
"description": "Extract AntD with no CSS reset", | ||
"type": "module", | ||
"main": "extract-antd-no-reset.mjs", | ||
"bin": { | ||
"extract-antd-no-reset": "./extract-antd-no-reset.mjs" | ||
}, | ||
"license": "MIT", | ||
"dependencies": {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.