create-asciitorium 0.1.20 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/templates/base/index.css +20 -3
- package/dist/templates/base/index.html +4 -4
- package/dist/templates/base/src/examples/AsciiArtExample.tsx +1 -1
- package/dist/templates/base/src/examples/ButtonExample.tsx +1 -1
- package/dist/templates/base/src/examples/LayoutExample.tsx +1 -1
- package/dist/templates/base/src/examples/MultiSelectExample.tsx +1 -1
- package/dist/templates/base/src/examples/SelectExample.tsx +1 -1
- package/dist/templates/base/src/main.tsx +36 -85
- package/dist/templates/base/vite.config.ts +6 -2
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@import url('https://fonts.cdnfonts.com/css/jetbrains-mono');
|
|
1
2
|
@font-face {
|
|
2
3
|
font-family: 'PrintChar21';
|
|
3
4
|
src:
|
|
@@ -9,15 +10,31 @@
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
body {
|
|
12
|
-
font-family: '
|
|
13
|
-
margin:
|
|
13
|
+
font-family: 'JetBrains Mono', sans-serif;
|
|
14
|
+
margin: 0;
|
|
14
15
|
background: black;
|
|
15
16
|
color: #3fff00;
|
|
16
17
|
|
|
17
|
-
/* Center the screen horizontally */
|
|
18
|
+
/* Center the screen both horizontally and vertically */
|
|
18
19
|
display: flex;
|
|
19
20
|
justify-content: center;
|
|
21
|
+
align-items: center;
|
|
20
22
|
height: 100vh; /* Full viewport height */
|
|
23
|
+
width: 100vw; /* Full viewport width */
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#screen {
|
|
27
|
+
/* Use 90% of viewport dimensions to leave some margin */
|
|
28
|
+
width: 90vw;
|
|
29
|
+
height: 90vh;
|
|
30
|
+
margin: 0;
|
|
31
|
+
padding: 0;
|
|
32
|
+
overflow: hidden; /* Hide scrollbars for clean appearance */
|
|
33
|
+
|
|
34
|
+
/* Ensure monospace font for proper character sizing */
|
|
35
|
+
font-family: 'PrintChar21', 'Courier New', Courier, monospace;
|
|
36
|
+
font-size: 16px; /* Base font size for character measurement */
|
|
37
|
+
line-height: 1; /* Tight line spacing for ASCII art */
|
|
21
38
|
}
|
|
22
39
|
|
|
23
40
|
.inverted {
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
|
-
<
|
|
6
|
-
<
|
|
5
|
+
<title>asciitorium</title>
|
|
6
|
+
<link rel="icon" type="image/png" href="/logo.png" />
|
|
7
7
|
<link rel="stylesheet" href="index.css" />
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
10
|
-
<
|
|
11
|
-
<script type="module" src="src/main.tsx"></script>
|
|
10
|
+
<pre id="screen">Loading...</pre>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
12
|
</body>
|
|
13
13
|
</html>
|
|
@@ -3,7 +3,7 @@ import { AsciiArt, Box, loadArt } from 'asciitorium';
|
|
|
3
3
|
const computer = await loadArt('./art/computer.txt');
|
|
4
4
|
|
|
5
5
|
export const AsciiArtExample = () => (
|
|
6
|
-
<Box width={42} height={28} layout="
|
|
6
|
+
<Box width={42} height={28} layout="aligned" label="ASCII Art Example:" border>
|
|
7
7
|
<AsciiArt content={computer} align="center" />
|
|
8
8
|
</Box>
|
|
9
9
|
);
|
|
@@ -12,7 +12,7 @@ export const ButtonExample = () => {
|
|
|
12
12
|
onClick={() => (buttonClickCount.value = buttonClickCount.value + 1)}
|
|
13
13
|
gap={{top: 4, bottom: 3}}
|
|
14
14
|
/>
|
|
15
|
-
<Box layout="
|
|
15
|
+
<Box layout="row" gap={{left: 6, right: 2}} align="center">
|
|
16
16
|
<Text>Click Count: </Text>
|
|
17
17
|
<Text width={4}>{buttonClickCount}</Text>
|
|
18
18
|
</Box>
|
|
@@ -31,7 +31,7 @@ export const SelectExample = () => {
|
|
|
31
31
|
selectedItem={selectValue}
|
|
32
32
|
/>
|
|
33
33
|
</Box>
|
|
34
|
-
<Box align="center" gap={{ left: 5 }} layout="
|
|
34
|
+
<Box align="center" gap={{ left: 5 }} layout="row">
|
|
35
35
|
<Text>Car Selected: </Text>
|
|
36
36
|
<Text width={20}>{selectValue}</Text>
|
|
37
37
|
</Box>
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
App,
|
|
3
|
-
Text,
|
|
4
3
|
AsciiArt,
|
|
5
4
|
Select,
|
|
6
|
-
Box,
|
|
7
5
|
Component,
|
|
6
|
+
Row,
|
|
8
7
|
PersistentState,
|
|
9
8
|
loadArt,
|
|
10
9
|
} from 'asciitorium';
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
import {
|
|
12
|
+
ButtonExample,
|
|
13
|
+
CelticBorderExample,
|
|
14
|
+
SelectExample,
|
|
15
|
+
MultiSelectExample,
|
|
16
|
+
RelativeSizingExample,
|
|
17
|
+
TextInputExample,
|
|
18
|
+
TabsExample,
|
|
19
|
+
TextExample,
|
|
20
|
+
AsciiArtExample,
|
|
21
|
+
SlidersExample,
|
|
22
|
+
} from 'asciitorium/examples';
|
|
21
23
|
|
|
22
24
|
// Load the title ASCII art
|
|
23
25
|
const titleArt = await loadArt('./art/asciitorium.txt');
|
|
@@ -32,102 +34,51 @@ const selectedComponent = new PersistentState(
|
|
|
32
34
|
const componentList = [
|
|
33
35
|
'AsciiArt',
|
|
34
36
|
'Button',
|
|
37
|
+
'CelticBorder',
|
|
35
38
|
'MultiSelect',
|
|
36
|
-
'
|
|
39
|
+
'RelativeSizing',
|
|
37
40
|
'Select',
|
|
41
|
+
'Sliders',
|
|
38
42
|
'Tabs',
|
|
39
43
|
'Text',
|
|
40
|
-
'TextInput'
|
|
44
|
+
'TextInput',
|
|
41
45
|
];
|
|
42
46
|
|
|
43
|
-
// Component mapping
|
|
44
|
-
const examples
|
|
47
|
+
// Component mapping for dynamic content
|
|
48
|
+
const examples = {
|
|
45
49
|
Button: ButtonExample,
|
|
50
|
+
CelticBorder: CelticBorderExample,
|
|
46
51
|
Select: SelectExample,
|
|
47
52
|
MultiSelect: MultiSelectExample,
|
|
53
|
+
RelativeSizing: RelativeSizingExample,
|
|
48
54
|
TextInput: TextInputExample,
|
|
49
|
-
|
|
55
|
+
Sliders: SlidersExample,
|
|
50
56
|
Tabs: TabsExample,
|
|
51
57
|
Text: TextExample,
|
|
52
|
-
AsciiArt: AsciiArtExample
|
|
58
|
+
AsciiArt: AsciiArtExample,
|
|
53
59
|
};
|
|
54
60
|
|
|
55
|
-
// Create a wrapper component that dynamically switches based on state
|
|
56
|
-
|
|
57
|
-
class DynamicExampleWrapper extends Box {
|
|
58
|
-
constructor() {
|
|
59
|
-
super({ width: 53, height: 28 });
|
|
60
|
-
|
|
61
|
-
// Initially set the current example
|
|
62
|
-
this.updateExample();
|
|
63
|
-
|
|
64
|
-
// Subscribe to changes in selectedComponent
|
|
65
|
-
selectedComponent.subscribe(() => {
|
|
66
|
-
this.updateExample();
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
private updateExample() {
|
|
71
|
-
// Properly remove existing children using removeChild to notify parent
|
|
72
|
-
const childrenToRemove = [...this.children]; // Create copy to avoid mutation during iteration
|
|
73
|
-
for (const child of childrenToRemove) {
|
|
74
|
-
child.destroy();
|
|
75
|
-
this.removeChild(child);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Get the current example factory function
|
|
79
|
-
const exampleFactory = examples[selectedComponent.value];
|
|
80
|
-
if (exampleFactory) {
|
|
81
|
-
// Call the factory function to create a new component instance
|
|
82
|
-
const exampleComponent = exampleFactory();
|
|
83
|
-
this.addChild(exampleComponent);
|
|
84
|
-
} else {
|
|
85
|
-
// Fallback for unknown component
|
|
86
|
-
this.addChild(
|
|
87
|
-
new Text({
|
|
88
|
-
width: 40,
|
|
89
|
-
height: 5,
|
|
90
|
-
border: true,
|
|
91
|
-
children: ['Unknown component'],
|
|
92
|
-
})
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Find the root App component and reset focus manager
|
|
97
|
-
this.notifyAppOfFocusChange();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
private notifyAppOfFocusChange() {
|
|
101
|
-
// Walk up the parent chain to find the App
|
|
102
|
-
let current: Component | undefined = this;
|
|
103
|
-
while (current && current.constructor.name !== 'App') {
|
|
104
|
-
current = current.parent;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// If we found the App, reset its focus manager
|
|
108
|
-
if (current && (current as any).focus) {
|
|
109
|
-
(current as any).focus.reset(current);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Construct the app with horizontal layout
|
|
115
61
|
const app = (
|
|
116
|
-
<App
|
|
62
|
+
<App>
|
|
117
63
|
<AsciiArt content={titleArt} align="center" gap={{ bottom: 2 }} />
|
|
118
|
-
<
|
|
119
|
-
{/* Left Panel - Navigation */}
|
|
64
|
+
<Row height="fit">
|
|
120
65
|
<Select
|
|
121
66
|
label="Components:"
|
|
122
|
-
width=
|
|
123
|
-
height=
|
|
67
|
+
width="30%"
|
|
68
|
+
height="fit"
|
|
124
69
|
items={componentList}
|
|
125
70
|
selectedItem={selectedComponent}
|
|
126
71
|
border
|
|
127
72
|
/>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
73
|
+
<Component
|
|
74
|
+
width="fit"
|
|
75
|
+
height="fit"
|
|
76
|
+
dynamicContent={{
|
|
77
|
+
selectedKey: selectedComponent,
|
|
78
|
+
componentMap: examples,
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
</Row>
|
|
131
82
|
</App>
|
|
132
83
|
);
|
|
133
84
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
1
|
+
import { defineConfig, Plugin } from 'vite';
|
|
2
2
|
|
|
3
3
|
// Minimal virtual shim for Node built-ins on the web build
|
|
4
4
|
function nodeBuiltinsShim(): Plugin {
|
|
@@ -26,7 +26,11 @@ function nodeBuiltinsShim(): Plugin {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export default defineConfig({
|
|
29
|
-
esbuild: {
|
|
29
|
+
esbuild: {
|
|
30
|
+
target: 'esnext',
|
|
31
|
+
jsx: 'automatic',
|
|
32
|
+
jsxImportSource: 'asciitorium',
|
|
33
|
+
},
|
|
30
34
|
build: { target: 'esnext' },
|
|
31
35
|
plugins: [nodeBuiltinsShim()],
|
|
32
36
|
server: {
|