Skip to content

Commit

Permalink
feat: Création de la page de speaker (#21)
Browse files Browse the repository at this point in the history
* feat: Page de speaker

* feat: Gestion de la page de speaker

* feat: Ajout de la photo des speakers

* test: Test sur les pages

* refactor: Renommage de la vue speakers en speakerList
  • Loading branch information
taorepoara authored Jun 2, 2023
1 parent 98f0d21 commit 4f3e90c
Show file tree
Hide file tree
Showing 17 changed files with 9,332 additions and 475 deletions.
2 changes: 1 addition & 1 deletion src/camping-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @property {string} key La clé du speaker
* @property {string} name Le nom du speaker
* @property {string} company L'entreprise du speaker
* @property {string} photoUrl L'url de la photo du speaker
* @property {string} photoURL L'url de la photo du speaker
* @property {Social[]} socials Les réseaux sociaux du speaker
*/

Expand Down
3 changes: 2 additions & 1 deletion src/index.gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export const views = {
}, toJSON: () => "pages.agenda"},
"map": "pages.map",
"session": "pages.session",
"speakers": "pages.speakers"
"speaker": "pages.speaker",
"speakerList": "pages.speakerList"
}
};
export const listeners = {
Expand Down
16 changes: 13 additions & 3 deletions src/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,26 @@ export const lenraRoutes = [
{
path: "/sessions/:key",
view: View(views.layout)
.props({
.props({
page: views.pages.session,
})
})
.context({
"pathParams": true
}),
},
{
path: "/speakers",
view: View(views.layout).props({ page: views.pages.speakers }),
view: View(views.layout).props({ page: views.pages.speakerList }),
},
{
path: "/speakers/:key",
view: View(views.layout)
.props({
page: views.pages.speaker,
})
.context({
"pathParams": true
}),
},
{
path: "/map",
Expand Down
Binary file modified src/resources/socials/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/resources/socials/twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 10 additions & 14 deletions src/utils/contentDescriber.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Flex, Flexible, Text, Wrap } from "@lenra/components";
import { Actionable, Flex, Flexible, Text, Wrap } from "@lenra/components";
import { LenraColors } from "@lenra/components/dist/colors.js";
import { Colors } from "@lenra/components/dist/colors.js";

/**
* Build a list of components from a list of content children generated by @moox/markdown-to-json
Expand Down Expand Up @@ -45,8 +44,6 @@ export function buildContentChildren(children) {
fontWeight: "bold",
});
case "p":
return Text("")
.children(buildContentChildren(child.children));
case "span":
return Text("")
.children(buildContentChildren(child.children));
Expand Down Expand Up @@ -82,18 +79,17 @@ export function buildContentChildren(children) {
])
.spacing(8);
case "a":
console.warn("Link are not supported yet", child);
// return Actionable(Text("")
// .children(buildContentChildren(child.children)))
// .onPressed("@lenra:navTo", { path: child.props.href });
const children = buildContentChildren(child.children);
if (children.length === 0) return null;
return Text("")
.children(children)
.style({
color: LenraColors.bluePulse,
decoration: "underline"
});
return Actionable(
Text("")
.children(children)
.style({
color: LenraColors.bluePulse,
decoration: "underline"
})
)
.onPressed("@lenra:navTo", { path: child.props.href });
default:
console.warn("Unknown tag", child.tag);
return Wrap(buildContentChildren(child.children));
Expand Down
2 changes: 1 addition & 1 deletion src/views/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function (_data, { page/* , context */ }, context) {
Container(
pageView
)
.maxWidth(page === views.pages.speakers ? 1600 : 800)
.maxWidth(page === views.pages.speakerList ? 1600 : 800)
])
.direction("vertical")
.padding(padding.symmetric(32, 16))
Expand Down
4 changes: 2 additions & 2 deletions src/views/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const navButtons = [
{
icon: "group",
path: "/speakers",
pages: [views.pages.speakers],
pages: [views.pages.speakerList, views.pages.speaker],
},
{
icon: "map",
Expand All @@ -39,7 +39,7 @@ export default function (_data, { page }) {
.padding(padding.all(20))
.color(pages.includes(page) ? colors.opacity(colors.Colors.white, 0.2) : colors.Colors.transparentMask)
)
.onPressed("@lenra:navTo", { path })
.onPressed("@lenra:navTo", { path })
)
)
.mainAxisAlignment("center")
Expand Down
19 changes: 14 additions & 5 deletions src/views/pages/agenda.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ function sessionCard(session) {
.filter(speaker => speaker in speakers)
.map(speaker => View(views.pages.agenda.speaker).props({ speaker }))
)
.direction("vertical"),
.direction("vertical")
.spacing(8),
Flex([
Text(`${session.attributes.time} - ${session.attributes.duration}`),
Text(`${session.attributes.time} - ${session.attributes.duration}`)
,
Text(rooms[session.attributes.room].name),
])
.direction("vertical"),
Expand All @@ -78,11 +80,18 @@ export function speaker(_data, props) {
return Text("Speaker not found");
}
return Flex([
// Image(speaker.attributes.photoURL),
Image(speaker.attributes.photoURL ?? "")
.width(40)
.height(40),
Flex([
Text(speaker.attributes.name),
Text(speaker.attributes.company ?? ""),
Text(speaker.attributes.name)
.style({
fontWeight: "bold",
}),
Text(speaker.attributes.company ?? "")
])
.direction("vertical")
])
.spacing(16)
.crossAxisAlignment("center")
}
9 changes: 7 additions & 2 deletions src/views/pages/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ function body(session) {
function speakerList(session) {
const cards = session.attributes.speakers
.filter(speaker => speaker in speakers)
.map(speaker => View(views.pages.agenda.speaker).props({ speaker }));
if (cards.length > 1)
.map(speaker =>
Actionable(
View(views.pages.agenda.speaker).props({ speaker })
)
.onPressed("@lenra:navTo", { path: `/speakers/${speaker}` })
);
if (cards.length > 0)
return [Wrap(cards).spacing(16)];
return cards;
}
100 changes: 100 additions & 0 deletions src/views/pages/speaker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { Actionable, Container, Flex, Flexible, Image, Text, Wrap, colors } from "@lenra/components";
import { sessions, speakers } from "../../camping-data.js";
import { buildContentChildren } from "../../utils/contentDescriber.js";

export default function (_data, /* _props, */{ context: { pathParams } }) {
const speaker = speakers[pathParams.key];
return Flex([
header(speaker),
...body(speaker),
...sessionList(speaker),
])
.direction("vertical")
.spacing(16)
.crossAxisAlignment("stretch")
}

/**
* @param {Speaker} speaker
* @returns
*/
function header(speaker) {
const children = [
Text(speaker.attributes.name)
.style({
fontSize: 24,
fontWeight: "bold",
})
];
if (speaker.attributes.company) {
children.push(Text(speaker.attributes.company)
.style({
fontSize: 20,
fontWeight: "bold",
}));
}
const flex = Flex(children)
.direction("vertical")
if (speaker.attributes.photoURL) {
return Wrap([
Image(speaker.attributes.photoURL)
.width(100)
.height(100),
flex
])
.spacing(16)
.alignment("center")
.crossAxisAlignment("center")
.runAlignment("center")
.runSpacing(16);
}
return flex;
}

/**
* @param {Speaker} speaker
* @returns
*/
function body(speaker) {
const children = buildContentChildren(speaker.children);
if (children.length > 1)
return [Flex(children).direction("vertical").spacing(8)];
return children;
}

/**
* @param {Speaker} speaker
* @returns
*/
function sessionList(speaker) {
const elements = Object.values(sessions)
.filter(session => session.attributes.speakers.includes(speaker.attributes.key))
.sort((a, b) => a.attributes.day - b.attributes.day || a.attributes.time.localeCompare(b.attributes.time))
.map(session =>
Actionable(
Flex([
Text("•"),
Flexible(Text(session.attributes.title)),
])
.spacing(8)
.crossAxisAlignment("center")
)
.onPressed("@lenra:navTo", { path: `/sessions/${session.attributes.key}` })
);
if (elements.length === 0) return [];
return [
Container(
Text("")
)
.color(colors.Colors.black)
.height(1),
Text("Séances")
.style({
fontSize: 20,
fontWeight: "bold",
}),
Flex(elements)
.spacing(16)
.direction("vertical")
];
}
69 changes: 69 additions & 0 deletions src/views/pages/speakerList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { Actionable, Container, Flex, Image, Text, Wrap, borderRadius } from "@lenra/components";
import { speakers } from "../../camping-data.js";

export default function (_data, _props) {
const sortedSpeakers = Object.values(speakers).sort((a, b) => a.attributes.name.localeCompare(b.attributes.name));
return Wrap(
sortedSpeakers.map(speaker =>
Actionable(
Container.card(
Flex([
Flex([
Text(speaker.attributes.name)
.style({
fontSize: 20,
fontWeight: "bold",
}),
Text(speaker.attributes.company ?? ""),
])
.direction("vertical")
.crossAxisAlignment("stretch"),
Container(
Image(speaker.attributes.photoURL ?? "")
.width(150)
.height(150)
.fit("cover")
.filterQuality("high")
.loadingPlaceholder(Text("Loading image..."))
.errorPlaceholder(Text("Failed to load image")),
)
.width(150)
.height(150)
.borderRadius(borderRadius.all(75))
// TODO: manage clip Behaviour, see https://github.com/lenra-io/lenra_cli/issues/270
.alignment("center"),
Container(
// Manage socials
Flex(
speaker.attributes.socials?.map(social =>
// TODO: manage link
Actionable(
Image(`socials/${social.icon}.png`)
.width(24)
.height(24)
.filterQuality("high")
)
.onPressed("@lenra:navTo", { path: social.link })
)
)
.spacing(16)
)
.height(24)
.alignment("center"),
])
.direction("vertical")
.mainAxisAlignment("spaceBetween")
.crossAxisAlignment("center")
.fillParent(true)
)
.width(276)
.height(276)
)
.onPressed("@lenra:navTo", { path: `/speakers/${speaker.attributes.key}` })
)
)
.runAlignment("spaceAround")
.spacing(32)
.runSpacing(32)
}

Loading

0 comments on commit 4f3e90c

Please sign in to comment.