@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
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export { default as Header } from './Header';
|
|
2
|
+
export { default as Toolbar } from './Toolbar';
|
|
3
|
+
export { default as Tracking } from './Tracking';
|
|
4
|
+
export { default as Logo } from './Logo';
|
|
5
|
+
|
|
6
|
+
export { default as Alert } from '@shoelace-style/shoelace/dist/react/alert/index.js';
|
|
7
|
+
export { default as AnimatedImage } from '@shoelace-style/shoelace/dist/react/animated-image/index.js';
|
|
8
|
+
export { default as Animation } from '@shoelace-style/shoelace/dist/react/animation/index.js';
|
|
9
|
+
export { default as Avatar } from '@shoelace-style/shoelace/dist/react/avatar/index.js';
|
|
10
|
+
export { default as Badge } from '@shoelace-style/shoelace/dist/react/badge/index.js';
|
|
11
|
+
export { default as Breadcrumb } from '@shoelace-style/shoelace/dist/react/breadcrumb/index.js';
|
|
12
|
+
export { default as BreadcrumbItem } from '@shoelace-style/shoelace/dist/react/breadcrumb-item/index.js';
|
|
13
|
+
export { default as Button } from '@shoelace-style/shoelace/dist/react/button/index.js';
|
|
14
|
+
export { default as ButtonGroup } from '@shoelace-style/shoelace/dist/react/button-group/index.js';
|
|
15
|
+
export { default as Card } from '@shoelace-style/shoelace/dist/react/card/index.js';
|
|
16
|
+
export { default as Carousel } from '@shoelace-style/shoelace/dist/react/carousel/index.js';
|
|
17
|
+
export { default as CarouselItem } from '@shoelace-style/shoelace/dist/react/carousel-item/index.js';
|
|
18
|
+
export { default as Checkbox } from '@shoelace-style/shoelace/dist/react/checkbox/index.js';
|
|
19
|
+
export { default as ColorPicker } from '@shoelace-style/shoelace/dist/react/color-picker/index.js';
|
|
20
|
+
export { default as CopyButton } from '@shoelace-style/shoelace/dist/react/copy-button/index.js';
|
|
21
|
+
export { default as Details } from '@shoelace-style/shoelace/dist/react/details/index.js';
|
|
22
|
+
export { default as Dialog } from '@shoelace-style/shoelace/dist/react/dialog/index.js';
|
|
23
|
+
export { default as Divider } from '@shoelace-style/shoelace/dist/react/divider/index.js';
|
|
24
|
+
export { default as Drawer } from '@shoelace-style/shoelace/dist/react/drawer/index.js';
|
|
25
|
+
export { default as Dropdown } from '@shoelace-style/shoelace/dist/react/dropdown/index.js';
|
|
26
|
+
export { default as FormatBytes } from '@shoelace-style/shoelace/dist/react/format-bytes/index.js';
|
|
27
|
+
export { default as FormatDate } from '@shoelace-style/shoelace/dist/react/format-date/index.js';
|
|
28
|
+
export { default as FormatNumber } from '@shoelace-style/shoelace/dist/react/format-number/index.js';
|
|
29
|
+
export { default as Icon } from '@shoelace-style/shoelace/dist/react/icon/index.js';
|
|
30
|
+
export { default as IconButton } from '@shoelace-style/shoelace/dist/react/icon-button/index.js';
|
|
31
|
+
export { default as ImageComparer } from '@shoelace-style/shoelace/dist/react/image-comparer/index.js';
|
|
32
|
+
export { default as Include } from '@shoelace-style/shoelace/dist/react/include/index.js';
|
|
33
|
+
export { default as Input } from '@shoelace-style/shoelace/dist/react/input/index.js';
|
|
34
|
+
export { default as Menu } from '@shoelace-style/shoelace/dist/react/menu/index.js';
|
|
35
|
+
export { default as MenuItem } from '@shoelace-style/shoelace/dist/react/menu-item/index.js';
|
|
36
|
+
export { default as MenuLabel } from '@shoelace-style/shoelace/dist/react/menu-label/index.js';
|
|
37
|
+
export { default as MutationObserver } from '@shoelace-style/shoelace/dist/react/mutation-observer/index.js';
|
|
38
|
+
export { default as Option } from '@shoelace-style/shoelace/dist/react/option/index.js';
|
|
39
|
+
export { default as Popup } from '@shoelace-style/shoelace/dist/react/popup/index.js';
|
|
40
|
+
export { default as ProgressBar } from '@shoelace-style/shoelace/dist/react/progress-bar/index.js';
|
|
41
|
+
export { default as ProgressRing } from '@shoelace-style/shoelace/dist/react/progress-ring/index.js';
|
|
42
|
+
export { default as QRCode } from '@shoelace-style/shoelace/dist/react/qr-code/index.js';
|
|
43
|
+
export { default as Radio } from '@shoelace-style/shoelace/dist/react/radio/index.js';
|
|
44
|
+
export { default as RadioButton } from '@shoelace-style/shoelace/dist/react/radio-button/index.js';
|
|
45
|
+
export { default as RadioGroup } from '@shoelace-style/shoelace/dist/react/radio-group/index.js';
|
|
46
|
+
export { default as Range } from '@shoelace-style/shoelace/dist/react/range/index.js';
|
|
47
|
+
export { default as Rating } from '@shoelace-style/shoelace/dist/react/rating/index.js';
|
|
48
|
+
export { default as RelativeTime } from '@shoelace-style/shoelace/dist/react/relative-time/index.js';
|
|
49
|
+
export { default as ResizeObserver } from '@shoelace-style/shoelace/dist/react/resize-observer/index.js';
|
|
50
|
+
export { default as Select } from '@shoelace-style/shoelace/dist/react/select/index.js';
|
|
51
|
+
export { default as Skeleton } from '@shoelace-style/shoelace/dist/react/skeleton/index.js';
|
|
52
|
+
export { default as Spinner } from '@shoelace-style/shoelace/dist/react/spinner/index.js';
|
|
53
|
+
export { default as SplitPanel } from '@shoelace-style/shoelace/dist/react/split-panel/index.js';
|
|
54
|
+
export { default as Switch } from '@shoelace-style/shoelace/dist/react/switch/index.js';
|
|
55
|
+
export { default as Tab } from '@shoelace-style/shoelace/dist/react/tab/index.js';
|
|
56
|
+
export { default as TabGroup } from '@shoelace-style/shoelace/dist/react/tab-group/index.js';
|
|
57
|
+
export { default as TabPanel } from '@shoelace-style/shoelace/dist/react/tab-panel/index.js';
|
|
58
|
+
export { default as Tag } from '@shoelace-style/shoelace/dist/react/tag/index.js';
|
|
59
|
+
export { default as Textarea } from '@shoelace-style/shoelace/dist/react/textarea/index.js';
|
|
60
|
+
export { default as Tooltip } from '@shoelace-style/shoelace/dist/react/tooltip/index.js';
|
|
61
|
+
export { default as Tree } from '@shoelace-style/shoelace/dist/react/tree/index.js';
|
|
62
|
+
export { default as TreeItem } from '@shoelace-style/shoelace/dist/react/tree-item/index.js';
|
|
63
|
+
export { default as VisuallyHidden } from '@shoelace-style/shoelace/dist/react/visually-hidden/index.js';
|
|
@@ -1,80 +1,123 @@
|
|
|
1
|
-
import "../../theme/sl
|
|
1
|
+
import "../../theme/hot-sl.css";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import "@shoelace-style/shoelace/dist/components/button/button.js";
|
|
4
|
+
import "@shoelace-style/shoelace/dist/components/button-group/button-group.js";
|
|
5
|
+
import "@shoelace-style/shoelace/dist/components/icon/icon.js";
|
|
6
|
+
import "@shoelace-style/shoelace/dist/components/tooltip/tooltip.js";
|
|
7
7
|
|
|
8
|
-
import { LitElement,
|
|
8
|
+
import { LitElement, html } from "lit";
|
|
9
9
|
import { property } from "lit/decorators.js";
|
|
10
|
+
import styles from './toolbar.styles.js';
|
|
11
|
+
import type { CSSResultGroup } from 'lit';
|
|
10
12
|
|
|
11
|
-
import registerBundledIcons from
|
|
13
|
+
import registerBundledIcons from "../../components/icons";
|
|
12
14
|
|
|
13
15
|
registerBundledIcons();
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
export class Toolbar extends LitElement {
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
// "some-css-var",
|
|
19
|
-
// {
|
|
20
|
-
// variants: {
|
|
21
|
-
// someProperty: {
|
|
22
|
-
// true: "some-css-var",
|
|
23
|
-
// false: "some-css-var",
|
|
24
|
-
// },
|
|
25
|
-
// },
|
|
26
|
-
// },
|
|
27
|
-
// );
|
|
19
|
+
static styles: CSSResultGroup = [styles];
|
|
28
20
|
|
|
29
|
-
|
|
30
|
-
@property() name = "hot-toolbar";
|
|
21
|
+
name = "hot-toolbar";
|
|
31
22
|
|
|
32
23
|
/** Change the position of the tooltips relative to buttons. */
|
|
33
|
-
@property({ type: String, attribute: "tooltip-position" })
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
@unocss-placeholder;
|
|
38
|
-
`,
|
|
39
|
-
// unsafeCSS(reset),
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
// class=${toolbarStyle({
|
|
43
|
-
// someProperty: this.someProperty,
|
|
44
|
-
// })}
|
|
24
|
+
@property({ type: String, attribute: "tooltip-position" })
|
|
25
|
+
accessor tooltipPosition =
|
|
26
|
+
"top";
|
|
27
|
+
|
|
45
28
|
protected render() {
|
|
46
29
|
return html`
|
|
47
|
-
<div class="
|
|
48
|
-
${this.renderButtonGroup(
|
|
49
|
-
{
|
|
50
|
-
|
|
30
|
+
<div class="toolbar">
|
|
31
|
+
${this.renderButtonGroup("History", [
|
|
32
|
+
{
|
|
33
|
+
content: "Undo",
|
|
34
|
+
icon: "arrow-counterclockwise",
|
|
35
|
+
label: "Undo",
|
|
36
|
+
action: this.undo,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
content: "Redo",
|
|
40
|
+
icon: "arrow-clockwise",
|
|
41
|
+
label: "Redo",
|
|
42
|
+
action: this.redo,
|
|
43
|
+
},
|
|
51
44
|
])}
|
|
52
|
-
${this.renderButtonGroup(
|
|
53
|
-
{
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
${this.renderButtonGroup("Formatting", [
|
|
46
|
+
{
|
|
47
|
+
content: "Bold",
|
|
48
|
+
icon: "type-bold",
|
|
49
|
+
label: "Bold",
|
|
50
|
+
action: this.bold,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
content: "Italic",
|
|
54
|
+
icon: "type-italic",
|
|
55
|
+
label: "Italic",
|
|
56
|
+
action: this.italic,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
content: "Underline",
|
|
60
|
+
icon: "type-underline",
|
|
61
|
+
label: "Underline",
|
|
62
|
+
action: this.underline,
|
|
63
|
+
},
|
|
56
64
|
])}
|
|
57
|
-
${this.renderButtonGroup(
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
${this.renderButtonGroup("Alignment", [
|
|
66
|
+
{
|
|
67
|
+
content: "Align Left",
|
|
68
|
+
icon: "justify-left",
|
|
69
|
+
label: "Align Left",
|
|
70
|
+
action: this.alignLeft,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
content: "Align Center",
|
|
74
|
+
icon: "justify",
|
|
75
|
+
label: "Align Center",
|
|
76
|
+
action: this.alignCenter,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
content: "Align Right",
|
|
80
|
+
icon: "justify-right",
|
|
81
|
+
label: "Align Right",
|
|
82
|
+
action: this.alignRight,
|
|
83
|
+
},
|
|
61
84
|
])}
|
|
62
85
|
</div>
|
|
63
86
|
`;
|
|
64
87
|
}
|
|
65
88
|
|
|
66
|
-
private renderButtonGroup(
|
|
89
|
+
private renderButtonGroup(
|
|
90
|
+
label: string,
|
|
91
|
+
buttons: Array<{
|
|
92
|
+
content: string;
|
|
93
|
+
icon: string;
|
|
94
|
+
label: string;
|
|
95
|
+
action?: (e: MouseEvent) => void;
|
|
96
|
+
}>
|
|
97
|
+
) {
|
|
67
98
|
return html`
|
|
68
99
|
<sl-button-group label=${label}>
|
|
69
|
-
${buttons.map(button => this.renderButton(button))}
|
|
100
|
+
${buttons.map((button) => this.renderButton(button))}
|
|
70
101
|
</sl-button-group>
|
|
71
102
|
`;
|
|
72
103
|
}
|
|
73
104
|
|
|
74
|
-
private renderButton({
|
|
105
|
+
private renderButton({
|
|
106
|
+
content,
|
|
107
|
+
icon,
|
|
108
|
+
label,
|
|
109
|
+
action,
|
|
110
|
+
}: {
|
|
111
|
+
content: string;
|
|
112
|
+
icon: string;
|
|
113
|
+
label: string;
|
|
114
|
+
action?: (e: MouseEvent) => void;
|
|
115
|
+
}) {
|
|
75
116
|
return html`
|
|
76
117
|
<sl-tooltip content=${content} placement="${this.tooltipPosition}">
|
|
77
|
-
<sl-button @click=${action ?? (() => {})}
|
|
118
|
+
<sl-button @click=${action ?? (() => {})}
|
|
119
|
+
><sl-icon library="bundled" name=${icon} label=${label}></sl-icon
|
|
120
|
+
></sl-button>
|
|
78
121
|
</sl-tooltip>
|
|
79
122
|
`;
|
|
80
123
|
}
|
|
@@ -84,42 +127,42 @@ export class Toolbar extends LitElement {
|
|
|
84
127
|
// stop propagation of the original event
|
|
85
128
|
e.stopPropagation();
|
|
86
129
|
this.dispatchEvent(new Event("undo"));
|
|
87
|
-
}
|
|
130
|
+
};
|
|
88
131
|
|
|
89
132
|
private readonly redo = (e: MouseEvent) => {
|
|
90
133
|
e.stopPropagation();
|
|
91
134
|
this.dispatchEvent(new Event("redo"));
|
|
92
|
-
}
|
|
135
|
+
};
|
|
93
136
|
|
|
94
137
|
private readonly bold = (e: MouseEvent) => {
|
|
95
138
|
e.stopPropagation();
|
|
96
139
|
this.dispatchEvent(new Event("bold"));
|
|
97
|
-
}
|
|
140
|
+
};
|
|
98
141
|
|
|
99
142
|
private readonly italic = (e: MouseEvent) => {
|
|
100
143
|
e.stopPropagation();
|
|
101
144
|
this.dispatchEvent(new Event("italic"));
|
|
102
|
-
}
|
|
145
|
+
};
|
|
103
146
|
|
|
104
147
|
private readonly underline = (e: MouseEvent) => {
|
|
105
148
|
e.stopPropagation();
|
|
106
149
|
this.dispatchEvent(new Event("underline"));
|
|
107
|
-
}
|
|
150
|
+
};
|
|
108
151
|
|
|
109
152
|
private readonly alignLeft = (e: MouseEvent) => {
|
|
110
153
|
e.stopPropagation();
|
|
111
154
|
this.dispatchEvent(new Event("leftalign"));
|
|
112
|
-
}
|
|
155
|
+
};
|
|
113
156
|
|
|
114
157
|
private readonly alignCenter = (e: MouseEvent) => {
|
|
115
158
|
e.stopPropagation();
|
|
116
159
|
this.dispatchEvent(new Event("centeralign"));
|
|
117
|
-
}
|
|
160
|
+
};
|
|
118
161
|
|
|
119
162
|
private readonly alignRight = (e: MouseEvent) => {
|
|
120
163
|
e.stopPropagation();
|
|
121
164
|
this.dispatchEvent(new Event("rightalign"));
|
|
122
|
-
}
|
|
165
|
+
};
|
|
123
166
|
}
|
|
124
167
|
|
|
125
168
|
export default Toolbar;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export default css`
|
|
4
|
+
.tracking {
|
|
5
|
+
position: absolute;
|
|
6
|
+
bottom: 20px;
|
|
7
|
+
left: 50%;
|
|
8
|
+
transform: translateX(-50%);
|
|
9
|
+
z-index: 1000;
|
|
10
|
+
width: 80vw;
|
|
11
|
+
text-align: center;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.tracking--header {
|
|
15
|
+
font-weight: var(--sl-font-weight-bold);
|
|
16
|
+
font-size: var(--sl-font-size-large);
|
|
17
|
+
text-align: center;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.tracking--link {
|
|
21
|
+
color: var(--sl-color-primary-700);
|
|
22
|
+
}
|
|
23
|
+
`
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import "../../theme/sl
|
|
1
|
+
import "../../theme/hot-sl.css";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import "@shoelace-style/shoelace/dist/components/alert/alert.js";
|
|
4
4
|
|
|
5
|
-
import { LitElement,
|
|
5
|
+
import { LitElement, html } from "lit";
|
|
6
6
|
import { property, state } from "lit/decorators.js";
|
|
7
|
+
import styles from './tracking.styles.js';
|
|
8
|
+
import type { CSSResultGroup } from 'lit';
|
|
7
9
|
|
|
8
|
-
import registerBundledIcons from
|
|
10
|
+
import registerBundledIcons from "../../components/icons";
|
|
9
11
|
|
|
10
12
|
registerBundledIcons();
|
|
11
13
|
|
|
@@ -16,69 +18,62 @@ declare global {
|
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export class Tracking extends LitElement {
|
|
19
|
-
|
|
21
|
+
|
|
22
|
+
static styles: CSSResultGroup = [styles];
|
|
23
|
+
|
|
24
|
+
name = "hot-tracking";
|
|
20
25
|
|
|
21
26
|
/** The Matomo site id for tracking. */
|
|
22
|
-
@property({ type: String, attribute: "site-id" })
|
|
27
|
+
@property({ type: String, attribute: "site-id" })
|
|
28
|
+
accessor siteId: string = "";
|
|
23
29
|
|
|
24
30
|
/** The domains to apply tracking. */
|
|
25
|
-
@property({ type: String })
|
|
31
|
+
@property({ type: String })
|
|
32
|
+
accessor domain: string = "";
|
|
26
33
|
|
|
27
34
|
/** Force display the banner. */
|
|
28
|
-
@property({ type: Boolean })
|
|
29
|
-
|
|
30
|
-
@state() isOpen: boolean = true;
|
|
35
|
+
@property({ type: Boolean })
|
|
36
|
+
accessor force: boolean = false;
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@unocss-placeholder;
|
|
35
|
-
`,
|
|
36
|
-
|
|
37
|
-
// Temp styles until UnoCSS setup
|
|
38
|
-
css`
|
|
39
|
-
#tracking-header {
|
|
40
|
-
font-weight: var(--sl-font-weight-bold);
|
|
41
|
-
font-size: var(--sl-font-size-large);
|
|
42
|
-
text-align: center;
|
|
43
|
-
}
|
|
44
|
-
sl-alert::part(base) {
|
|
45
|
-
position: absolute;
|
|
46
|
-
bottom: 20px;
|
|
47
|
-
left: 50%;
|
|
48
|
-
transform: translateX(-50%);
|
|
49
|
-
z-index: 1000;
|
|
50
|
-
width: 80vw;
|
|
51
|
-
text-align: center;
|
|
52
|
-
}
|
|
53
|
-
`
|
|
54
|
-
];
|
|
38
|
+
@property({ type: Boolean })
|
|
39
|
+
accessor isOpen: boolean = true;
|
|
55
40
|
|
|
56
41
|
protected render() {
|
|
57
|
-
return html`<sl-alert
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
42
|
+
return html`<sl-alert class="tracking" variant="danger" ?open=${this.isOpen}>
|
|
43
|
+
<sl-icon
|
|
44
|
+
id="hot-red-text"
|
|
45
|
+
library="bundled"
|
|
46
|
+
slot="icon"
|
|
47
|
+
name="info-circle"
|
|
48
|
+
></sl-icon>
|
|
49
|
+
|
|
50
|
+
<p id="tracking-header" class="tracking--header">About the information we collect</p>
|
|
51
|
+
|
|
52
|
+
<p>
|
|
53
|
+
We use cookies and similar technologies to recognize and analyze your
|
|
54
|
+
visits, and measure traffic usage and activity. You can learn about how
|
|
55
|
+
we use the data about your visit or information you provide reading our
|
|
56
|
+
<a
|
|
57
|
+
class="tracking--link"
|
|
58
|
+
href="https://www.hotosm.org/privacy"
|
|
59
|
+
target="_blank"
|
|
60
|
+
rel="noopener noreferrer"
|
|
61
|
+
>privacy policy</a
|
|
62
|
+
>. By clicking "I Agree", you consent to the use of cookies.
|
|
63
|
+
</p>
|
|
64
|
+
|
|
65
|
+
<sl-button
|
|
66
|
+
@click=${(e: MouseEvent) => {
|
|
67
|
+
this._setAgree(e);
|
|
68
|
+
}}
|
|
69
|
+
>I Agree</sl-button
|
|
70
|
+
>
|
|
71
|
+
<sl-button
|
|
72
|
+
@click=${(e: MouseEvent) => {
|
|
73
|
+
this._setDisagree(e);
|
|
74
|
+
}}
|
|
75
|
+
>I Do Not Agree</sl-button
|
|
76
|
+
>
|
|
82
77
|
</sl-alert>`;
|
|
83
78
|
}
|
|
84
79
|
|
|
@@ -87,10 +82,10 @@ export class Tracking extends LitElement {
|
|
|
87
82
|
const _paq = (window._paq = window._paq || []);
|
|
88
83
|
if (_paq.length === 0) return;
|
|
89
84
|
|
|
90
|
-
_paq.push([
|
|
85
|
+
_paq.push(["rememberConsentGiven"]);
|
|
91
86
|
this.isOpen = false;
|
|
92
|
-
localStorage.setItem(`${this.siteId}-matomo-agree`,
|
|
93
|
-
this.dispatchEvent(new Event(
|
|
87
|
+
localStorage.setItem(`${this.siteId}-matomo-agree`, "true");
|
|
88
|
+
this.dispatchEvent(new Event("agree", { bubbles: true, composed: true }));
|
|
94
89
|
}
|
|
95
90
|
|
|
96
91
|
private _setDisagree(_e: MouseEvent) {
|
|
@@ -98,10 +93,12 @@ export class Tracking extends LitElement {
|
|
|
98
93
|
const _paq = (window._paq = window._paq || []);
|
|
99
94
|
if (_paq.length === 0) return;
|
|
100
95
|
|
|
101
|
-
_paq.push([
|
|
96
|
+
_paq.push(["forgetConsentGiven"]);
|
|
102
97
|
this.isOpen = false;
|
|
103
|
-
localStorage.setItem(`${this.siteId}-matomo-agree`,
|
|
104
|
-
this.dispatchEvent(
|
|
98
|
+
localStorage.setItem(`${this.siteId}-matomo-agree`, "false");
|
|
99
|
+
this.dispatchEvent(
|
|
100
|
+
new Event("disagree", { bubbles: true, composed: true })
|
|
101
|
+
);
|
|
105
102
|
}
|
|
106
103
|
|
|
107
104
|
connectedCallback() {
|
|
@@ -109,59 +106,66 @@ export class Tracking extends LitElement {
|
|
|
109
106
|
|
|
110
107
|
// Close and halt execution if wrong domain
|
|
111
108
|
if (!this.force && window.location.hostname !== this.domain) {
|
|
112
|
-
console.warn(
|
|
109
|
+
console.warn(
|
|
110
|
+
`Matomo init failed. ${window.location.hostname} does not match ${this.domain}.`
|
|
111
|
+
);
|
|
113
112
|
this.isOpen = false;
|
|
114
113
|
return;
|
|
115
114
|
}
|
|
116
|
-
|
|
115
|
+
|
|
117
116
|
const matomoTrackingId = this.siteId;
|
|
118
117
|
|
|
119
118
|
// Close and halt execution if siteId or domain not set
|
|
120
|
-
if (
|
|
121
|
-
|
|
119
|
+
if (
|
|
120
|
+
!this.force &&
|
|
121
|
+
(matomoTrackingId.length === 0 || this.domain.length === 0)
|
|
122
|
+
) {
|
|
123
|
+
console.warn("Matomo init failed. No site id or domains provided.");
|
|
122
124
|
this.isOpen = false;
|
|
123
125
|
return;
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
// Close and halt execution if already disagreed
|
|
127
129
|
const consent = localStorage.getItem(`${this.siteId}-matomo-agree`);
|
|
128
|
-
if (consent ===
|
|
130
|
+
if (consent === "false") {
|
|
129
131
|
this.isOpen = false;
|
|
130
132
|
return;
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
// Close prompt only if already agreed, continue
|
|
134
|
-
if (consent ===
|
|
136
|
+
if (consent === "true") {
|
|
135
137
|
this.isOpen = false;
|
|
136
138
|
}
|
|
137
139
|
|
|
138
|
-
console.log(
|
|
140
|
+
console.log(
|
|
141
|
+
`Setting Matomo tracking for site=${matomoTrackingId} domain=${this.domain}`
|
|
142
|
+
);
|
|
139
143
|
|
|
140
144
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
141
145
|
const _paq = (window._paq = window._paq || []);
|
|
142
|
-
|
|
146
|
+
|
|
143
147
|
// tracker methods like "setCustomDimension" should be called before "trackPageView"
|
|
144
|
-
_paq.push([
|
|
145
|
-
_paq.push([
|
|
146
|
-
_paq.push([
|
|
147
|
-
_paq.push([
|
|
148
|
-
_paq.push([
|
|
149
|
-
|
|
148
|
+
_paq.push(["requireConsent"]);
|
|
149
|
+
_paq.push(["setDomains", [this.domain]]);
|
|
150
|
+
_paq.push(["trackPageView"]);
|
|
151
|
+
_paq.push(["enableLinkTracking"]); // Tracks downloads
|
|
152
|
+
_paq.push(["trackVisibleContentImpressions"]); // Tracks content
|
|
153
|
+
|
|
150
154
|
(function () {
|
|
151
|
-
const u =
|
|
152
|
-
_paq.push([
|
|
153
|
-
_paq.push([
|
|
155
|
+
const u = "//matomo.hotosm.org/";
|
|
156
|
+
_paq.push(["setTrackerUrl", u + "matomo.php"]);
|
|
157
|
+
_paq.push(["setSiteId", matomoTrackingId]);
|
|
154
158
|
|
|
155
159
|
const d = document;
|
|
156
|
-
const g = d.createElement(
|
|
157
|
-
const s = d.getElementsByTagName(
|
|
160
|
+
const g = d.createElement("script");
|
|
161
|
+
const s = d.getElementsByTagName("script")[0];
|
|
158
162
|
|
|
159
163
|
if (s?.parentNode != null) {
|
|
160
164
|
g.async = true;
|
|
161
|
-
g.src = u +
|
|
165
|
+
g.src = u + "matomo.js";
|
|
162
166
|
s.parentNode.insertBefore(g, s);
|
|
163
167
|
} else {
|
|
164
|
-
console.warn(
|
|
168
|
+
console.warn("Script insertion failed. Parent node is null.");
|
|
165
169
|
}
|
|
166
170
|
})();
|
|
167
171
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LitElement, CSSResultGroup } from 'lit';
|
|
2
|
+
import { sizes } from './header.styles.js';
|
|
3
|
+
|
|
4
|
+
interface MenuItem {
|
|
5
|
+
label: string;
|
|
6
|
+
clickEvent: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare class Header extends LitElement {
|
|
9
|
+
static styles: CSSResultGroup;
|
|
10
|
+
name: string;
|
|
11
|
+
/** Use a text-based title in the header. */
|
|
12
|
+
accessor title: string;
|
|
13
|
+
/** Display a logo on the left of the header. */
|
|
14
|
+
accessor logo: string | URL;
|
|
15
|
+
/** Add a drawer icon with a click event to e.g. open a sidebar. */
|
|
16
|
+
accessor drawer: boolean;
|
|
17
|
+
/** Array of menu items to include as navigation tabs. */
|
|
18
|
+
accessor tabs: MenuItem[];
|
|
19
|
+
/** Size of toolbar vertically. */
|
|
20
|
+
accessor size: sizes;
|
|
21
|
+
/** Border bottom. */
|
|
22
|
+
accessor borderBottom: boolean;
|
|
23
|
+
accessor selectedTab: number;
|
|
24
|
+
protected render(): import('lit').TemplateResult<1>;
|
|
25
|
+
private _selectTab;
|
|
26
|
+
private _handleLogin;
|
|
27
|
+
}
|
|
28
|
+
export default Header;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const headerVariants: (props?: ({
|
|
2
|
+
size?: "small" | "medium" | "large" | null | undefined;
|
|
3
|
+
borderBottom?: boolean | null | undefined;
|
|
4
|
+
} & import('class-variance-authority/dist/types').ClassProp) | undefined) => string;
|
|
5
|
+
export type sizes = "small" | "medium" | "large";
|
|
6
|
+
export declare const styles: import('lit').CSSResult;
|