Skip to content

Commit

Permalink
change broadcast tour location icon
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Oct 6, 2024
1 parent 0bd36d7 commit cfbc85b
Showing 1 changed file with 125 additions and 125 deletions.
250 changes: 125 additions & 125 deletions ui/analyse/src/study/relay/relayTourView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,37 +53,37 @@ export const tourSide = (ctx: RelayViewContext) => {
...(empty
? [startCountdown(relay)]
: [
h('div.relay-tour__side__header', [
h(
'button.relay-tour__side__name',
{ hook: bind('mousedown', relay.tourShow.toggle, relay.redraw) },
relay.roundName(),
),
!ctrl.isEmbed &&
h('button.streamer-show.data-count', {
attrs: { 'data-icon': licon.Mic, 'data-count': relay.streams.length, title: 'Streamers' },
class: {
disabled: !relay.streams.length,
active: relay.showStreamerMenu(),
streaming: relay.isStreamer(),
},
hook: bind('click', relay.showStreamerMenu.toggle, relay.redraw),
}),
h('button.relay-tour__side__search', {
attrs: { 'data-icon': licon.Search, title: 'Search' },
hook: bind('click', study.search.open.toggle),
}),
]),
h('div.relay-tour__side__header', [
h(
'button.relay-tour__side__name',
{ hook: bind('mousedown', relay.tourShow.toggle, relay.redraw) },
relay.roundName(),
),
!ctrl.isEmbed &&
h('button.streamer-show.data-count', {
attrs: { 'data-icon': licon.Mic, 'data-count': relay.streams.length, title: 'Streamers' },
class: {
disabled: !relay.streams.length,
active: relay.showStreamerMenu(),
streaming: relay.isStreamer(),
},
hook: bind('click', relay.showStreamerMenu.toggle, relay.redraw),
}),
h('button.relay-tour__side__search', {
attrs: { 'data-icon': licon.Search, title: 'Search' },
hook: bind('click', study.search.open.toggle),
}),
]),
]),
!ctrl.isEmbed && relay.showStreamerMenu() && renderStreamerMenu(relay),
!empty && gamesList(study, relay),
!ctrl.isEmbed &&
h('div.chat__members', {
hook: onInsert(el => {
makeChatEl(ctrl, chat => el.parentNode!.insertBefore(chat, el));
watchers(el);
}),
h('div.chat__members', {
hook: onInsert(el => {
makeChatEl(ctrl, chat => el.parentNode!.insertBefore(chat, el));
watchers(el);
}),
}),
],
);
};
Expand Down Expand Up @@ -112,7 +112,7 @@ const showInfo = (i: RelayTourInfo, dates?: RelayTourDates) => {
['dates', dates && showDates(dates), 'objects.spiral-calendar'],
['format', i.format, 'objects.crown'],
['tc', i.tc, 'objects.mantelpiece-clock'],
['location', i.location, 'travel-places.world-map'],
['location', i.location, 'travel-places.globe-showing-europe-africa'],
['players', i.players, 'activity.sparkles'],
['website', i.website, null, 'Official website'],
['standings', i.standings, null, 'Standings'],
Expand All @@ -134,9 +134,9 @@ const showInfo = (i: RelayTourInfo, dates?: RelayTourDates) => {
const dateFormat = memoize(() =>
window.Intl && Intl.DateTimeFormat
? new Intl.DateTimeFormat(site.displayLocale, {
month: 'short',
day: '2-digit',
} as any).format
month: 'short',
day: '2-digit',
} as any).format
: (d: Date) => d.toLocaleDateString(),
);

Expand All @@ -149,9 +149,9 @@ const showDates = (dates: RelayTourDates) => {
const showSource = (data: RelayData) =>
data.lcc
? h('div.relay-tour__source', [
'PGN source: ',
h('a', { attrs: { href: 'https://www.livechesscloud.com' } }, 'LiveChessCloud'),
])
'PGN source: ',
h('a', { attrs: { href: 'https://www.livechesscloud.com' } }, 'LiveChessCloud'),
])
: undefined;

const overview = (ctx: RelayViewContext) => {
Expand All @@ -161,8 +161,8 @@ const overview = (ctx: RelayViewContext) => {
showInfo(tour.info, tour.dates),
tour.description
? h('div.relay-tour__markup', {
hook: innerHTML(tour.description, () => tour.description!),
})
hook: innerHTML(tour.description, () => tour.description!),
})
: undefined,
...(ctx.ctrl.isEmbed ? [] : [showSource(ctx.relay.data), share(ctx)]),
];
Expand Down Expand Up @@ -222,18 +222,18 @@ const groupSelect = (ctx: RelayViewContext, group: RelayGroup) => {
),
...(toggle()
? [
h('label.fullscreen-mask', clickHook),
h(
'nav.mselect__list',
group.tours.map(tour =>
h(
`a.mselect__item${tour.id == ctx.relay.data.tour.id ? '.current' : ''}`,
{ attrs: { href: ctx.study.embeddablePath(`/broadcast/-/${tour.id}`) } },
tour.name,
),
h('label.fullscreen-mask', clickHook),
h(
'nav.mselect__list',
group.tours.map(tour =>
h(
`a.mselect__item${tour.id == ctx.relay.data.tour.id ? '.current' : ''}`,
{ attrs: { href: ctx.study.embeddablePath(`/broadcast/-/${tour.id}`) } },
tour.name,
),
),
]
),
]
: []),
],
);
Expand All @@ -259,49 +259,49 @@ const roundSelect = (relay: RelayCtrl, study: StudyCtrl) => {
]),
...(toggle()
? [
h('label.fullscreen-mask', clickHook),
h('label.fullscreen-mask', clickHook),
h(
'div.relay-tour__round-select__list.mselect__list',
h(
'div.relay-tour__round-select__list.mselect__list',
'table',
h(
'table',
h(
'tbody',
{
hook: bind('click', (e: MouseEvent) => {
const target = e.target as HTMLElement;
if (target.tagName != 'A')
site.redirect($(target).parents('tr').find('a').attr('href')!);
}),
},
relay.data.rounds.map((round, i) =>
h(`tr.mselect__item${round.id == study.data.id ? '.current-round' : ''}`, [
h(
'td.name',
h(
'a',
{ attrs: { href: study.embeddablePath(relay.roundUrlWithHash(round)) } },
round.name,
),
),
h(
'td.time',
round.startsAt
? commonDateFormat(new Date(round.startsAt))
: round.startsAfterPrevious
? `Starts after ${relay.data.rounds[i - 1]?.name || 'the previous round'}`
: '',
),
'tbody',
{
hook: bind('click', (e: MouseEvent) => {
const target = e.target as HTMLElement;
if (target.tagName != 'A')
site.redirect($(target).parents('tr').find('a').attr('href')!);
}),
},
relay.data.rounds.map((round, i) =>
h(`tr.mselect__item${round.id == study.data.id ? '.current-round' : ''}`, [
h(
'td.name',
h(
'td.status',
roundStateIcon(round, false) ||
(round.startsAt ? timeago(round.startsAt) : undefined),
'a',
{ attrs: { href: study.embeddablePath(relay.roundUrlWithHash(round)) } },
round.name,
),
]),
),
),
h(
'td.time',
round.startsAt
? commonDateFormat(new Date(round.startsAt))
: round.startsAfterPrevious
? `Starts after ${relay.data.rounds[i - 1]?.name || 'the previous round'}`
: '',
),
h(
'td.status',
roundStateIcon(round, false) ||
(round.startsAt ? timeago(round.startsAt) : undefined),
),
]),
),
),
),
]
),
]
: []),
],
);
Expand Down Expand Up @@ -344,48 +344,48 @@ const header = (ctx: RelayViewContext) => {
? h('img', { attrs: { src: d.tour.image } })
: ctx.study.members.isOwner()
? h(
'a.button.relay-tour__header__image-upload',
{ attrs: { href: `/broadcast/${d.tour.id}/edit` } },
'Upload tournament image',
)
'a.button.relay-tour__header__image-upload',
{ attrs: { href: `/broadcast/${d.tour.id}/edit` } },
'Upload tournament image',
)
: undefined,
),
]),
studyD && h('div.relay-tour__note.pinned', h('div', [h('div', { hook: richHTML(studyD, false) })])),
d.note &&
h(
'div.relay-tour__note',
h('div', [
h('div', { hook: richHTML(d.note, false) }),
h('small', 'This note is visible to contributors only.'),
]),
),
h(
'div.relay-tour__note',
h('div', [
h('div', { hook: richHTML(d.note, false) }),
h('small', 'This note is visible to contributors only.'),
]),
),
h('div.relay-tour__nav', [makeTabs(ctrl), ...subscribe(relay, ctrl)]),
];
};

const subscribe = (relay: RelayCtrl, ctrl: AnalyseCtrl) =>
defined(relay.data.isSubscribed)
? [
toggle(
{
name: 'Subscribe',
id: 'tour-subscribe',
title:
'Subscribe to be notified when each round starts. You can toggle bell or push ' +
'notifications for broadcasts in your account preferences.',
cls: 'relay-tour__subscribe',
checked: relay.data.isSubscribed,
change: (v: boolean) => {
xhr.text(`/broadcast/${relay.data.tour.id}/subscribe?set=${v}`, { method: 'post' });
relay.data.isSubscribed = v;
ctrl.redraw();
},
toggle(
{
name: 'Subscribe',
id: 'tour-subscribe',
title:
'Subscribe to be notified when each round starts. You can toggle bell or push ' +
'notifications for broadcasts in your account preferences.',
cls: 'relay-tour__subscribe',
checked: relay.data.isSubscribed,
change: (v: boolean) => {
xhr.text(`/broadcast/${relay.data.tour.id}/subscribe?set=${v}`, { method: 'post' });
relay.data.isSubscribed = v;
ctrl.redraw();
},
ctrl.trans,
ctrl.redraw,
),
]
},
ctrl.trans,
ctrl.redraw,
),
]
: [];

const makeTabs = (ctrl: AnalyseCtrl) => {
Expand All @@ -412,26 +412,26 @@ const makeTabs = (ctrl: AnalyseCtrl) => {
? makeTab('stats', 'Stats')
: ctrl.isEmbed
? h(
'a.relay-tour__tabs--open.text',
{
attrs: { href: relay.tourPath(), target: '_blank', 'data-icon': licon.Expand },
},
'Open in Lichess',
)
'a.relay-tour__tabs--open.text',
{
attrs: { href: relay.tourPath(), target: '_blank', 'data-icon': licon.Expand },
},
'Open in Lichess',
)
: undefined,
]);
};

const roundStateIcon = (round: RelayRound, titleAsText: boolean) =>
round.ongoing
? h(
'span.round-state.ongoing',
{ attrs: { ...dataIcon(licon.DiscBig), title: !titleAsText && 'Ongoing' } },
titleAsText && 'Ongoing',
)
'span.round-state.ongoing',
{ attrs: { ...dataIcon(licon.DiscBig), title: !titleAsText && 'Ongoing' } },
titleAsText && 'Ongoing',
)
: round.finished &&
h(
'span.round-state.finished',
{ attrs: { ...dataIcon(licon.Checkmark), title: !titleAsText && 'Finished' } },
titleAsText && 'Finished',
);
h(
'span.round-state.finished',
{ attrs: { ...dataIcon(licon.Checkmark), title: !titleAsText && 'Finished' } },
titleAsText && 'Finished',
);

0 comments on commit cfbc85b

Please sign in to comment.