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

CSS-in-JS Attempt v2 #73

Merged
merged 8 commits into from
Aug 23, 2019
Merged

CSS-in-JS Attempt v2 #73

merged 8 commits into from
Aug 23, 2019

Conversation

horacioh
Copy link
Contributor

@horacioh horacioh commented Jul 23, 2019

closes #62

  • reduce the amount of files on the project (just index.js now)
  • Using styled-components on this one. seems to be a more performant solution all well documented and adopted.
  • remove the Math.min call on stickyHeaderCount & stickyColumnCount. that was causing to just return 1 everytime. maybe if you want more than 1 column/row fixed this is not helpful.
  • update tests to pass with new components

PLEASE GIVE SOME FEEDBACK!!

this is IMHO a good starting point to start migrating the code. also I can after this PR being merged, migrate the code to Typescript :)

@horacioh horacioh mentioned this pull request Jul 23, 2019
src/index.js Outdated

this.index = index = index + 1;
}
const Cell = styled.div`
Copy link
Contributor

Choose a reason for hiding this comment

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

@horacioh I think these cells should still have the classNames they had before so people who do use css can easily select them. I think the tests should include those selectors as well, as they did before to be clear about what is being selected rather than just 'span's and 'div's.

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 this is something I was thinking before, we can leave the classes, but with no extra css for them, just for users to override it.

another option i thought was to have this refactor as a breaking change. but I dunno about how people will react to this...

I'm OK with both options!

about the tests, I think targeting the actual components is clear enough. what do you think is different from this compared to css classes?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep the classes. Will comment inline in test file to show

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@@ -6,7 +6,9 @@
"bugs": {
"url": "https://github.com/henrybuilt/react-sticky-table/issues"
},
"dependencies": {},
"dependencies": {
"styled-components": "^4.3.2"
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the difference between emotion and styled-components, or are they the same? My understanding was that they were different, but am seeing a mix here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they are both solving the same problem: both are libraries to write CSS in JS. emotions used to be faster, but now seems styled components to be more performant.

I changed it to styled components on this version.

@maxhudson
Copy link
Contributor

@horacioh I haven't actually checked this out on my computer yet, but looks good other than the comments I left

babel.config.js Outdated
@@ -12,7 +12,7 @@ module.exports = {
}
]
],
plugins: ['@babel/plugin-proposal-class-properties'],
plugins: ['@babel/plugin-proposal-class-properties', 'emotion'],
Copy link
Contributor

Choose a reason for hiding this comment

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

@horacioh seems like this should be removed based on what you said about styled components

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uops! my bad...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the review!

babel.config.js Outdated
@@ -25,7 +25,7 @@ module.exports = {
],
'@babel/preset-react'
],
plugins: ['@babel/plugin-proposal-class-properties']
plugins: ['@babel/plugin-proposal-class-properties', 'emotion']
Copy link
Contributor

Choose a reason for hiding this comment

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

@horacioh same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@@ -17,6 +17,6 @@ describe('Cell', () => {
</Cell>
);

expect(cell.find('.sticky-table-cell span')).to.have.length(2);
expect(cell.find(Cell).find('span')).to.have.length(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

@horacioh nevermind about tests - this was the only one I noticed, and it's clear the way you have it

@maxhudson
Copy link
Contributor

@horacioh Please check the storybook by running yarn run storybook

It appears the styles are not working - I'm not sure why.

Also getting this error which would be great if you could fix: The pseudo class ":first-child" is potentially unsafe when doing server-side rendering. Try changing it to ":first-of-type".

@horacioh
Copy link
Contributor Author

horacioh commented Aug 1, 2019

@maxhudson can you share a screenshot of what you see on the storybooks? I just run it and everything seems to be ok..

Screen Shot 2019-08-01 at 11 24 00 PM

Screen Shot 2019-08-01 at 11 24 10 PM

Screen Shot 2019-08-01 at 11 24 24 PM

Screen Shot 2019-08-01 at 11 24 31 PM

Screen Shot 2019-08-01 at 11 24 40 PM

@horacioh
Copy link
Contributor Author

horacioh commented Aug 1, 2019

@maxhudson the ":first-child" error seems to be some storybook error

@maxhudson
Copy link
Contributor

Screen Shot 2019-08-08 at 7 51 48 AM

@maxhudson
Copy link
Contributor

@horacioh after looking at this more, I'm excited about it as it cleans things up quite a bit! Just gotta figure out what's up with storybook, which I'm not sure how to debug as there's no problem on your end and on my end I'm not seeing any reason for the lack of functionality

@maxhudson
Copy link
Contributor

Can you also resolve conflict with index.js?

@horacioh
Copy link
Contributor Author

horacioh commented Aug 8, 2019

@maxhudson sure thing! will do it later today :)

@maxhudson
Copy link
Contributor

The commit I just pushed fixed my storybook issue

@maxhudson
Copy link
Contributor

@horacioh once that conflict is resolved we can merge!

@horacioh
Copy link
Contributor Author

@maxhudson hey! 👋

finally i got time to fix the conflict. I also delete duplicate css from the storybook demo. ti had an extra border that was not correctly being positioned.

hope now is ready to merge! :)

@maxhudson maxhudson merged commit d2769bd into henrybuilt:master Aug 23, 2019
@maxhudson
Copy link
Contributor

@horacioh merged! Thanks for all the help :)

@maxhudson maxhudson mentioned this pull request Aug 29, 2019
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.

migrate to CSS-in-JS
2 participants