@hotosm/ui 0.2.0-b3 → 0.2.0-b5
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 +105 -105
- package/components/header/header.styles.ts +103 -0
- package/components/header/header.ts +160 -0
- package/components/{icons.js → icons.ts} +25 -13
- package/components/index.ts +265 -0
- package/components/logo/logo.styles.ts +8 -0
- package/components/logo/logo.ts +37 -0
- package/components/react/Header.ts +16 -0
- package/{react/Header.js → components/react/Logo.ts} +9 -5
- 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 +171 -0
- package/components/tracking/tracking.styles.ts +23 -0
- package/components/tracking/tracking.ts +177 -0
- 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/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/dist/components/tracking/tracking.d.ts +23 -0
- package/dist/components/tracking/tracking.styles.d.ts +2 -0
- package/dist/hotosm-ui.js +18450 -0
- package/dist/style.css +1 -0
- package/package.json +29 -35
- package/theme/hot-sl.css +194 -0
- package/theme/hot.css +191 -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/Button.d.ts +0 -16
- package/components/Button.js +0 -75
- package/components/Header.d.ts +0 -16
- package/components/Header.js +0 -152
- package/components/Toolbar.d.ts +0 -26
- package/components/Toolbar.js +0 -123
- package/components/Tracking.d.ts +0 -26
- package/components/Tracking.js +0 -167
- package/components/index.d.ts +0 -4
- package/components/index.js +0 -6
- package/dist/assets/logo-CqlPtOQW.png +0 -0
- package/dist/components.js +0 -121
- package/dist/styles.css +0 -1092
- package/react/Button.js +0 -14
- package/react/Toolbar.js +0 -21
- package/react/Tracking.js +0 -15
- package/react/index.d.ts +0 -4
- package/react/index.js +0 -6
- package/theme/logo.png +0 -0
- /package/{components → dist/components}/icons.d.ts +0 -0
- /package/{react → dist/components/react}/Header.d.ts +0 -0
- /package/{react/Button.d.ts → dist/components/react/Logo.d.ts} +0 -0
- /package/{react → dist/components/react}/Toolbar.d.ts +0 -0
- /package/{react → dist/components/react}/Tracking.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,158 +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
|
-
|
|
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.
|
|
49
58
|
|
|
50
|
-
|
|
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.
|
|
51
63
|
|
|
52
|
-
-
|
|
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
|
-
|
|
67
|
+
## Quick start
|
|
56
68
|
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
There are two options: NPM and Components Bundle.
|
|
70
|
+
|
|
71
|
+
### NPM
|
|
72
|
+
|
|
73
|
+
Appropriate for applications that have installable dependencies
|
|
59
74
|
|
|
60
|
-
|
|
75
|
+
`npm install @hotosm/ui`
|
|
61
76
|
|
|
62
|
-
|
|
63
|
-
- Import the components.
|
|
77
|
+
Import the library in your project and use the components.
|
|
64
78
|
|
|
65
79
|
```html
|
|
66
80
|
<script>
|
|
67
|
-
import '@hotosm/ui/dist/
|
|
81
|
+
import '@hotosm/ui/dist/style.css';
|
|
82
|
+
import '@hotosm/ui/dist/hotosm-ui.js';
|
|
68
83
|
</script>
|
|
84
|
+
```
|
|
69
85
|
|
|
70
|
-
|
|
71
|
-
<hot-
|
|
86
|
+
```html
|
|
87
|
+
<hot-logo><hot-logo>
|
|
72
88
|
```
|
|
73
89
|
|
|
74
|
-
####
|
|
90
|
+
#### React
|
|
75
91
|
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
src="https://cdn.jsdelivr.net/npm/@hotosm/ui@latest/dist/components.js"
|
|
80
|
-
></script>
|
|
92
|
+
```js
|
|
93
|
+
import { Logo } from '@hotosm/ui/components/react';
|
|
94
|
+
```
|
|
81
95
|
|
|
82
|
-
|
|
96
|
+
```jsx
|
|
97
|
+
<Logo />
|
|
83
98
|
```
|
|
84
99
|
|
|
85
|
-
|
|
86
|
-
most recent tagged release.
|
|
100
|
+
### Components Bundle
|
|
87
101
|
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
- This is the compiled JavaScript bundle generated from the TypeScript code.
|
|
103
|
+
- The components require no additional dependencies and are minified.
|
|
90
104
|
|
|
91
|
-
|
|
105
|
+
Appropriate for HTML / Markdown / HTMX.
|
|
92
106
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
```html
|
|
108
|
+
<link
|
|
109
|
+
rel="stylesheet"
|
|
110
|
+
href="https://s3.amazonaws.com/hotosm-ui/latest/style.css"
|
|
111
|
+
/>
|
|
98
112
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
```
|
|
113
|
+
<script
|
|
114
|
+
type="module"
|
|
115
|
+
src="https://s3.amazonaws.com/hotosm-ui/latest/dist/hotosm-ui.js"
|
|
116
|
+
></script>
|
|
104
117
|
|
|
105
|
-
|
|
106
|
-
|
|
118
|
+
<hot-logo></hot-logo>
|
|
119
|
+
```
|
|
107
120
|
|
|
108
|
-
|
|
109
|
-
- If there is a conflict between Lit versions, the `lit` package can also be pinned
|
|
110
|
-
via `peerDependency`.
|
|
121
|
+
## Using Extra Shoelace Components
|
|
111
122
|
|
|
112
|
-
|
|
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.
|
|
113
125
|
|
|
114
|
-
|
|
115
|
-
import '@hotosm/ui/components/Toolbar';
|
|
126
|
+
Shoelace is an UI library that is exported directly from `@hotosm/ui`.
|
|
116
127
|
|
|
117
|
-
|
|
118
|
-
|
|
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
|
|
133
|
+
import '@hotosm/ui/components/button/button';
|
|
134
|
+
```
|
|
122
135
|
|
|
123
|
-
|
|
124
|
-
|
|
136
|
+
```html
|
|
137
|
+
<hot-button disabled variant="secondary">Can't Click Me</hot-button>
|
|
138
|
+
```
|
|
125
139
|
|
|
126
|
-
|
|
140
|
+
### React Shoelace Wrappers
|
|
127
141
|
|
|
128
|
-
```
|
|
129
|
-
|
|
142
|
+
```js
|
|
143
|
+
import { Button } from '@hotosm/ui/components';
|
|
130
144
|
```
|
|
131
145
|
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const HomePage = ({}) => {
|
|
136
|
-
return (
|
|
137
|
-
<div className="your-css-classes">
|
|
138
|
-
<div
|
|
139
|
-
...
|
|
140
|
-
>
|
|
141
|
-
<Button disabled />
|
|
142
|
-
</div>
|
|
143
|
-
</div>
|
|
144
|
-
);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
export default HomePage;
|
|
146
|
+
```html
|
|
147
|
+
<Button disabled variant="secondary">Can't Click Me</Button>
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
-
|
|
151
|
-
> required for the React wrappers.
|
|
150
|
+
### Examples
|
|
152
151
|
|
|
153
|
-
|
|
152
|
+
You can found examples for HTML and also all common frameworks
|
|
153
|
+
(React, Svelte, Vue) under `/examples`.
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
from Shoelace in your app.
|
|
155
|
+
### Development
|
|
157
156
|
|
|
158
|
-
|
|
159
|
-
library (particularly if using the ES Modules)
|
|
157
|
+
HOT UI is developed in TypeScript, using Lit and @lit/react.
|
|
160
158
|
|
|
161
|
-
|
|
159
|
+
Primarily we want to have:
|
|
162
160
|
|
|
163
|
-
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
-
|
|
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.
|
|
169
168
|
|
|
170
|
-
|
|
171
|
-
described in the Shoelace docs.
|
|
169
|
+
### How to contribute
|
|
172
170
|
|
|
173
|
-
|
|
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!
|
|
174
175
|
|
|
175
|
-
|
|
176
|
-
the following to your `package.json`:
|
|
176
|
+
There's also a React storybook that you can use for testing:
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
178
|
+
- Run the React storybook `pnpm run dev-react`
|
|
179
|
+
|
|
180
|
+
For **styling**, check `/theme`:
|
|
181
|
+
|
|
182
|
+
- `hot-sl.css` has a Shoelace theme, re-defining styles variables
|
|
183
|
+
|
|
184
|
+
### License
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
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
|
+
`
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import "../../theme/hot-sl.css";
|
|
2
|
+
|
|
3
|
+
import "@shoelace-style/shoelace/dist/components/icon-button/icon-button.js";
|
|
4
|
+
import "@shoelace-style/shoelace/dist/components/tab-panel/tab-panel.js";
|
|
5
|
+
import "@shoelace-style/shoelace/dist/components/tab-group/tab-group.js";
|
|
6
|
+
import "@shoelace-style/shoelace/dist/components/tab/tab.js";
|
|
7
|
+
|
|
8
|
+
import { LitElement, html } from "lit";
|
|
9
|
+
import { property } from "lit/decorators.js";
|
|
10
|
+
import { headerVariants, type sizes, styles } from './header.styles.js';
|
|
11
|
+
import type { CSSResultGroup } from 'lit';
|
|
12
|
+
|
|
13
|
+
import registerBundledIcons from "../../components/icons";
|
|
14
|
+
|
|
15
|
+
registerBundledIcons();
|
|
16
|
+
|
|
17
|
+
interface MenuItem {
|
|
18
|
+
label: string;
|
|
19
|
+
clickEvent: () => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class Header extends LitElement {
|
|
23
|
+
|
|
24
|
+
static styles: CSSResultGroup = [styles];
|
|
25
|
+
|
|
26
|
+
name = "hot-header";
|
|
27
|
+
|
|
28
|
+
/** Use a text-based title in the header. */
|
|
29
|
+
@property({ type: String })
|
|
30
|
+
accessor title: string = "";
|
|
31
|
+
|
|
32
|
+
/** Display a logo on the left of the header. */
|
|
33
|
+
@property({ type: String })
|
|
34
|
+
accessor logo: string | URL = "";
|
|
35
|
+
|
|
36
|
+
/** Add a drawer icon with a click event to e.g. open a sidebar. */
|
|
37
|
+
@property({ type: Boolean })
|
|
38
|
+
accessor drawer: boolean = true;
|
|
39
|
+
|
|
40
|
+
/** Array of menu items to include as navigation tabs. */
|
|
41
|
+
@property({ type: Array })
|
|
42
|
+
accessor tabs: MenuItem[] = [];
|
|
43
|
+
|
|
44
|
+
/** Size of toolbar vertically. */
|
|
45
|
+
@property({ type: String })
|
|
46
|
+
accessor size: sizes = "small";
|
|
47
|
+
|
|
48
|
+
/** Border bottom. */
|
|
49
|
+
@property({ type: Boolean })
|
|
50
|
+
accessor borderBottom: boolean = true;
|
|
51
|
+
|
|
52
|
+
@property()
|
|
53
|
+
accessor selectedTab: number = 0;
|
|
54
|
+
|
|
55
|
+
protected render() {
|
|
56
|
+
const logoSrc =
|
|
57
|
+
typeof this.logo === "string" || this.logo instanceof URL
|
|
58
|
+
? typeof this.logo === "string"
|
|
59
|
+
? this.logo
|
|
60
|
+
: this.logo.href
|
|
61
|
+
: "";
|
|
62
|
+
|
|
63
|
+
return html`
|
|
64
|
+
<header class=${headerVariants({
|
|
65
|
+
size: this.size,
|
|
66
|
+
borderBottom: this.borderBottom
|
|
67
|
+
})}>
|
|
68
|
+
<a href="/" class="header--link">
|
|
69
|
+
${logoSrc.length > 0
|
|
70
|
+
? html`
|
|
71
|
+
<img
|
|
72
|
+
id="logo"
|
|
73
|
+
src="${this.logo}"
|
|
74
|
+
alt="Logo"
|
|
75
|
+
class="header--logo-img"
|
|
76
|
+
/>
|
|
77
|
+
`
|
|
78
|
+
: html`
|
|
79
|
+
<hot-logo
|
|
80
|
+
?iconOnly="${this.title.length > 0}"
|
|
81
|
+
>
|
|
82
|
+
</hot-logo>
|
|
83
|
+
`}
|
|
84
|
+
${this.title.length > 0
|
|
85
|
+
? html`
|
|
86
|
+
<h1 class="header--title">
|
|
87
|
+
${this.title}
|
|
88
|
+
</h1>
|
|
89
|
+
`
|
|
90
|
+
: null}
|
|
91
|
+
</a>
|
|
92
|
+
|
|
93
|
+
${/* Navigation bar for desktop, hide on mobile */ ""}
|
|
94
|
+
<nav
|
|
95
|
+
class="header--nav"
|
|
96
|
+
>
|
|
97
|
+
<sl-tab-group class="header--tab-group">
|
|
98
|
+
${this.tabs.map(
|
|
99
|
+
(item, index) => html`
|
|
100
|
+
<sl-tab
|
|
101
|
+
class="header--tab"
|
|
102
|
+
slot="nav"
|
|
103
|
+
panel="general"
|
|
104
|
+
@click=${(e: MouseEvent) => {
|
|
105
|
+
this._selectTab(e, item.clickEvent, index);
|
|
106
|
+
}}
|
|
107
|
+
?selected=${this.selectedTab === index}
|
|
108
|
+
>${item.label}</sl-tab
|
|
109
|
+
>
|
|
110
|
+
`
|
|
111
|
+
)}
|
|
112
|
+
</sl-tab-group>
|
|
113
|
+
</nav>
|
|
114
|
+
|
|
115
|
+
${/* Stacked navigation drawer for mobile */ ""}
|
|
116
|
+
${/* NOTE this should probably be in a drawer instead */ ""}
|
|
117
|
+
<nav
|
|
118
|
+
class="header--nav-mobile"
|
|
119
|
+
></nav>
|
|
120
|
+
|
|
121
|
+
<div id="right-section" class="header--right-section">
|
|
122
|
+
<sl-icon-button
|
|
123
|
+
library="bundled"
|
|
124
|
+
name="person-circle"
|
|
125
|
+
class="header--person-circle"
|
|
126
|
+
label="login"
|
|
127
|
+
@click=${(e: MouseEvent) => {
|
|
128
|
+
this._handleLogin(e);
|
|
129
|
+
}}
|
|
130
|
+
></sl-icon-button>
|
|
131
|
+
${this.drawer
|
|
132
|
+
? html`
|
|
133
|
+
<sl-icon-button
|
|
134
|
+
library="bundled"
|
|
135
|
+
class="header--drawer"
|
|
136
|
+
name="list"
|
|
137
|
+
label="drawer-open"
|
|
138
|
+
></sl-icon-button>
|
|
139
|
+
`
|
|
140
|
+
: null}
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</header>
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private _selectTab(_e: MouseEvent, clickAction: () => void, index: number) {
|
|
148
|
+
this.selectedTab = index;
|
|
149
|
+
clickAction();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private _handleLogin(_e: MouseEvent) {
|
|
153
|
+
this.dispatchEvent(new Event("login"));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export default Header;
|
|
158
|
+
|
|
159
|
+
// Define web component
|
|
160
|
+
customElements.define("hot-header", Header);
|
|
@@ -2,71 +2,83 @@
|
|
|
2
2
|
// Bundled icons hardcoded into hotosm/ui.
|
|
3
3
|
// They are a subset of used Shoelace icons (which use Bootstrap icons)
|
|
4
4
|
//
|
|
5
|
+
|
|
6
|
+
import type { IconLibraryResolver } from "@shoelace-style/shoelace/dist/components/icon/library";
|
|
5
7
|
import { registerIconLibrary } from '@shoelace-style/shoelace/dist/utilities/icon-library.js';
|
|
8
|
+
|
|
6
9
|
const icons = {
|
|
7
|
-
|
|
10
|
+
list: `
|
|
8
11
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-list" viewBox="0 0 16 16">
|
|
9
12
|
<path fill-rule="evenodd" d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"/>
|
|
10
13
|
</svg>
|
|
11
14
|
`,
|
|
12
|
-
|
|
15
|
+
'info-circle': `
|
|
13
16
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-circle" viewBox="0 0 16 16">
|
|
14
17
|
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
|
|
15
18
|
<path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/>
|
|
16
19
|
</svg>
|
|
17
20
|
`,
|
|
18
|
-
|
|
21
|
+
'arrow-counterclockwise': `
|
|
19
22
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-counterclockwise" viewBox="0 0 16 16">
|
|
20
23
|
<path fill-rule="evenodd" d="M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2v1z"/>
|
|
21
24
|
<path d="M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466z"/>
|
|
22
25
|
</svg>
|
|
23
26
|
`,
|
|
24
|
-
|
|
27
|
+
'arrow-clockwise': `
|
|
25
28
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-clockwise" viewBox="0 0 16 16">
|
|
26
29
|
<path fill-rule="evenodd" d="M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2v1z"/>
|
|
27
30
|
<path d="M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 4.658A.25.25 0 0 1 8 4.466z"/>
|
|
28
31
|
</svg>
|
|
29
32
|
`,
|
|
30
|
-
|
|
33
|
+
'type-bold': `
|
|
31
34
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-bold" viewBox="0 0 16 16">
|
|
32
35
|
<path d="M8.21 13c2.106 0 3.412-1.087 3.412-2.823 0-1.306-.984-2.283-2.324-2.386v-.055a2.176 2.176 0 0 0 1.852-2.14c0-1.51-1.162-2.46-3.014-2.46H3.843V13H8.21zM5.908 4.674h1.696c.963 0 1.517.451 1.517 1.244 0 .834-.629 1.32-1.73 1.32H5.908V4.673zm0 6.788V8.598h1.73c1.217 0 1.88.492 1.88 1.415 0 .943-.643 1.449-1.832 1.449H5.907z"/>
|
|
33
36
|
</svg>
|
|
34
37
|
`,
|
|
35
|
-
|
|
38
|
+
'type-italic': `
|
|
36
39
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-italic" viewBox="0 0 16 16">
|
|
37
40
|
<path d="M7.991 11.674 9.53 4.455c.123-.595.246-.71 1.347-.807l.11-.52H7.211l-.11.52c1.06.096 1.128.212 1.005.807L6.57 11.674c-.123.595-.246.71-1.346.806l-.11.52h3.774l.11-.52c-1.06-.095-1.129-.211-1.006-.806z"/>
|
|
38
41
|
</svg>
|
|
39
42
|
`,
|
|
40
|
-
|
|
43
|
+
'type-underline': `
|
|
41
44
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-underline" viewBox="0 0 16 16">
|
|
42
45
|
<path d="M5.313 3.136h-1.23V9.54c0 2.105 1.47 3.623 3.917 3.623s3.917-1.518 3.917-3.623V3.136h-1.23v6.323c0 1.49-.978 2.57-2.687 2.57-1.709 0-2.687-1.08-2.687-2.57V3.136zM12.5 15h-9v-1h9v1z"/>
|
|
43
46
|
</svg>
|
|
44
47
|
`,
|
|
45
|
-
|
|
48
|
+
'justify-left': `
|
|
46
49
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-justify-left" viewBox="0 0 16 16">
|
|
47
50
|
<path fill-rule="evenodd" d="M2 12.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/>
|
|
48
51
|
</svg>
|
|
49
52
|
`,
|
|
50
|
-
|
|
53
|
+
justify: `
|
|
51
54
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-justify" viewBox="0 0 16 16">
|
|
52
55
|
<path fill-rule="evenodd" d="M2 12.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/>
|
|
53
56
|
</svg>
|
|
54
57
|
`,
|
|
55
|
-
|
|
58
|
+
'justify-right': `
|
|
56
59
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-justify-right" viewBox="0 0 16 16">
|
|
57
60
|
<path fill-rule="evenodd" d="M6 12.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-4-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/>
|
|
58
61
|
</svg>
|
|
59
62
|
`,
|
|
63
|
+
'person-circle': `
|
|
64
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person-circle" viewBox="0 0 16 16">
|
|
65
|
+
<path d="M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"/>
|
|
66
|
+
<path fill-rule="evenodd" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z"/>
|
|
67
|
+
</svg>
|
|
68
|
+
`
|
|
60
69
|
};
|
|
61
|
-
|
|
70
|
+
|
|
71
|
+
const libraryResolver: IconLibraryResolver = (name: string) => {
|
|
62
72
|
if (name in icons) {
|
|
63
|
-
return `data:image/svg+xml,${encodeURIComponent(icons[name])}`;
|
|
73
|
+
return `data:image/svg+xml,${encodeURIComponent(icons[name as keyof typeof icons])}`;
|
|
64
74
|
}
|
|
65
75
|
return '';
|
|
66
|
-
}
|
|
76
|
+
}
|
|
77
|
+
|
|
67
78
|
function registerBundledIcons() {
|
|
68
79
|
registerIconLibrary('bundled', {
|
|
69
80
|
resolver: libraryResolver,
|
|
70
81
|
});
|
|
71
82
|
}
|
|
83
|
+
|
|
72
84
|
export default registerBundledIcons;
|