api-console-assets
Version:
This repo only exists to publish api console components to npm
130 lines (121 loc) • 4.9 kB
HTML
<!--
@license
Copyright 2016 The Advanced REST client authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="docs-parameters-behavior.html">
<link rel="import" href="docs-parameters-table-shared-styles.html">
<link rel="import" href="raml-type-property-description.html">
<!--
`<docs-form-parameters-table>` Displays a list of parameters for the
`x-www-form-urlencoded` form type.
### Example
```
<docs-form-parameters-table
type="[[ramlType]]"></docs-form-parameters-table>
```
### Styling
`<docs-form-parameters-table>` provides the following custom properties and mixins for styling:
Custom property | Description | Default
----------------|-------------|----------
`--docs-parameters-table` | Mixin applied to all parameter table elements | `{}`
`--docs-parameters-url-table` | Mixin applied to this elements | `{}`
`--params-table-header-background-color` | Background color of table header | `#00A1DF`
`--params-table-header-color` | Font color of table header | `rgba(255, 255, 255, 0.87)`
`--params-table-subheader-background-color` | Background color of table subheader | `rgba(0, 161, 223, 0.24)`
`--params-table-subheader-color` | Font color of table subheader | `rgba(0, 0, 0, 0.87)`
`--params-table-row-border-color` | Border color of table rows | `rgba(0, 161, 223, 1)`
`--params-table-row-subproperty-border-color` | Border color of table row which is a description of child property. | `rgba(0, 161, 223, 0.24)`
`--params-table-row-background-color` | Background color of table's each row | `#fff`
`--params-table-row-color` | Font color of table's each row | `#fff`
`--docs-parameters-table-cell` | Mixin applied to each cell | `{}`
`--docs-parameters-table-meta` | Mixin applied to property's metadata (example, pattern, etc) | `{}`
`--docs-body-parameters-table-json` | Mixin applied to the JSON output | `{}`
`--docs-body-parameters-table-type-name` | Mixin applied to the name of the type | `{}`
@element docs-json-parameters-table
@demo demo/index.html
-->
<dom-module id="docs-form-parameters-table">
<template>
<style include="docs-parameters-table-shared-styles"></style>
<style>
:host {
display: block;
}
</style>
<template is="dom-if" if="[[hasParams]]">
<div class="params-table">
<div class="thead params-table-header">
<section class="tr">
<span class="th">Parameter</span>
<span class="th">Type</span>
<span class="th">Description</span>
</section>
</div>
<h5 class="narrow-title">Properties</h5>
<div class="tbody">
<template is="dom-repeat" items="[[readProperties(type.formParameters)]]">
<section class="tr">
<div class="td param-name">
<span class="name">[[item.name]]</span>
<template is="dom-if" if="[[item.required]]">
<span class="required-label">(required)</span>
</template>
</div>
<div class="td param-type">
<span class="type">[[item.type]]</span>
<template is="dom-if" if="[[hasValue(item.enum)]]">
<span class="enum-label">(enum)</span>
</template>
</div>
<div class="td param-desc">
<raml-type-property-description item="[[item]]"></raml-type-property-description>
</div>
</section>
</template>
</div>
</div>
</template>
</template>
<script>
Polymer({
is: 'docs-form-parameters-table',
behaviors: [RamlBehaviors.DocsParametersBehavior],
properties: {
/**
* A RAML's type definition for the body payload.
*/
type: Object,
// True when `type` is present
hasParams: {
type: Boolean,
computed: '_computeHasParams(type.*)',
value: false,
notify: true,
reflectToAttribute: true
},
// If true then the narrow layout is applied.
narrow: {
type: Boolean,
reflectToAttribute: true
}
},
_computeHasParams: function(record) {
if (!record.base) {
return false;
}
var object = record.base;
return !!(object.formParameters && Object.keys(object.formParameters).length);
}
});
</script>
</dom-module>