-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcomponent-publisher.ink
More file actions
207 lines (198 loc) · 8.17 KB
/
component-publisher.ink
File metadata and controls
207 lines (198 loc) · 8.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<link rel="import" type="template" href="@/components/html/head.ink" name="html-head" />
<link rel="import" type="template" href="@/components/html/header.ink" name="html-header" />
<link rel="import" type="template" href="@/components/html/aside.ink" name="html-aside" />
<link rel="import" type="component" href="@stackpress/ink-ui/layout/panel.ink" name="panel-layout" />
<link rel="import" type="component" href="@stackpress/ink-ui/element/icon.ink" name="element-icon" />
<link rel="import" type="component" href="@stackpress/ink-ui/element/tab.ink" name="element-tab" />
<link rel="import" type="component" href="@/components/api/docs.ink" name="api-docs" />
<link rel="import" type="component" href="@/components/ide/app/head.ink" name="app-head" />
<link rel="import" type="component" href="@/components/ide/app/left.ink" name="app-left" />
<link rel="import" type="component" href="@/components/ide/app/main.ink" name="app-main" />
<link rel="import" type="component" href="@/components/ide/app.ink" name="ide-app" />
<link rel="import" type="component" href="@/components/ide/code.ink" name="ide-code" />
<link rel="import" type="component" href="@/components/i18n/translate.ink" name="i18n-translate" />
<style>
@ink theme;
@ink reset;
@ink fouc-opacity;
@ink utilities;
</style>
<script>
import { env } from '@stackpress/ink';
import { _ } from '@/components/i18n';
const url = '/docs/component-publisher.html';
const title = _('Component Publisher - Ink reactive web component template engine.');
const description = _('How to use Ink to publish web components.');
const toggle = () => {
document.getElementsByTagName('panel-layout')[0].toggle('left');
};
</script>
<html>
<html-head />
<body class="light bg-t-0 tx-t-1 tx-arial">
<panel-layout>
<header><html-header /></header>
<aside left><html-aside /></aside>
<main>
<api-docs>
<h1 class="tx-primary tx-upper tx-30 py-20">
{_('Component Publisher')}
</h1>
<i18n-translate p trim class="tx-lh-36 py-20">
Web components are a set of web platform APIs that allow you
to create new custom, reusable, encapsulated HTML tags to use
in web pages and web apps. Custom components and widgets build
on the Web Component standards, will work across modern
browsers, and can be used with any JavaScript library or
framework that works with HTML.
</i18n-translate>
<i18n-translate p trim class="tx-lh-36 py-20">
Web components are based on existing web standards. Features
to support web components are currently being added to the
HTML and DOM specs, letting web developers easily extend HTML
with new elements with encapsulated styling and custom behavior.
</i18n-translate>
<element-alert solid curved info>
<element-icon name="info-circle" />
<strong>Note:</strong> Web components even work in React
projects.
</element-alert>
<i18n-translate p trim class="tx-lh-36 py-20">
First, create a project with the following structure and files.
</i18n-translate>
<ide-app height={290} title="My Project">
<app-head>
<div class="flex scroll-x-auto pt-5 pl-5">
<element-tab
on
class="relative ml-2 p-10 ct-sm b-solid b-t-1 bx-1 bt-1 bb-0"
active="bg-black tx-white"
inactive="bg-t-1 tx-t-1"
group="publisher"
selector="#build-ts"
>
src/build.ts
</element-tab>
<element-tab
class="relative ml-2 p-10 ct-sm b-solid b-t-1 bx-1 bt-1 bb-0"
active="bg-black tx-white"
inactive="bg-t-1 tx-t-1"
group="publisher"
selector="#component-ink"
>
src/component.ink
</element-tab>
<element-tab
class="relative ml-2 p-10 ct-sm b-solid b-t-1 bx-1 bt-1 bb-0"
active="bg-black tx-white"
inactive="bg-t-1 tx-t-1"
group="publisher"
selector="#package-json"
>
package.json
</element-tab>
</div>
</app-head>
<app-left>
<h5 class="p-5">
<element-icon name="chevron-down" />
<span>src</span>
</h5>
<element-tab
on
class="pl-15 pt-10 block"
active="tx-white"
inactive="tx-muted"
group="publisher"
selector="#build-ts"
>
<element-icon name="file" />
build.ts
</element-tab>
<element-tab
class="pl-15 pt-10 block"
active="tx-white"
inactive="tx-muted"
group="publisher"
selector="#component-ink"
>
<element-icon name="file" />
component.ink
</element-tab>
<element-tab
class="pt-10 block"
active="tx-white"
inactive="tx-muted"
group="publisher"
selector="#package-json"
>
<element-icon name="file" />
package.json
</element-tab>
</app-left>
<app-main>
<ide-code id="build-ts" lang="js" numbers trim detab={16}>{`
import http from 'http';
import ink from '@stackpress/ink/compiler';
//create ink compiler
const compiler = ink({ cwd: __dirname });
//load component, and render
const component = compiler
.fromSource('./component.ink')
.component();
//save component
compiler.fs.writeFileSync('/path/to/component.js', component);
`}</ide-code>
<ide-code id="component-ink" style="display:none" numbers trim detab={16}>{`
<style>
.title { text-align: center; }
</style>
<script>
const title = 'Hello';
</script>
<h1 class="title">{title}</h1>
`}</ide-code>
<ide-code id="package-json" style="display:none" lang="js" numbers trim detab={16}>{`
{
"name": "my-project",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "ts-node ./src/build.ts"
},
"dependencies": {
"@stackpress/ink": "0.3.30"
},
"devDependencies": {
"@stackpress/ink-dev": "0.3.30",
"@types/node": "22.1.0",
"ts-node": "10.9.2",
"typescript": "5.5.4"
}
}
`}</ide-code>
</app-main>
</ide-app>
<i18n-translate p trim class="tx-lh-36 py-20">
To test the build script and see the results, run the
following command in terminal.
</i18n-translate>
<ide-code lang="bash">
npm run build
</ide-code>
<nav class="flex">
<a class="tx-primary py-40" href="/ink/docs/static-site.html">
<element-icon name="chevron-left" theme="tx-1" />
{_('Static Site Generator')}
</a>
<a class="flex-grow tx-right tx-primary py-40" href="/ink/docs/developer-tools.html">
{_('Developer Tools')}
<element-icon name="chevron-right" theme="tx-1" />
</a>
</nav>
<footer class="foot"></footer>
</api-docs>
</main>
</panel-layout>
</body>
</html>