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

feat(store-ui): Add Skeleton Atom #911

Merged
merged 7 commits into from
Sep 13, 2021
Merged

Conversation

lariciamota
Copy link
Contributor

@lariciamota lariciamota commented Aug 18, 2021

What's the purpose of this pull request?

Add the Skeleton Atom to store-ui with its story and test

How it works?

How to test it?

https://github.com/vtex-sites/storecomponents.store/pull/1197

References

@lariciamota lariciamota requested a review from a team as a code owner August 18, 2021 21:11
@netlify
Copy link

netlify bot commented Aug 18, 2021

✔️ Deploy Preview for storeui ready!

🔨 Explore the source changes: 1eea48d

🔍 Inspect the deploy log: https://app.netlify.com/sites/storeui/deploys/613f4ce8a3c8ba000712624c

😎 Browse the preview: https://deploy-preview-911--storeui.netlify.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 18, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 1eea48d:

Sandbox Source
Store UI Typescript Configuration

@emersonlaurentino emersonlaurentino linked an issue Aug 18, 2021 that may be closed by this pull request
@Gmantiqueira
Copy link
Contributor

Awesome! Just one thing, I'm not sure about the styling. We're trying to decouple everything from @emotion and putting every CSS rule inside our themes. For example, the theme-b2c-tailwind.

What about putting only the essential styles inside the style={} prop (Pure CSS), then everything else inside our theme? In this case, the problem are the keyframes solution with pure inline CSS.

Maybe something like this works:

let styleSheet = document.styleSheets[0];

let keyframes =
`@keyframes store-skeleton {
   0% {
    /* Animating absolute units, such as vw, has
    better performance than relative units, such as %,
    because it needs to be recalculated every frame */
    
    transform: translate3d(-150vw, 0, 0);
   }
   100% {
    transform: translate3d(0, 0, 0);
   }
 }`;

styleSheet.insertRule(keyframes, styleSheet.cssRules.length);

Then it'll push the keyframes rule with pure JS. But well, I'm not sure.

@lariciamota
Copy link
Contributor Author

Awesome! Just one thing, I'm not sure about the styling. We're trying to decouple everything from @emotion and putting every CSS rule inside our themes. For example, the theme-b2c-tailwind.

What about putting only the essential styles inside the style={} prop (Pure CSS), then everything else inside our theme? In this case, the problem are the keyframes solution with pure inline CSS.

Maybe something like this works:

let styleSheet = document.styleSheets[0];

let keyframes =
`@keyframes store-skeleton {
   0% {
    /* Animating absolute units, such as vw, has
    better performance than relative units, such as %,
    because it needs to be recalculated every frame */
    
    transform: translate3d(-150vw, 0, 0);
   }
   100% {
    transform: translate3d(0, 0, 0);
   }
 }`;

styleSheet.insertRule(keyframes, styleSheet.cssRules.length);

Then it'll push the keyframes rule with pure JS. But well, I'm not sure.

Good to know! Thank you, I'll look into it

@emersonlaurentino
Copy link
Member

maybe you just leave the classes inside the component and the style is added by the theme. For example, if you are using Tailwind, you can use one of these animations: https://tailwindcss.com/docs/animation

Copy link
Contributor

@igorbrasileiro igorbrasileiro left a comment

Choose a reason for hiding this comment

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

Nice job @lariciamota 👏 ! Left some comments

packages/store-ui/src/atoms/Skeleton/Skeleton.tsx Outdated Show resolved Hide resolved
packages/store-ui/src/atoms/Skeleton/Skeleton.tsx Outdated Show resolved Hide resolved
@emersonlaurentino
Copy link
Member

Hey, @lariciamota . I think this PR is a little confused, I say not in relation to what you did, but in relation to the Issue.

We want our components to be style agnostic, just logic. However, it is impossible to make Skeleton without being biased by some lib (in your case @emotion/core).

I believe we should review what exactly we want with this Component. One suggestion would be to have just one div that receives the data-store-skeleton and all the logic is in the @vtex/theme-b2c-tailwind theme. What do you think?

@Gmantiqueira
Copy link
Contributor

Gmantiqueira commented Aug 30, 2021

I believe we should review what exactly we want with this Component. One suggestion would be to have just one div that receives the data-store-skeleton and all the logic is in the @vtex/theme-b2c-tailwind theme. What do you think?

@emersonlaurentino I don't think so, this way our Skeleton component will be "useless" and the component functionality itself will be inside the theme. I prefer doing all the logic inside the component with native CSS, since the Skeleton doesn't need to have so many customizations. I believe that people will not change those styles very often.

The problem here is the CSS Specificity. If we put the logic inside the style attribute (inline), people will struggle to overwrite it with the data-store-attribute.

@lariciamota lariciamota force-pushed the feature/skeleton-atom branch 2 times, most recently from 357a07b to 2222557 Compare September 2, 2021 19:29
Copy link
Contributor

@igorbrasileiro igorbrasileiro left a comment

Choose a reason for hiding this comment

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

Nice job!

Copy link
Contributor

@Gmantiqueira Gmantiqueira left a comment

Choose a reason for hiding this comment

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

Nice!!

@lariciamota lariciamota force-pushed the feature/skeleton-atom branch from 92e590e to ee4407b Compare September 6, 2021 15:01
@lariciamota lariciamota merged commit ef25cde into master Sep 13, 2021
@lariciamota lariciamota deleted the feature/skeleton-atom branch September 13, 2021 13:20
Gmantiqueira pushed a commit that referenced this pull request Sep 14, 2021
* Add skeleton atom

* Move animation to theme

* Import tailwind utilities

* Update test

* Use only 1 div

* Update story

* Extend HTMLDivElement
Gmantiqueira pushed a commit that referenced this pull request Sep 15, 2021
* Add skeleton atom

* Move animation to theme

* Import tailwind utilities

* Update test

* Use only 1 div

* Update story

* Extend HTMLDivElement
Gmantiqueira pushed a commit that referenced this pull request Sep 16, 2021
* Add skeleton atom

* Move animation to theme

* Import tailwind utilities

* Update test

* Use only 1 div

* Update story

* Extend HTMLDivElement
Gmantiqueira pushed a commit that referenced this pull request Sep 17, 2021
* Spinner component for loading

* Spinner exports

* Fix data-testid

Co-authored-by: Igor Brasileiro <brasileiro456@gmail.com>

* remove explicit children prop

Co-authored-by: Igor Brasileiro <brasileiro456@gmail.com>

* BREAKING CHANGE: Remove deprecated folders (#927)

* feat(store-ui): adding list atom (#918)

Create List component as an Atom.

* feat(store-ui): Add Skeleton Atom (#911)

* Add skeleton atom

* Move animation to theme

* Import tailwind utilities

* Update test

* Use only 1 div

* Update story

* Extend HTMLDivElement

* Spinner exports

* lint

* Fix Spinner test

* removing duplicated line in package.json

Co-authored-by: Igor Brasileiro <brasileiro456@gmail.com>
Co-authored-by: Tiago Gimenes <tlgimenes@gmail.com>
Co-authored-by: Bento Pereira <40964933+bentoper@users.noreply.github.com>
Co-authored-by: Larícia Mota <laricia.mota@vtex.com.br>
Gmantiqueira pushed a commit that referenced this pull request Sep 17, 2021
* Add skeleton atom

* Move animation to theme

* Import tailwind utilities

* Update test

* Use only 1 div

* Update story

* Extend HTMLDivElement
Gmantiqueira pushed a commit that referenced this pull request Sep 17, 2021
* Add skeleton atom

* Move animation to theme

* Import tailwind utilities

* Update test

* Use only 1 div

* Update story

* Extend HTMLDivElement
rrbambokian pushed a commit that referenced this pull request Sep 30, 2021
* Add skeleton atom

* Move animation to theme

* Import tailwind utilities

* Update test

* Use only 1 div

* Update story

* Extend HTMLDivElement
rrbambokian pushed a commit that referenced this pull request Sep 30, 2021
* Spinner component for loading

* Spinner exports

* Fix data-testid

Co-authored-by: Igor Brasileiro <brasileiro456@gmail.com>

* remove explicit children prop

Co-authored-by: Igor Brasileiro <brasileiro456@gmail.com>

* BREAKING CHANGE: Remove deprecated folders (#927)

* feat(store-ui): adding list atom (#918)

Create List component as an Atom.

* feat(store-ui): Add Skeleton Atom (#911)

* Add skeleton atom

* Move animation to theme

* Import tailwind utilities

* Update test

* Use only 1 div

* Update story

* Extend HTMLDivElement

* Spinner exports

* lint

* Fix Spinner test

* removing duplicated line in package.json

Co-authored-by: Igor Brasileiro <brasileiro456@gmail.com>
Co-authored-by: Tiago Gimenes <tlgimenes@gmail.com>
Co-authored-by: Bento Pereira <40964933+bentoper@users.noreply.github.com>
Co-authored-by: Larícia Mota <laricia.mota@vtex.com.br>
Gmantiqueira pushed a commit that referenced this pull request Oct 12, 2021
* Add skeleton atom

* Move animation to theme

* Import tailwind utilities

* Update test

* Use only 1 div

* Update story

* Extend HTMLDivElement
Gmantiqueira pushed a commit that referenced this pull request Oct 14, 2021
* Add skeleton atom

* Move animation to theme

* Import tailwind utilities

* Update test

* Use only 1 div

* Update story

* Extend HTMLDivElement
Gmantiqueira pushed a commit that referenced this pull request Oct 21, 2021
* Add skeleton atom

* Move animation to theme

* Import tailwind utilities

* Update test

* Use only 1 div

* Update story

* Extend HTMLDivElement
Gmantiqueira pushed a commit that referenced this pull request Oct 21, 2021
* BREAKING CHANGE: Remove deprecated folders (#927)

* feat(store-ui): adding list atom (#918)

Create List component as an Atom.

* feat(store-ui): Add Skeleton Atom (#911)

* Add skeleton atom

* Move animation to theme

* Import tailwind utilities

* Update test

* Use only 1 div

* Update story

* Extend HTMLDivElement

* Spinner exports

* lint

* Loading Button molecule

* removing duplicated line in package.json

* Remove loading prop default value

* Adds component inheritance inside docs

* change spread props naming

Co-authored-by: Tiago Gimenes <tlgimenes@gmail.com>
Co-authored-by: Bento Pereira <40964933+bentoper@users.noreply.github.com>
Co-authored-by: Larícia Mota <laricia.mota@vtex.com.br>
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.

Skeleton
5 participants