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

Style properties #13

Open
jrmyio opened this issue Aug 15, 2014 · 8 comments
Open

Style properties #13

jrmyio opened this issue Aug 15, 2014 · 8 comments

Comments

@jrmyio
Copy link

jrmyio commented Aug 15, 2014

When working with ampersand-dom-bindings I came accros an issue where I want to change the width of a block element. I had to generate a style like string "width: " + percentage + "%;" to tackle the use case. It would be handy to have ampersand-dom-bindings to also be able to change CSS aka Style properties directly.

I am not sure if this should be covered in the ampersand-dom repo.

@legastero
Copy link

Worth double checking that this still works, and updating docs if so: https://github.com/henrikjoreteg/bind-transforms

@wraithgar
Copy link
Contributor

+1 this probably needs to be done at least to match class bindings, i.e. style, booleanStyle, switchStyle

@herkyl
Copy link

herkyl commented Dec 15, 2014

+1 I run across the same issue, needing to set the width & left of an element using bindings

@pgilad
Copy link
Member

pgilad commented Aug 30, 2015

@legastero @wraithgar @ConneXNL @herkyl
Will an optional transform function be sufficient? That way you can manipulate the outcome itself and do whatever you want with it.

@herkyl
Copy link

herkyl commented Aug 31, 2015

@pgilad could you give a code example of what exactly you are thinking of

@pgilad
Copy link
Member

pgilad commented Aug 31, 2015

// Use as a regular binding
var bindings = domBindings({
    'model.name': {
        type: 'text',
        selector: '.any-selector',
        transform: function(value, binding) {
          return value + '%';
        }
    }
});

@herkyl
Copy link

herkyl commented Aug 31, 2015

    'model.width': {
        cssProp: 'width',
        selector: '.any-selector',
        transform: function(value, binding) {
          return value + 'px';
        }
    }

What about something like this?

@pgilad
Copy link
Member

pgilad commented Aug 31, 2015

I was suggesting a transform function that will be run (if defined) before applying the value to whatever the binding type is.
I think we're talking about different problems...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants