Skip to content

Commit

Permalink
Add documentation for property-types to style spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauren Budorick committed Apr 17, 2018
1 parent cd3241f commit a75b518
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
42 changes: 42 additions & 0 deletions docs/pages/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,29 @@ const navigation = [
}
]
},
{
"title": "Property types",
"subnav": [
{
"title": "Data-driven"
},
{
"title": "Cross-faded"
},
{
"title": "Cross-faded data-driven"
},
{
"title": "Color ramp"
},
{
"title": "Data-constant"
},
{
"title": "Constant"
}
]
},
{
"title": "Other",
"subnav": [
Expand Down Expand Up @@ -368,6 +391,9 @@ class Item extends React.Component {

{this.props.transition &&
<em className='quiet'><span className='icon opacity inline quiet' />Transitionable. </em>}

<em className='quiet'>
Should be represented by a <a href={'#property-types-' + this.props['property-type']}>{this.props['property-type']}</a> property. </em>
</div>

{this.props.doc &&
Expand Down Expand Up @@ -1399,6 +1425,22 @@ export default class extends React.Component {
</div>
</div>

<div className='pad2 prose'>
<a id='property-types' className='anchor'/>
<h2><a href='#property-types' title='link to property types'>Property types</a></h2>
<div className='keyline-all fill-white'>
{Object.keys(ref['property-type']).map((propType, i) => {
const propTypeDoc = ref['property-type'][propType].doc;
return (
<div className='pad2 keyline-bottom' key={i}>
<a id={'property-types-' + propType} className='anchor'/>
<h3 className='space-bottom1'><a href={'#property-types-' + propType} title={'link to ' + propType}>{propType}</a></h3>
<p>{propTypeDoc}</p>
</div>);
})}
</div>
</div>

<div className='pad2 prose'>
<a id='other' className='anchor'/>
<h2><a href='#other' title='link to other'>Other</a></h2>
Expand Down
26 changes: 26 additions & 0 deletions src/style-spec/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -4994,5 +4994,31 @@
"units": "milliseconds",
"doc": "Length of time before a transition begins."
}
},
"property-type": {
"data-driven": {
"type": "property-type",
"doc": "Property is interpolable and can be represented using a property expression."
},
"cross-faded": {
"type": "property-type",
"doc": "Property is non-interpolable; rather, its values will be cross-faded to smoothly transition between integer zooms."
},
"cross-faded-data-driven": {
"type": "property-type",
"doc": "Property is non-interpolable; rather, its values will be cross-faded to smoothly transition between integer zooms. It can be represented using a property expression."
},
"color-ramp": {
"type": "property-type",
"doc": "Property should be specified using a color ramp from which the output color can be sampled based on a property calculation."
},
"data-constant": {
"type": "property-type",
"doc": "Property is interpolable but cannot be represented using a property expression."
},
"constant": {
"type": "property-type",
"doc": "Property is constant across all zoom levels and property values."
}
}
}
5 changes: 3 additions & 2 deletions test/unit/style-spec/spec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function validSchema(k, t, obj, ref, version, kind) {
'text-justify-enum',
'text-anchor-enum',
'text-transform-enum',
'visibility-enum'
'visibility-enum',
'property-type'
]);
const keys = [
'default',
Expand Down Expand Up @@ -124,7 +125,7 @@ function validSchema(k, t, obj, ref, version, kind) {
}
} else if (obj.expression !== undefined) {
const expression = obj.expression;
t.equal(true, ['data-driven', 'cross-faded-data-driven', 'cross-faded', 'color-ramp', 'data-constant'].indexOf(obj['property-type']) >= 0, `${k}.expression: property-type: ${obj['property-type']}`);
t.ok(ref['property-type'][obj['property-type']], `${k}.expression: property-type: ${obj['property-type']}`);
t.equal('boolean', typeof expression.interpolated, `${k}.expression.interpolated.required (boolean)`);
t.equal(true, Array.isArray(expression.parameters), `${k}.expression.parameters array`);
if (obj['property-type'] !== 'color-ramp') t.equal(true, expression.parameters.every(k => k === 'zoom' || k === 'feature'));
Expand Down

0 comments on commit a75b518

Please sign in to comment.