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

[WIP] Qase v.0.1 #2

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open

[WIP] Qase v.0.1 #2

wants to merge 43 commits into from

Conversation

prestonalexwebster
Copy link
Collaborator

No description provided.

Copy link

@titovmx titovmx left a comment

Choose a reason for hiding this comment

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

I love how the code is structured and covered with tests.
I left a few comments to think about, especially concerned about Styled Components usage and data loading, would be glad to discuss.

[SpacerJustify.SpaceBetween]: 'justify-content: space-between;'
};

export const StyledSpacer = styled.div<StyledDivProps>`
Copy link

Choose a reason for hiding this comment

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

I see a few issues with such a high degree of styled component customization:

  • requires providing a lot of additional enums and mappings of keys to CSS rules. You might end up with all CSS declared in this way.
  • having $css prop as the plain text makes it unclear which css properties should be defined as props, which should be defined as ad-hoc $css value
  • props passing through a few components, i.e. Spacer -> StyledSpacer, you have to repeat any new prop whenever it is added.
  • I guess performance is still issue of Styled Components, and all these props have to be recalculated on render and reinserted into the document. It's likely not a problem for a small app, however, could become while codebase is growing.

I would recommend simplifying such components. If you need to have div in a lot of different ways I'd rather put it as a styled div in that particular place without defining maps of styles. If you don't want to repeat a common part, you can extract it and reuse later like:

const FlexDiv = styled.div`
  display: flex;
  box-sizing: border-box;
`

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes very good point. Spacer become too large. $css prop was added mostly in order to deal with margins.
Do you suggest to create styled component for each case separatly, and then reuse most common of them?
And do you suggest to minify mapping props to styles as much as possible? For instanse use it only for colors, padding and margins?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed and css prop approach from codebase

}
const resolve = getJsonpResolver(callbackId);
if(!resolve) {
throw new Error('No resolver was found!')
Copy link

Choose a reason for hiding this comment

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

You have prettier in the project but seemingly it is not set up in your IDE.
I'd recommend doing it and running npx prettier 'src/**/*.{ts,tsx}' --write to auto-fix current problems.
Notice that the current .prettierrc.json dictates having 2-spaces indent and eliminating semicolons

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, for sure

const script = document.createElement('script');
const callbackId = generateId(path);
let onAbort: undefined|EventListenerOrEventListenerObject;
return new Promise((resolve, reject) => {
Copy link

Choose a reason for hiding this comment

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

Could you please explain your motivation to use this approach to load data? Have you considered using Fetch API?

Copy link
Collaborator Author

@prestonalexwebster prestonalexwebster Nov 4, 2023

Choose a reason for hiding this comment

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

As far as I understand. Fetch api does not support JSONP out of the box (because of CORS when you open local html file). I create this fetch-like wrapper in order to load jsonp files. It implements standard JSONP flow. Loading jsonp like it is javascript, and by implementing global jsonp loader function. Plus some logic to make this api fetch-like.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Anyway we can get rid of this, by trying to use libs like jsonp-fetch instead.

Copy link

Choose a reason for hiding this comment

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

Just curious where did you take these icons? Have you considered using FontAwesome lib?

Copy link
Collaborator Author

@prestonalexwebster prestonalexwebster Nov 4, 2023

Choose a reason for hiding this comment

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

I exported them from the figma, and minified by svgo after that. Didn't noticed that all of them come from font awesome lib.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

partially fixed, some components requires PRO version of lib, waiting for credentials

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.

3 participants