@hotosm/ui 0.2.0-b4 → 0.2.0-b6
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 +99 -107
- package/components/header/header.styles.ts +103 -0
- package/components/header/header.ts +117 -194
- package/components/icons.ts +1 -1
- package/components/index.ts +68 -62
- package/components/logo/logo.styles.ts +8 -0
- package/components/logo/logo.ts +37 -0
- package/components/react/Header.ts +16 -0
- package/components/react/Logo.ts +15 -0
- package/components/react/Toolbar.ts +24 -0
- package/components/react/Tracking.ts +17 -0
- package/components/react/index.ts +63 -0
- package/components/toolbar/toolbar.styles.ts +6 -0
- package/components/toolbar/toolbar.ts +100 -57
- package/components/tracking/tracking.styles.ts +23 -0
- package/components/tracking/tracking.ts +89 -85
- package/dist/components/header/header.d.ts +28 -0
- package/dist/components/header/header.styles.d.ts +6 -0
- package/dist/components/index.d.ts +130 -0
- package/dist/components/logo/logo.d.ts +10 -0
- package/dist/components/logo/logo.styles.d.ts +2 -0
- package/dist/components/react/Tracking.d.ts +2 -0
- package/dist/components/react/index.d.ts +62 -0
- package/dist/components/toolbar/toolbar.d.ts +20 -0
- package/dist/components/toolbar/toolbar.styles.d.ts +2 -0
- package/{components → dist/components}/tracking/tracking.d.ts +8 -9
- package/dist/components/tracking/tracking.styles.d.ts +2 -0
- package/dist/{components.js → hotosm-ui.js} +3707 -3671
- package/dist/style.css +1 -1
- package/package.json +35 -33
- package/theme/hot-sl.css +180 -0
- package/theme/hot.css +177 -121
- package/theme/logo/hot-logo-icon.svg +1 -0
- package/theme/logo/hot-logo-png.png +0 -0
- package/theme/logo/hot-logo-text.svg +1 -0
- package/components/header/header.d.ts +0 -30
- package/components/header/header.js +0 -237
- package/components/icons.js +0 -78
- package/components/index.d.ts +0 -127
- package/components/index.js +0 -127
- package/components/toolbar/toolbar.d.ts +0 -24
- package/components/toolbar/toolbar.js +0 -121
- package/components/tracking/tracking.js +0 -164
- package/react/Header.js +0 -14
- package/react/Toolbar.js +0 -21
- package/react/Tracking.js +0 -15
- package/react/index.d.ts +0 -3
- package/react/index.js +0 -5
- package/theme/logo.png +0 -0
- package/theme/sl-custom.css +0 -74
- /package/{components → dist/components}/icons.d.ts +0 -0
- /package/{react → dist/components/react}/Header.d.ts +0 -0
- /package/{react/Toolbar.d.ts → dist/components/react/Logo.d.ts} +0 -0
- /package/{react/Tracking.d.ts → dist/components/react/Toolbar.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- markdownlint-disable -->
|
|
4
4
|
<p align="center">
|
|
5
|
-
<img src="https://github.com/hotosm/
|
|
5
|
+
<img src="https://github.com/hotosm/ui/blob/main/theme/logo/hot-logo-png.png?raw=true" width="250" alt="HOT"></a>
|
|
6
6
|
</p>
|
|
7
7
|
<p align="center">
|
|
8
8
|
<em>Shared Web Components with theming for use across HOTOSM tools.</em>
|
|
@@ -30,166 +30,158 @@
|
|
|
30
30
|
</a>
|
|
31
31
|
</p>
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
<p align="center">
|
|
34
|
+
📖 <strong>Documentation</strong>:
|
|
35
|
+
<a href="https://hotosm.github.io/ui/" target="_blank">https://hotosm.github.io/ui/</a><br>
|
|
36
|
+
</p>
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
<p align="center">
|
|
39
|
+
🖥️ <strong>Source Code</strong>:
|
|
40
|
+
<a href="https://github.com/hotosm/ui" target="_blank">https://github.com/hotosm/ui</a><br>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
<p align="center">
|
|
44
|
+
🎯 <strong>Roadmap / Tasks</strong>:
|
|
45
|
+
<a href="https://github.com/orgs/hotosm/projects/37/views/3" target="_blank">https://github.com/orgs/hotosm/projects/37/views/3</a>
|
|
46
|
+
</p>
|
|
36
47
|
|
|
37
|
-
---
|
|
38
48
|
|
|
39
49
|
<!-- markdownlint-enable -->
|
|
40
50
|
|
|
41
|
-
|
|
42
|
-
to reduce code duplication.
|
|
51
|
+
---
|
|
43
52
|
|
|
44
|
-
|
|
45
|
-
[Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components),
|
|
46
|
-
currently written in **Lit**, using TypeScript.
|
|
53
|
+
## Shared UI Components with HOT Theming
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
the
|
|
55
|
+
This repository contains HOT themed UI components to reduce code duplication
|
|
56
|
+
and simplify the lives of developers needing to prototype and develop well
|
|
57
|
+
designed web applications quickly.
|
|
50
58
|
|
|
51
|
-
|
|
59
|
+
They are available as
|
|
60
|
+
[Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)
|
|
61
|
+
with support for usage in [almost all](https://custom-elements-everywhere.com)
|
|
62
|
+
modern web frameworks.
|
|
52
63
|
|
|
53
|
-
|
|
64
|
+
The main goal of this project is not to re-invent the wheel, or add an extra burden
|
|
65
|
+
of development and maintenance.
|
|
54
66
|
|
|
55
|
-
|
|
56
|
-
- **CDN**: appropriate for HTML / Markdown / HTMX.
|
|
67
|
+
## Quick start
|
|
57
68
|
|
|
58
|
-
|
|
69
|
+
There are two options: NPM and Components Bundle.
|
|
59
70
|
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
### NPM
|
|
72
|
+
|
|
73
|
+
Appropriate for applications that have installable dependencies
|
|
62
74
|
|
|
63
|
-
|
|
75
|
+
`npm install @hotosm/ui`
|
|
64
76
|
|
|
65
|
-
|
|
66
|
-
- Import the components.
|
|
77
|
+
Import the library in your project and use the components.
|
|
67
78
|
|
|
68
79
|
```html
|
|
69
80
|
<script>
|
|
70
81
|
import '@hotosm/ui/dist/style.css';
|
|
71
|
-
import '@hotosm/ui/dist/
|
|
82
|
+
import '@hotosm/ui/dist/hotosm-ui.js';
|
|
72
83
|
</script>
|
|
84
|
+
```
|
|
73
85
|
|
|
74
|
-
|
|
75
|
-
<hot-
|
|
86
|
+
```html
|
|
87
|
+
<hot-logo><hot-logo>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### React
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
import { Logo } from '@hotosm/ui/components/react';
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```jsx
|
|
97
|
+
<Logo />
|
|
76
98
|
```
|
|
77
99
|
|
|
78
|
-
|
|
100
|
+
### Components Bundle
|
|
101
|
+
|
|
102
|
+
- This is the compiled JavaScript bundle generated from the TypeScript code.
|
|
103
|
+
- The components require no additional dependencies and are minified.
|
|
104
|
+
|
|
105
|
+
Appropriate for HTML / Markdown / HTMX.
|
|
79
106
|
|
|
80
107
|
```html
|
|
81
|
-
// Import the styles (or create your own)
|
|
82
108
|
<link
|
|
83
109
|
rel="stylesheet"
|
|
84
|
-
href="https://s3.amazonaws.com/hotosm-ui/latest/style.css"
|
|
110
|
+
href="https://s3.amazonaws.com/hotosm-ui/latest/dist/style.css"
|
|
85
111
|
/>
|
|
86
112
|
|
|
87
|
-
// Import the components
|
|
88
113
|
<script
|
|
89
114
|
type="module"
|
|
90
|
-
src="https://
|
|
115
|
+
src="https://s3.amazonaws.com/hotosm-ui/latest/dist/hotosm-ui.js"
|
|
91
116
|
></script>
|
|
92
117
|
|
|
93
|
-
<hot-
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
The `jsdelivr` CDN only includes package releases, with `@latest` pointing to the
|
|
97
|
-
most recent tagged release.
|
|
118
|
+
<hot-logo></hot-logo>
|
|
119
|
+
```
|
|
98
120
|
|
|
99
|
-
|
|
100
|
-
`https://s3.amazonaws.com/hotosm-ui/latest/dist/components.js`
|
|
101
|
-
|
|
102
|
-
### ES Modules
|
|
103
|
-
|
|
104
|
-
- Using the TypeScript ES Modules allows for cherry-picking components, so
|
|
105
|
-
'tree-shaking' can remove the remaining ones you don't use.
|
|
106
|
-
- If you are developing an application that uses `@hotosm/ui` components,
|
|
107
|
-
including a bundler such as rollup/vite/webpack, this is probably the best approach.
|
|
108
|
-
- However, you must first add Lit as a `peerDependency` in your `package.json`:
|
|
121
|
+
## Using Extra Shoelace Components
|
|
109
122
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
"lit": "^3.1.0"
|
|
113
|
-
}
|
|
114
|
-
```
|
|
123
|
+
The HOT UI library contains many composite components, such as headers, sidebars,
|
|
124
|
+
tracking banners, etc, and does not re-invent the wheel for low-level components.
|
|
115
125
|
|
|
116
|
-
|
|
117
|
-
> hotosm/ui.
|
|
126
|
+
Shoelace is an UI library that is exported directly from `@hotosm/ui`.
|
|
118
127
|
|
|
119
|
-
|
|
128
|
+
To access the low-level components, such as buttons, dropdowns, modals, etc,
|
|
129
|
+
simply import the component of the same name from the [Shoelace docs]
|
|
130
|
+
(<https://shoelace.style>):
|
|
120
131
|
|
|
121
132
|
```js
|
|
122
|
-
import '@hotosm/ui/components/
|
|
123
|
-
|
|
124
|
-
// Then in your template
|
|
125
|
-
<hot-header @login="${someFunction()}"></hot-header>
|
|
133
|
+
import '@hotosm/ui/components/button/button';
|
|
126
134
|
```
|
|
127
135
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
web components.
|
|
136
|
+
```html
|
|
137
|
+
<hot-button disabled variant="secondary">Can't Click Me</hot-button>
|
|
138
|
+
```
|
|
132
139
|
|
|
133
|
-
|
|
140
|
+
### React Shoelace Wrappers
|
|
134
141
|
|
|
135
|
-
```
|
|
136
|
-
|
|
142
|
+
```js
|
|
143
|
+
import { Button } from '@hotosm/ui/components';
|
|
137
144
|
```
|
|
138
145
|
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const HomePage = ({}) => {
|
|
143
|
-
return (
|
|
144
|
-
<div className="your-css-classes">
|
|
145
|
-
<div
|
|
146
|
-
...
|
|
147
|
-
>
|
|
148
|
-
<Header @onLogin="${someFunction()}" />
|
|
149
|
-
</div>
|
|
150
|
-
</div>
|
|
151
|
-
);
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
export default HomePage;
|
|
146
|
+
```html
|
|
147
|
+
<Button disabled variant="secondary">Can't Click Me</Button>
|
|
155
148
|
```
|
|
156
149
|
|
|
157
|
-
|
|
158
|
-
> required for the React wrappers.
|
|
150
|
+
### Examples
|
|
159
151
|
|
|
160
|
-
|
|
152
|
+
You can found examples for HTML and also all common frameworks
|
|
153
|
+
(React, Svelte, Vue) under `/examples`.
|
|
161
154
|
|
|
162
|
-
|
|
163
|
-
tracking banners, etc, and does not re-invent the wheel for low-level components.
|
|
155
|
+
### Development
|
|
164
156
|
|
|
165
|
-
|
|
157
|
+
HOT UI is developed in TypeScript, using Lit and @lit/react.
|
|
166
158
|
|
|
167
|
-
|
|
168
|
-
simply import the component of the same name from the [Shoelace docs]
|
|
169
|
-
(<https://shoelace.style>):
|
|
159
|
+
Primarily we want to have:
|
|
170
160
|
|
|
171
|
-
|
|
172
|
-
|
|
161
|
+
- Low level components exported from the Shoelace web component
|
|
162
|
+
library, simply re-exported with our default styling / CSS overrides.
|
|
163
|
+
- A few composite components (header, sidebar, etc):
|
|
164
|
+
- Consistent styling across most of our tools where it counts.
|
|
165
|
+
- Reduction in duplicated logic, such as user management, OAuth login, etc.
|
|
166
|
+
- Improved developer experience, reduced development time for new tools, while
|
|
167
|
+
maintaining consistency in look and feel of applications.
|
|
173
168
|
|
|
174
|
-
|
|
175
|
-
<hot-button disabled variant="secondary">Can't Click Me</hot-button>
|
|
176
|
-
```
|
|
169
|
+
### How to contribute
|
|
177
170
|
|
|
178
|
-
|
|
179
|
-
|
|
171
|
+
- Clone the project `git clone git@github.com:hotosm/ui.git`
|
|
172
|
+
- Install dependencies `pnpm install`
|
|
173
|
+
- Run the storybook `pnpm run dev`
|
|
174
|
+
- Write code!
|
|
180
175
|
|
|
181
|
-
|
|
176
|
+
There's also a React storybook that you can use for testing:
|
|
182
177
|
|
|
183
|
-
-
|
|
184
|
-
the following to your `package.json`:
|
|
178
|
+
- Run the React storybook `pnpm run dev-react`
|
|
185
179
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
```
|
|
180
|
+
For **styling**, check `/theme`:
|
|
181
|
+
|
|
182
|
+
- `hot-sl.css` has a Shoelace theme, re-defining styles variables
|
|
183
|
+
|
|
184
|
+
### License
|
|
193
185
|
|
|
194
|
-
|
|
195
|
-
|
|
186
|
+
HOT UI is free and open source software! you may use any HOT UI project under the
|
|
187
|
+
terms of the GNU Affero General Public License (AGPL) Version 3.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
|
|
4
|
+
export const headerVariants = cva(
|
|
5
|
+
// Defaults to include in all variants
|
|
6
|
+
`
|
|
7
|
+
header
|
|
8
|
+
`,
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
size: {
|
|
12
|
+
small: "header--size-small",
|
|
13
|
+
medium: "header--size-medium",
|
|
14
|
+
large: "header--size-large",
|
|
15
|
+
},
|
|
16
|
+
borderBottom: {
|
|
17
|
+
true: "border-bottom",
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export type sizes = "small" | "medium" | "large";
|
|
24
|
+
|
|
25
|
+
export const styles = css`
|
|
26
|
+
.header {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: space-between;
|
|
30
|
+
padding: 0 var(--sl-spacing-small);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.header.border-bottom {
|
|
34
|
+
border-bottom: var(--sl-spacing-3x-small) solid var(--sl-color-neutral-50);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.header--size-small {
|
|
38
|
+
height: var(--sl-spacing-4x-large);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.header--size-medium {
|
|
42
|
+
height: calc(var(--sl-spacing-4x-large) * 2);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.header--size-large {
|
|
46
|
+
height: calc(var(--sl-spacing-4x-large) * 4);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.header--link {
|
|
50
|
+
text-decoration: none;
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
justify-content: space-between;
|
|
54
|
+
gap: var(--sl-spacing-small);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.header--title {
|
|
58
|
+
color: var(--sl-color-neutral-950);
|
|
59
|
+
font-family: var(--sl-font-sans);
|
|
60
|
+
font-size: var(--sl-font-size-x-large);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.header--tab-group {
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.header--tab::part(base) {
|
|
68
|
+
font-size: var(--sl-font-size-medium);
|
|
69
|
+
font-weight: var(--sl-font-weight-normal);
|
|
70
|
+
color: var(--sl-color-neutral-950);
|
|
71
|
+
padding: var(--sl-spacing-small) var(--sl-spacing-small);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.header--tab-group::part(base) {
|
|
75
|
+
--track-color: transparent;
|
|
76
|
+
--indicator-color: var(--sl-color-neutral-950);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.header--nav {
|
|
80
|
+
justify-content: space-between;
|
|
81
|
+
justify-items: center;
|
|
82
|
+
gap: var(--sl-spacing-medium);
|
|
83
|
+
font-weight: var(--sl-font-weight-semibold);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.header--nav-mobile {
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.header--person-circle {
|
|
90
|
+
font-size: var(--sl-font-size-x-large);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.header--drawer {
|
|
94
|
+
font-size: var(--sl-font-size-x-large)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.header--right-section {
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.header--logo-img {
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
`
|