Browse Source

Add `stylable-require` property on Component Model

pull/506/merge
Artur Arseniev 8 years ago
parent
commit
687e1503ce
  1. 3
      src/dom_components/model/Component.js
  2. 7
      src/style_manager/model/Property.js
  3. 13
      src/style_manager/view/PropertyView.js

3
src/dom_components/model/Component.js

@ -39,6 +39,9 @@ module.exports = Backbone.Model.extend(Styleable).extend({
// All other properties will be hidden from the style manager // All other properties will be hidden from the style manager
stylable: true, stylable: true,
// Indicate an array of style properties to show up which has been marked as `toRequire`
'stylable-require': '',
// Indicate an array of style properties which should be hidden from the style manager // Indicate an array of style properties which should be hidden from the style manager
unstylable: '', unstylable: '',

7
src/style_manager/model/Property.js

@ -12,6 +12,13 @@ module.exports = require('backbone').Model.extend({
status: '', status: '',
visible: true, visible: true,
fixedValues: ['initial', 'inherit'], fixedValues: ['initial', 'inherit'],
// If true, will be hidden by default and will show up only for targets
// which require this property (via `stylable-require`)
// Use case:
// you can add all SVG CSS properties with toRequire as true
// and then require them on SVG Components
toRequire: 0,
}, },

13
src/style_manager/view/PropertyView.js

@ -375,9 +375,15 @@ module.exports = Backbone.View.extend({
* @return {Boolean} * @return {Boolean}
*/ */
isTargetStylable(target) { isTargetStylable(target) {
if (this.model.get('id') == 'flex-width') {
//debugger;
}
const trg = target || this.getTarget(); const trg = target || this.getTarget();
const property = this.model.get('property'); const model = this.model;
const property = model.get('property');
const toRequire = model.get('toRequire');
const unstylable = trg.get('unstylable'); const unstylable = trg.get('unstylable');
const stylableReq = trg.get('stylable-require');
let stylable = trg.get('stylable'); let stylable = trg.get('stylable');
// Stylable could also be an array indicating with which property // Stylable could also be an array indicating with which property
@ -391,6 +397,11 @@ module.exports = Backbone.View.extend({
stylable = unstylable.indexOf(property) < 0; stylable = unstylable.indexOf(property) < 0;
} }
// Check if the property is available only if requested
if (toRequire) {
stylable = (stylableReq && stylableReq.indexOf(property) >= 0) || !target;
}
return stylable; return stylable;
}, },

Loading…
Cancel
Save