Skip to content

Commit

Permalink
lint: format code styles and make eslint happy (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD authored Sep 20, 2023
2 parents 3c7a9e8 + 1d4c477 commit ed98a0b
Show file tree
Hide file tree
Showing 52 changed files with 558 additions and 461 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
}
}
],
"lit/attribute-value-entities": "off",
"@typescript-eslint/prefer-string-starts-ends-with": "off",
"@typescript-eslint/no-dynamic-delete": "off",
"@typescript-eslint/no-non-null-assertion": "off",
Expand Down
2 changes: 1 addition & 1 deletion demo/font/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion demo/font/simple.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8" />
Expand Down
13 changes: 8 additions & 5 deletions demo/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ l10n.setResourceLoader((locale) => {
code: locale.language === 'fa' ? 'fa-IR' : 'en-US',
rev: 2,
},
data: locale.language === 'fa' ? {
'hi': 'سلام',
} : {
'hi': 'hello',
},
data:
locale.language === 'fa'
? {
hi: 'سلام',
}
: {
hi: 'hello',
},
};
});

Expand Down
4 changes: 3 additions & 1 deletion demo/icon/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

alwatr-icon {
font-size: 2em;
transition: font-size 0.5s, color 0.5s;
transition:
font-size 0.5s,
color 0.5s;
margin: 0.3em;
}
alwatr-icon:hover {
Expand Down
6 changes: 1 addition & 5 deletions demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,5 @@

"include": ["**/*.ts"],
"exclude": ["*.d.ts", "node_modules"],
"references": [
{"path": "../packages/router"},
{"path": "../packages/icon"},
{"path": "../packages/i18n"}
]
"references": [{"path": "../packages/router"}, {"path": "../packages/icon"}, {"path": "../packages/i18n"}]
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Refresh" content="0; URL=/demo/" />
Expand Down
27 changes: 8 additions & 19 deletions packages/demo-pwa/esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ const esbuildContext = await esbuild.context({

plugins: [
postCssPlugin({
plugins: [
postcssImport,
postcssNesting,
postcssTailwind,
postcssPresetEnv,
],
plugins: [postcssImport, postcssNesting, postcssTailwind, postcssPresetEnv],
}),
],

Expand All @@ -111,12 +106,12 @@ async function makeHtml() {
const outFiles = Object.keys(metafile.outputs);

const jsFilename = outFiles
.find((filename) => filename.includes(srcFilename) && filename.endsWith('.js'))
.substring(outDir.length + 1);
.find((filename) => filename.includes(srcFilename) && filename.endsWith('.js'))
.substring(outDir.length + 1);

const cssFilename = outFiles
.find((filename) => filename.includes(srcFilename) && filename.endsWith('.css'))
.substring(outDir.length + 1);
.find((filename) => filename.includes(srcFilename) && filename.endsWith('.css'))
.substring(outDir.length + 1);

logger.logProperty?.('jsFilename', jsFilename);
logger.logProperty?.('cssFilename', cssFilename);
Expand All @@ -131,9 +126,7 @@ async function makeHtml() {
throw new Error('css_filename_not_found');
}

htmlContent = htmlContent
.replaceAll(`${srcFilename}.css`, cssFilename)
.replaceAll(`${srcFilename}.js`, jsFilename);
htmlContent = htmlContent.replaceAll(`${srcFilename}.css`, cssFilename).replaceAll(`${srcFilename}.js`, jsFilename);

await copyPromise; // wait to cp done
await fs.writeFile(`${outDir}/index.html`, htmlContent, {encoding: 'utf-8', flag: 'w'});
Expand All @@ -147,22 +140,18 @@ async function buildServiceWorker() {
globDirectory: `${outDir}/`,
clientsClaim: true,
skipWaiting: true,
globPatterns: [
'**/*.{js,css,json,png,svg,ico,webp,woff2,html}',
],
globPatterns: ['**/*.{js,css,json,png,svg,ico,webp,woff2,html}'],
});

logger.logOther?.('serviceWorkerPath', build);
}

if (watchMode) {
esbuildContext.watch();
}
else {
} else {
await makeHtml();
esbuildContext.dispose();


if (debugMode) {
console.log(await esbuild.analyzeMetafile((await esBuildPromise).metafile));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/demo-pwa/res/service-worker.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log('Service worker not build in development mode.')
console.log('Service worker not build in development mode.');
22 changes: 20 additions & 2 deletions packages/demo-pwa/src/share/app-navigation-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ appNavigationContext.setValue({

topAppBarContext.setValue({
title: 'الوتر دمو',
startIcon: {svg: icons.person, onClick: () => {console.log('`startIcon` clicked');}},
endIconList: [{svg: icons.refresh, onClick: () => {console.log('`refreshIcon` clicked');}}, {svg: icons.home, onClick: () => {console.log('`homeIcon` clicked');}}],
startIcon: {
svg: icons.person,
onClick: () => {
console.log('`startIcon` clicked');
},
},
endIconList: [
{
svg: icons.refresh,
onClick: () => {
console.log('`refreshIcon` clicked');
},
},
{
svg: icons.home,
onClick: () => {
console.log('`homeIcon` clicked');
},
},
],
});
35 changes: 21 additions & 14 deletions packages/demo-pwa/src/ui/alwatr-pwa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ export type PageName = 'home' | 'favorites' | 'contact' | 'other' | '_404';

appLogger.logModule?.('alwatr-pwa');


export class AlwatrPwaDirective extends AlwatrDynamicDirective {
constructor(partInfo: PartInfo) {
super(partInfo, '<alwatr-pwa>');
}

* render(): unknown {
*render(): unknown {
this._logger.logMethod?.('render');

yield this._renderTopAppBar();
Expand All @@ -33,15 +32,21 @@ export class AlwatrPwaDirective extends AlwatrDynamicDirective {
}

protected _renderNavigationBar(): unknown {
return alwatrObserve(appNavigationContext, (content: AppNavigationContext) => alwatrNavigationBar(content.navigationBar));
return alwatrObserve(appNavigationContext, (content: AppNavigationContext) =>
alwatrNavigationBar(content.navigationBar),
);
}

protected _renderNavigationDrawer(): unknown {
return alwatrObserve(appNavigationContext, (content: AppNavigationContext) => alwatrNavigationDrawer(content.navigationDrawer));
return alwatrObserve(appNavigationContext, (content: AppNavigationContext) =>
alwatrNavigationDrawer(content.navigationDrawer),
);
}

protected _renderNavigationRail(): unknown {
return alwatrObserve(appNavigationContext, (context: AppNavigationContext) => alwatrNavigationRail(context.navigationRail));
return alwatrObserve(appNavigationContext, (context: AppNavigationContext) =>
alwatrNavigationRail(context.navigationRail),
);
}

protected _renderTopAppBar(): unknown {
Expand All @@ -50,15 +55,17 @@ export class AlwatrPwaDirective extends AlwatrDynamicDirective {

protected _renderContent(): unknown {
return alwatrObserve(router, (route: RouteContext) => {
const page = route.sectionList[0] as PageName ?? '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',
}));
const page = (route.sectionList[0] as PageName) ?? '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',
}),
);
});
}
}
Expand Down
20 changes: 12 additions & 8 deletions packages/demo-pwa/src/ui/button.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {AlwatrDynamicDirective, classMap, directive, html, type PartInfo} from '@alwatr/fract';

export interface ButtonOptions {
/**
/**
* Label.
*/
label: string,
label: string;

disabled?: boolean;
disabled?: boolean;

extendClass?: string
extendClass?: string;
}

export class AlwatrButtonDirective extends AlwatrDynamicDirective {
Expand All @@ -19,10 +19,14 @@ export class AlwatrButtonDirective extends AlwatrDynamicDirective {
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>`;
class="${classMap({
'opacity-25 pointer-events-none': options.disabled === true,
})} inline-flex select-none items-center justify-center rounded-lg bg-primary bg-opacity-90 px-5
py-3 text-center text-base font-medium text-onPrimary hover:bg-opacity-100
active:bg-opacity-95"
>
${options.label}
</button>`;
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/demo-pwa/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {tailwindConfig} from '@alwatr/style'
import {tailwindConfig} from '@alwatr/style';

export default tailwindConfig;
2 changes: 1 addition & 1 deletion packages/demo-pwa/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"name": "ts-lit-plugin",
"strict": true
}
],
]
},

"include": ["src/**/*.ts"],
Expand Down
20 changes: 9 additions & 11 deletions packages/demo-pwa/web-dev-server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ const config = {
rootDir: 'dist',
appIndex: 'index.html',
plugins: [],
middleware: [(context, next) => {
// if file not found, return app index.html
if (!(
context.url === '/' ||
context.url.startsWith('/__w') ||
existsSync(config.rootDir + context.url)
)) {
context.url = config.appIndex;
}
return next();
}],
middleware: [
(context, next) => {
// if file not found, return app index.html
if (!(context.url === '/' || context.url.startsWith('/__w') || existsSync(config.rootDir + context.url))) {
context.url = config.appIndex;
}
return next();
},
],
};

export default config;
6 changes: 3 additions & 3 deletions packages/font/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Performance Improvements

* **pwa:** optimize first load and rendering ([343d757](https://github.com/AliMD/fract/commit/343d757eefab6572df54fb4f7624698e9a9f9e11))
- **pwa:** optimize first load and rendering ([343d757](https://github.com/AliMD/fract/commit/343d757eefab6572df54fb4f7624698e9a9f9e11))

# 0.30.0 (2023-03-06)

Expand All @@ -29,13 +29,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Features

* new ui design system ([8c9c8ba](https://github.com/AliMD/fract/commit/8c9c8ba29c477838f3e7034b902f4e0dafabd17c))
- new ui design system ([8c9c8ba](https://github.com/AliMD/fract/commit/8c9c8ba29c477838f3e7034b902f4e0dafabd17c))

# 0.26.0 (2022-12-22)

### Bug Fixes

* **packages/*:** package path in refrences ([841d86d](https://github.com/AliMD/fract/commit/841d86dc2555fdc86a950b490ea2eb9fffe4df2d))
- **packages/\*:** package path in refrences ([841d86d](https://github.com/AliMD/fract/commit/841d86dc2555fdc86a950b490ea2eb9fffe4df2d))

# [1.0.0](https://github.com/AliMD/fract/compare/v0.32.0...v1.0.0) (2023-06-14)

Expand Down
6 changes: 5 additions & 1 deletion packages/font/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ Insert these lines inside `<head>` tag.
<link rel="preconnect" href="https://cdn.jsdelivr.net" />
<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin />

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@alwatr/[email protected]/vazirmatn-roundot.min.css" fetchpriority="high" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@alwatr/[email protected]/vazirmatn-roundot.min.css"
fetchpriority="high"
/>

<link
rel="preload"
Expand Down
Loading

0 comments on commit ed98a0b

Please sign in to comment.