@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 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 the components
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://s3.amazonaws.com/hotosm-ui/latest/components/Button.js"
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 create your own)
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
- > core.js will contain the minimal low level components.
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
- ### React
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
- import '@hotosm/ui/components/Button'
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
- <hot-button disabled>
108
- </hot-button>
188
+ <Button disabled />
109
189
  </div>
110
190
  </div>
111
191
  );
@@ -0,0 +1,3 @@
1
+ export { default as Button } from './Button';
2
+ export { default as Toolbar } from './Toolbar';
3
+ export { default as Tracking } from './Tracking';
@@ -0,0 +1,5 @@
1
+ // Index to import all components together
2
+ // import '@hotosm/ui/components';
3
+ export { default as Button } from './Button';
4
+ export { default as Toolbar } from './Toolbar';
5
+ export { default as Tracking } from './Tracking';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotosm/ui",
3
- "version": "0.2.0a6",
3
+ "version": "0.2.0a7",
4
4
  "description": "Shared UI components with theming for use across HOTOSM tools.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -0,0 +1,2 @@
1
+ declare const reactWrapper: React.ForwardRefExoticComponent<any>;
2
+ export default reactWrapper;
@@ -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;
@@ -0,0 +1,2 @@
1
+ declare const reactWrapper: React.ForwardRefExoticComponent<any>;
2
+ export default reactWrapper;
@@ -0,0 +1,2 @@
1
+ declare const reactWrapper: React.ForwardRefExoticComponent<any>;
2
+ export default reactWrapper;
@@ -0,0 +1,3 @@
1
+ export { default as Button } from './Button';
2
+ export { default as Toolbar } from './Toolbar';
3
+ export { default as Tracking } from './Tracking';
package/react/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // Index to import all components together
2
+ // import '@hotosm/ui/react';
3
+ export { default as Button } from './Button';
4
+ export { default as Toolbar } from './Toolbar';
5
+ export { default as Tracking } from './Tracking';
@@ -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;
@@ -1,6 +0,0 @@
1
- import Tracking from '../components/Tracking';
2
- declare const reactWrapper: import("@lit/react").ReactWebComponent<Tracking, {
3
- onHotAgree: string;
4
- onHotDisagree: string;
5
- }>;
6
- export default reactWrapper;
File without changes
File without changes