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

Can the colors of things be changed? #157

Open
rajid opened this issue Mar 31, 2017 · 5 comments
Open

Can the colors of things be changed? #157

rajid opened this issue Mar 31, 2017 · 5 comments

Comments

@rajid
Copy link

rajid commented Mar 31, 2017

I'd like to change the color of the toggle, when it's "on" from red to green. I'd also like to make the submit button green. Is there a way to set colors in the Clay driven API? I was expecting some "attribute" but can't find any such documention.

@keegan-lillo
Copy link
Contributor

There isn't a "direct" API for changing styles as the intent is for it to look as close to the native styling as possible, however you do have access to the "Minified" api of the element itself via the $element property: https://github.com/pebble/clay#clayitem-object-config-
http://minifiedjs.com/api/

clayConfig.on(clayConfig.EVENTS.AFTER_BUILD, function() {
  var coolStuffToggle = clayConfig.getItemByMessageKey('cool_stuff');
  coolStuffToggle.on('change', function() {
    // only set the background if toggled
    var toggled = this.get();
    coolStuffToggle.$element.select('.marker').set('$backgroundColor',  toggled ? 'green' : null);
    coolStuffToggle.$element.select('.slide').set('$backgroundColor', toggled ? 'darkgreen' : null);
  })
});

@rajid
Copy link
Author

rajid commented Mar 31, 2017 via email

@rajid
Copy link
Author

rajid commented Apr 1, 2017 via email

@keegan-lillo
Copy link
Contributor

Yeh none of those selectors will target what you want. Have a look at the source for a submit button https://github.com/pebble/clay/blob/master/src/templates/components/submit.tpl

You want . select("button") not . select(".button")

I'm also not sure why you want to change the colors of the elements. The whole point behind Clay is for it to maintain visual consistency with the rest of the Pebble app (and other developers). By you changing the colors of things, you're interrupting that consistency.

@rajid
Copy link
Author

rajid commented Apr 1, 2017 via email

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

No branches or pull requests

2 participants