Skip to content

Commit

Permalink
color and stlying for toc complete
Browse files Browse the repository at this point in the history
  • Loading branch information
IanKBovard committed Sep 18, 2018
1 parent 29d49e3 commit cc534af
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 35 deletions.
File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions src/book-view/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
import '@polymer/iron-ajax/iron-ajax.js';
import'./book-description.js';
import'./table-of-contents.js';
import'./book-title.js';

class BookView extends PolymerElement {
static get template() {
return html`
<style>
:host {
}
.book-data {
width: 100%;
overflow: hidden;
white-space: nowrap;
}
</style>
<iron-ajax
auto
url="https://d1re4mvb3lawey.cloudfront.net/pg1017/index.json"
handle-as="json"
on-response="handleResponse">
</iron-ajax>
<div class="book-data">
<book-title title="{{bookData.title}}">
</book-title>
<book-description isbn="{{bookData.isbn}}" authors="{{bookData.contributors}}">
</book-description>
<table-of-contents toc="{{bookData.toc}}">
</table-of-contents>
</div>
`;
}
handleResponse(res){
this.bookData = res.detail.response
console.log(this.bookData.toc)
return
}
constructor() {
super();
this.bookData = {}
}
}

window.customElements.define('book-view', BookView);
26 changes: 22 additions & 4 deletions src/table-of-contents.js → src/book-view/table-of-contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,33 @@ class TableOfContents extends PolymerElement {
.toc-content {
position: relative;
padding-left: 30px;
white-space: nowrap;
}
ol {
display: block;
list-style-type: decimal;
}
li {
display: list-item;
}
a {
color: inherit;
text-decoration: none;
}
a:hover {
background-color: #FFD700;
}
</style>
<div class="toc-container">
<span class="toc-text">Contents</span>
<div class="toc-content">
<template is="dom-repeat" items="[[toc]]">
<p>{{item}}</p>
</template>
<ol>
<template is="dom-repeat" items="[[toc]]">
<li>
<a href="{{item.file}}">Title should go here</a>
</li>
</template>
</ol>
</div>
</div>
`;
Expand Down
33 changes: 2 additions & 31 deletions src/my-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
import { setPassiveTouchGestures, setRootPath } from '@polymer/polymer/lib/utils/settings.js';
import '@polymer/iron-ajax/iron-ajax.js';
import'./book-description.js';
import'./table-of-contents.js';
import'./book-title.js';
import './book-view/index.js';
// Gesture events like tap and track generated from touch will not be
// preventable, allowing for better scrolling performance.
setPassiveTouchGestures(true);
Expand All @@ -28,36 +25,10 @@ class MyApp extends PolymerElement {
<style>
:host {
}
.book-data {
width: 100%;
overflow: hidden;
white-space: nowrap;
}
</style>
<iron-ajax
auto
url="https://d1re4mvb3lawey.cloudfront.net/pg1017/index.json"
handle-as="json"
on-response="handleResponse">
</iron-ajax>
<div class="book-data">
<book-title title="{{bookData.title}}">
</book-title>
<book-description isbn="{{bookData.isbn}}" authors="{{bookData.contributors}}">
</book-description>
<table-of-contents toc="{{bookData.toc}}">
</table-of-contents>
</div>
<book-view></book-view>
`;
}
handleResponse(res){
this.bookData = res.detail.response
return
}
constructor() {
super();
this.bookData = {}
}
}

window.customElements.define('my-app', MyApp);

0 comments on commit cc534af

Please sign in to comment.