Skip to content

Commit

Permalink
Fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasstrehle committed Mar 28, 2024
1 parent b1fdde1 commit 973f946
Show file tree
Hide file tree
Showing 12 changed files with 463 additions and 339 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/uix-deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup Deno
uses: "denoland/setup-deno@v1"
- name: Run Tests
run: "deno run -Aq --import-map https://dev.cdn.unyt.org/importmap.json https://dev.cdn.unyt.org/unyt_tests/run.ts -s --reportfile testreport.xml"
run: "deno run -Aq --import-map ./importmap.json https://cdn.unyt.org/unyt-tests/run.ts -s --reportfile testreport.xml"
- name: Publish Test Report
uses: "mikepenz/action-junit-report@v3"
if: "success() || failure()"
Expand All @@ -24,8 +24,10 @@ jobs:
steps:
- name: Checkout Repo
uses: "actions/checkout@v3"
with:
submodules: recursive
- name: Setup Deno
uses: "denoland/setup-deno@v1"
- name: Deploy UIX App
run: "deno run --importmap https://dev.cdn.unyt.org/uix1/importmap.json -Aqr https://dev.cdn.unyt.org/uix1/run.ts --stage prod --detach "
run: "deno run --importmap ./importmap.json -Aqr https://cdn.unyt.org/[email protected]/run.ts --stage prod --detach"
needs: test
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The repository includes persistent data storage and implements both
```
3. Run the project local
```bash
$ uix -lb --port 8000
$ uix --port 8000
```
4. Navigate to your favourite web browser and open http://localhost:8000 to see
everything in action.
Expand Down Expand Up @@ -105,4 +105,4 @@ is ready for user interactions as soon as it loads.
---
<sub>&copy; unyt 2023 • [unyt.org](https://unyt.org)</sub>
<sub>&copy; unyt 2024 • [unyt.org](https://unyt.org)</sub>
11 changes: 2 additions & 9 deletions backend/entrypoint.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { Overview } from "../common/Overview.tsx";
import { listStorage } from "backend/lists.eternal.ts";
import { renderBackend, renderHybrid, renderStatic } from "uix/base/render-methods.ts";
import { Entrypoint } from "uix/html/entrypoints.ts";
import { List } from "common/List.tsx";
import { lazy } from "uix/html/entrypoint-providers.tsx";
import { Lists } from "backend/lists.ts";

// The frontend routes definition
export default {
'/': renderHybrid(<Overview lists={listStorage}/>), // On '/'-route display the overview component
// '/:id': lazy(async (_, {id}) => {
// return renderBackend(<List list={await Lists.get(id)}/>) // render the list component
// }),
'*': null // Letting the frontend handle all other routes
'/': <Overview lists={listStorage}/>,
'*': null
} satisfies Entrypoint;
4 changes: 1 addition & 3 deletions backend/lists.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// deno-lint-ignore-file require-await
import { listStorage } from "./lists.eternal.ts";

export type ListItem = {
Expand All @@ -12,9 +13,7 @@ export type SharedList = {
items: Set<ListItem>
}


export class Lists {

static async get(id: string) {
// create new list if none exists
if (!listStorage.has(id)) {
Expand All @@ -25,5 +24,4 @@ export class Lists {
}
return listStorage.get(id)!;
}

}
21 changes: 0 additions & 21 deletions common/ColorModeToggle.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion common/List.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
width: 500px;
height: fit-content;
padding: 40px;
background-color: var(--bg_content);
background-color: var(--bg);
border: 1px solid gray;
border-radius: 10px;
justify-content: center;
Expand Down
42 changes: 13 additions & 29 deletions common/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@ import { ListItem, type SharedList } from "backend/lists.ts";
import { map, always } from "datex-core-legacy/functions.ts";
import { template } from "uix/html/template.ts";
import { Component } from "uix/components/Component.ts";
import { ObjectRef } from "unyt_core/runtime/pointers.ts";
import { ColorModeToggle } from "common/ColorModeToggle.tsx";
import { local_text } from "unyt_core/datex_short.ts";

const strings = {
add: local_text({
de: 'Eintrag hinzufügen',
en: 'Add Item'
}),
cleanup: local_text({
de: 'Löschen',
en: 'Cleanup'
})
}

@template(function(this: List) {
return <div>
Expand All @@ -24,20 +10,21 @@ const strings = {
</div>
<ol>
{
map(this.options.list.items as Set<ObjectRef<ListItem>>, (item, index) =>
<li>
<input type="checkbox" checked={item.$.checked} id={`checkbox-${index}`}/>
<label for={`checkbox-${index}`}>{item.$.name}</label>
<span>{item.$.amount} {item.$.type}{always(()=>item.amount! > 1 ? 's': '')}</span>
map(this.options.list.items, (item, index) => {
const reactiveItem = item.$ as unknown as ListItem;
return <li>
<input type="checkbox" checked={reactiveItem.checked} id={`checkbox-${index}`}/>
<label for={`checkbox-${index}`}>{reactiveItem.name}</label>
<span>{reactiveItem.amount} {reactiveItem.type}{always(()=>item.amount! > 1 ? 's': '')}</span>
</li>
)
})
}
</ol>
<button class="add-button" onclick:frontend={() => this.dialog.showModal()}>
{strings.add}
Add item
</button>
<button class="remove-button" onclick:frontend={() => this.removeChecked()}>
{strings.cleanup}
Cleanup
</button>
<dialog id="dialog" onclick:frontend={function (e) { if (e.target == this) this.close()}}>
<input placeholder="Enter item name" type="text" id="name"/>
Expand All @@ -49,17 +36,15 @@ const strings = {
</select>
<div id="add" onclick:frontend={() => this.addItem()}>Add</div>
</dialog>

<ColorModeToggle/>
</div>
})
export class List extends Component<{list: SharedList}> {

/** references to the DOM elements */
@id declare name: HTMLInputElement;
@id declare amount: HTMLInputElement;
@id declare type: HTMLOptionElement;
@id declare dialog: HTMLDialogElement;
@id name!: HTMLInputElement;
@id amount!: HTMLInputElement;
@id type!: HTMLOptionElement;
@id dialog!: HTMLDialogElement;

/**
* Remove all checked items
Expand All @@ -83,7 +68,6 @@ export class List extends Component<{list: SharedList}> {
amount: Number(this.amount.value),
type: this.type.value,
});

this.dialog.close()
}
}
9 changes: 0 additions & 9 deletions common/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@ import { SharedList } from "backend/lists.ts";
import { map } from "datex-core-legacy/functions.ts";
import { template } from "uix/html/template.ts";
import { Component } from "uix/components/Component.ts";
import { logger } from "unyt_core/datex_all.ts";

let x = $$({a: "xa12"})

function tsversion(x:any) {
logger.error("called", datex.meta)
return $$(Deno.version.typescript)
}

// FIX: without ...map
@template(function(this: Overview) {
return <div>
<h1>Overview</h1>
Expand Down
8 changes: 5 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"importMap": "./importmap.json",
"_publicImportMap": "./importmap.json",
"importMap": "./.datex-cache/importmap.lock.json",
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "uix",
"lib": [
"deno.window"
"deno.window",
"dom"
]
}
}
}
Loading

0 comments on commit 973f946

Please sign in to comment.