@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.
Files changed (54) hide show
  1. package/README.md +99 -107
  2. package/components/header/header.styles.ts +103 -0
  3. package/components/header/header.ts +117 -194
  4. package/components/icons.ts +1 -1
  5. package/components/index.ts +68 -62
  6. package/components/logo/logo.styles.ts +8 -0
  7. package/components/logo/logo.ts +37 -0
  8. package/components/react/Header.ts +16 -0
  9. package/components/react/Logo.ts +15 -0
  10. package/components/react/Toolbar.ts +24 -0
  11. package/components/react/Tracking.ts +17 -0
  12. package/components/react/index.ts +63 -0
  13. package/components/toolbar/toolbar.styles.ts +6 -0
  14. package/components/toolbar/toolbar.ts +100 -57
  15. package/components/tracking/tracking.styles.ts +23 -0
  16. package/components/tracking/tracking.ts +89 -85
  17. package/dist/components/header/header.d.ts +28 -0
  18. package/dist/components/header/header.styles.d.ts +6 -0
  19. package/dist/components/index.d.ts +130 -0
  20. package/dist/components/logo/logo.d.ts +10 -0
  21. package/dist/components/logo/logo.styles.d.ts +2 -0
  22. package/dist/components/react/Tracking.d.ts +2 -0
  23. package/dist/components/react/index.d.ts +62 -0
  24. package/dist/components/toolbar/toolbar.d.ts +20 -0
  25. package/dist/components/toolbar/toolbar.styles.d.ts +2 -0
  26. package/{components → dist/components}/tracking/tracking.d.ts +8 -9
  27. package/dist/components/tracking/tracking.styles.d.ts +2 -0
  28. package/dist/{components.js → hotosm-ui.js} +3707 -3671
  29. package/dist/style.css +1 -1
  30. package/package.json +35 -33
  31. package/theme/hot-sl.css +180 -0
  32. package/theme/hot.css +177 -121
  33. package/theme/logo/hot-logo-icon.svg +1 -0
  34. package/theme/logo/hot-logo-png.png +0 -0
  35. package/theme/logo/hot-logo-text.svg +1 -0
  36. package/components/header/header.d.ts +0 -30
  37. package/components/header/header.js +0 -237
  38. package/components/icons.js +0 -78
  39. package/components/index.d.ts +0 -127
  40. package/components/index.js +0 -127
  41. package/components/toolbar/toolbar.d.ts +0 -24
  42. package/components/toolbar/toolbar.js +0 -121
  43. package/components/tracking/tracking.js +0 -164
  44. package/react/Header.js +0 -14
  45. package/react/Toolbar.js +0 -21
  46. package/react/Tracking.js +0 -15
  47. package/react/index.d.ts +0 -3
  48. package/react/index.js +0 -5
  49. package/theme/logo.png +0 -0
  50. package/theme/sl-custom.css +0 -74
  51. /package/{components → dist/components}/icons.d.ts +0 -0
  52. /package/{react → dist/components/react}/Header.d.ts +0 -0
  53. /package/{react/Toolbar.d.ts → dist/components/react/Logo.d.ts} +0 -0
  54. /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/fmtm/blob/main/images/hot_logo.png?raw=true" style="width: 200px;" alt="HOT"></a>
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
- 📖 **Documentation**: <a href="https://hotosm.github.io/ui/" target="_blank">https://hotosm.github.io/ui/</a>
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
- 🖥️ **Source Code**: <a href="https://github.com/hotosm/ui" target="_blank">https://github.com/hotosm/ui</a>
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
- Shared UI components with theming for use across HOTOSM tools,
42
- to reduce code duplication.
51
+ ---
43
52
 
44
- The components are
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
- Compositie components (header, sidebar, etc) are generated using Shoelace, with
49
- the remaining low-level components exported from the Shoelace library too.
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
- ## Install
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
- There are two options for install:
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
- - **NPM**: appropriate for applications that have installable dependencies.
56
- - **CDN**: appropriate for HTML / Markdown / HTMX.
67
+ ## Quick start
57
68
 
58
- ### Components Bundle
69
+ There are two options: NPM and Components Bundle.
59
70
 
60
- - This is the compiled JavaScript bundle generated from the TypeScript code.
61
- - The components require no additional dependencies and are minified.
71
+ ### NPM
72
+
73
+ Appropriate for applications that have installable dependencies
62
74
 
63
- #### Via NPM
75
+ `npm install @hotosm/ui`
64
76
 
65
- - Install package `@hotosm/ui` as a dependency in your `package.json`.
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/components.js';
82
+ import '@hotosm/ui/dist/hotosm-ui.js';
72
83
  </script>
84
+ ```
73
85
 
74
- // Use the components in your templates
75
- <hot-header @login="someFunction()"> </hot-header>
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
- #### Via CDN
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://cdn.jsdelivr.net/npm/@hotosm/ui@latest/dist/components.js"
115
+ src="https://s3.amazonaws.com/hotosm-ui/latest/dist/hotosm-ui.js"
91
116
  ></script>
92
117
 
93
- <hot-header @login="someFunction()> </hot-header>
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
- There is also an S3-based CDN, where `latest` tracks the `main` branch of the repo:
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
- ```json
111
- "peerDependencies": {
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
- > Ideally the version of Lit installed should match the version used in
117
- > hotosm/ui.
126
+ Shoelace is an UI library that is exported directly from `@hotosm/ui`.
118
127
 
119
- Example:
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/header/header';
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
- ### React
129
-
130
- Versions of React below v19 require a specific 'wrapper' component to use the
131
- web components.
136
+ ```html
137
+ <hot-button disabled variant="secondary">Can't Click Me</hot-button>
138
+ ```
132
139
 
133
- Use these instead of the standard `@hotosm/ui/components/xxx`:
140
+ ### React Shoelace Wrappers
134
141
 
135
- ```bash
136
- pnpm install @hotosm/ui
142
+ ```js
143
+ import { Button } from '@hotosm/ui/components';
137
144
  ```
138
145
 
139
- ```js
140
- import { Button } from '@hotosm/ui/react/Header'
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
- > Note that while web components must always have a closing tag, this is not
158
- > required for the React wrappers.
150
+ ### Examples
159
151
 
160
- ## Using Extra Shoelace Components
152
+ You can found examples for HTML and also all common frameworks
153
+ (React, Svelte, Vue) under `/examples`.
161
154
 
162
- The UI library contains many composite components, such as headers, sidebars,
163
- tracking banners, etc, and does not re-invent the wheel for low-level components.
155
+ ### Development
164
156
 
165
- Shoelace is an excellent UI library that is exported directly from `@hotosm/ui`.
157
+ HOT UI is developed in TypeScript, using Lit and @lit/react.
166
158
 
167
- To access the low-level components, such as buttons, dropdowns, modals, etc,
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
- ```js
172
- import '@hotosm/ui/components/button/button';
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
- // Then in your template
175
- <hot-button disabled variant="secondary">Can't Click Me</hot-button>
176
- ```
169
+ ### How to contribute
177
170
 
178
- If you are using a bundler, you must bundle the (icon) assets yourself,
179
- described in the Shoelace docs.
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
- ### Example of bundling assets
176
+ There's also a React storybook that you can use for testing:
182
177
 
183
- - To include the Shoelace assets in your final bundle (dist), you could add
184
- the following to your `package.json`:
178
+ - Run the React storybook `pnpm run dev-react`
185
179
 
186
- ```json
187
- "scripts": {
188
- "clean-icons": "rm -rf public/assets/icons",
189
- "get-icons": "cp -r node_modules/@shoelace-style/shoelace/dist/assets/icons public/",
190
- "setup-dist": "pnpm run clean-icons && pnpm run get-icons",
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
- - Now the Shoelace assets will be bundled with your dist, under `/shoelace`.
195
- - Following the example, also add `public/assets/icons` to your `.gitignore` file.
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
+ `