Skip to content

Commit 1c8ee9d

Browse files
committed
back, home, exit buttons
1 parent 2f273a1 commit 1c8ee9d

File tree

25 files changed

+306
-166
lines changed

25 files changed

+306
-166
lines changed

components/App/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
/*******************************************
2+
* App
3+
*
4+
* Extends Page with events & scripting
5+
*******************************************/
6+
17
import { randomUUID } from 'crypto';
28

39
import { Page } from '../index.js';
410

5-
/**
6-
* App
7-
*/
8-
911
class App extends Page {
1012

1113
/*******************************************

components/Audio/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
/*******************************************
2+
* Audio
3+
*
4+
* An audio player
5+
*******************************************/
6+
7+
18
import { randomUUID } from 'crypto';
29

310
import { Playable } from '../index.js';
411

5-
/**
6-
* Audio
7-
*/
8-
912
class Audio extends Playable {
1013

1114
/*******************************************

components/Component/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { randomUUID } from 'crypto';
2-
3-
/**
1+
/*******************************************
42
* Component
5-
*/
3+
*
4+
* The base component class with common
5+
* methods and properties
6+
*******************************************/
7+
8+
import { randomUUID } from 'crypto';
69

710
class Component {
811

components/Data/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { Component } from '../index.js';
2-
3-
/**
1+
/*******************************************
42
* Data
5-
*/
3+
*
4+
* Represents a viewable data structure
5+
* element
6+
*******************************************/
7+
8+
import { Component } from '../index.js';
69

710
class Data extends Component {
811

components/Document/index.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
/*******************************************
2+
* Document
3+
*
4+
* Represents a viewable file or
5+
* document element
6+
*******************************************/
7+
18
import fs from 'fs/promises';
29
import { randomUUID } from 'crypto';
310

411
import { Component, Data } from '../index.js';
512

6-
/**
7-
* Document
8-
*/
9-
1013
class Document extends Component {
1114
static async load (filePath, onLoad) {
1215
const response = await fs.readFile(filePath);
@@ -45,14 +48,29 @@ class Document extends Component {
4548
return this.data?.toString?.() || '';
4649
}
4750

51+
/**
52+
* open
53+
* Open a file or document source
54+
**/
55+
4856
open (source) {
4957
this.onLoad(source);
5058
}
5159

60+
/**
61+
* close
62+
* Close and unload the current file
63+
**/
64+
5265
close () {
5366
this.onUnload();
5467
}
5568

69+
/**
70+
* onLoad
71+
* Handle load
72+
**/
73+
5674
onLoad (source) {
5775
const json = JSON.parse(source?.toString());
5876
const base64String = source?.toString?.('base64') || '';
@@ -80,10 +98,6 @@ class Document extends Component {
8098
this.encoding = sourceType.slice(sourceType.indexOf(';') + 1, source.indexOf(','));
8199
this.format = sourceType.slice(sourceType.indexOf('/') + 1, sourceType.indexOf(';'));
82100
}
83-
84-
onScroll (event) {
85-
console.log('scroll', event);
86-
}
87101
}
88102

89103
export default Document;

components/Image/index.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
/*******************************************
2+
* Image
3+
*
4+
* A viewable image
5+
*******************************************/
6+
17
import { randomUUID } from 'crypto';
28

39
import { WINDOW_OPTIONS } from '../../constants.js';
410

511
import { Media } from '../index.js';
612

7-
/**
8-
* Image
9-
*/
10-
1113
class Image extends Media {
1214
static fit (isContain) {
1315
return (
@@ -85,10 +87,20 @@ class Image extends Media {
8587
return this.height;
8688
}
8789

90+
/**
91+
* onHover
92+
* Handle hover
93+
**/
94+
8895
onHover (event, component) {
8996
console.log('Image.onHover', event, component.id);
9097
}
9198

99+
/**
100+
* onClick
101+
* Handle click
102+
**/
103+
92104
onClick (event, component) {
93105
console.log('Image.onClick', event, component.id);
94106
}

components/Input/index.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*******************************************
2+
* Input
3+
*
4+
* A stateful text input with a
5+
* placeholder and basic key validation
6+
*******************************************/
7+
18
import { randomUUID } from 'crypto';
29

310
import {
@@ -7,10 +14,6 @@ import {
714

815
import { Rect, Text } from '../index.js';
916

10-
/**
11-
* Input
12-
*/
13-
1417
class Input extends Rect {
1518

1619
/*******************************************
@@ -80,6 +83,11 @@ class Input extends Rect {
8083
return `<Input #${this.id}>`;
8184
}
8285

86+
/**
87+
* onClick
88+
* Handle click
89+
**/
90+
8391
onClick (event, component) {
8492
const { id } = component;
8593

@@ -99,6 +107,11 @@ class Input extends Rect {
99107
this.state.focusTarget = component?.id;
100108
}
101109

110+
/**
111+
* onKeyDown
112+
* Handle keydown
113+
**/
114+
102115
onKeyDown (event, component) {
103116
let { key = '' } = event;
104117

components/Link/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
/*******************************************
2+
* Link
3+
*
4+
* A text link with a hover state that
5+
* navigates to a path
6+
*******************************************/
7+
18
import { randomUUID } from 'crypto';
29

310
import { Rect, Text } from '../index.js';
411

5-
/**
6-
* Link
7-
*/
8-
912
class Link extends Rect {
1013

1114
/*******************************************

components/Media/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
/*******************************************
2+
* Media
3+
*
4+
* Base media class with common methods
5+
* and properties for viewable media
6+
*******************************************/
7+
18
import fs from 'fs/promises';
29
import notifier from 'node-notifier';
310

411
import { Pressable } from '../index.js';
512

6-
const ERROR_MESSAGE = {
7-
'HTTP/404': 'File not found.'
8-
};
9-
10-
/**
11-
* Media
12-
*/
13+
import { ERROR_MESSAGE } from '../../constants.js';
1314

1415
class Media extends Pressable {
1516
static async load (filePath, onLoad) {

components/Page/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
/*******************************************
2+
* Page
3+
*
4+
* Extends Document with a title and
5+
* JSX value
6+
*******************************************/
7+
18
import { randomUUID } from 'crypto';
29

310
import { Document } from '../index.js';
411

5-
/**
6-
* Page
7-
*/
8-
912
class Page extends Document {
1013

1114
/*******************************************
@@ -22,7 +25,7 @@ class Page extends Document {
2225
this.type = 'page';
2326
this.id = id || `${this.type}-${randomUUID().slice(0, 8)}`;
2427
this.title = title;
25-
this.value = null;
28+
this.value = '';
2629

2730
this.attributes = {
2831
id: this.id,

0 commit comments

Comments
 (0)