Skip to content

Commit

Permalink
refactor(hdom-components): update notification & appLink comps
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed May 7, 2018
1 parent a11803c commit 4f8e7ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 5 additions & 5 deletions packages/hdom-components/src/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { isString } from "@thi.ng/checks/is-string";
export const link = (attribs: any, body: any) =>
["a", isString(attribs) ? { href: attribs } : attribs, body];

export const appLink = (attribs: any, body: any, onclick: (e: Event) => void) =>
link(
export const appLink = (_, attribs: any, onclick: EventListener, body: any) =>
["a",
{
...attribs,
href: "#",
onclick: (e) => { e.preventDefault(); onclick(e); }
onclick: (e) => { e.preventDefault(); onclick(e); },
...attribs,
},
body);
body];
9 changes: 3 additions & 6 deletions packages/hdom-components/src/notification.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IObjectOf } from "@thi.ng/api/api";
import { button } from "./button";
import { appLink } from "./link";

export interface NotificationOpts {
/**
Expand Down Expand Up @@ -56,15 +56,12 @@ export interface NotificationArgs {
* @param opts
*/
export const notification = (opts?: Partial<NotificationOpts>) => {
const closeBt = opts.close && button({
attribs: opts.attribsClose
});
return (_, args: Partial<NotificationArgs>, body: any) =>
["div",
{ ...opts.attribs, ...args.attribs },
opts.icon,
body,
args.onclose && closeBt ?
[closeBt, { onclick: args.onclose }, opts.close] :
opts.close && args.onclose ?
[appLink, opts.attribsClose, args.onclose, opts.close] :
undefined];
};

0 comments on commit 4f8e7ba

Please sign in to comment.