@hotosm/ui 0.2.0-a7 → 0.2.0-a8
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 +22 -2
- package/components/Header.d.ts +16 -0
- package/components/Header.js +150 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/package.json +14 -3
- package/react/Header.d.ts +2 -0
- package/react/Header.js +11 -0
- package/react/index.d.ts +1 -0
- package/react/index.js +1 -0
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ pnpm install @hotosm/ui
|
|
|
76
76
|
// Import the components & styles (or add your own styling)
|
|
77
77
|
<link
|
|
78
78
|
rel="stylesheet"
|
|
79
|
-
href="https://s3.amazonaws.com/hotosm-ui/latest/theme/
|
|
79
|
+
href="https://s3.amazonaws.com/hotosm-ui/latest/theme/styles.css"
|
|
80
80
|
/>
|
|
81
81
|
<script
|
|
82
82
|
type="module"
|
|
@@ -105,7 +105,7 @@ pnpm install @hotosm/ui
|
|
|
105
105
|
|
|
106
106
|
```js
|
|
107
107
|
<script>
|
|
108
|
-
import '@hotosm/ui/theme/
|
|
108
|
+
import '@hotosm/ui/theme/styles.css'
|
|
109
109
|
import '@hotosm/ui/components/Button'
|
|
110
110
|
</script>
|
|
111
111
|
|
|
@@ -193,3 +193,23 @@ const HomePage = ({}) => {
|
|
|
193
193
|
|
|
194
194
|
export default HomePage;
|
|
195
195
|
```
|
|
196
|
+
|
|
197
|
+
## Using Extra Shoelace Components
|
|
198
|
+
|
|
199
|
+
The UI library is not comprehensive & you may wish to use additional components
|
|
200
|
+
from Shoelace in your app.
|
|
201
|
+
|
|
202
|
+
Ideally you should install the same version of @shoelace-style/shoelace as this
|
|
203
|
+
library.
|
|
204
|
+
|
|
205
|
+
To determine which version:
|
|
206
|
+
|
|
207
|
+
- View the
|
|
208
|
+
[@hotosm/ui](https://www.npmjs.com/package/@hotosm/ui?activeTab=versions)
|
|
209
|
+
package on npmjs.com.
|
|
210
|
+
- Select the version you are using.
|
|
211
|
+
- Go to the `Code` tab, then open the `package.json` file.
|
|
212
|
+
- The version of shoelace used should be in the `dependencies` section.
|
|
213
|
+
|
|
214
|
+
If you are using a bundler, you must bundle the (icon) assets yourself,
|
|
215
|
+
as described above.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "../theme/hot.css";
|
|
2
|
+
import '@shoelace-style/shoelace/dist/themes/light.css';
|
|
3
|
+
import '@shoelace-style/shoelace/dist/themes/dark.css';
|
|
4
|
+
import '@shoelace-style/shoelace/dist/components/icon-button/icon-button.js';
|
|
5
|
+
import '@shoelace-style/shoelace/dist/components/tab-panel/tab-panel.js';
|
|
6
|
+
import '@shoelace-style/shoelace/dist/components/tab/tab.js';
|
|
7
|
+
import { LitElement } from "lit";
|
|
8
|
+
export declare class Header extends LitElement {
|
|
9
|
+
name: string;
|
|
10
|
+
title: string;
|
|
11
|
+
logo: string | URL;
|
|
12
|
+
drawer: boolean;
|
|
13
|
+
static styles: import("lit").CSSResult[];
|
|
14
|
+
protected render(): import("lit").TemplateResult<1>;
|
|
15
|
+
}
|
|
16
|
+
export default Header;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import "../theme/hot.css";
|
|
8
|
+
import '@shoelace-style/shoelace/dist/themes/light.css';
|
|
9
|
+
import '@shoelace-style/shoelace/dist/themes/dark.css';
|
|
10
|
+
import '@shoelace-style/shoelace/dist/components/icon-button/icon-button.js';
|
|
11
|
+
import '@shoelace-style/shoelace/dist/components/tab-panel/tab-panel.js';
|
|
12
|
+
import '@shoelace-style/shoelace/dist/components/tab/tab.js';
|
|
13
|
+
import { LitElement, css, html } from "lit";
|
|
14
|
+
import { property } from "lit/decorators.js";
|
|
15
|
+
const hotLogo = new URL('../theme/logo.png', import.meta.url);
|
|
16
|
+
// import { cva } from "class-variance-authority";
|
|
17
|
+
// const headerStyle = cva(
|
|
18
|
+
// "some-css-var",
|
|
19
|
+
// {
|
|
20
|
+
// variants: {
|
|
21
|
+
// someProperty: {
|
|
22
|
+
// true: "some-css-var",
|
|
23
|
+
// false: "some-css-var",
|
|
24
|
+
// },
|
|
25
|
+
// },
|
|
26
|
+
// },
|
|
27
|
+
// );
|
|
28
|
+
export class Header extends LitElement {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.name = "hot-header";
|
|
32
|
+
this.title = '';
|
|
33
|
+
this.logo = hotLogo;
|
|
34
|
+
this.drawer = true;
|
|
35
|
+
}
|
|
36
|
+
// class=${headerStyle({
|
|
37
|
+
// someProperty: this.someProperty,
|
|
38
|
+
// })}
|
|
39
|
+
render() {
|
|
40
|
+
const logoSrc = typeof this.logo === 'string' || this.logo instanceof URL ? (typeof this.logo === 'string' ? this.logo : this.logo.href) : '';
|
|
41
|
+
return html `
|
|
42
|
+
<header>
|
|
43
|
+
|
|
44
|
+
${(logoSrc.length > 0) ? html `
|
|
45
|
+
<div id="logo-block">
|
|
46
|
+
<img id="logo" src="${this.logo}" alt="Logo">
|
|
47
|
+
</div>
|
|
48
|
+
` : null}
|
|
49
|
+
|
|
50
|
+
${(this.title.length > 0) ? html `
|
|
51
|
+
<h1>${this.title}</h1>
|
|
52
|
+
` : null}
|
|
53
|
+
|
|
54
|
+
<sl-tab-group>
|
|
55
|
+
<sl-tab slot="nav" panel="projects">Explore Projects</sl-tab>
|
|
56
|
+
<sl-tab slot="nav" panel="organisations">Manage Organizations</sl-tab>
|
|
57
|
+
</sl-tab-group>
|
|
58
|
+
|
|
59
|
+
${this.drawer ? html `
|
|
60
|
+
<div id="drawer-block" style="font-size: 32px;">
|
|
61
|
+
<sl-icon-button name="list" label="drawer-open"></sl-icon-button>
|
|
62
|
+
</div>
|
|
63
|
+
` : null}
|
|
64
|
+
|
|
65
|
+
</header>
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
Header.styles = [
|
|
70
|
+
css `
|
|
71
|
+
@unocss-placeholder;
|
|
72
|
+
`,
|
|
73
|
+
// unsafeCSS(reset),
|
|
74
|
+
css `
|
|
75
|
+
header {
|
|
76
|
+
display: flex;
|
|
77
|
+
justify-content: space-between;
|
|
78
|
+
align-items: center;
|
|
79
|
+
background: var(--app-color-primary);
|
|
80
|
+
color: white;
|
|
81
|
+
padding: 12px;
|
|
82
|
+
padding-top: 4px;
|
|
83
|
+
|
|
84
|
+
position: fixed;
|
|
85
|
+
left: 0;
|
|
86
|
+
top: 0;
|
|
87
|
+
height: 50px;
|
|
88
|
+
width: 100%;
|
|
89
|
+
-webkit-app-region: drag;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
header h1 {
|
|
93
|
+
margin-top: 0;
|
|
94
|
+
margin-bottom: 0;
|
|
95
|
+
font-size: 12px;
|
|
96
|
+
font-weight: bold;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
nav a {
|
|
100
|
+
margin-left: 10px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
#logo-block {
|
|
104
|
+
height: 40px;
|
|
105
|
+
max-width: 50%;
|
|
106
|
+
display: flex;
|
|
107
|
+
justify-content: space-between;
|
|
108
|
+
align-items: center;
|
|
109
|
+
gap: 8px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#logo {
|
|
113
|
+
height: 100%;
|
|
114
|
+
width: 100%
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
#drawer-block {
|
|
118
|
+
display: flex;
|
|
119
|
+
justify-content: space-between;
|
|
120
|
+
align-items: right;
|
|
121
|
+
gap: 8px;
|
|
122
|
+
padding-right: 30px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@media(prefers-color-scheme: light) {
|
|
126
|
+
header {
|
|
127
|
+
color: black;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
nav a {
|
|
131
|
+
color: initial;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
`
|
|
135
|
+
];
|
|
136
|
+
__decorate([
|
|
137
|
+
property()
|
|
138
|
+
], Header.prototype, "name", void 0);
|
|
139
|
+
__decorate([
|
|
140
|
+
property({ type: String })
|
|
141
|
+
], Header.prototype, "title", void 0);
|
|
142
|
+
__decorate([
|
|
143
|
+
property({ type: String })
|
|
144
|
+
], Header.prototype, "logo", void 0);
|
|
145
|
+
__decorate([
|
|
146
|
+
property({ type: Boolean })
|
|
147
|
+
], Header.prototype, "drawer", void 0);
|
|
148
|
+
export default Header;
|
|
149
|
+
// Define web component
|
|
150
|
+
customElements.define("hot-header", Header);
|
package/components/index.d.ts
CHANGED
package/components/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Index to import all components together
|
|
2
2
|
// import '@hotosm/ui/components';
|
|
3
3
|
export { default as Button } from './Button';
|
|
4
|
+
export { default as Header } from './Header';
|
|
4
5
|
export { default as Toolbar } from './Toolbar';
|
|
5
6
|
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.
|
|
3
|
+
"version": "0.2.0a8",
|
|
4
4
|
"description": "Shared UI components with theming for use across HOTOSM tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@lit/react": "^1.0.4",
|
|
38
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
39
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
38
40
|
"@storybook/addon-essentials": "^7.6.5",
|
|
39
41
|
"@storybook/addon-links": "^7.6.5",
|
|
40
42
|
"@storybook/blocks": "^7.6.5",
|
|
@@ -42,6 +44,8 @@
|
|
|
42
44
|
"@storybook/web-components-vite": "^7.6.19",
|
|
43
45
|
"@typescript-eslint/eslint-plugin": "^6.4.0",
|
|
44
46
|
"@unocss/postcss": "^0.58.5",
|
|
47
|
+
"@web/rollup-plugin-html": "^2.3.0",
|
|
48
|
+
"@web/rollup-plugin-import-meta-assets": "^2.2.1",
|
|
45
49
|
"autoprefixer": "^10.4.16",
|
|
46
50
|
"class-variance-authority": "0.7.0",
|
|
47
51
|
"clsx": "2.0.0",
|
|
@@ -56,6 +60,10 @@
|
|
|
56
60
|
"lit": "^3.1.0",
|
|
57
61
|
"react": "^18.2.0",
|
|
58
62
|
"react-dom": "^18.2.0",
|
|
63
|
+
"rollup": "^4.18.0",
|
|
64
|
+
"rollup-plugin-css-only": "^4.5.2",
|
|
65
|
+
"rollup-plugin-minify-html-literals": "^1.2.6",
|
|
66
|
+
"rollup-plugin-summary": "^2.0.1",
|
|
59
67
|
"storybook": "^7.6.5",
|
|
60
68
|
"typescript": "^5.2.2",
|
|
61
69
|
"unocss": "^0.58.0",
|
|
@@ -66,6 +74,7 @@
|
|
|
66
74
|
"react-dom": "Required for Storybook"
|
|
67
75
|
},
|
|
68
76
|
"files": [
|
|
77
|
+
"dist/**/*",
|
|
69
78
|
"components/*.js",
|
|
70
79
|
"components/*.d.ts",
|
|
71
80
|
"react/*.js",
|
|
@@ -85,8 +94,10 @@
|
|
|
85
94
|
},
|
|
86
95
|
"homepage": "https://github.com/hotosm/ui#readme",
|
|
87
96
|
"scripts": {
|
|
88
|
-
"dev": "pnpm run
|
|
89
|
-
"
|
|
97
|
+
"dev": "pnpm run compile && storybook dev -p 3001 --no-open",
|
|
98
|
+
"compile": "tsc",
|
|
99
|
+
"copy-shoelace-assets": "rm -rf dist/assets/icons && cp -r node_modules/@shoelace-style/shoelace/dist/assets dist/",
|
|
100
|
+
"build": "pnpm run compile && rollup --config && pnpm run copy-shoelace-assets",
|
|
90
101
|
"build:docstrings": "wca analyze 'components/*.ts' --outDir 'docs/components' --format 'markdown'",
|
|
91
102
|
"build:stories": "pnpm run build && storybook build --output-dir=docs/stories",
|
|
92
103
|
"build:docs": "pnpm run build:docstrings && pnpm run build:stories",
|
package/react/Header.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { createComponent } from '@lit/react';
|
|
4
|
+
import Header from '../components/Header';
|
|
5
|
+
const reactWrapper = createComponent({
|
|
6
|
+
tagName: 'hot-header',
|
|
7
|
+
elementClass: Header,
|
|
8
|
+
react: React,
|
|
9
|
+
displayName: 'hot-header'
|
|
10
|
+
});
|
|
11
|
+
export default reactWrapper;
|
package/react/index.d.ts
CHANGED
package/react/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Index to import all components together
|
|
2
2
|
// import '@hotosm/ui/react';
|
|
3
3
|
export { default as Button } from './Button';
|
|
4
|
+
export { default as Header } from './Header';
|
|
4
5
|
export { default as Toolbar } from './Toolbar';
|
|
5
6
|
export { default as Tracking } from './Tracking';
|