e-oj / Magic-Grid

A simple, lightweight Javascript library for dynamic grid layouts.
https://www.npmjs.com/package/magic-grid
MIT License
3.14k stars 144 forks source link

How is it use in React? #7

Closed BigFaceMaster closed 5 years ago

imlinus commented 5 years ago

Hi,

I know there was talk about making a React port over here (https://github.com/e-oj/Magic-Grid/issues/1#issuecomment-437940490)

Though, I can't find anything yet :(

You are more than welcome to create your own React port, be sure to link it to @e-oj so he can add it to the readme πŸ‘ :-)

Happy Holidays, ImLinus

BigFaceMaster commented 5 years ago

OK,I'll create react version。

imlinus commented 5 years ago

Happy days!! That's awesome πŸ‘

e-oj commented 5 years ago

@BigFaceMaster You can also integrate it by creating a Magic Grid instance after the dom components have been created. I haven't used react but here's a Vue.js example.

BigFaceMaster commented 5 years ago

Yes, but I think the react version is better for react.

e-oj commented 5 years ago

@BigFaceMaster Yeah I'd like a React version. I'll leave this issue open till you're done. Post back here when its ready so I'll add it to the readme.

Merry Christmas πŸŽ…

BigFaceMaster commented 5 years ago

OK, I'll tell you when I finish it. Merry Christmas~~~

IniZio commented 5 years ago

Porting to React at https://github.com/IniZio/React-Magic-Grid which basically mirrors https://github.com/imlinus/Vue-Magic-Grid. But I am not sure if using this way of actually importing magic-grid and instantiating it at componentDidMount is better :thinking:

e-oj commented 5 years ago

@IniZio It's hard to say which method is better. Some like the plain JS approach while others might prefer a component that's built for their frontend framework. It's best to have both options available so everyone is covered.

A few of the functions have changed since @imlinus made the Vue.js port. I've modified the setup and positionItems functions to increase efficiency and the getMax utility function has been removed completely. Update your functions to match the updated functions. @imlinus, you should do the same for vue-magic-grid.

Thanks a lot for contributing guys, I really appreciate it. πŸ‘ πŸ‘

IniZio commented 5 years ago

I think its better to not duplicate logic across frameworks though, otherwise behaviours might differ between them. Nearly all of the logic can be reused if container selector part is refactored.

e-oj commented 5 years ago

Nearly all of the logic can be reused if container selector part is refactored.

Refactored how?

IniZio commented 5 years ago

Someone took the name react-magic-grid though, using magic-grid-react instead for now :/

imlinus commented 5 years ago

I'll take a look at the code sometime later this week, today I'm too hungover πŸ˜πŸ––

Happy new year lads ❀

e-oj commented 5 years ago

@IniZio I've added your repo to the readme. Try to get the code up to date though.

IniZio commented 5 years ago

Updated React version so that it use reusing almost all of magic-grid's code as peerDependencies :)