|
14 | 14 | <link rel="import" href="../app-layout/app-header-layout/app-header-layout.html"> |
15 | 15 | <link rel="import" href="../app-layout/app-toolbar/app-toolbar.html"> |
16 | 16 | <link rel="import" href="../iron-ajax/iron-ajax.html"> |
| 17 | +<link rel="import" href="../iron-doc-viewer/default-theme.html"> |
17 | 18 | <link rel="import" href="../iron-doc-viewer/iron-doc-nav.html"> |
18 | | -<link rel="import" href="../iron-doc-viewer/iron-doc-viewer-default-theme.html"> |
19 | 19 | <link rel="import" href="../iron-doc-viewer/iron-doc-viewer.html"> |
20 | 20 | <link rel="import" href="../iron-icons/iron-icons.html"> |
21 | 21 | <link rel="import" href="../paper-icon-button/paper-icon-button.html"> |
|
25 | 25 |
|
26 | 26 | <dom-module id="iron-component-page"> |
27 | 27 | <template> |
28 | | - <style include="iron-doc-viewer-default-theme"> |
| 28 | + <style include="iron-doc-default-theme"> |
| 29 | + [hidden] { |
| 30 | + display: none; |
| 31 | + } |
| 32 | + |
29 | 33 | iron-doc-viewer { |
30 | | - margin: 16px 0 0 24px; |
| 34 | + margin: 20px 0 0 20px; |
31 | 35 | max-width: 56em; |
32 | 36 | } |
33 | 37 |
|
|
37 | 41 | background-color: #5a5a5a; |
38 | 42 | } |
39 | 43 |
|
| 44 | + [condensed-title] { |
| 45 | + white-space: nowrap; |
| 46 | + } |
| 47 | + |
40 | 48 | app-drawer { |
41 | 49 | --app-drawer-content-container: { |
42 | 50 | background-color: #f9f9f9; |
|
49 | 57 | overflow-x: hidden; |
50 | 58 | } |
51 | 59 |
|
| 60 | + /** |
| 61 | + * iron-doc-viewer uses scrollIntoView for fragment links, but this |
| 62 | + * doesn't take into account our app-header, so by default when our |
| 63 | + * scroll block is the document, we'll scroll things hidden underneath |
| 64 | + * the app-header. |
| 65 | + */ |
| 66 | + #scroller { |
| 67 | + overflow-y: auto; |
| 68 | + height: calc(100vh - 64px); |
| 69 | + } |
| 70 | + |
52 | 71 | iron-doc-viewer { |
53 | 72 | --iron-doc-title: { |
54 | 73 | display: none; |
|
77 | 96 | Could not load descriptor "[[descriptorUrl]]". <br> [[_error.error]] |
78 | 97 | </paper-toast> |
79 | 98 |
|
80 | | - <app-drawer-layout id="layout" fullbleed> |
| 99 | + <app-drawer-layout fullbleed narrow="{{_narrow}}"> |
81 | 100 |
|
82 | 101 | <app-drawer id="drawer" slot="drawer" swipe-open> |
83 | 102 | <iron-doc-nav |
|
90 | 109 | <app-header-layout> |
91 | 110 | <app-header slot="header" fixed> |
92 | 111 | <app-toolbar> |
93 | | - <paper-icon-button icon="menu" drawer-toggle></paper-icon-button> |
| 112 | + <paper-icon-button |
| 113 | + icon="menu" |
| 114 | + drawer-toggle |
| 115 | + hidden$="[[!_narrow]]"> |
| 116 | + </paper-icon-button> |
| 117 | + |
94 | 118 | <div condensed-title>[[_title]]</div> |
95 | 119 | </app-toolbar> |
96 | 120 | </app-header> |
97 | 121 |
|
98 | | - <iron-doc-viewer |
99 | | - descriptor="[[_descriptor]]" |
100 | | - title="{{_title}}" |
101 | | - path="{{_path}}"> |
102 | | - </iron-doc-viewer> |
| 122 | + <div id="scroller"> |
| 123 | + <iron-doc-viewer |
| 124 | + descriptor="[[_descriptor]]" |
| 125 | + base-href="[[baseHref]]" |
| 126 | + title="{{_title}}" |
| 127 | + path="{{_path}}"> |
| 128 | + </iron-doc-viewer> |
| 129 | + </div> |
103 | 130 |
|
104 | 131 | </app-header-layout> |
105 | 132 | </app-drawer-layout> |
|
111 | 138 | is: 'iron-component-page', |
112 | 139 |
|
113 | 140 | properties: { |
| 141 | + /** |
| 142 | + * URL of the Polymer Analyzer descriptor to fetch and display. |
| 143 | + */ |
114 | 144 | descriptorUrl: { |
115 | 145 | type: String, |
| 146 | + value: 'analysis.json', |
116 | 147 | observer: '_descriptorUrlChanged' |
117 | 148 | }, |
118 | 149 |
|
| 150 | + /** |
| 151 | + * By default all routing is performed using the URL fragment |
| 152 | + * (e.g. `docs.html#/elements/my-element`). If your server supports |
| 153 | + * it and you would like to use the real URL path instead (e.g. |
| 154 | + * `/docs/elements/my-element`), set this to the base path where the |
| 155 | + * page is mounted (e.g. `/` or `/docs/`). |
| 156 | + */ |
| 157 | + baseHref: String, |
| 158 | + |
119 | 159 | _loading: Boolean, |
120 | 160 |
|
121 | 161 | _error: Object, |
|
127 | 167 |
|
128 | 168 | _path: String, |
129 | 169 |
|
| 170 | + _narrow: Boolean, |
| 171 | + |
130 | 172 | _title: { |
131 | 173 | type: String, |
132 | 174 | observer: '_titleChanged' |
133 | 175 | } |
134 | 176 | }, |
135 | 177 |
|
136 | 178 | _onNavSelect() { |
137 | | - document.body.scrollTop = 0; |
138 | | - if (this.$.layout.narrow) { |
| 179 | + // Note we need to listen for this event, and can't rely just on the |
| 180 | + // path changing, because the user might click on the nav item they |
| 181 | + // are already viewing. |
| 182 | + window.document.body.scrollTop = 0; |
| 183 | + if (this._narrow) { |
139 | 184 | this.$.drawer.close(); |
140 | 185 | } |
141 | 186 | }, |
|
152 | 197 | this._changing = true; |
153 | 198 | this._descriptor = _flatten(descriptor); |
154 | 199 | this._changing = false; |
155 | | - |
156 | | - return; |
157 | | - |
158 | | - var behaviors = descriptor.metadata |
159 | | - && descriptor.metadata.polymer |
160 | | - && descriptor.metadata.polymer.behaviors; |
161 | | - |
162 | | - if ((descriptor.namespaces || []).length) { |
163 | | - this._path = '/namespaces/' + descriptor.namespaces[0].name; |
164 | | - } else if ((descriptor.elements || []).length) { |
165 | | - var element = descriptor.elements; |
166 | | - this._path = '/elements/' + (element.tagname || element.name); |
167 | | - } else if ((behaviors || []).length) { |
168 | | - this._path = '/behaviors/' + behaviors[0].name; |
169 | | - } else if ((descriptor.mixins || []).length) { |
170 | | - this._path = '/mixins/' + descriptor.mixins[0].name; |
171 | | - } else if ((descriptor.classes || []).length) { |
172 | | - this._path = '/classes/' + descriptor.classes[0].name; |
173 | | - } |
174 | 200 | }, |
175 | 201 |
|
176 | 202 | _titleChanged(title) { |
|
0 commit comments