Skip to content
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

Replace generated complex CSS with handcrafted CSS #291

Merged

Conversation

lpardosixtosMs
Copy link
Contributor

@lpardosixtosMs lpardosixtosMs commented Jul 28, 2023

We are replacing the current auto-generated CSS rules for the complex DOM with a smaller number of handcrafted rules (see supporting doc.

Changes to the complex DOM generator:

  • Removes the CSS random generator and the previous generated rules.
  • Adds and modifies existing popovers to the complex DOM UI.
  • Styles existing and new popovers with non-matching CSS rules (Rules that partially match some element in the todoMVC list items). big-dom-generator/src/app.css.
  • General complex DOM code cleanup and refactoring.
  • Modifies the build script accordingly.
  • Adds the modified todomvc CSS that contains the targeted rules, the complex version doesn't consume the same css as the standalone versions anymore. big-dom-generator/utils/app.css

Changes to the standalone version:

  • Adds a data-priority attribute to the todoMVC list items that will be used to provide additional styling using new handcrafted CSS.

Changes to the complex versions:

  • Small modifications to the build scripts.
  • Rebuilds on top of the generator and standalone changes.

Hosted version (with all complex todoMVC variations enabled): https://lpardosixtosms.github.io/SpeedometerComplexHandcraftedAll/?developerMode=&tags=todomvc&measurementMethod=timer#home


---------

Co-authored-by: Luis Fernando Pardo Sixtos <lpardosixtos@microsoft.com>
Co-authored-by: lpardosixtosMs <94007365+lpardosixtosMs@users.noreply.github.com>
@lpardosixtosMs
Copy link
Contributor Author

Comparison before and after the change.
Before:
results-before

After:
results-after

@lpardosixtosMs lpardosixtosMs marked this pull request as ready for review July 28, 2023 18:13
@lpardosixtosMs
Copy link
Contributor Author

@rniwa @bgrins @flashdesignory PTAL. This looks like a big change, but it is mostly refactoring and adding things to the complex DOM, the most important files to review are big-dom-generator/src/app.css and big-dom-generator/utils/app.css, which contain the handcrafted complex CSS; and also the changes to the standalone versions.

We still need to remove the extra class names that we previously added to the standalone versions, but we can do it in a follow up PR.

@lpardosixtosMs
Copy link
Contributor Author

Styled popovers:
image
image
image
image
image
image
image

@bgrins
Copy link
Contributor

bgrins commented Aug 1, 2023

From a high level this looks like a good change. In addition to being a simplification, having the rules apply visual effects (like prioritized items) is an improvement. I haven't gone through all the CSS in the PR but wanted to signal support from a first pass review.

Copy link
Contributor

@flashdesignory flashdesignory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't run it locally, but changes make sense

Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also looks reasonable to me.

* Move reused logic into buildComplex Util function
* Update build scripts
fs.copyFileSync(sourcePath, targetPath);
}

if (cssFilePath) {
// get the name of the css file that's in the dist, we do this because the name of the css file may change
const cssFile = fs.readdirSync(path.join(callerDirectory, sourceDirectory, cssFolder), { withFileTypes: true }).find((dirent) => dirent.isFile() && cssFileNamePattern.test(dirent.name))?.name;
Copy link
Contributor

@julienw julienw Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that this project is ignored by eslint and prettier (see .eslintignore and .prettierignore), it would probably be good to not ignore the handcrafted files such as this one and the others such as the handcrafted CSS file.

Could you either add the handcrafted files or ignore just the generated files, and run the formatter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good if you want to do this in a follow-up to more clearly distinguish the concerns.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC this project is not ignored, both the rules added to the .prettierignore and .eslintignore both start with "!".

I also see these files in the output when I run the formatter.
image

I can remove the rules I added previously in a follow-up since they aren't needed and I already have a follow-up PR in the works.

!/resources/todomvc/big-dom-generator

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right I got confused.
Our project's prettier is configured with printWidth: 250. I find this too long and got confused by this long line, but looks like this is accepted by prettier then...
Maybe you could split it up a bit still, up to you.

Comment on lines +11 to +13
cssFilePath,
cssFolder = "", // sometimes the css file we are looking for may be nested in another folder.
cssFileNamePattern, // The css file name pattern is used to find the css file in the source dist directory.
Copy link
Contributor

@julienw julienw Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe write clearly in a comment that cssFileNamePattern is mandatory if cssFilePath is present? Maybe it could even be good to check this in the code and throw an intelligible error if that's absent, but I'll let you choose if you want to implement this improvement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will include in the follow-up which touches these files, I like the improvement.

Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ with these changes

@issackjohn
Copy link
Contributor

Thank you everyone for your reviews, merging this now.

@issackjohn issackjohn merged commit 5107c73 into WebKit:main Aug 15, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants