Skip to content

Commit 7897035

Browse files
committed
feat(web): add support for sponsored sessions
1 parent 39f8821 commit 7897035

9 files changed

Lines changed: 60 additions & 3 deletions

File tree

‎docs/default-firebase-data.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
"language": "English",
151151
"presentation": "https://speakerdeck.com/gdglviv/mete-atamel-windows-and-net-on-google-cloud-platform",
152152
"speakers": ["mete_atamel", "adrian_kajda"],
153+
"sponsor": "Google",
153154
"tags": ["Cloud"],
154155
"title": "Windows and .NET on Google Cloud Platform ",
155156
"day": "2016-09-09",

‎packages/storage/schemas/firestore.schema.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@
243243
"type": "array",
244244
"items": { "type": "string" }
245245
},
246+
"sponsor": {
247+
"description": "The sponsor's name, for a session given to a sponsor. The schedule labels it as sponsored.",
248+
"type": "string"
249+
},
246250
"startTime": {
247251
"description": "When the session starts, in the event time zone.",
248252
"$ref": "#/$defs/time"

‎packages/translations/source/en.xlf‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@
281281
<trans-unit id="schedule.tabs.day">
282282
<source>Day <x id="0" equiv-text="${index + 1}"/></source>
283283
</trans-unit>
284+
<trans-unit id="schedule.session.sponsored">
285+
<source>Sponsored</source>
286+
</trans-unit>
284287
<trans-unit id="schedule.session.rate">
285288
<source>Rate <x id="0" equiv-text="${session.title}"/></source>
286289
</trans-unit>
@@ -680,6 +683,9 @@
680683
<trans-unit id="pages.session.details">
681684
<source>Session details</source>
682685
</trans-unit>
686+
<trans-unit id="pages.session.sponsored-by">
687+
<source>Sponsored by <x id="0" equiv-text="${session.sponsor}"/></source>
688+
</trans-unit>
683689
<trans-unit id="pages.session.bookmarked">
684690
<source>Bookmarked</source>
685691
</trans-unit>

‎packages/web/src/components/schedule/session-element.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ describe('session-element', () => {
9191
);
9292
});
9393

94+
it('labels a sponsored session before its tags', async () => {
95+
const { shadowRoot } = await render({ session: { ...session, sponsor: 'Acme' } });
96+
const chips = [...shadowRoot.querySelectorAll('.chips hb-chip')];
97+
98+
expect(chips.map((chip) => chip.textContent?.trim())).toEqual(['Sponsored', 'Web', 'Cloud']);
99+
expect(chips[0]).toHaveAttribute('accent', '1');
100+
});
101+
102+
it('labels a sponsored session without tags', async () => {
103+
const { shadowRoot } = await render({
104+
session: { ...session, tags: [], sponsor: 'Acme' },
105+
});
106+
107+
expect(shadowRoot.querySelector('.chips')).toHaveTextContent('Sponsored');
108+
});
109+
94110
it('skips a speaker that does not exist', async () => {
95111
const { shadowRoot } = await render({
96112
session: { ...session, speakers: [...session.speakers!, { id: 12 }] } as never,

‎packages/web/src/components/schedule/session-element.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,18 @@ export class SessionElement extends ThemedElement {
204204
style="${styleMap({ '--stripe': session.mainTag ? tagColor(session.mainTag) : undefined })}"
205205
>
206206
${
207-
session.tags?.length
207+
session.sponsor || session.tags?.length
208208
? html`<ul class="chips">
209-
${session.tags.map(
209+
${
210+
session.sponsor
211+
? html`<li>
212+
<hb-chip class="sponsored" accent="1">
213+
${msg('Sponsored', { id: 'schedule.session.sponsored' })}
214+
</hb-chip>
215+
</li>`
216+
: nothing
217+
}
218+
${(session.tags ?? []).map(
210219
(tag) =>
211220
html`<li><hb-chip style="${styleMap(tagChipStyle(tag))}">${tag}</hb-chip></li>`,
212221
)}

‎packages/web/src/models/session.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('session', () => {
1616
'language',
1717
'presentation',
1818
'speakers',
19+
'sponsor',
1920
'startTime',
2021
'tags',
2122
'title',

‎packages/web/src/models/session.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export interface SessionData {
1212
presentation?: string;
1313
speakers?: string[];
1414
source?: string;
15+
/** The sponsor's name, for a session given to a sponsor. The schedule labels it as sponsored. */
16+
sponsor?: string;
1517
startTime?: string;
1618
tags?: string[];
1719
title: string;

‎packages/web/src/views/session-page.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ describe('session-page', () => {
119119
]);
120120
});
121121

122+
it('names the sponsor of a sponsored session', async () => {
123+
vi.mocked(selectSession).mockReturnValue({ ...session, sponsor: 'Acme' } as never);
124+
const { shadowRoot } = await render();
125+
126+
expect(shadowRoot.querySelector('.details .sponsored')).toHaveTextContent('Sponsored by Acme');
127+
});
128+
122129
it('leaves out the language when the session has none', async () => {
123130
vi.mocked(selectSession).mockReturnValue({ ...session, language: undefined } as never);
124131
const { shadowRoot } = await render();

‎packages/web/src/views/session-page.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Success } from '@abraham/remotedata';
2-
import { msg } from '@lit/localize';
2+
import { msg, str } from '@lit/localize';
33
import { css, html, nothing, type PropertyValues } from 'lit';
44
import { customElement, property, state } from 'lit/decorators.js';
55
import { styleMap } from 'lit/directives/style-map.js';
@@ -197,6 +197,17 @@ export class SessionPage extends ThemedElement {
197197
return html`
198198
<ul class="details" aria-label="${msg('Session details', { id: 'pages.session.details' })}">
199199
${details.map((detail) => html`<li><hb-chip class="plain">${detail}</hb-chip></li>`)}
200+
${
201+
session.sponsor
202+
? html`<li>
203+
<hb-chip class="sponsored" accent="1">
204+
${msg(str`Sponsored by ${session.sponsor}`, {
205+
id: 'pages.session.sponsored-by',
206+
})}
207+
</hb-chip>
208+
</li>`
209+
: nothing
210+
}
200211
${(session.tags ?? []).map(
201212
(tag) => html`<li><hb-chip style="${styleMap(tagChipStyle(tag))}">${tag}</hb-chip></li>`,
202213
)}

0 commit comments

Comments
 (0)