@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.
Files changed (58) hide show
  1. package/README.md +105 -105
  2. package/components/header/header.styles.ts +103 -0
  3. package/components/header/header.ts +160 -0
  4. package/components/{icons.js → icons.ts} +25 -13
  5. package/components/index.ts +265 -0
  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/{react/Header.js → components/react/Logo.ts} +9 -5
  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 +171 -0
  15. package/components/tracking/tracking.styles.ts +23 -0
  16. package/components/tracking/tracking.ts +177 -0
  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/index.d.ts +62 -0
  23. package/dist/components/toolbar/toolbar.d.ts +20 -0
  24. package/dist/components/toolbar/toolbar.styles.d.ts +2 -0
  25. package/dist/components/tracking/tracking.d.ts +23 -0
  26. package/dist/components/tracking/tracking.styles.d.ts +2 -0
  27. package/dist/hotosm-ui.js +18450 -0
  28. package/dist/style.css +1 -0
  29. package/package.json +29 -35
  30. package/theme/hot-sl.css +194 -0
  31. package/theme/hot.css +191 -121
  32. package/theme/logo/hot-logo-icon.svg +1 -0
  33. package/theme/logo/hot-logo-png.png +0 -0
  34. package/theme/logo/hot-logo-text.svg +1 -0
  35. package/components/Button.d.ts +0 -16
  36. package/components/Button.js +0 -75
  37. package/components/Header.d.ts +0 -16
  38. package/components/Header.js +0 -152
  39. package/components/Toolbar.d.ts +0 -26
  40. package/components/Toolbar.js +0 -123
  41. package/components/Tracking.d.ts +0 -26
  42. package/components/Tracking.js +0 -167
  43. package/components/index.d.ts +0 -4
  44. package/components/index.js +0 -6
  45. package/dist/assets/logo-CqlPtOQW.png +0 -0
  46. package/dist/components.js +0 -121
  47. package/dist/styles.css +0 -1092
  48. package/react/Button.js +0 -14
  49. package/react/Toolbar.js +0 -21
  50. package/react/Tracking.js +0 -15
  51. package/react/index.d.ts +0 -4
  52. package/react/index.js +0 -6
  53. package/theme/logo.png +0 -0
  54. /package/{components → dist/components}/icons.d.ts +0 -0
  55. /package/{react → dist/components/react}/Header.d.ts +0 -0
  56. /package/{react/Button.d.ts → dist/components/react/Logo.d.ts} +0 -0
  57. /package/{react → dist/components/react}/Toolbar.d.ts +0 -0
  58. /package/{react → dist/components/react}/Tracking.d.ts +0 -0
@@ -1,26 +0,0 @@
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/button/button.js';
5
- import '@shoelace-style/shoelace/dist/components/button-group/button-group.js';
6
- import '@shoelace-style/shoelace/dist/components/icon/icon.js';
7
- import '@shoelace-style/shoelace/dist/components/tooltip/tooltip.js';
8
- import { LitElement } from "lit";
9
- export declare class Toolbar extends LitElement {
10
- name: string;
11
- /** Change the position of the tooltips relative to buttons. */
12
- tooltipPosition: string;
13
- static styles: import("lit").CSSResult[];
14
- protected render(): import("lit").TemplateResult<1>;
15
- private renderButtonGroup;
16
- private renderButton;
17
- private readonly undo;
18
- private readonly redo;
19
- private readonly bold;
20
- private readonly italic;
21
- private readonly underline;
22
- private readonly alignLeft;
23
- private readonly alignCenter;
24
- private readonly alignRight;
25
- }
26
- export default Toolbar;
@@ -1,123 +0,0 @@
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/button/button.js';
11
- import '@shoelace-style/shoelace/dist/components/button-group/button-group.js';
12
- import '@shoelace-style/shoelace/dist/components/icon/icon.js';
13
- import '@shoelace-style/shoelace/dist/components/tooltip/tooltip.js';
14
- import { LitElement, css, html } from "lit";
15
- import { property } from "lit/decorators.js";
16
- import registerBundledIcons from '../components/icons';
17
- registerBundledIcons();
18
- // import { cva } from "class-variance-authority";
19
- // const toolbarStyle = cva(
20
- // "some-css-var",
21
- // {
22
- // variants: {
23
- // someProperty: {
24
- // true: "some-css-var",
25
- // false: "some-css-var",
26
- // },
27
- // },
28
- // },
29
- // );
30
- export class Toolbar extends LitElement {
31
- constructor() {
32
- super(...arguments);
33
- this.name = "hot-toolbar";
34
- /** Change the position of the tooltips relative to buttons. */
35
- this.tooltipPosition = "top";
36
- this.undo = (e) => {
37
- // As the original event is also named 'click'
38
- // stop propagation of the original event
39
- e.stopPropagation();
40
- this.dispatchEvent(new Event("hot-undo-click"));
41
- };
42
- this.redo = (e) => {
43
- e.stopPropagation();
44
- this.dispatchEvent(new Event("hot-redo-click"));
45
- };
46
- this.bold = (e) => {
47
- e.stopPropagation();
48
- this.dispatchEvent(new Event("hot-bold-click"));
49
- };
50
- this.italic = (e) => {
51
- e.stopPropagation();
52
- this.dispatchEvent(new Event("hot-italic-click"));
53
- };
54
- this.underline = (e) => {
55
- e.stopPropagation();
56
- this.dispatchEvent(new Event("hot-underline-click"));
57
- };
58
- this.alignLeft = (e) => {
59
- e.stopPropagation();
60
- this.dispatchEvent(new Event("hot-leftalign-click"));
61
- };
62
- this.alignCenter = (e) => {
63
- e.stopPropagation();
64
- this.dispatchEvent(new Event("hot-centeralign-click"));
65
- };
66
- this.alignRight = (e) => {
67
- e.stopPropagation();
68
- this.dispatchEvent(new Event("hot-rightalign-click"));
69
- };
70
- }
71
- // class=${toolbarStyle({
72
- // someProperty: this.someProperty,
73
- // })}
74
- render() {
75
- return html `
76
- <div class="button-group-toolbar">
77
- ${this.renderButtonGroup('History', [
78
- { content: 'Undo', icon: 'arrow-counterclockwise', label: 'Undo', action: this.undo },
79
- { content: 'Redo', icon: 'arrow-clockwise', label: 'Redo', action: this.redo }
80
- ])}
81
- ${this.renderButtonGroup('Formatting', [
82
- { content: 'Bold', icon: 'type-bold', label: 'Bold', action: this.bold },
83
- { content: 'Italic', icon: 'type-italic', label: 'Italic', action: this.italic },
84
- { content: 'Underline', icon: 'type-underline', label: 'Underline', action: this.underline }
85
- ])}
86
- ${this.renderButtonGroup('Alignment', [
87
- { content: 'Align Left', icon: 'justify-left', label: 'Align Left', action: this.alignLeft },
88
- { content: 'Align Center', icon: 'justify', label: 'Align Center', action: this.alignCenter },
89
- { content: 'Align Right', icon: 'justify-right', label: 'Align Right', action: this.alignRight }
90
- ])}
91
- </div>
92
- `;
93
- }
94
- renderButtonGroup(label, buttons) {
95
- return html `
96
- <sl-button-group label=${label}>
97
- ${buttons.map(button => this.renderButton(button))}
98
- </sl-button-group>
99
- `;
100
- }
101
- renderButton({ content, icon, label, action }) {
102
- return html `
103
- <sl-tooltip content=${content} placement="${this.tooltipPosition}">
104
- <sl-button @click=${action ?? (() => { })}><sl-icon library="bundled" name=${icon} label=${label}></sl-icon></sl-button>
105
- </sl-tooltip>
106
- `;
107
- }
108
- }
109
- Toolbar.styles = [
110
- css `
111
- @unocss-placeholder;
112
- `,
113
- // unsafeCSS(reset),
114
- ];
115
- __decorate([
116
- property()
117
- ], Toolbar.prototype, "name", void 0);
118
- __decorate([
119
- property({ type: String, attribute: "tooltip-position" })
120
- ], Toolbar.prototype, "tooltipPosition", void 0);
121
- export default Toolbar;
122
- // Define web component
123
- customElements.define("hot-toolbar", Toolbar);
@@ -1,26 +0,0 @@
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/alert/alert.js';
5
- import { LitElement } from "lit";
6
- declare global {
7
- interface Window {
8
- _paq: any[];
9
- }
10
- }
11
- export declare class Tracking extends LitElement {
12
- name: string;
13
- /** The Matomo site id for tracking. */
14
- siteId: string;
15
- /** The domains to apply tracking. */
16
- domain: string;
17
- /** Force display the banner. */
18
- force: boolean;
19
- isOpen: boolean;
20
- static styles: import("lit").CSSResult[];
21
- protected render(): import("lit").TemplateResult<1>;
22
- private _setAgree;
23
- private _setDisagree;
24
- connectedCallback(): void;
25
- }
26
- export default Tracking;
@@ -1,167 +0,0 @@
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/alert/alert.js';
11
- import { LitElement, css, html } from "lit";
12
- import { property, state } from "lit/decorators.js";
13
- import registerBundledIcons from '../components/icons';
14
- registerBundledIcons();
15
- export class Tracking extends LitElement {
16
- constructor() {
17
- super(...arguments);
18
- this.name = "hot-tracking";
19
- /** The Matomo site id for tracking. */
20
- this.siteId = "";
21
- /** The domains to apply tracking. */
22
- this.domain = "";
23
- /** Force display the banner. */
24
- this.force = false;
25
- this.isOpen = true;
26
- }
27
- render() {
28
- return html `<sl-alert
29
- variant="danger"
30
- ?open=${this.isOpen}
31
- >
32
- <sl-icon id="hot-red-text" library="bundled" slot="icon" name="info-circle"></sl-icon>
33
-
34
- <p id="tracking-header">
35
- About the information we collect
36
- </p>
37
-
38
- <p>
39
- We use cookies and similar technologies to recognize and analyze your visits,
40
- and measure traffic usage and activity. You can learn about how we use the data
41
- about your visit or information you provide reading our
42
- <a
43
- style="color: #d63f3f;"
44
- href="https://www.hotosm.org/privacy"
45
- target="_blank"
46
- rel="noopener noreferrer"
47
- >privacy policy</a>.
48
- By clicking "I Agree", you consent to the use of cookies.
49
- </p>
50
-
51
- <sl-button @click=${(e) => { this._setAgree(e); }}>I Agree</sl-button>
52
- <sl-button @click=${(e) => { this._setDisagree(e); }}>I Do Not Agree</sl-button>
53
- </sl-alert>`;
54
- }
55
- _setAgree(_e) {
56
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
57
- const _paq = (window._paq = window._paq || []);
58
- if (_paq.length === 0)
59
- return;
60
- _paq.push(['rememberConsentGiven']);
61
- this.isOpen = false;
62
- localStorage.setItem(`${this.siteId}-matomo-agree`, 'true');
63
- this.dispatchEvent(new Event('agree', { bubbles: true, composed: true }));
64
- }
65
- _setDisagree(_e) {
66
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
67
- const _paq = (window._paq = window._paq || []);
68
- if (_paq.length === 0)
69
- return;
70
- _paq.push(['forgetConsentGiven']);
71
- this.isOpen = false;
72
- localStorage.setItem(`${this.siteId}-matomo-agree`, 'false');
73
- this.dispatchEvent(new Event('disagree', { bubbles: true, composed: true }));
74
- }
75
- connectedCallback() {
76
- super.connectedCallback();
77
- // Close and halt execution if wrong domain
78
- if (!this.force && window.location.hostname !== this.domain) {
79
- console.warn(`Matomo init failed. ${window.location.hostname} does not match ${this.domain}.`);
80
- this.isOpen = false;
81
- return;
82
- }
83
- const matomoTrackingId = this.siteId;
84
- // Close and halt execution if siteId or domain not set
85
- if (!this.force && (matomoTrackingId.length === 0 || this.domain.length === 0)) {
86
- console.warn('Matomo init failed. No site id or domains provided.');
87
- this.isOpen = false;
88
- return;
89
- }
90
- // Close and halt execution if already disagreed
91
- const consent = localStorage.getItem(`${this.siteId}-matomo-agree`);
92
- if (consent === 'false') {
93
- this.isOpen = false;
94
- return;
95
- }
96
- // Close prompt only if already agreed, continue
97
- if (consent === 'true') {
98
- this.isOpen = false;
99
- }
100
- console.log(`Setting Matomo tracking for site=${matomoTrackingId} domain=${this.domain}`);
101
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
102
- const _paq = (window._paq = window._paq || []);
103
- // tracker methods like "setCustomDimension" should be called before "trackPageView"
104
- _paq.push(['requireConsent']);
105
- _paq.push(['setDomains', [this.domain]]);
106
- _paq.push(['trackPageView']);
107
- _paq.push(['enableLinkTracking']); // Tracks downloads
108
- _paq.push(['trackVisibleContentImpressions']); // Tracks content
109
- (function () {
110
- const u = '//matomo.hotosm.org/';
111
- _paq.push(['setTrackerUrl', u + 'matomo.php']);
112
- _paq.push(['setSiteId', matomoTrackingId]);
113
- const d = document;
114
- const g = d.createElement('script');
115
- const s = d.getElementsByTagName('script')[0];
116
- if (s?.parentNode != null) {
117
- g.async = true;
118
- g.src = u + 'matomo.js';
119
- s.parentNode.insertBefore(g, s);
120
- }
121
- else {
122
- console.warn('Script insertion failed. Parent node is null.');
123
- }
124
- })();
125
- }
126
- }
127
- Tracking.styles = [
128
- css `
129
- @unocss-placeholder;
130
- `,
131
- // Temp styles until UnoCSS setup
132
- css `
133
- #tracking-header {
134
- font-weight: var(--sl-font-weight-bold);
135
- font-size: var(--sl-font-size-large);
136
- color: #d63f3f;
137
- text-align: center;
138
- }
139
- sl-alert::part(base) {
140
- position: absolute;
141
- bottom: 20px;
142
- left: 50%;
143
- transform: translateX(-50%);
144
- z-index: 1000;
145
- width: 80vw;
146
- text-align: center;
147
- }
148
- `
149
- ];
150
- __decorate([
151
- property()
152
- ], Tracking.prototype, "name", void 0);
153
- __decorate([
154
- property({ type: String, attribute: "site-id" })
155
- ], Tracking.prototype, "siteId", void 0);
156
- __decorate([
157
- property({ type: String })
158
- ], Tracking.prototype, "domain", void 0);
159
- __decorate([
160
- property({ type: Boolean })
161
- ], Tracking.prototype, "force", void 0);
162
- __decorate([
163
- state()
164
- ], Tracking.prototype, "isOpen", void 0);
165
- export default Tracking;
166
- // Define web component
167
- customElements.define("hot-tracking", Tracking);
@@ -1,4 +0,0 @@
1
- export { default as Button } from './Button';
2
- export { default as Header } from './Header';
3
- export { default as Toolbar } from './Toolbar';
4
- export { default as Tracking } from './Tracking';
@@ -1,6 +0,0 @@
1
- // Index to import all components together
2
- // import '@hotosm/ui/components';
3
- export { default as Button } from './Button';
4
- export { default as Header } from './Header';
5
- export { default as Toolbar } from './Toolbar';
6
- export { default as Tracking } from './Tracking';
Binary file