Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor code #5

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions package-old.json

This file was deleted.

48 changes: 25 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,41 @@
"start:build": "web-dev-server --root-dir dist --app-index index.html"
},
"dependencies": {
"@dreamworld/dw-button": "^2.1.2",
"@dreamworld/dw-dialog": "^3.4.0",
"@dreamworld/dw-icon": "^2.1.1",
"@dreamworld/dw-icon-button": "^2.1.3",
"@dreamworld/dw-input": "^2.1.6",
"@dreamworld/dw-list-item": "^2.1.0",
"@dreamworld/dw-switch": "^2.1.0",
"@dreamworld/dw-tooltip": "^2.1.1",
"@dreamworld/dw-dialog": "^4.1.2",
"@dreamworld/dw-list-item": "^3.4.0",
"@dreamworld/hammerjs": "^1.0.1",
"@dreamworld/material-styles": "^1.3.1",
"@dreamworld/material-styles": "^2.5.0",
"@dreamworld/pwa-helpers": "^1.11.1",
"@dreamworld/router": "^1.0.0",
"@dw/i18next-esm": "^15.0.9",
"@lit-labs/virtualizer": "^0.6.0",
"@material/mwc-button": "^0.27.0",
"@material/mwc-icon": "^0.27.0",
"@material/mwc-icon-button": "^0.27.0",
"@material/mwc-textfield": "^0.27.0",
"i18next-xhr-backend": "^3.2.2",
"lit": "^2.0.0",
"lit": "^2.3.1",
"lodash-es": "^4.17.21",
"moment": "^2.29.1",
"redux": "^4.1.1",
"redux-saga": "^1.1.3",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0"
"moment": "^2.29.4",
"redux": "^4.2.0",
"redux-saga": "^1.2.1",
"redux-thunk": "^2.4.1",
"reselect": "^4.1.6"
},
"devDependencies": {
"@open-wc/building-rollup": "^2.0.1",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.1.1",
"@web/dev-server": "^0.1.25",
"@open-wc/building-rollup": "^2.0.2",
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-node-resolve": "^14.0.1",
"@web/dev-server": "^0.1.34",
"@web/rollup-plugin-copy": "^0.3.0",
"@web/rollup-plugin-html": "^1.10.1",
"rollup": "^2.62.0",
"@web/rollup-plugin-html": "^1.11.0",
"rollup": "^2.79.0",
"rollup-plugin-minify-html-literals": "^1.2.6",
"rollup-plugin-summary": "^1.3.0",
"rollup-plugin-summary": "^1.4.3",
"rollup-plugin-terser": "^7.0.2"
},
"resolutions": {
"@material/mwc-ripple": "^0.27.0",
"@material/mwc-icon": "^0.27.0",
"@material/mwc-icon-button": "^0.27.0"
}
}
24 changes: 16 additions & 8 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
// Import rollup plugins
import html from "@web/rollup-plugin-html";
import {copy} from "@web/rollup-plugin-copy";
import { copy } from "@web/rollup-plugin-copy";
import resolve from "@rollup/plugin-node-resolve";
import {terser} from "rollup-plugin-terser";
import { terser } from "rollup-plugin-terser";
import minifyHTML from "rollup-plugin-minify-html-literals";
import summary from "rollup-plugin-summary";

export default {
plugins: [
// Entry point for application build; can specify a glob to build multiple
// HTML files for non-SPA app
html({
input: 'index.html',
input: "index.html",
}),
// Resolve bare module specifiers to relative paths
resolve(),
// Minify HTML template literals
minifyHTML(),
// Minify JS
terser({
ecma: 2021,
module: true,
warnings: true,
}),
// Print bundle summary
summary(),
// Optional: copy any static assets to build directory
copy({
patterns: ['src/img/**/*', 'src/locales/**/*']
})
patterns: ["src/img/**/*", "src/locales/**/*"],
}),
],
output: {
dir: 'dist',
dir: "dist",
},
preserveEntrySignatures: 'strict',
};
preserveEntrySignatures: "strict",
};
71 changes: 35 additions & 36 deletions src/app-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ import { LitElement, html, css } from "lit";

//Redux
import { connect } from "pwa-helpers/connect-mixin.js";
import { store } from './redux/store';
import { store } from "./redux/store";
import * as app from "./redux/app";
import * as router from './redux/router';
import * as router from "./redux/router";

//Views
import './views/header/app-header';
import "./views/header/app-header";

export class AppSection extends connect(store)(LitElement) {

static styles = css`
:host{
:host {
flex: 1;
display: flex;
}

.backdrop{
.backdrop {
flex: 1 1 0%;
background-color: rgba(0, 0, 0, 0);
z-index: -9;
Expand All @@ -27,28 +26,28 @@ export class AppSection extends connect(store)(LitElement) {
transition: background-color var(--drawer-open-time);
}

.backdrop[opened]{
.backdrop[opened] {
background-color: rgba(0, 0, 0, 0.8);
z-index: 3;
}

.section{
.section {
flex: 1;
position: relative;
display: flex;
flex-direction: column;
transition: margin-left var(--drawer-open-time);
}

:host([layout='desktop']) .section{
:host([layout="desktop"]) .section {
padding: 4px;
}

:host([layout='desktop']) .section[opened]{
:host([layout="desktop"]) .section[opened] {
margin-left: calc(var(--drawer-width) + 16px);
}

.body{
.body {
display: flex;
margin-top: 56px;
}
Expand All @@ -60,15 +59,15 @@ export class AppSection extends connect(store)(LitElement) {
reflect: true,
},
drawerOpened: {
type: String
type: String,
},
_page: {
type: String
type: String,
},
_id: {
type: Number
type: Number,
},
}
};

constructor() {
super();
Expand All @@ -79,7 +78,6 @@ export class AppSection extends connect(store)(LitElement) {
}

_getInitView() {

return this._getInitView();
}

Expand All @@ -88,68 +86,69 @@ export class AppSection extends connect(store)(LitElement) {
${this._getBackdropVew()}
<div class="section" ?opened=${this.drawerOpened}>
<app-header></app-header>
<div class="body">
${this._getPageView()}
</div>
<div class="body">${this._getPageView()}</div>
</div>
`;
}

_getBackdropVew() {
return this.layout === 'mobile'
? html`<div class="backdrop" @click="${this._onDrawerToggel}" ?opened=${this.drawerOpened}></div>`
return this.layout === "mobile"
? html`<div
class="backdrop"
@click="${this._onDrawerToggel}"
?opened=${this.drawerOpened}
></div>`
: html``;
}

_getPageView() {

if (this._page === "root" || this._page === "home") {
import('./views//home/app-home');
return html`<app-home></app-home>`
import("./views//home/app-home");
return html`<app-home></app-home>`;
}

if (this._page === "shows") {
import('./views/tv-shows/tv-shows.js');
import("./views/tv-shows/tv-shows.js");
return html`<tv-shows></tv-shows>`;
}

if (this._page === "movies" && this._id === undefined) {
import('./views/movies/app-movies');
import("./views/movies/app-movies");
return html`<app-movies></app-movies>`;
}

if (this._page === "movies" && this._id !== undefined) {
import('./views/movies/movie-details');
import("./views/movies/movie-details");
return html`<movie-details></movie-details>`;
}

if (this._page === "person" && this._id === undefined) {
import('./views/person/app-person');
import("./views/person/app-person");
return html`<app-person></app-person>`;
}

if (this._page === "person" && this._id !== undefined) {
import('./views/person/person-view');
import("./views/person/person-view");
return html`<person-view></person-view>`;
}

if (this._page === "test") {
import('./views/test/test-page');
import("./views/test/test-page");
return html`<test-page></test-page>`;
}

if (this._page === "not-found") {
import('./views/not-found');
return html`<not-found></not-found>`
import("./views/not-found");
return html`<not-found></not-found>`;
}

import('./views/not-found');
return html`<not-found></not-found>`
import("./views/not-found");
return html`<not-found></not-found>`;
}

_onDrawerToggel() {
store.dispatch({
type: 'drawerStatusChange',
type: "drawerStatusChange",
drawerOpened: this.drawerOpened ? false : true,
});
}
Expand All @@ -163,4 +162,4 @@ export class AppSection extends connect(store)(LitElement) {
}
}

window.customElements.define("app-section", AppSection);
window.customElements.define("app-section", AppSection);
11 changes: 6 additions & 5 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
if('serviceWorker' in navigator){
navigator.serviceWorker.register("/service-worker.js")
.then( (reg) => console.log('service worker registered'))
.catch( (err) => console.log('service worker not registered'))
}
if ("serviceWorker" in navigator) {
navigator.serviceWorker
.register("/service-worker.js")
.then((reg) => console.log("service worker registered"))
.catch((err) => console.log("service worker not registered"));
}
Loading