@hotosm/ui 0.2.0-a6 → 0.2.0-a7
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/README.md +93 -13
- package/components/index.d.ts +3 -0
- package/components/index.js +5 -0
- package/package.json +1 -1
- package/react/Button.d.ts +2 -0
- package/react/Button.js +14 -0
- package/react/Toolbar.d.ts +2 -0
- package/react/Tracking.d.ts +2 -0
- package/react/index.d.ts +3 -0
- package/react/index.js +5 -0
- package/react/HotToolbar.d.ts +0 -12
- package/react/HotTracking.d.ts +0 -6
- /package/react/{HotToolbar.js → Toolbar.js} +0 -0
- /package/react/{HotTracking.js → Tracking.js} +0 -0
package/README.md
CHANGED
|
@@ -59,35 +59,43 @@ pnpm install @hotosm/ui
|
|
|
59
59
|
|
|
60
60
|
## Usage
|
|
61
61
|
|
|
62
|
-
### HTML / HTMX
|
|
62
|
+
### CDN (HTML / HTMX)
|
|
63
63
|
|
|
64
64
|
```html
|
|
65
|
-
// Import
|
|
65
|
+
// Import Shoelace dependency
|
|
66
|
+
<link
|
|
67
|
+
rel="stylesheet"
|
|
68
|
+
href="https://cdn.jsdelivr.net/npm/@shoelace-style
|
|
69
|
+
/shoelace@2.15.1/cdn/themes/light.css" />
|
|
66
70
|
<script
|
|
67
71
|
type="module"
|
|
68
|
-
src="https://
|
|
72
|
+
src="https://cdn.jsdelivr.net/npm/@shoelace-style/
|
|
73
|
+
shoelace@2.15.1/cdn/shoelace-autoloader.js"
|
|
69
74
|
></script>
|
|
70
75
|
|
|
71
|
-
// Import the styles (or
|
|
76
|
+
// Import the components & styles (or add your own styling)
|
|
72
77
|
<link
|
|
73
78
|
rel="stylesheet"
|
|
74
79
|
href="https://s3.amazonaws.com/hotosm-ui/latest/theme/hot.css"
|
|
75
80
|
/>
|
|
81
|
+
<script
|
|
82
|
+
type="module"
|
|
83
|
+
src="https://s3.amazonaws.com/hotosm-ui/latest/components/Button.js"
|
|
84
|
+
></script>
|
|
76
85
|
|
|
77
86
|
<div>
|
|
78
87
|
<hot-button disabled> </hot-button>
|
|
79
88
|
</div>
|
|
80
89
|
```
|
|
81
90
|
|
|
91
|
+
> Using the Shoelace autoloader will lazy load only the components you use.
|
|
92
|
+
|
|
82
93
|
See the docs for more [usage examples](https://hotosm.github.io/ui/usage/).
|
|
83
94
|
|
|
84
|
-
>
|
|
85
|
-
>
|
|
86
|
-
> extra.js will contain additional wrapper components.
|
|
87
|
-
>
|
|
88
|
-
> There should be versioning of the components, plus a /latest/ version too.
|
|
95
|
+
> Components are versioned under subdirectories, with /latest/ tracking the
|
|
96
|
+
> `main` branch, plus versioned releases.
|
|
89
97
|
|
|
90
|
-
###
|
|
98
|
+
### ES6 Imports (most frameworks)
|
|
91
99
|
|
|
92
100
|
Install your required version with a pin, or latest:
|
|
93
101
|
|
|
@@ -96,7 +104,80 @@ pnpm install @hotosm/ui
|
|
|
96
104
|
```
|
|
97
105
|
|
|
98
106
|
```js
|
|
99
|
-
|
|
107
|
+
<script>
|
|
108
|
+
import '@hotosm/ui/theme/hot.css'
|
|
109
|
+
import '@hotosm/ui/components/Button'
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
<hot-button disabled></hot-button>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
> Note that web components must always have a closing tag.
|
|
116
|
+
|
|
117
|
+
#### Importing Icons
|
|
118
|
+
|
|
119
|
+
The icon pack for Shoelace must be imported to display in components.
|
|
120
|
+
|
|
121
|
+
There are two options:
|
|
122
|
+
|
|
123
|
+
##### 1. CDN Assets
|
|
124
|
+
|
|
125
|
+
Just add the Shoelace icons via CDN in your HTML file:
|
|
126
|
+
|
|
127
|
+
```html
|
|
128
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style
|
|
129
|
+
/shoelace@2.15.1/cdn/themes/light.css" />
|
|
130
|
+
|
|
131
|
+
// Or dark
|
|
132
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style
|
|
133
|
+
/shoelace@2.15.1/cdn/themes/dark.css" />
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
##### 2. Bundle Assets Yourself
|
|
137
|
+
|
|
138
|
+
- Add Shoelace as a `peerDependency` and to your `package.json`:
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
"peerDependencies": {
|
|
142
|
+
"@shoelace-style/shoelace": "^2.15.1"
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
- Also add `vite-plugin-static-copy` as a devDependency:
|
|
147
|
+
`pnpm install -D vite-plugin-static-copy`
|
|
148
|
+
- Add to your `vite.config.ts`:
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|
152
|
+
|
|
153
|
+
export default defineConfig({
|
|
154
|
+
plugins: [
|
|
155
|
+
viteStaticCopy({
|
|
156
|
+
targets: [
|
|
157
|
+
{
|
|
158
|
+
src: 'node_modules/@shoelace-style/shoelace/dist/assets',
|
|
159
|
+
dest: ''
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
}),
|
|
163
|
+
],
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
- Now the Shoelace assets will be bundled with your dist, under `/shoelace`.
|
|
167
|
+
|
|
168
|
+
#### React
|
|
169
|
+
|
|
170
|
+
Versions of React below v19 require a specific 'wrapper' component to use the
|
|
171
|
+
web components.
|
|
172
|
+
|
|
173
|
+
Use these instead of the standard `@hotosm/ui/components/xxx`:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
pnpm install @hotosm/ui
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
import { Button } from '@hotosm/ui/react/Button'
|
|
100
181
|
|
|
101
182
|
const HomePage = ({}) => {
|
|
102
183
|
return (
|
|
@@ -104,8 +185,7 @@ const HomePage = ({}) => {
|
|
|
104
185
|
<div
|
|
105
186
|
...
|
|
106
187
|
>
|
|
107
|
-
<
|
|
108
|
-
</hot-button>
|
|
188
|
+
<Button disabled />
|
|
109
189
|
</div>
|
|
110
190
|
</div>
|
|
111
191
|
);
|
package/package.json
CHANGED
package/react/Button.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { createComponent } from '@lit/react';
|
|
4
|
+
import Button from '../components/Button';
|
|
5
|
+
const reactWrapper = createComponent({
|
|
6
|
+
tagName: 'hot-button',
|
|
7
|
+
elementClass: Button,
|
|
8
|
+
react: React,
|
|
9
|
+
events: {
|
|
10
|
+
onClick: 'click',
|
|
11
|
+
},
|
|
12
|
+
displayName: 'hot-button'
|
|
13
|
+
});
|
|
14
|
+
export default reactWrapper;
|
package/react/index.d.ts
ADDED
package/react/index.js
ADDED
package/react/HotToolbar.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Toolbar from '../components/Toolbar';
|
|
2
|
-
declare const reactWrapper: import("@lit/react").ReactWebComponent<Toolbar, {
|
|
3
|
-
onHotUndoClick: string;
|
|
4
|
-
onHotRedoClick: string;
|
|
5
|
-
onHotBoldClick: string;
|
|
6
|
-
onHotItalicClick: string;
|
|
7
|
-
onHotUnderlineClick: string;
|
|
8
|
-
onHotLeftalignClick: string;
|
|
9
|
-
onHotCenteralignClick: string;
|
|
10
|
-
onHotRightalignClick: string;
|
|
11
|
-
}>;
|
|
12
|
-
export default reactWrapper;
|
package/react/HotTracking.d.ts
DELETED
|
File without changes
|
|
File without changes
|