Giter Club home page Giter Club logo

Comments (11)

felixakiragreen avatar felixakiragreen commented on April 19, 2024 2

innerHeight() - this.getDOMNode().clientHeight
css() - React classSet or Element classList or this.getDOMNode().style or this.getDOMNode().cssText
width() - this.getDOMNode().style.width
outerWidth() - this.getDOMNode().offsetWidth
height() - this.getDOMNode().style.height
parent() - Node.parentElement
addClass() / removeClass() - I would encourage using React's classSet, but Element.classList.add or remove can also be used
offset() - Element.getBoundingClientRect()
on() / off() - Element.addEventListener, but this can be handled by React's native events and probably shouldn't be necessary.

However, while these can be directly substituted, for many of them (like classes, events) React has its own pattern and way of doing things. This will require changing a little logic, but it will make everything run much smoother and allow for easier future development.

from material-ui.

totty90 avatar totty90 commented on April 19, 2024

https://github.com/callemall/material-ui/blob/b244832e01eeb15f19e1dff45b90863ef137daee/docs/dist/js/drop-down-menu.jsx#L35

from material-ui.

zzmp avatar zzmp commented on April 19, 2024

Isn't that just a docs specific dependency?

Does this mean that all of the source is implemented under the docs folder? That's incredibly unintuitive.

from material-ui.

totty90 avatar totty90 commented on April 19, 2024

Look here var $el = $(this.getDOMNode()),. You are right docs is the worst folder to put your src in. That's that I opened this issue

from material-ui.

felixakiragreen avatar felixakiragreen commented on April 19, 2024

👍

React and JQuery do not play nicely and ideally no React components should rely on JQuery.

from material-ui.

hai-cea avatar hai-cea commented on April 19, 2024

Here's what we're currently using out of the jQuery library:

Components:

  • Dialog - innerHeight(), css()
  • DropdownIcon - width(), css()
  • DropdownMenu - width(), css()
  • Menu - outterWidth(), width(), height(), css()
  • Ripple - parent(), offset(), addClass(), removeClass(), css()

Mixins & Utils:

  • ClickAwayable - on(), off()
  • CssEvent - one()

Any suggestions on how we could remove the jQuery dependency and still have the above functionality?

from material-ui.

philipgiuliani avatar philipgiuliani commented on April 19, 2024

It would be nice to remove the jQuery dependency, since people are currently avoiding to use it because of the overheat in some projects.

from material-ui.

plus- avatar plus- commented on April 19, 2024

React and JQuery do not play nicely

@DUBERT care to elaborate on that, I'd like to know

from material-ui.

hai-cea avatar hai-cea commented on April 19, 2024

I've removed some of the jQuery dependencies. Still working on the others. Here's what's left:

  • Menu - outterWidth(), width(), height(), children(), css()
  • Ripple - parent(), offset(), addClass(), removeClass(), css()

Mixins & Utils:

  • ClickAwayable - on(), off()
  • CssEvent - one()

from material-ui.

hai-cea avatar hai-cea commented on April 19, 2024

There is one jQuery dependency that I can't get rid of. Currently, I'm using jQuery to namespace click events for the click-awayable mixin. This mixin allows components to do something if a click event happens outside of the component.

Anyone have a good way to do this with native JS? Here's the JS file I'm talking about:
https://github.com/callemall/material-ui/blob/master/src/js/mixins/click-awayable.js

from material-ui.

hai-cea avatar hai-cea commented on April 19, 2024

Figured it out. :)

from material-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.