Skip to content

Commit

Permalink
refactor(demo): new demo application
Browse files Browse the repository at this point in the history
  • Loading branch information
MM25Zamanian committed Mar 25, 2024
1 parent a73f96d commit d277578
Show file tree
Hide file tree
Showing 18 changed files with 595 additions and 1,175 deletions.
1 change: 0 additions & 1 deletion demo/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions demo/dialog/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>Gecut Dialog</title>
<link rel="stylesheet" href="/demo/__styles.css" />
<script type="module" src="../main/global.ts"></script>
<script type="module" src="./scripts.ts"></script>
</head>
<body class="bg-surface max-w-screen-sm mx-auto px-2"></body>
<script type="module" src="scripts.js"></script>
</html>
Binary file added demo/dialog/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 7 additions & 13 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
<html lang="en">
<html lang="en" class="color-scheme-auto bg-background">
<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>Gecut</title>
<style>
html {
color-scheme: light dark;
}
</style>
<script type="module" src="main/scripts.ts"></script>
<script type="module" src="main/global.ts"></script>
</head>

<body>
<ol>
<li><a href="./es-bench/">ES Bench</a></li>
<li><a href="./fetch/">Fetch</a></li>
<li><a href="./math/">Math</a></li>
<li><a href="./validator/">Validator</a></li>
</ol>
<body class="bg-surface container mx-auto p-4">
<h2 class="text-headlineMedium text-onSurface">Hybrid UI Demos</h2>

<div id="container" class="w-full gap-4 py-4 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4"></div>
</body>
</html>
7 changes: 7 additions & 0 deletions demo/main/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import '@gecut/styles/css';
@import '@gecut/styles/palettes/h260.css';

html,
body {
@apply h-full;
}
1 change: 1 addition & 0 deletions demo/main/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './global.css';
55 changes: 55 additions & 0 deletions demo/main/scripts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* eslint-disable max-len */
import {classMap} from 'lit/directives/class-map.js';
import {map} from 'lit/directives/map.js';
import {html, render} from 'lit/html.js';

interface Demo {
title: string;
href: string;

align?: 'center' | 'bottom' | 'top';
}

const container = document.getElementById('container');
const demos: Demo[] = [
{
title: 'Dialog',
href: '/dialog/',
align: 'center',
},
{
title: 'Top App Bar',
href: '/top-bar/',
align: 'top',
},
];

if (container)
render(
map(
demos,
(demo) => html`
<a
href=${demo.href}
class="flex flex-col p-4 !m-0 group card-elevated dark:card-filled-selectable w-full hover:elevation-5 transition-shadow duration-500 dark:!shadow-none"
>
<div class="aspect-w-4 aspect-h-3 w-full overflow-hidden rounded-md relative">
<img
src="${demo.href}preview.png"
class="h-full w-full object-cover invert dark:invert-0 ${classMap({
'object-center': demo.align === 'center' || !demo.align,
'object-top': demo.align === 'top',
'object-bottom': demo.align === 'bottom',
})}"
/>
<div
class="absolute z-above inset-0 shadow-[inset_0px_4px_48px_0px_#0002] group-hover:shadow-[inset_0px_8px_16px_4px_#0004] transition-shadow duration-500 dark:!shadow-none"
></div>
</div>
<h2 class="text-onSurfaceVariant text-titleMedium mt-4">${demo.title}</h2>
</a>
`,
),
container,
);
17 changes: 13 additions & 4 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@
"author": "S. MohammadMahdi Zamanian <[email protected]> (https://mm25zamanian.ir)",
"type": "module",
"private": true,
"devDependencies": {
"@types/node": "^20.11.30"
"scripts": {
"serve": "vite --host 0.0.0.0 --port 3031 --open --clearScreen -d",
"build": "vite build --clearScreen"
},
"dependencies": {
"devDependencies": {
"@gecut/components": "workspace:^",
"@gecut/lit-helper": "workspace:^",
"@gecut/signal": "^2.0.1-alpha.0",
"lit": "^3.1.2"
"@gecut/styles": "workspace:^",
"@gecut/types": "^2.1.1-alpha.0",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@types/node": "^20.11.30",
"autoprefixer": "^10.4.19",
"lit": "^3.1.2",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.1",
"vite": "^5.2.4"
}
}
6 changes: 6 additions & 0 deletions demo/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
34 changes: 0 additions & 34 deletions demo/styles.css

This file was deleted.

6 changes: 4 additions & 2 deletions tailwind.config.mjs → demo/tailwind.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ export default {

content: [
'index.html',
'demo/**/*.html',
'demo/**/*.ts',
'**/*.html',
'**/*.ts',
path.dirname(require.resolve('@gecut/components')) + '/**/*.js',
],

plugins: [...tailwindConfig.plugins, require('@tailwindcss/aspect-ratio')],
};
6 changes: 3 additions & 3 deletions demo/top-bar/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>Gecut Top Bar</title>
<link rel="stylesheet" href="/demo/__styles.css" />
<script type="module" src="../main/global.ts"></script>
<script type="module" src="./scripts.ts"></script>
</head>
<body class="bg-surface max-w-screen-sm mx-auto px-2"></body>
<script type="module" src="scripts.js"></script>
<body class="bg-surface max-w-screen-sm mx-auto px-2 root"></body>
</html>
Binary file added demo/top-bar/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion demo/top-bar/scripts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable max-len */
import {gecutSmallTopBar} from '@gecut/components';
import {map} from 'lit/directives/map.js';
import {range} from 'lit/directives/range.js';
import {html, render} from 'lit/html.js';

render(
Expand All @@ -21,7 +23,12 @@ render(
title: 'Gecut Top Bar',
})}
<main role="main">
<h1 class="text-headlineMedium text-primary">h</h1>
<div class="gecut-page scrollabe">
${map(
range(window.innerHeight / 10),
(i) => html`<p class="text-bodyMedium text-onSurfaceVariant">Random Content: ${i}</p>`,
)}
</div>
</main>
`,
document.body,
Expand Down
2 changes: 1 addition & 1 deletion demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@

"include": ["**/*.ts"],
"exclude": ["*.d.ts", "node_modules"],
"references": [{"path": "../packages/components"}, {"path": "../packages/lit-helper"}]
"references": [{"path": "../packages/components"}, {"path": "../packages/styles"}, {"path": "../packages/lit-helper"}]
}
29 changes: 29 additions & 0 deletions demo/vite.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {defineConfig} from 'vite';

const entrys = ['dialog', 'top-bar'];
const DIST_PATH = './dist/';
const pages = entrys.reduce((result, name) => {
result[name] = `src/${name}/index.html`;

return result;
}, {});

export default defineConfig(() => {
return {
css: {
postcss: 'postcss.config.mjs',
},

build: {
target: ['esnext', 'edge100', 'firefox100', 'chrome100', 'safari18'],
outDir: DIST_PATH,
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
},
rollupOptions: {
input: {main: 'index.html', ...pages},
},
},
};
});
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@
"build": "run-s build:ts build:r",
"build:ts": "tsc --build",
"build:r": "lerna run build",
"build:css": "tailwindcss -i ./demo/styles.css -o ./demo/__styles.css",
"format": "run-s format:prettier format:eslint",
"format:eslint": "yarn run lint:ts --fix",
"format:prettier": "prettier . --ignore-path .gitignore --write",
"clean": "git clean -d -x -f --exclude=node_modules --exclude='*.env' --exclude=_data --exclude='.pnp*' --exclude=.yarn",
"serve": "wds",
"watch": "run-p 'watch:*' serve",
"serve": "lerna run serve",
"watch": "run-p 'watch:*'",
"watch:ts": "yarn run build:ts --watch --preserveWatchOutput",
"watch:css": "yarn run build:css --watch",
"pull": "git pull",
"release": "lerna version",
"publish": "lerna publish from-package"
Expand All @@ -66,13 +64,11 @@
"@types/node": "^20.11.30",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@web/dev-server": "^0.4.3",
"eslint": "^8.57.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"tailwindcss": "^3.4.1",
"typescript": "^5.4.2"
},
"dependencies": {
Expand Down
Loading

0 comments on commit d277578

Please sign in to comment.