Skip to content

Prettier enhancements: handle more file types & improve loading states #184

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

VirtualDOMinic
Copy link
Contributor

Covers issue #183
Also relates to issue #176

Enhancements in this PR:

  • Gives prettier button state (pre, during, finished, error)
  • Handles more filetypes (e.g. ts, css, json)
  • Hides prettier button if we cannot format file

See comments left inline, too!

Dominic Coelho added 2 commits March 5, 2020 09:49
- Add to prettier state (text and icons)
- Extract prettier logic to util file
- Set correct parder for a few common filetypes beyond js
- Hide the prettier button if not able to process the file type
Comment on lines +156 to +159
setPrettierButtonState(afterPrettierState);
} catch (e) {
console.error(e);
setPrettierButtonState(errorPrettierState);
Copy link

Choose a reason for hiding this comment

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

💭 put the button state setting in the UI component? better separation of concerns?

Copy link

Choose a reason for hiding this comment

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

💭 right after the call to loadPrettierParserScriptForExtension?
https://github.com/FormidableLabs/runpkg/pull/184/files#diff-bb8820440d0617732459bfe856f864abR42

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm 50/50 about this! On one hand it could be nice to keep the setStates in the component where the useState is used instead of passing the setter to this file, but on the other hand I feel this way keeps the Article component less cluttered (and is a bit easier).

Open to going the route you suggest though 🤔. Might see what others think

Comment on lines +25 to +52
const beforePrettierState = {
message: prettierButtonMessages.before,
disabled: false, // redundant?
icon: PrettierIcon,
};

const duringPrettierState = {
message: prettierButtonMessages.during,
disabled: true,
icon: LoadingIcon,
};

const afterPrettierState = {
message: prettierButtonMessages.after,
disabled: true,
icon: CheckMarkIcon,
};

const errorPrettierState = {
message: prettierButtonMessages.error,
disabled: true,
icon: ErrorIcon,
};

const cannotPrettierState = {
hidden: true,
icon: null,
};
Copy link

Choose a reason for hiding this comment

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

🆒 way to handle the UI states

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤗 Yeah I prefer the neatness of having these separated out clearly! Probably influenced by TS enums and Redux

@kiraarghy
Copy link
Contributor

@lukejacksonn could you close this PR/ remove me as a reviewer please 😊

@hartzis hartzis removed the request for review from kiraarghy July 19, 2021 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants