@debtcollective/dc-header-component
Advanced tools
Comparing version 1.1.3 to 1.2.0
@@ -6,2 +6,14 @@ # Change Log | ||
# [1.2.0](https://github.com/debtcollective/packages/compare/v1.1.3...v1.2.0) (2020-09-22) | ||
### Features | ||
* **header-links:** add member hub link if user is authenticated ([b520e1e](https://github.com/debtcollective/packages/commit/b520e1e)) | ||
* **user-avatar:** create popup for the user avatar ([295ad7a](https://github.com/debtcollective/packages/commit/295ad7a)) | ||
## [1.1.3](https://github.com/debtcollective/packages/compare/v1.1.2...v1.1.3) (2020-09-18) | ||
@@ -8,0 +20,0 @@ |
@@ -24,2 +24,9 @@ 'use strict'; | ||
} | ||
/** | ||
* Event to detect escape key press | ||
*/ | ||
handleEscapeKey(event) { | ||
if (event.keyCode === 27) | ||
this.closeDropdown(); | ||
} | ||
toggleDropdown() { | ||
@@ -26,0 +33,0 @@ this.open = !this.open; |
@@ -7,3 +7,3 @@ 'use strict'; | ||
patch.patchBrowser().then(options => { | ||
return index.bootstrapLazy([["dc-collapser.cjs",[[0,"dc-collapser",{"label":[1],"items":[16],"open":[32]}]]],["dc-dropdown.cjs",[[0,"dc-dropdown",{"label":[1],"items":[16],"open":[32]},[[4,"click","handleClickOutside"]]]]],["dc-header_3.cjs",[[1,"dc-header",{"links":[1],"donateurl":[1],"community":[1],"host":[1],"logo":[1],"logosmall":[1],"user":[32],"isMenuOpen":[32]},[[0,"toggleMenu","toggleMenuHandler"]]],[4,"dc-menu",{"open":[4],"logo":[1]}],[0,"dc-user-items",{"community":[1],"user":[16]}]]]], options); | ||
return index.bootstrapLazy([["dc-collapser.cjs",[[0,"dc-collapser",{"label":[1],"items":[16],"open":[32]}]]],["dc-dropdown.cjs",[[0,"dc-dropdown",{"label":[1],"items":[16],"open":[32]},[[4,"click","handleClickOutside"],[4,"keydown","handleEscapeKey"]]]]],["dc-header_4.cjs",[[1,"dc-header",{"links":[1],"donateurl":[1],"community":[1],"memberhuburl":[1],"host":[1],"logo":[1],"logosmall":[1],"user":[32],"isMenuOpen":[32]},[[0,"toggleMenu","toggleMenuHandler"]]],[0,"dc-user-items",{"community":[1],"user":[16]}],[4,"dc-menu",{"open":[4],"logo":[1]}],[0,"dc-user-popup",{"community":[1],"user":[16],"open":[32]},[[4,"click","handleClickOutside"],[4,"keydown","handleEscapeKey"]]]]]], options); | ||
}); |
@@ -11,3 +11,3 @@ 'use strict'; | ||
return patch.patchEsm().then(() => { | ||
return index.bootstrapLazy([["dc-collapser.cjs",[[0,"dc-collapser",{"label":[1],"items":[16],"open":[32]}]]],["dc-dropdown.cjs",[[0,"dc-dropdown",{"label":[1],"items":[16],"open":[32]},[[4,"click","handleClickOutside"]]]]],["dc-header_3.cjs",[[1,"dc-header",{"links":[1],"donateurl":[1],"community":[1],"host":[1],"logo":[1],"logosmall":[1],"user":[32],"isMenuOpen":[32]},[[0,"toggleMenu","toggleMenuHandler"]]],[4,"dc-menu",{"open":[4],"logo":[1]}],[0,"dc-user-items",{"community":[1],"user":[16]}]]]], options); | ||
return index.bootstrapLazy([["dc-collapser.cjs",[[0,"dc-collapser",{"label":[1],"items":[16],"open":[32]}]]],["dc-dropdown.cjs",[[0,"dc-dropdown",{"label":[1],"items":[16],"open":[32]},[[4,"click","handleClickOutside"],[4,"keydown","handleEscapeKey"]]]]],["dc-header_4.cjs",[[1,"dc-header",{"links":[1],"donateurl":[1],"community":[1],"memberhuburl":[1],"host":[1],"logo":[1],"logosmall":[1],"user":[32],"isMenuOpen":[32]},[[0,"toggleMenu","toggleMenuHandler"]]],[0,"dc-user-items",{"community":[1],"user":[16]}],[4,"dc-menu",{"open":[4],"logo":[1]}],[0,"dc-user-popup",{"community":[1],"user":[16],"open":[32]},[[4,"click","handleClickOutside"],[4,"keydown","handleEscapeKey"]]]]]], options); | ||
}); | ||
@@ -14,0 +14,0 @@ }; |
@@ -6,2 +6,3 @@ { | ||
"./components/dc-header/dc-menu.js", | ||
"./components/dc-header/dc-user-popup.js", | ||
"./components/dc-header/dc-user-items.js", | ||
@@ -8,0 +9,0 @@ "./components/dc-header/dc-header.js" |
@@ -14,2 +14,9 @@ import { Component, h, State, Prop, Listen } from "@stencil/core"; | ||
} | ||
/** | ||
* Event to detect escape key press | ||
*/ | ||
handleEscapeKey(event) { | ||
if (event.keyCode === 27) | ||
this.closeDropdown(); | ||
} | ||
toggleDropdown() { | ||
@@ -85,3 +92,9 @@ this.open = !this.open; | ||
"passive": false | ||
}, { | ||
"name": "keydown", | ||
"method": "handleEscapeKey", | ||
"target": "document", | ||
"capture": false, | ||
"passive": false | ||
}]; } | ||
} |
@@ -18,2 +18,6 @@ import { Component, Prop, State, h, Watch, getAssetPath, Host, Listen } from "@stencil/core"; | ||
/** | ||
* URL to the member hub page | ||
*/ | ||
this.memberhuburl = "https://debtcollective.org/hub"; | ||
/** | ||
* Logo image | ||
@@ -46,3 +50,11 @@ */ | ||
render() { | ||
var _a; | ||
const user = this.user; | ||
const authLinks = [ | ||
{ | ||
text: 'Member hub', | ||
href: this.memberhuburl | ||
} | ||
]; | ||
const linksToRender = ((_a = this.user) === null || _a === void 0 ? void 0 : _a.id) ? [...authLinks, ...this._links] : this._links; | ||
return (h(Host, null, | ||
@@ -56,3 +68,3 @@ h("header", { class: "header" }, | ||
h("nav", { class: "nav" }, | ||
h("slot", { name: "header" }, this._links.map(({ text, href }) => (h("div", { class: "nav-item d-md-flex" }, | ||
h("slot", { name: "header" }, linksToRender.map(({ text, href }) => (h("div", { class: "nav-item d-md-flex" }, | ||
h("a", { class: "nav-link", href: href }, text)))))), | ||
@@ -65,3 +77,3 @@ h("div", { class: "session-items" }, user ? (h("dc-user-items", { user: user, community: this.community })) : (h("div", { class: "session-links" }, | ||
h("dc-menu", { open: this.isMenuOpen, logo: this.logo }, | ||
h("slot", { name: "menu" }, this._links.map(({ text, href }) => (h("div", { class: "nav-item" }, | ||
h("slot", { name: "menu" }, linksToRender.map(({ text, href }) => (h("div", { class: "nav-item" }, | ||
h("a", { class: "nav-link", href: href }, text)))))))); | ||
@@ -132,2 +144,20 @@ } | ||
}, | ||
"memberhuburl": { | ||
"type": "string", | ||
"mutable": false, | ||
"complexType": { | ||
"original": "string", | ||
"resolved": "string", | ||
"references": {} | ||
}, | ||
"required": false, | ||
"optional": true, | ||
"docs": { | ||
"tags": [], | ||
"text": "URL to the member hub page" | ||
}, | ||
"attribute": "memberhuburl", | ||
"reflect": false, | ||
"defaultValue": "\"https://debtcollective.org/hub\"" | ||
}, | ||
"host": { | ||
@@ -134,0 +164,0 @@ "type": "string", |
import { Component, h, Host, Prop } from "@stencil/core"; | ||
import { preffixCommunityURL, getAvatarURL } from "../../utils/community"; | ||
import { preffixCommunityURL } from "../../utils/community"; | ||
import "./dc-user-popup"; | ||
export class Menu { | ||
@@ -15,4 +16,3 @@ render() { | ||
generalNoticeCount !== 0 && (h("span", { class: "badge-notification unread-notifications" }, generalNoticeCount)))), | ||
h("a", { id: "current-user", href: preffixCommunityURL(this.community, `u/${this.user.username}`), target: "_blank" }, | ||
h("img", { alt: "Profile picture", width: "32", height: "32", src: getAvatarURL(this.user, this.community), title: this.user.username, class: "avatar" })))); | ||
h("dc-user-popup", { user: this.user, community: this.community }))); | ||
} | ||
@@ -19,0 +19,0 @@ static get is() { return "dc-user-items"; } |
@@ -14,3 +14,3 @@ // https://stackoverflow.com/a/33829607/1422380 | ||
const json = await response.json(); | ||
return json; | ||
return json.csrf; | ||
}; | ||
@@ -45,1 +45,18 @@ const getCurrentUser = async (discourseEndpoint, { csrfToken }) => { | ||
}; | ||
export const logout = async (discourseEndpoint, username) => { | ||
const url = `${discourseEndpoint}/session/${username}`; | ||
const csrfToken = await getCSRFToken(discourseEndpoint); | ||
try { | ||
await fetch(url, { | ||
method: "DELETE", | ||
credentials: "include", | ||
headers: { | ||
Accept: "application/json", | ||
"X-CSRF-Token": csrfToken, | ||
}, | ||
}); | ||
} | ||
catch (error) { | ||
console.error(error); | ||
} | ||
}; |
@@ -18,2 +18,9 @@ import { r as registerInstance, h } from './index-491ec3cf.js'; | ||
}; | ||
/** | ||
* Event to detect escape key press | ||
*/ | ||
Dropdown.prototype.handleEscapeKey = function (event) { | ||
if (event.keyCode === 27) | ||
this.closeDropdown(); | ||
}; | ||
Dropdown.prototype.toggleDropdown = function () { | ||
@@ -20,0 +27,0 @@ this.open = !this.open; |
@@ -20,2 +20,9 @@ import { r as registerInstance, h } from './index-491ec3cf.js'; | ||
} | ||
/** | ||
* Event to detect escape key press | ||
*/ | ||
handleEscapeKey(event) { | ||
if (event.keyCode === 27) | ||
this.closeDropdown(); | ||
} | ||
toggleDropdown() { | ||
@@ -22,0 +29,0 @@ this.open = !this.open; |
@@ -1,1 +0,1 @@ | ||
import{b as e}from"./p-fda4441b.js";import{p as o}from"./p-79b6293a.js";o().then(o=>e([["p-9a728e4a",[[0,"dc-collapser",{label:[1],items:[16],open:[32]}]]],["p-fbf49d6c",[[0,"dc-dropdown",{label:[1],items:[16],open:[32]},[[4,"click","handleClickOutside"]]]]],["p-683f7004",[[1,"dc-header",{links:[1],donateurl:[1],community:[1],host:[1],logo:[1],logosmall:[1],user:[32],isMenuOpen:[32]},[[0,"toggleMenu","toggleMenuHandler"]]],[4,"dc-menu",{open:[4],logo:[1]}],[0,"dc-user-items",{community:[1],user:[16]}]]]],o)); | ||
import{b as e}from"./p-fda4441b.js";import{p as o}from"./p-79b6293a.js";o().then(o=>e([["p-9a728e4a",[[0,"dc-collapser",{label:[1],items:[16],open:[32]}]]],["p-36548087",[[0,"dc-dropdown",{label:[1],items:[16],open:[32]},[[4,"click","handleClickOutside"],[4,"keydown","handleEscapeKey"]]]]],["p-afcb1f94",[[1,"dc-header",{links:[1],donateurl:[1],community:[1],memberhuburl:[1],host:[1],logo:[1],logosmall:[1],user:[32],isMenuOpen:[32]},[[0,"toggleMenu","toggleMenuHandler"]]],[0,"dc-user-items",{community:[1],user:[16]}],[4,"dc-menu",{open:[4],logo:[1]}],[0,"dc-user-popup",{community:[1],user:[16],open:[32]},[[4,"click","handleClickOutside"],[4,"keydown","handleEscapeKey"]]]]]],o)); |
@@ -1,1 +0,1 @@ | ||
System.register(["./p-cf24986c.system.js","./p-3a231e41.system.js"],(function(){"use strict";var e,s;return{setters:[function(s){e=s.b},function(e){s=e.p}],execute:function(){s().then((function(s){return e([["p-96646821.system",[[0,"dc-collapser",{label:[1],items:[16],open:[32]}]]],["p-2c3dc090.system",[[0,"dc-dropdown",{label:[1],items:[16],open:[32]},[[4,"click","handleClickOutside"]]]]],["p-cd7171f9.system",[[1,"dc-header",{links:[1],donateurl:[1],community:[1],host:[1],logo:[1],logosmall:[1],user:[32],isMenuOpen:[32]},[[0,"toggleMenu","toggleMenuHandler"]]],[4,"dc-menu",{open:[4],logo:[1]}],[0,"dc-user-items",{community:[1],user:[16]}]]]],s)}))}}})); | ||
System.register(["./p-cf24986c.system.js","./p-3a231e41.system.js"],(function(){"use strict";var e,n;return{setters:[function(n){e=n.b},function(e){n=e.p}],execute:function(){n().then((function(n){return e([["p-96646821.system",[[0,"dc-collapser",{label:[1],items:[16],open:[32]}]]],["p-64b15ce8.system",[[0,"dc-dropdown",{label:[1],items:[16],open:[32]},[[4,"click","handleClickOutside"],[4,"keydown","handleEscapeKey"]]]]],["p-86014705.system",[[1,"dc-header",{links:[1],donateurl:[1],community:[1],memberhuburl:[1],host:[1],logo:[1],logosmall:[1],user:[32],isMenuOpen:[32]},[[0,"toggleMenu","toggleMenuHandler"]]],[0,"dc-user-items",{community:[1],user:[16]}],[4,"dc-menu",{open:[4],logo:[1]}],[0,"dc-user-popup",{community:[1],user:[16],open:[32]},[[4,"click","handleClickOutside"],[4,"keydown","handleEscapeKey"]]]]]],n)}))}}})); |
@@ -54,2 +54,6 @@ /* eslint-disable */ | ||
"logosmall": string; | ||
/** | ||
* URL to the member hub page | ||
*/ | ||
"memberhuburl"?: string; | ||
} | ||
@@ -83,2 +87,19 @@ interface DcMenu { | ||
} | ||
interface DcUserPopup { | ||
/** | ||
* URL to the community | ||
*/ | ||
"community": string; | ||
/** | ||
* An object with the user data. Follows Discourse structure as https://docs.discourse.org/#tag/Users/paths/~1users~1{username}.json/get | ||
*/ | ||
"user": { | ||
id: number; | ||
admin: boolean; | ||
avatar_template: string; | ||
username: string; | ||
unread_notifications: number; | ||
unread_high_priority_notifications: number; | ||
}; | ||
} | ||
} | ||
@@ -116,2 +137,8 @@ declare global { | ||
}; | ||
interface HTMLDcUserPopupElement extends Components.DcUserPopup, HTMLStencilElement { | ||
} | ||
var HTMLDcUserPopupElement: { | ||
prototype: HTMLDcUserPopupElement; | ||
new (): HTMLDcUserPopupElement; | ||
}; | ||
interface HTMLElementTagNameMap { | ||
@@ -123,2 +150,3 @@ "dc-collapser": HTMLDcCollapserElement; | ||
"dc-user-items": HTMLDcUserItemsElement; | ||
"dc-user-popup": HTMLDcUserPopupElement; | ||
} | ||
@@ -172,2 +200,6 @@ } | ||
"logosmall"?: string; | ||
/** | ||
* URL to the member hub page | ||
*/ | ||
"memberhuburl"?: string; | ||
} | ||
@@ -202,2 +234,19 @@ interface DcMenu { | ||
} | ||
interface DcUserPopup { | ||
/** | ||
* URL to the community | ||
*/ | ||
"community"?: string; | ||
/** | ||
* An object with the user data. Follows Discourse structure as https://docs.discourse.org/#tag/Users/paths/~1users~1{username}.json/get | ||
*/ | ||
"user"?: { | ||
id: number; | ||
admin: boolean; | ||
avatar_template: string; | ||
username: string; | ||
unread_notifications: number; | ||
unread_high_priority_notifications: number; | ||
}; | ||
} | ||
interface IntrinsicElements { | ||
@@ -209,2 +258,3 @@ "dc-collapser": DcCollapser; | ||
"dc-user-items": DcUserItems; | ||
"dc-user-popup": DcUserPopup; | ||
} | ||
@@ -221,4 +271,5 @@ } | ||
"dc-user-items": LocalJSX.DcUserItems & JSXBase.HTMLAttributes<HTMLDcUserItemsElement>; | ||
"dc-user-popup": LocalJSX.DcUserPopup & JSXBase.HTMLAttributes<HTMLDcUserPopupElement>; | ||
} | ||
} | ||
} |
@@ -19,2 +19,6 @@ export declare class Dropdown { | ||
handleClickOutside(event: any): void; | ||
/** | ||
* Event to detect escape key press | ||
*/ | ||
handleEscapeKey(event: any): void; | ||
dropdownTrigger: Node; | ||
@@ -21,0 +25,0 @@ dropdownItems: Node; |
@@ -27,2 +27,6 @@ import "./dc-menu"; | ||
/** | ||
* URL to the member hub page | ||
*/ | ||
memberhuburl?: string; | ||
/** | ||
* URL to the component host | ||
@@ -29,0 +33,0 @@ * without the latest "/" |
@@ -0,1 +1,2 @@ | ||
import "./dc-user-popup"; | ||
export declare class Menu { | ||
@@ -2,0 +3,0 @@ /** |
export declare const syncCurrentUser: (discourseEndpoint: any) => Promise<any>; | ||
export declare const logout: (discourseEndpoint: any, username: any) => Promise<void>; |
{ | ||
"name": "@debtcollective/dc-header-component", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Stencil header component for debtcollective web apps", | ||
@@ -40,3 +40,3 @@ "main": "dist/index.js", | ||
"license": "MIT", | ||
"gitHead": "e96222354a933678359027fe896d8bf57ffe7cad" | ||
"gitHead": "26792f1fd59943327799dd4090c105e3441af82c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
979564
105
13004
17
31