Skip to content

Commit

Permalink
chore: create a demo workspace (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
wibus-wee authored Dec 20, 2022
1 parent 85c6bf5 commit 2ee5c2f
Show file tree
Hide file tree
Showing 15 changed files with 297 additions and 1 deletion.
21 changes: 21 additions & 0 deletions demo/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Jwc.js

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 14 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite + Jwc.js App</title>
<link rel="stylesheet" href="./src/index.css">
<script type="module" src="./src/index.ts"></script>
</head>
<body>
<app-element count="2022" ></app-element>
</body>
</html>
18 changes: 18 additions & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"vite": "^4.0.1",
"jwcjs": "*"
}
}
14 changes: 14 additions & 0 deletions demo/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite + Jwc.js App</title>
<link rel="stylesheet" href="./index.css">
<script type="module" src="./index.es.js"></script>
</head>
<body>
<app-element></app-element>
</body>
</html>
8 changes: 8 additions & 0 deletions demo/public/jwc-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions demo/public/jwc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions demo/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions demo/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

:host {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 0.25s;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.jwc:hover {
filter: drop-shadow(0 0 2em rgb(0, 0, 0));
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}

@media (prefers-color-scheme: dark) {
.logo.jwc:hover {
filter: drop-shadow(0 0 2em rgb(255, 255, 255));
}
}


button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}


@media (prefers-color-scheme: light) {
button {
background-color: #f9f9f9;
}
}
76 changes: 76 additions & 0 deletions demo/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { JwcComponent, Component, Prop, h, Fragment } from "jwcjs";
import styles from "./App.css?inline";

@Component({
name: "app-element",
css: styles,
})
export class App extends JwcComponent {
constructor() {
super();
}

@Prop({ default: 0, attr: "count" })
public count = 0;

public onClick = () => {
this.count++;
};

// get media
public getSystemColorScheme() {
return window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
}

public override connectedCallback() {
super.connectedCallback();
window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", () => {
this.updateDiff();
console.log("change");
});
}

public override disconnectedCallback() {
super.disconnectedCallback();
window
.matchMedia("(prefers-color-scheme: dark)")
.removeEventListener("change", () => {
this.updateDiff();
});
}

public override render() {
return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src="/vite.svg" class="logo" alt="Vite logo" />
</a>
<a href="https://github.com/jwcjs/core" target="_blank">
<img
src={
this.getSystemColorScheme() === "dark"
? "/jwc-dark.svg"
: "/jwc.svg"
}
class="logo jwc"
alt="Jwc logo"
/>
</a>
</div>
<div class={"card"}>
<button onClick={this.onClick}>
count is {String(this.count)}
</button>
</div>
<p class="read-the-docs">
Click on the Vite and Jwc logos to learn more
</p>
</>
);
}
}
62 changes: 62 additions & 0 deletions demo/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}


h1 {
font-size: 3.2em;
line-height: 1.1;
}


@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}


#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
1 change: 1 addition & 0 deletions demo/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./App";
1 change: 1 addition & 0 deletions demo/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
2 changes: 2 additions & 0 deletions demo/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { defineConfig } from "vite";
export default defineConfig({});
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

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

3 changes: 2 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
packages:
- packages/*
- packages/*
- demo

0 comments on commit 2ee5c2f

Please sign in to comment.