Code Monkey home page Code Monkey logo

Comments (13)

cakesifu avatar cakesifu commented on July 19, 2024

👍 on this.

from classnames.

JedWatson avatar JedWatson commented on July 19, 2024

As long as there isn't a negative performance impact, I think this is a reasonable change to the API.

from classnames.

dcousens avatar dcousens commented on July 19, 2024

I personally don't think de duplication is the responsibility of this library, given it is entirely a user input problem.

from classnames.

JedWatson avatar JedWatson commented on July 19, 2024

Can someone put forward the use-case that is driving this requirement? (I mean big picture, not simple example)

Looking at the complexity of implementation I'm inclined to agree with @dcousens

from classnames.

longlho avatar longlho commented on July 19, 2024

So my use case is that a React component which uses this library to allow class name overwrites w/ a specific set of default classNames, so something like classNames('foo', extraStuff).

Conceptually since this library allows a chaining/combining a set of class names, specifying {foo: false} at the end of the chain and have it still appear in the output makes it very hard to debug, as you basically have to crawl down the chain of abstractions and figure out which layer injected foo in. And since foo will always be there you need to have hacky CSS rule to make certain selectors more specific and/or throw !important in there.

from classnames.

cakesifu avatar cakesifu commented on July 19, 2024

I agree with @dcousens but I also have 2 compelling reasons for adding this in anyway:

  1. In order to do the de-duplication outside of the library one would have to parse the inputs and do most of the work that the library already does.
  2. Allowing later arguments to overwrite previous arguments is more idiomatic and almost expected behavior (think _.extend).

from classnames.

longlho avatar longlho commented on July 19, 2024

@cezar-berea We're having some discussion in the PR itself. @JedWatson mentioned exposing .dedupe (or .merge if we wanna be similar to _.merge) and I think that's probably best as an opt-in due to performance impact

from classnames.

dcousens avatar dcousens commented on July 19, 2024

@JedWatson what is your conclusion here, .dedupe?

from classnames.

3den avatar 3den commented on July 19, 2024

can someone get that merged?

from classnames.

JedWatson avatar JedWatson commented on July 19, 2024

@3den will land it this weekend.

from classnames.

dcousens avatar dcousens commented on July 19, 2024

@JedWatson as .dedupe?

from classnames.

dcousens avatar dcousens commented on July 19, 2024

Closing this in favour of #31

from classnames.

JedWatson avatar JedWatson commented on July 19, 2024

Just released 2.1.0 with this included.

from classnames.

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.