-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(demo-pwa): enhance fracting (#1349)
- Loading branch information
Showing
12 changed files
with
294 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!DOCTYPE html> | ||
<html lang="fa-IR" dir="rtl" class="h-full w-full [overscroll-behavior:none]"> | ||
<head> | ||
<base href="/" /> | ||
|
||
<meta charset="utf-8" /> | ||
<title>Alwatr UI Playground</title> | ||
|
||
<link rel="stylesheet" href="main.css" /> | ||
|
||
<meta name="color-scheme" content="light dark" /> | ||
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#673ab7" /> | ||
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#673ab7" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=2, user-scalable=yes, viewport-fit=cover" | ||
/> | ||
|
||
<link rel="shortcut icon" href="image/favicon.ico" /> | ||
<link rel="manifest" href="manifest.webmanifest" /> | ||
<!-- Add to home screen for Chrome on Android. Fallback for manifest.json --> | ||
<meta name="mobile-web-app-capable" content="yes" /> | ||
<meta name="application-name" content="Alwatr PWA Starter" /> | ||
<!-- Add to home screen for Safari on iOS --> | ||
<meta name="apple-mobile-web-app-capable" content="yes" /> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> | ||
<meta name="apple-mobile-web-app-title" content="Alwatr PWA Starter" /> | ||
<link rel="apple-touch-startup-image" href="image/icon-192.png" /> | ||
<!-- Home screen icons --> | ||
<link rel="apple-touch-icon" href="image/icon-180.png" /> | ||
<!-- Tile icon for Windows 8 (144x144 + tile color) --> | ||
<meta name="msapplication-TileImage" content="image/icon-512.png" /> | ||
<meta name="msapplication-TileColor" content="#673ab7" /> | ||
<meta name="msapplication-tap-highlight" content="no" /> | ||
|
||
<meta name="description" content="Alwatr Progressive Web Application Demo." /> | ||
<meta name="twitter:card" content="summary" /> | ||
<meta name="twitter:site" content="@alidotmd" /> | ||
<meta property="og:title" content="Alwatr UI Demo" /> | ||
<meta property="og:type" content="website" /> | ||
<meta | ||
property="og:image" | ||
content="https://repository-images.githubusercontent.com/441522257/86c54c14-edda-44cd-a9af-6430ef14a000" | ||
/> | ||
<meta | ||
property="og:image:secure_url" | ||
content="https://repository-images.githubusercontent.com/441522257/86c54c14-edda-44cd-a9af-6430ef14a000" | ||
/> | ||
<meta property="og:image:type" content="image/png" /> | ||
<meta property="og:image:width" content="500" /> | ||
<meta property="og:image:height" content="500" /> | ||
<meta property="og:image:alt" content="The Alwatr, Made with love for him." /> | ||
<meta name="og:description" content="Alwatr Progressive Web Application Demo." /> | ||
|
||
<link rel="canonical" href="https://demo.alwatr.ir" /> | ||
</head> | ||
<body | ||
class="h-full w-full max-w-full max-h-full m-0 p-0 overflow-clip transform-gpu break-words touch-pan-x touch-pan-y touch-pinch-zoom bg-background font-vazirmatn text-onBackground text-bodyMedium [contain:size_layout_paint_style] [overscroll-behavior:none]" | ||
> | ||
<div | ||
id="alwatr_pwa" | ||
class="!flex h-full w-full max-w-full max-h-full flex-col flex-nowrap items-stretch overflow-clip [contain:size_layout_paint_style]" | ||
> | ||
درحال بارگذاری... | ||
</div> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import '@alwatr/style/main.css'; | ||
@import '@alwatr/style/palettes/h260.css'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {render} from '@alwatr/fract'; | ||
|
||
import './main.css'; | ||
import {appLogger} from './share/logger.js'; | ||
import {alwatrPwa, alwatrPwaContainer} from './ui/alwatr-pwa.js'; | ||
|
||
appLogger.logModule?.('main'); | ||
|
||
alwatrPwaContainer.replaceChildren(); // clean content | ||
render(alwatrPwa(), alwatrPwaContainer); | ||
alwatrPwaContainer.removeAttribute('unresolved'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// TODO: rename me to index | ||
import {AlwatrDynamicDirective, directive, html, type PartInfo} from '@alwatr/fract'; | ||
|
||
import {alwatrButton} from './button.js'; | ||
import {appLogger} from '../share/logger.js'; | ||
|
||
export type PageName = 'home' | 'favorites' | 'contact' | 'other' | '_404'; | ||
|
||
appLogger.logModule?.('app'); | ||
|
||
// function* renderApp(): unknown { | ||
// yield html`${alwatrTopAppBar({ | ||
// headline: 'Alwatr PWA Demo', | ||
// })}`; | ||
|
||
// const main = alwatrObserve(router, (route: RouteContext) => { | ||
// const page = <PageName>route.sectionList[0] ?? 'home'; | ||
// return cache(renderState(page, { | ||
// home: () => html`<h1>home2...</h1>`, | ||
// favorites: () => html`${alwatrPageTest(page)}`, | ||
// other: () => html`${alwatrPageTest(page)}`, | ||
// contact: () => html`<h1>call...</h1>`, | ||
// _404: () => html`<h1>404!</h1>`, | ||
// _default: '_404', | ||
// })); | ||
// }); | ||
|
||
// yield html`<main class="scroll-area">${main}</main>`; | ||
|
||
// yield html`${alwatrNavigationBar({ | ||
// itemList: [ | ||
// {icon: icons.home, href: '/home'}, | ||
// {icon: icons.star, href: '/favorites'}, | ||
// {icon: icons.triangle, href: '/other'}, | ||
// {icon: icons.call, href: '/contact'}, | ||
// ], | ||
// })}`; | ||
// } | ||
|
||
export class AlwatrPwaDirective extends AlwatrDynamicDirective { | ||
constructor(partInfo: PartInfo) { | ||
super(partInfo, '<alwatr-pwa>'); | ||
} | ||
|
||
render(): unknown { | ||
this._logger.logMethod?.('render'); | ||
return html` | ||
<div class="p-10"> | ||
<h1 class="text-titleMedium text-center">سلام ...</h1> | ||
${alwatrButton({label: 'کلید ۱', extendClass: 'text-red-50'})} | ||
${alwatrButton({label: 'پریز ۲', disabled: true})} | ||
</div> | ||
`; | ||
} | ||
} | ||
|
||
// TODO: send app rendered signal | ||
|
||
export const alwatrPwa = directive(AlwatrPwaDirective); | ||
|
||
export const alwatrPwaContainer = document.getElementById('alwatr_pwa')!; | ||
|
||
if (alwatrPwaContainer === null) { | ||
throw new Error('Cannot find `<div id="alwatr_pwa">` element!'); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {AlwatrDynamicDirective, classMap, directive, html, type PartInfo} from '@alwatr/fract'; | ||
|
||
export type ButtonOptions = { | ||
/** | ||
* Label. | ||
*/ | ||
label: string, | ||
|
||
disabled?: boolean; | ||
|
||
extendClass?: string | ||
} | ||
|
||
export class AlwatrButtonDirective extends AlwatrDynamicDirective { | ||
constructor(partInfo: PartInfo) { | ||
super(partInfo, '<alwatr-button>'); | ||
} | ||
|
||
render(options: ButtonOptions): unknown { | ||
this._logger.logMethodArgs?.('render', options); | ||
return html`<button | ||
class="inline-flex justify-center items-center py-3 px-5 text-base font-medium text-center text-onPrimary | ||
rounded-lg bg-primary bg-opacity-90 hover:bg-opacity-100 active:bg-opacity-95 select-none | ||
${classMap({'opacity-25 pointer-events-none': options.disabled === true})}" | ||
>${options.label}</button>`; | ||
} | ||
} | ||
|
||
export const alwatrButton = directive(AlwatrButtonDirective); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.