Coder Social home page Coder Social logo

Comments (4)

dfreeman avatar dfreeman commented on September 13, 2024

Unfortunately this is working as expected, though the README dances around the issue a little 😞

Currently localClassNameBindings only works for toggling classes based on a boolean value. Mapping string values basically requires one more layer of indirection than you can package up in a single computed, since the name of the property you're binding to in turn depends on a dynamic property value.

It's possible we may be able to come up with a way around this by manually Ember.binding things on init, but we should be careful of the perf costs of setting up these extra bindings. Will need to noodle on it some.

from ember-css-modules.

dfreeman avatar dfreeman commented on September 13, 2024

Actually, it looks like the README lies and says strings will be coerced and treated as booleans, which clearly isn't the case. I'll update that for the time being to be clearer(/actually accurate).

from ember-css-modules.

luxzeitlos avatar luxzeitlos commented on September 13, 2024

Cant we just do something like this:

  init() {
    this._super(...arguments);
    const names = get(this, 'localClassNameBindings');
    get(this, 'classNameBindings').pushObject('__local_class_names');
    set(this, '__local_class_names', Ember.computed(...names, function() {
      return names
        .map(n => get(this, n)) // get property value
        .map(c => c.split(' ')) // get array of array of classes
        .reduce((a, b) => [...a, ...b]) // flatten to array of classes
        .map(v => styles[v]) // get local class name
        .filter(s => s) // remove non-existring
        .join(' ');
    }));
  },

from ember-css-modules.

dfreeman avatar dfreeman commented on September 13, 2024

Fixed by #81

from ember-css-modules.

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.