Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
refactored to use puremvc from NPM
  • Loading branch information
saadshams committed Aug 26, 2024
1 parent 65fc529 commit 603028a
Show file tree
Hide file tree
Showing 33 changed files with 287 additions and 1,689 deletions.
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2023, Saad Shams <saad.shams@puremvc.org>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ This demo illustrates techniques for performing routine client-side maintenance
* [plainJS](https://plainjs.com/javascript/)
* Vanilla JS Animations using [Robert Penner's Easing Functions](http://robertpenner.com/easing/) | [Cheat Sheet](https://easings.net/)

## Installation
```shell
npm run build
npm run preview
```

## Semantic HTML Components

```html
Expand Down
18 changes: 9 additions & 9 deletions bin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Employee Admin</title>
<script type="module" crossorigin src="/assets/index-0MBlhyuv.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-VK0D6HqQ.css">
<script type="module" crossorigin src="/assets/index-CjLqF_GI.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CtjMmi5U.css">
</head>
<body>
<div class="fluid">
Expand Down Expand Up @@ -46,27 +46,27 @@ <h2>User Form</h2>
<ul>
<li>
<label for="first">First Name:</label>
<input type="text" id="first" name="first" required>
<input type="text" id="first" name="first" required />
</li>
<li>
<label for="last">Last Name:</label>
<input type="text" id="last" name="last" required>
<input type="text" id="last" name="last" required />
</li>
<li>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<input type="email" id="email" name="email" required />
</li>
<li>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<input type="text" id="username" name="username" required />
</li>
<li>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<input type="password" id="password" name="password" required />
</li>
<li>
<label for="confirm">Confirm:</label>
<input type="password" id="confirm" name="confirm" required>
<input type="password" id="confirm" name="confirm" required />
</li>
<li>
<label for="department">Department:</label>
Expand Down Expand Up @@ -102,4 +102,4 @@ <h2>User Roles</h2>

</div>
</body>
</html>
</html>
8 changes: 8 additions & 0 deletions build/playwright.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// playwright.js
// PureMVC JS Demo - EmployeeAdmin
//
// Copyright(c) 2023 Saad Shams <saad.shams@puremvc.org>
// Your reuse is governed by the BSD 3-Clause License
//

// @ts-check
import {defineConfig, devices} from "@playwright/test";

Expand Down
8 changes: 7 additions & 1 deletion build/vite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import path from 'path';
//
// vite.js
// PureMVC JS Demo - EmployeeAdmin
//
// Copyright(c) 2023 Saad Shams <saad.shams@puremvc.org>
// Your reuse is governed by the BSD 3-Clause License
//

export default {
root: "src",
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@
"browserslist": [
"defaults",
"cover 99.5%"
]
],
"dependencies": {
"@puremvc/puremvc-js-multicore-framework": "2.0.7"
}
}
6 changes: 6 additions & 0 deletions src/css/app.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
@charset "UTF-8";
/**
app.css
PureMVC JS Demo - EmployeeAdmin
Copyright(c) 2023 Saad Shams <saad.shams@puremvc.org>
Your reuse is governed by the BSD 3-Clause License
*/
@import url("base.css");
@import url("layout.css");
@import url("module_user.css");
Expand Down
7 changes: 7 additions & 0 deletions src/css/base.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
@charset "UTF-8";
/**
base.css
PureMVC JS Demo - EmployeeAdmin
Copyright(c) 2023 Saad Shams <saad.shams@puremvc.org>
Your reuse is governed by the BSD 3-Clause License
*/
*, *::before, *::after {
box-sizing: border-box;
}
Expand Down
7 changes: 7 additions & 0 deletions src/css/layout.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
@charset "UTF-8";
/**
layout.css
PureMVC JS Demo - EmployeeAdmin
Copyright(c) 2023 Saad Shams <saad.shams@puremvc.org>
Your reuse is governed by the BSD 3-Clause License
*/
html {
height: 100%;
}
Expand Down
7 changes: 7 additions & 0 deletions src/css/module_form.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
@charset "UTF-8";
/**
module_form.css
PureMVC JS Demo - EmployeeAdmin
Copyright(c) 2023 Saad Shams <saad.shams@puremvc.org>
Your reuse is governed by the BSD 3-Clause License
*/
#userForm .wrapper {
display: flex;
flex-direction: column;
Expand Down
9 changes: 8 additions & 1 deletion src/css/module_role.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
@charset "UTF-8";
/**
module_role.css
PureMVC JS Demo - EmployeeAdmin
Copyright(c) 2023 Saad Shams <saad.shams@puremvc.org>
Your reuse is governed by the BSD 3-Clause License
*/
#userRole .wrapper {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -66,4 +73,4 @@
padding: 0 7px;
margin-right: 10px;
}
}
}
8 changes: 8 additions & 0 deletions src/css/module_user.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
@charset "UTF-8";
/**
module_user.css
PureMVC JS Demo - EmployeeAdmin
Copyright(c) 2023 Saad Shams <saad.shams@puremvc.org>
Your reuse is governed by the BSD 3-Clause License
*/
#userList .wrapper {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -51,6 +58,7 @@
padding: 10px;
margin-top: auto;
}

@media screen and (max-width: 767px) { /* Small screens (phones) */
#userList main ul li label span:nth-child(n+2),
#userList main ul li:first-child span:nth-child(n+2) { /* Hide all columns starting from the 2nd column */
Expand Down
7 changes: 7 additions & 0 deletions src/css/theme-dark.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
@charset "UTF-8";
/**
theme-dark.css
PureMVC JS Demo - EmployeeAdmin
Copyright(c) 2023 Saad Shams <saad.shams@puremvc.org>
Your reuse is governed by the BSD 3-Clause License
*/
:root {
--dark-theme-color: #ffffff;
--dark-theme-background: #121212;
Expand Down
7 changes: 7 additions & 0 deletions src/css/theme.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
@charset "UTF-8";
/**
theme.css
PureMVC JS Demo - EmployeeAdmin
Copyright(c) 2023 Saad Shams <saad.shams@puremvc.org>
Your reuse is governed by the BSD 3-Clause License
*/
:root {
--light-theme-color: #ffffff;
--light-theme-disabled: #eaeded;
Expand Down
4 changes: 2 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Employee Admin</title>
<link rel="stylesheet" href="css/app.css">
<script type="module" src="js/app.js"></script>
<script type="module" src="js/Application.js"></script>
</head>
<body>
<div class="fluid">
Expand Down Expand Up @@ -102,4 +102,4 @@ <h2>User Roles</h2>

</div>
</body>
</html>
</html>
14 changes: 14 additions & 0 deletions src/js/Application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Application.js
// PureMVC JS Demo - EmployeeAdmin
//
// Copyright(c) 2023 Saad Shams <saad.shams@puremvc.org>
// Your reuse is governed by the BSD 3-Clause License
//

import {ApplicationFacade} from "./ApplicationFacade.js";

document.addEventListener("DOMContentLoaded", () => {
ApplicationFacade.getInstance("EmployeeAdmin").startup();
});

16 changes: 12 additions & 4 deletions src/js/ApplicationFacade.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import {puremvc} from "./api/puremvc-2.0.0.js"
//
// ApplicationFacade.js
// PureMVC JS Demo - EmployeeAdmin
//
// Copyright(c) 2023 Saad Shams <saad.shams@puremvc.org>
// Your reuse is governed by the BSD 3-Clause License
//

import {Facade} from "@puremvc/puremvc-js-multicore-framework";
import {StartupCommand} from "./controller/StartupCommand.js";

export class ApplicationFacade extends puremvc.Facade {
export class ApplicationFacade extends Facade {

static get STARTUP () { return "startup" }

Expand Down Expand Up @@ -29,11 +37,11 @@ export class ApplicationFacade extends puremvc.Facade {
}

static getInstance(key) {
return puremvc.Facade.getInstance(key, k => new ApplicationFacade(k));
return Facade.getInstance(key, k => new ApplicationFacade(k));
}

startup(app) {
this.sendNotification(ApplicationFacade.STARTUP, app);
}

}
}
Loading

0 comments on commit 603028a

Please sign in to comment.