Skip to content

Commit

Permalink
content(feat): launch design system .italia v1 (1429)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Daniele Nolè <102873965+danielenole@users.noreply.github.com>
  • Loading branch information
Fupete and danielenole authored Oct 22, 2024
1 parent f2f4b39 commit bb1d911
Show file tree
Hide file tree
Showing 18 changed files with 1,003 additions and 100 deletions.
28 changes: 14 additions & 14 deletions src/components/highlight/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Highlight({

const classes =
"highlight-content d-lg-flex" +
`${specular ? " flex-lg-row-reverse" : ""}` +
`${!specular ? " flex-lg-row-reverse" : ""}` +
`${reversedMobile ? " d-flex flex-column-reverse" : ""}` +
`${img || overlayImg ? "" : " no-image"}`;

Expand Down Expand Up @@ -76,19 +76,6 @@ function Highlight({
<div className="row">
<div className="col-12 g-0">
<div className={classes}>
<div className={ratioClass}>
{img && (
<ImageResponsive className="main-image" src={img} alt={alt} />
)}
{icon && <Icon {...icon} />}
{overlayImg && (
<ImageResponsive
src={overlayImg}
alt={overlayAlt}
className="overlay-image"
/>
)}
</div>
<div className="text-container px-3 py-5 px-lg-5 py-lg-6">
<HLevel id={id}>{title}</HLevel>
{subtitle && <p className="lead mb-4">{subtitle}</p>}
Expand All @@ -103,6 +90,19 @@ function Highlight({
)}
{children}
</div>
<div className={ratioClass}>
{img && (
<ImageResponsive className="main-image" src={img} alt={alt} />
)}
{icon && <Icon {...icon} />}
{overlayImg && (
<ImageResponsive
src={overlayImg}
alt={overlayAlt}
className="overlay-image"
/>
)}
</div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/highlight/highlight.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
}
.text-container {
padding: var(--hl-y-padding-desk) var(--hl-x-padding-desk);
flex-grow: 1;
flex-grow: 1;
}
&.highlight-big {
.img-container {
Expand Down
27 changes: 24 additions & 3 deletions src/components/media-player/media-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ import ReactMarkdown from "react-markdown";
// - [future] modular approach for local videos/youtubes/...
// - [future] download thumbnail during build - eg. url: http://i3.ytimg.com/vi/_0j7ZQ67KtY/hqdefault.jpg

function MediaPlayerEl({ url, lang, subtitles, trascription, poster }) {
function MediaPlayerEl({
url,
lang,
subtitles,
trascription,
trascriptionLabel,
trascriptionLabelEN,
trascriptionHeadingLevel,
poster,
}) {
const messages = {
it: {
rememberLabel: "Ricorda per tutti i video",
Expand All @@ -27,11 +36,23 @@ function MediaPlayerEl({ url, lang, subtitles, trascription, poster }) {
},
};

// trascription label
if (trascriptionLabel) messages.it.trascriptionLabel = trascriptionLabel;
if (trascriptionLabelEN) messages.en.trascriptionLabel = trascriptionLabelEN;

let video = null;
const t = (key) => messages[lang][key];

const videoId = `video-js-${uniqueId("id_")}`;

// trascription heading level
let HLevel;
if (trascriptionHeadingLevel) {
HLevel = `h${trascriptionHeadingLevel}`;
} else {
HLevel = `h2`;
}

useEffect(() => {
// eslint-disable-next-line no-new
new AcceptOverlay(document.getElementById(`${videoId}-accept-video`), {
Expand Down Expand Up @@ -116,7 +137,7 @@ function MediaPlayerEl({ url, lang, subtitles, trascription, poster }) {
</div>
<div className="vjs-transcription accordion">
<div className="accordion-item">
<h2 className="accordion-header " id="transcription-head9">
<HLevel className="accordion-header " id="transcription-head9">
<button
className="accordion-button collapsed"
type="button"
Expand All @@ -127,7 +148,7 @@ function MediaPlayerEl({ url, lang, subtitles, trascription, poster }) {
>
{t("trascriptionLabel")}
</button>
</h2>
</HLevel>
{trascription && (
<div
id={`${videoId}-transcription`}
Expand Down
122 changes: 122 additions & 0 deletions src/components/section-media/section-media.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import classNames from "classnames";
import * as React from "react";
import "./section-media.scss";
import Button from "../button/button";
import CookieRemove from "../cookieremove/cookieremove";
import MediaPlayer from "../media-player/media-player";

function SectionMedia({
title,
hiddenSectionTitle,
headingLevel,
text,
buttons,
full,
centered,
fullColumn,
paddingLeft,
background,
components,
menu,
noSpace,
id,
}) {
const SwitchComponents = {
CookieRemove,
MediaPlayer,
};

// heading level
let HLevel;
if (headingLevel) {
HLevel = `h${headingLevel}`;
} else {
HLevel = `h2`;
}

const container = classNames({
"fullcolumn-editorial": fullColumn,
"container-xxl": !fullColumn,
});

const row = classNames({
row: !fullColumn,
"flex-lg-row-reverse": menu && !fullColumn,
});

const grid = classNames({
"col-12 g-0": full && !fullColumn,
"col-md-10 offset-md-1 col-lg-8 offset-lg-0": full && menu && !fullColumn,
"col-12 col-md-10 offset-md-1 col-lg-7 offset-lg-1": !full && !fullColumn,
"m-auto": !full && centered && !fullColumn,
});

const styles = classNames("section-media", {
[`bg-${background}`]: background,
"py-0": noSpace,
"text-white": background === "dark",
"ps-lg-4 ps-xl-5": paddingLeft,
});

const titleStyles = classNames({
"mb-1": text,
"mb-0": !text,
"visually-hidden": hiddenSectionTitle,
});

const textContainerStyles = "text-container px-3 px-lg-5 text-center pb-5";
const textStyles = "text-container mb-5 d-flex justify-content-center";
const textStylesP = "lead font-sans-serif mb-auto text-center";

// buttons
let ButtonsRender;
if (buttons) {
ButtonsRender = buttons.map((btn, index) => (
<Button key={`button-${index}`} {...btn} />
));
}

// xxx a11y downgrade if title is not set, quick fix to review asap
if (!title) {
// eslint-disable-next-line no-param-reassign
id = undefined;
}

return (
<section className={styles} aria-labelledby={id}>
<div className={container}>
<div className={row}>
<div className={grid}>
<div>
<div className={textContainerStyles}>
{title && (
<HLevel className={titleStyles} id={id}>
{title}
</HLevel>
)}
{text && (
<div className={textStyles}>
<p className={textStylesP}>{text}</p>
</div>
)}
{ButtonsRender && (
<div className="buttons-wrapper mt-5">
<div>{ButtonsRender}</div>
</div>
)}
</div>
<div className="img-container">
{components?.map((item, index) => {
const Switcher = SwitchComponents[item.name];
return <Switcher key={`switcher-${index}`} {...item} />;
})}
</div>
</div>
</div>
</div>
</div>
</section>
);
}

export default SectionMedia;
66 changes: 66 additions & 0 deletions src/components/section-media/section-media.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@import "../../scss/bootstrap-breakpoints";

.section-media {
padding-top: var(--section-editorial-y-padding);
padding-bottom: var(--section-editorial-y-padding);

&.bg-primary-light {
background-color: var(--color-primary-light);
}

}

//Mobile only ------------------------------------------------------------------------------------------
@include media-breakpoint-down(sm) {}

//Small tablet ------------------------------------------------------------------------------------------
@include media-breakpoint-up(sm) {}

//Tablet portrait ---------------------------------------------------------------------------------------
@include media-breakpoint-up(md) {}

//Tablet landscape --------------------------------------------------------------------------------------
@include media-breakpoint-up(lg) {
.section-media {
padding-top: var(--section-editorial-y-padding-desk);
padding-bottom: var(--section-editorial-y-padding-desk);

&.highlight-big {
.img-container {
width: 50%;
}
}
}

.design-system .section-media {

h2,
.text-container p {
width: 75%;
}

.content h2 {
width: inherit;
}
}
}

//Laptop ------------------------------------------------------------------------------------------------
@include media-breakpoint-up(xl) {
.section-media {
&.highlight-big {
.img-container {
width: 50%;
}
}
}
}

//Desktop -----------------------------------------------------------------------------------------------
@include media-breakpoint-up(xxl) {}

//Hover states ------------------------------------------------------------------------------------------
@media (hover: hover) {}

//Transitions (A11y reduced motion disabled) ------------------------------------------------------------
@media screen and (prefers-reduced-motion: no-preference) {}
Loading

0 comments on commit bb1d911

Please sign in to comment.