diff options
author | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-09-17 18:58:23 -0400 |
---|---|---|
committer | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-09-17 18:58:23 -0400 |
commit | 5bcdeb20644b41f7a68ca0ddb2b164528d8af355 (patch) | |
tree | 387990f767aee97573102ffa75dc2d55858bc253 /src/components/forum-element.js | |
parent | 7400d72053dd4463b93055aaf3050872d9a49af9 (diff) |
Working on abstraction of forum page to allow comments on forums.
Diffstat (limited to 'src/components/forum-element.js')
-rw-r--r-- | src/components/forum-element.js | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/src/components/forum-element.js b/src/components/forum-element.js new file mode 100644 index 0000000..138cc6a --- /dev/null +++ b/src/components/forum-element.js @@ -0,0 +1,137 @@ +/** +@license +Copyright (c) 2018 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +import { LitElement, html } from '@polymer/lit-element'; +import { connect } from 'pwa-helpers/connect-mixin.js'; + +// This element is connected to the Redux store. +import { store } from '../store.js'; + +//These are the actions needed by this element. +import { adminApproveHours, adminRejectHours } from '../actions/firebaseAdmin.js'; + +// Import button styles +import { ButtonSharedStyles } from './button-shared-styles.js'; + +class ForumElement extends connect(store)(LitElement) { + _render(props) { + return html` + ${ButtonSharedStyles} + + <style> + + paper-card { + display: block; + padding-bottom: 3px; + } + + .button-grid { + display: grid; + grid-template-rows: 1fr; + } + + .card-content > h4 { + text-align: right; + font-weight: lighter; + font-style: italic; + word-break: break-all; + } + + .card-content > h3 { + word-break: break-all; + } + + .card-content > h3, p { + text-align: center; + } + + .success { + width: 100%; + margin-top: 5px; + } + + @media (min-width: 460px) { + .button-grid { + grid-template-columns: 1fr 1fr; + } + + #comment-subject-field { + margin-left: auto; + margin-right: auto; + text-align: center; + width: 50%; + } + } + + + </style> + + <paper-card + elevation="0"> + <div class="card-content"> + <h4>${props.author}</h4> + <h3>${props.subject}</h3> + <p>${props.content}</p> + </div> + <div class="card-actions"> + <div class="button-grid"> + <paper-button class="info" raised onclick="${() => this.showComments = !this.showComments}">Show Comments</paper-button> + <paper-button raised onclick="${() => this.postComment = !this.postComment}">${this.postComment? "Hide Draft" : "Post Comment"}</paper-button> + </div> + + <div hidden="${!props.postComment}"> + <hr> + <paper-input label="Comment Subject" id="comment-subject-field"></paper-input> + <paper-textarea label="Comment Content" id="comment-content-field"></paper-textarea> + <paper-button class="success">Submit Comment</paper-comment> + </div> + + <div hidden="${!props.showComments}"> + <hr hidden="${!props.showComments && !props.postComment}"> + <h4>Comments</h4> + + </div> + </div> + </div> + </paper-card> + `; + } + + static get properties() { return { + signedIn: Boolean, + + author: String, + subject: String, + content: String, + + showComments: Boolean, + postComment: Boolean + }}; + + _stateChanged(state) { + this.signedIn = state.firebaseAuth.signedIn; + } + + constructor() { + super(); + + this.signedIn = false; + + this.author = ""; + this.subject = ""; + this.content = ""; + + this.showComments = false; + this.postComment = false; + } + +} + +window.customElements.define('forum-element', ForumElement); |