Skip to content

Commit

Permalink
more ui userLink refactor WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Nov 19, 2023
1 parent a7d664d commit ccd8069
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
2 changes: 1 addition & 1 deletion ui/msg/css/_side.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
background: mix($c-msg, $c-bg-box, 30%);
}

&__icon {
.user-link {
flex: 0 0 auto;
font-size: 2.3em;
}
Expand Down
5 changes: 3 additions & 2 deletions ui/msg/src/view/contact.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { h, VNode } from 'snabbdom';
import { Contact, LastMsg } from '../interfaces';
import MsgCtrl from '../ctrl';
import { userName, userIcon } from './util';
import { userName } from './util';
import * as licon from 'common/licon';
import userLink from 'common/userLink';
import { hookMobileMousedown } from 'common/device';

export default function renderContact(ctrl: MsgCtrl, contact: Contact, active?: string): VNode {
Expand All @@ -17,7 +18,7 @@ export default function renderContact(ctrl: MsgCtrl, contact: Contact, active?:
hook: hookMobileMousedown(_ => ctrl.openConvo(user.id)),
},
[
userIcon(user, 'msg-app__side__contact__icon'),
userLink(user),
h('div.msg-app__side__contact__user', [
h('div.msg-app__side__contact__head', [
h('div.msg-app__side__contact__name', userName(user)),
Expand Down
10 changes: 5 additions & 5 deletions ui/msg/src/view/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import throttle from 'common/throttle';
import MsgCtrl from '../ctrl';
import { SearchResult, User } from '../interfaces';
import renderContacts from './contact';
import { userName, userIcon } from './util';
import { userName } from './util';
import userLink from 'common/userLink';
import { hookMobileMousedown } from 'common/device';

export function renderInput(ctrl: MsgCtrl): VNode {
return h('div.msg-app__side__search', [
export const renderInput = (ctrl: MsgCtrl): VNode =>
h('div.msg-app__side__search', [
h('input', {
attrs: {
value: '',
Expand All @@ -30,7 +31,6 @@ export function renderInput(ctrl: MsgCtrl): VNode {
},
}),
]);
}

export function renderResults(ctrl: MsgCtrl, res: SearchResult): VNode {
return h('div.msg-app__search.msg-app__side__content', [
Expand Down Expand Up @@ -69,7 +69,7 @@ function renderUser(ctrl: MsgCtrl, user: User): VNode {
hook: hookMobileMousedown(_ => ctrl.openConvo(user.id)),
},
[
userIcon(user, 'msg-app__side__contact__icon'),
userLink(user),
h('div.msg-app__side__contact__user', [
h('div.msg-app__side__contact__head', [h('div.msg-app__side__contact__name', userName(user))]),
]),
Expand Down
13 changes: 0 additions & 13 deletions ui/msg/src/view/util.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
import { h, VNode } from 'snabbdom';
import { User } from '../interfaces';

export function userIcon(user: User, cls: string): VNode {
return h(
'div.user-link.' + cls,
{
class: {
online: user.online,
offline: !user.online,
},
},
[h('i.line' + (user.patron ? '.patron' : ''))],
);
}

export const userName = (user: User): Array<string | VNode> =>
user.title
? [
Expand Down

0 comments on commit ccd8069

Please sign in to comment.