diff options
author | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-08-04 23:14:31 -0400 |
---|---|---|
committer | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-08-04 23:14:31 -0400 |
commit | 2b17d5468f8f96ad041eec6a61e77f0483e003e0 (patch) | |
tree | 44029a5c83dd231ccec9dfe84241b79de6f46e45 /src | |
parent | 0f1eb120167c921270a5b1146ba519f477da288c (diff) |
Removed some other uneccessary fles
Diffstat (limited to 'src')
-rw-r--r-- | src/components/counter-element.js | 66 | ||||
-rw-r--r-- | src/components/my-icons.js | 17 | ||||
-rw-r--r-- | src/components/shop-cart.js | 67 | ||||
-rw-r--r-- | src/components/shop-item.js | 33 | ||||
-rw-r--r-- | src/components/shop-products.js | 68 |
5 files changed, 0 insertions, 251 deletions
diff --git a/src/components/counter-element.js b/src/components/counter-element.js deleted file mode 100644 index 680c077..0000000 --- a/src/components/counter-element.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -@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'; - -// These are the elements needed by this element. -import { plusIcon, minusIcon } from './my-icons.js'; - -// These are the shared styles needed by this element. -import { ButtonSharedStyles } from './button-shared-styles.js'; - -// This is a reusable element. It is not connected to the store. You can -// imagine that it could just as well be a third-party element that you -// got from someone else. -class CounterElement extends LitElement { - _render(props) { - return html` - ${ButtonSharedStyles} - <style> - span { width: 20px; display: inline-block; text-align: center; font-weight: bold;} - </style> - <div> - <p> - Clicked: <span>${props.clicks}</span> times. - Value is <span>${props.value}</span>. - <button on-click="${() => this._onIncrement()}" title="Add 1">${plusIcon}</button> - <button on-click="${() => this._onDecrement()}" title="Minus 1">${minusIcon}</button> - </p> - </div> - `; - } - - static get properties() { return { - /* The total number of clicks you've done. */ - clicks: Number, - /* The current value of the counter. */ - value: Number - }}; - - constructor() { - super(); - this.clicks = 0; - this.value = 0; - } - - _onIncrement() { - this.value++; - this.clicks++; - this.dispatchEvent(new CustomEvent('counter-incremented')); - } - - _onDecrement() { - this.value--; - this.clicks++; - this.dispatchEvent(new CustomEvent('counter-decremented')); - } -} - -window.customElements.define('counter-element', CounterElement); diff --git a/src/components/my-icons.js b/src/components/my-icons.js deleted file mode 100644 index 76d5834..0000000 --- a/src/components/my-icons.js +++ /dev/null @@ -1,17 +0,0 @@ -/** -@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 { html } from '@polymer/lit-element'; - -export const menuIcon = html`<svg height="24" viewBox="0 0 24 24" width="24"><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"></path></svg>`; -export const addToCartIcon = html`<svg height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0zm18.31 6l-2.76 5z" fill="none"/><path id="cart-path" d="M11 9h2V6h3V4h-3V1h-2v3H8v2h3v3zm-4 9c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zm10 0c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2zm-9.83-3.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.86-7.01L19.42 4h-.01l-1.1 2-2.76 5H8.53l-.13-.27L6.16 6l-.95-2-.94-2H1v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.13 0-.25-.11-.25-.25z"/></svg>`; -export const removeFromCartIcon = html`<svg height="24" viewBox="0 0 24 24" width="24"><path d="M22.73 22.73L2.77 2.77 2 2l-.73-.73L0 2.54l4.39 4.39 2.21 4.66-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h7.46l1.38 1.38c-.5.36-.83.95-.83 1.62 0 1.1.89 2 1.99 2 .67 0 1.26-.33 1.62-.84L21.46 24l1.27-1.27zM7.42 15c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h2.36l2 2H7.42zm8.13-2c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.08-.14.12-.31.12-.48 0-.55-.45-1-1-1H6.54l9.01 9zM7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2z"/><path d="M0 0h24v24H0z" fill="none"/></svg>`; -export const minusIcon = html`<svg height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M7 11v2h10v-2H7zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg>`; -export const plusIcon = html`<svg height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg>`; diff --git a/src/components/shop-cart.js b/src/components/shop-cart.js deleted file mode 100644 index 1fd7f15..0000000 --- a/src/components/shop-cart.js +++ /dev/null @@ -1,67 +0,0 @@ -/** -@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 elements needed by this element. -import { removeFromCartIcon } from './my-icons.js'; -import './shop-item.js'; - -// These are the actions needed by this element. -import { removeFromCart } from '../actions/shop.js'; - -// These are the reducers needed by this element. -import { cartItemsSelector, cartTotalSelector } from '../reducers/shop.js'; - -// These are the shared styles needed by this element. -import { ButtonSharedStyles } from './button-shared-styles.js'; - -class ShopCart extends connect(store)(LitElement) { - _render({_items, _total}) { - return html` - ${ButtonSharedStyles} - <style> - :host { display: block; } - </style> - <p hidden="${_items.length !== 0}">Please add some products to cart.</p> - ${_items.map((item) => - html` - <div> - <shop-item name="${item.title}" amount="${item.amount}" price="${item.price}"></shop-item> - <button - on-click="${(e) => store.dispatch(removeFromCart(e.currentTarget.dataset['index']))}" - data-index$="${item.id}" - title="Remove from cart"> - ${removeFromCartIcon} - </button> - </div> - ` - )} - <p hidden="${!_items.length}"><b>Total:</b> ${_total}</p> - `; - } - - static get properties() { return { - _items: Array, - _total: Number - }} - - // This is called every time something is updated in the store. - _stateChanged(state) { - this._items = cartItemsSelector(state); - this._total = cartTotalSelector(state); - } -} - -window.customElements.define('shop-cart', ShopCart); diff --git a/src/components/shop-item.js b/src/components/shop-item.js deleted file mode 100644 index 6c6dcb9..0000000 --- a/src/components/shop-item.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -@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'; - -// This element is *not* connected to the Redux store. -class ShopItem extends LitElement { - _render(props) { - return html` - ${props.name}: - <span hidden="${props.amount === 0}">${props.amount} * </span> - $${props.price} - </span> - `; - } - - static get properties() { - return { - name: String, - amount: String, - price: String - } - } -} - -window.customElements.define('shop-item', ShopItem); diff --git a/src/components/shop-products.js b/src/components/shop-products.js deleted file mode 100644 index b5b33e2..0000000 --- a/src/components/shop-products.js +++ /dev/null @@ -1,68 +0,0 @@ -/** -@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 elements needed by this element. -import './shop-item.js'; - -// These are the actions needed by this element. -import { getAllProducts, addToCart } from '../actions/shop.js'; - -// These are the elements needed by this element. -import { addToCartIcon } from './my-icons.js'; - -// These are the shared styles needed by this element. -import { ButtonSharedStyles } from './button-shared-styles.js'; - -class ShopProducts extends connect(store)(LitElement) { - _render({_products}) { - return html` - ${ButtonSharedStyles} - <style> - :host { display: block; } - </style> - ${Object.keys(_products).map((key) => { - const item = _products[key]; - return html` - <div> - <shop-item name="${item.title}" amount="${item.inventory}" price="${item.price}"></shop-item> - <button - disabled="${item.inventory === 0}" - on-click="${(e) => store.dispatch(addToCart(e.currentTarget.dataset['index']))}" - data-index$="${item.id}" - title="${item.inventory === 0 ? 'Sold out' : 'Add to cart' }"> - ${item.inventory === 0 ? 'Sold out': addToCartIcon } - </button> - </div> - ` - })} - `; - } - - static get properties() { return { - _products: Object - }} - - _firstRendered() { - store.dispatch(getAllProducts()); - } - - // This is called every time something is updated in the store. - _stateChanged(state) { - this._products = state.shop.products; - } -} - -window.customElements.define('shop-products', ShopProducts); |