Browse Source

Update styleManager docs

up-style-manager
Artur Arseniev 5 years ago
parent
commit
72c8bab882
  1. 7
      docs/modules/Style-manager.md
  2. 29
      src/style_manager/index.js

7
docs/modules/Style-manager.md

@ -443,7 +443,14 @@ For a more advanced usage you can rely on the [Style Manager API] to perform dif
// Set as a target the CSS selector (the relative CSSRule will be created if doesn't exist yet)
sm.select('.btn > span');
// Get the last selected target
const lastTarget = sm.getLastSelected();
lastTarget?.toCSS && console.log(lastTarget.toCSS());
// Update selected targets with a custom style
sm.addStyleTargets({ color: 'red' });
```
* Adding new types.

29
src/style_manager/index.js

@ -31,6 +31,8 @@
* * [select](#select)
* * [getSelected](#getselected)
* * [getLastSelected](#getlastselected)
* * [getSelectedParents](#getselectedparents)
* * [addStyleTargets](#addstyletargets)
* * [addType](#addtype)
* * [getType](#gettype)
* * [getTypes](#gettypes)
@ -349,6 +351,25 @@ export default () => {
return this.model.get('lastTarget') || null;
},
/**
* Get parent rules of the last selected target.
* @returns {Array<[CSSRule]>}
*/
getSelectedParents() {
return this.model.get('lastTargetParents') || [];
},
/**
* Update selected targets with a custom style.
* @param {Object} style Style object
* @param {Object} [opts={}] Options
* @example
* styleManager.addStyleTargets({ color: 'red' });
*/
addStyleTargets(style, opts) {
this.getSelected().map(t => t.addStyle(style, opts));
},
/**
* Get what to style inside Style Manager. If you select the component
* without classes the entity is the Component itself and all changes will
@ -531,14 +552,6 @@ export default () => {
return (propTarget && propTarget.targets) || [];
},
addStyleTargets(style, opts) {
this.getSelected().map(t => t.addStyle(style, opts));
},
getSelectedParents() {
return this.model.get('lastTargetParents') || [];
},
getEmitter() {
return SectView.propTarget;
},

Loading…
Cancel
Save