Skip to content

Commit aa66c05

Browse files
authored
Merge pull request #133 from PolymerElements/polish
Misc polish and bug fixes.
2 parents ad6a17d + 27ec3c4 commit aa66c05

File tree

2 files changed

+59
-33
lines changed

2 files changed

+59
-33
lines changed

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"dependencies": {
2020
"app-layout": "PolymerElements/app-layout#1 - 2",
2121
"iron-ajax": "PolymerElements/iron-ajax#1 - 2",
22-
"iron-doc-viewer": "PolymerElements/iron-doc-viewer#master",
22+
"iron-doc-viewer": "PolymerElements/iron-doc-viewer#>=3.0.0-rc.1",
2323
"iron-icons": "PolymerElements/iron-icons#1 - 2",
2424
"paper-icon-button": "PolymerElements/paper-icon-button#1 - 2",
2525
"paper-styles": "PolymerElements/paper-styles#1 - 2",
@@ -35,7 +35,7 @@
3535
"dependencies": {
3636
"app-layout": "PolymerElements/app-layout#^1.0.0",
3737
"iron-ajax": "PolymerElements/iron-ajax#^1.0.0",
38-
"iron-doc-viewer": "PolymerElements/iron-doc-viewer#master",
38+
"iron-doc-viewer": "PolymerElements/iron-doc-viewer#>=3.0.0-rc.1",
3939
"iron-icons": "PolymerElements/iron-icons#^1.0.0",
4040
"paper-icon-button": "PolymerElements/paper-icon-button#^1.0.0",
4141
"paper-styles": "PolymerElements/paper-styles#^1.0.0",

iron-component-page.html

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<link rel="import" href="../app-layout/app-header-layout/app-header-layout.html">
1515
<link rel="import" href="../app-layout/app-toolbar/app-toolbar.html">
1616
<link rel="import" href="../iron-ajax/iron-ajax.html">
17+
<link rel="import" href="../iron-doc-viewer/default-theme.html">
1718
<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">
1919
<link rel="import" href="../iron-doc-viewer/iron-doc-viewer.html">
2020
<link rel="import" href="../iron-icons/iron-icons.html">
2121
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
@@ -25,9 +25,13 @@
2525

2626
<dom-module id="iron-component-page">
2727
<template>
28-
<style include="iron-doc-viewer-default-theme">
28+
<style include="iron-doc-default-theme">
29+
[hidden] {
30+
display: none;
31+
}
32+
2933
iron-doc-viewer {
30-
margin: 16px 0 0 24px;
34+
margin: 20px 0 0 20px;
3135
max-width: 56em;
3236
}
3337

@@ -37,6 +41,10 @@
3741
background-color: #5a5a5a;
3842
}
3943

44+
[condensed-title] {
45+
white-space: nowrap;
46+
}
47+
4048
app-drawer {
4149
--app-drawer-content-container: {
4250
background-color: #f9f9f9;
@@ -49,6 +57,17 @@
4957
overflow-x: hidden;
5058
}
5159

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+
5271
iron-doc-viewer {
5372
--iron-doc-title: {
5473
display: none;
@@ -77,7 +96,7 @@
7796
Could not load descriptor "[[descriptorUrl]]". <br> [[_error.error]]
7897
</paper-toast>
7998

80-
<app-drawer-layout id="layout" fullbleed>
99+
<app-drawer-layout fullbleed narrow="{{_narrow}}">
81100

82101
<app-drawer id="drawer" slot="drawer" swipe-open>
83102
<iron-doc-nav
@@ -90,16 +109,24 @@
90109
<app-header-layout>
91110
<app-header slot="header" fixed>
92111
<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+
94118
<div condensed-title>[[_title]]</div>
95119
</app-toolbar>
96120
</app-header>
97121

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>
103130

104131
</app-header-layout>
105132
</app-drawer-layout>
@@ -111,11 +138,24 @@
111138
is: 'iron-component-page',
112139

113140
properties: {
141+
/**
142+
* URL of the Polymer Analyzer descriptor to fetch and display.
143+
*/
114144
descriptorUrl: {
115145
type: String,
146+
value: 'analysis.json',
116147
observer: '_descriptorUrlChanged'
117148
},
118149

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+
119159
_loading: Boolean,
120160

121161
_error: Object,
@@ -127,15 +167,20 @@
127167

128168
_path: String,
129169

170+
_narrow: Boolean,
171+
130172
_title: {
131173
type: String,
132174
observer: '_titleChanged'
133175
}
134176
},
135177

136178
_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) {
139184
this.$.drawer.close();
140185
}
141186
},
@@ -152,25 +197,6 @@
152197
this._changing = true;
153198
this._descriptor = _flatten(descriptor);
154199
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-
}
174200
},
175201

176202
_titleChanged(title) {

0 commit comments

Comments
 (0)