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

Few improvements #56

Closed
3 of 5 tasks
rafaelss95 opened this issue Feb 4, 2021 · 7 comments
Closed
3 of 5 tasks

Few improvements #56

rafaelss95 opened this issue Feb 4, 2021 · 7 comments

Comments

@rafaelss95
Copy link

rafaelss95 commented Feb 4, 2021

I'm submitting a ... (check one with "x")

  • bug report => search github for a similar issue or PR before submitting
  • feature request

Suggestions:

  • Use OnPush change detection for performance reasons;
  • @Input for changing the "Loading..." text ( );
  • Better typings with strict mode. Currently we can't pass null/undefined properties, for example. A really usual case is the use with AsyncPipe where the options could be undefined. ngAcceptInputType_* static members could help here.

Also, it seems that animation can't accept literal false (

animation: 'progress' | 'progress-dark' | 'pulse' | 'false' = 'progress';
)

Another thing is that the theme is not compatible with NgStyle, so we can't pass something like {'max-width.px': widthExp} as the current signature is {[k: string]: string;}

I can try to help by sending a PR, if it is desirable. Thanks for this amazing lib :)

@willmendesneto
Copy link
Owner

Hi @rafaelss95 , thanks for raising this issue.

Ok, so let's try to discuss each of these points since it's an issue covering different points:

  • Use OnPush change detection for performance reasons
  • @input for changing the "Loading..." text
  • Also, it seems that animation can't accept literal false

Nice findings. I'm applying these changes at the moment, thanks for the suggestions!

Another thing is that the theme is not compatible with NgStyle, so we can't pass something like {'max-width.px': widthExp} as the current signature is {[k: string]: string;}

Actually, this is a design decision. Since you can use [theme] for it, there's no reason to support NgStyle via attribute bindings, like the scenario you described. For it you can use something like {"max-width": "100px"} should work as expected and I never received any message with scenarios when a binding in [theme] was required.

Better typings with strict mode...

Could you share a real scenario when you'll have to use AsyncPipe for it and that ngAcceptInputType_* ? I'm just concerned that won't be a realistic scenario and maybe sharing something specific you're facing might help on that.

@willmendesneto
Copy link
Owner

AT TIME:

@rafaelss95
Copy link
Author

Hey @willmendesneto sorry for late response. I saw that you made progress with this, and I'd want to say thanks for this awesome lib and for providing a fast feedback on these suggestions.

Btw, could we have a way to pass a default config to the .forRoot()?

static forRoot(): ModuleWithProviders<NgxSkeletonLoaderModule> {

It'd be really nice to set a custom loadingText globally, and why not the other properties as well.


That being said, let me try to address the remaining two points...

Actually, this is a design decision. Since you can use [theme] for it, there's no reason to support NgStyle via attribute bindings, like the scenario you described. For it you can use something like {"max-width": "100px"} should work as expected and I never received any message with scenarios when a binding in [theme] was required.

Hmm, I don't think my suggestion was clear enough. Let me try to explain better now...

As the [theme] @Input is just a bridge to pass an style via [ngStyle] as we can see here:

I don't get why it isn't compatible with NgStyle and that's why I was suggesting to use the same signature of [ngStyle] ({ [klass: string]: any; }) in [theme].

Could you share a real scenario when you'll have to use AsyncPipe for it and that ngAcceptInputType_* ? I'm just concerned that won't be a realistic scenario and maybe sharing something specific you're facing might help on that.

We don't even have to go that far, by using examples with AsyncPipe, just try to use (in a application with strict mode enabled) like in README:

<ngx-skeleton-loader count="5"></ngx-skeleton-loader>

You'll receive Type 'string' is not assignable to type 'number'.

@willmendesneto
Copy link
Owner

Thanks for elaborate on the issue. Maybe we should split that in few other issues to make it easier to manage, but definitely some improvements to be added!

I’m not sure if I’ll have some time these days to apply that, but pull requests are more than welcome (It’s totally fine if you can’t raise them, I can add them)!

@willmendesneto
Copy link
Owner

Sharing some updates:

  • strict types are now available on the package;
  • theme attribute is now following the same types asngStyle. So now it can be used as style attributes as well, having both the same signature.

@willmendesneto
Copy link
Owner

I'm closing this issue for now since it was a lot of issues in a single one. Please feel free to open a single issue, so we could discuss more and see if it's valuable for the module!

And thanks again for raising those points 🎉

@rafaelss95
Copy link
Author

Hey @willmendesneto, thanks for addressing this! I've just updated right now and I've encountered a problem that I reported in #61 and a missing suggestion in #62.

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

No branches or pull requests

2 participants