HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
- var categories=[{id:1,name:"Activities"},{id:2,name:"Frontend"},{id:3,name:"Backend"},{id:4,name:"QA"},{id:5,name:"Mobile"},{id:6,name:"Teamlead"},{id:7,name:"Future"}];
- var schedule=[{date:"30 March",periods:[{timeStart:"10:30",timeEnd:"10:45",status:"completed",events:[{title:"Grand opening",link:"#",categoryId:1,speakerName:"",speakerImage:"",speakerCompany:"",location:"Hall #1",isAddedToFavorites:!1,backgroundId:1}]},{timeStart:"10:50",timeEnd:"11:30",status:"completed",events:[{title:"Тренды невозможного",link:"#",categoryId:7,speakerName:"Евгений Черешнев",speakerImage:"https://2019.codefest.ru/upload/members/photo_1548787955_200.jpg",speakerCompany:"Biolink.Tech",location:"Hangar",isAddedToFavorites:!0,backgroundId:""},{title:"Рефакторинг: договариваемся, планируем, внедряем!",link:"#",categoryId:6,speakerName:"Алексей Катаев",speakerImage:"https://2019.codefest.ru/upload/members/photo_1547747987_200.jpg",speakerCompany:"Skyeng",location:"Hall #3",isAddedToFavorites:!1,backgroundId:""},{title:"Code Battle",link:"#",categoryId:1,speakerName:"",speakerImage:"",speakerCompany:"",location:"Wrike stand",isAddedToFavorites:!0,backgroundId:2},{title:"May the F[_] be with You. Функциональный подход к проектированию API",link:"#",categoryId:3,speakerName:"Иван Фастов",speakerImage:"https://2019.codefest.ru/upload/members/photo_1551973214_200.jpg",speakerCompany:"Тинькофф",location:"Hall #4",isAddedToFavorites:!1,backgroundId:""}]},{timeStart:"11:00",timeEnd:"11:30",status:"completed",events:[{title:"Просмотр фильма о дизайнерах-маньяках",link:"#",categoryId:1,speakerName:"",speakerImage:"",speakerCompany:"",location:"Yandex stand",isAddedToFavorites:!1,backgroundId:3}]},{timeStart:"11:50",timeEnd:"12:30",status:"active",events:[{title:"Сжимаем Javascript по-взрослому",link:"#",categoryId:2,speakerName:"Алексей Золотых",speakerImage:"https://2019.codefest.ru/upload/members/photo_1552416059_200.jpg",speakerCompany:"Infobip",location:"Hall #2",isAddedToFavorites:!0,backgroundId:""},{title:"Context: The missing ingredient in multilingual software translation",link:"#",categoryId:4,speakerName:"Mirjana Andovska",speakerImage:"https://2019.codefest.ru/upload/members/photo_1546541112_200.jpg",speakerCompany:"Netcetera",location:"Hall #1",isAddedToFavorites:!1,backgroundId:""},{title:"iOS. Переход на тёмную сторону",link:"#",categoryId:5,speakerName:"Антон Спивак",speakerImage:"https://2019.codefest.ru/upload/members/photo_1550597366_200.jpg",speakerCompany:"ВКонтакте",location:"Hall #7",isAddedToFavorites:!1,backgroundId:""}]},{timeStart:"12:30",timeEnd:"13:00",status:"coming",events:[{title:"Wrike Garage game",link:"#",categoryId:1,speakerName:"",speakerImage:"",speakerCompany:"",location:"Wrike stand",isAddedToFavorites:!1,backgroundId:4}]},{timeStart:"13:00",timeEnd:"13:50",status:"coming",events:[{title:"Forward-looking city making",link:"#",categoryId:7,speakerName:"Daniela Allmeier",speakerImage:"https://2019.codefest.ru/upload/members/photo_1549301703_200.jpg",speakerCompany:"RAUMPOSITION",location:"Hangar",isAddedToFavorites:!1,backgroundId:""},{title:"Эффективные 1-на-1",link:"#",categoryId:6,speakerName:"Георгий Могелашвили",speakerImage:"https://2019.codefest.ru/upload/members/photo_1545919642_200.jpg",speakerCompany:"Booking.com",location:"Hall #3",isAddedToFavorites:!1,backgroundId:""},{title:"Инструментирование Go кода",link:"#",categoryId:3,speakerName:"Максим Чечель",speakerImage:"https://2019.codefest.ru/upload/members/photo_1550689359_200.jpg",speakerCompany:"Juno",location:"Hall #4",isAddedToFavorites:!1,backgroundId:""}]}]},{date:"31 March",periods:[{timeStart:"10:30",timeEnd:"11:20",status:"coming",events:[{title:"Beyond Web-Apps: WebAssembly, JS and React to rewrite native apps",link:"#",categoryId:2,speakerName:"Florian Rival",speakerImage:"https://2019.codefest.ru/upload/members/photo_1548181969_200.jpg",speakerCompany:"Facebook",location:"Hall #5",isAddedToFavorites:!0,backgroundId:""},{title:"Как превратить QA команду в руины?",link:"#",categoryId:4,speakerName:"Юлия Долбилова",speakerImage:"https://2019.codefest.ru/upload/members/photo_1547744684_200.jpg",speakerCompany:"Додо Пицца",location:"Hall #6",isAddedToFavorites:!1,backgroundId:""},{title:"iOS. Функциональный Swift — это просто",link:"#",categoryId:5,speakerName:"Евгений Ёлчев",speakerImage:"https://2019.codefest.ru/upload/members/photo_1547748822_200.jpg",speakerCompany:"RedMadRobot",location:"Hall #7",isAddedToFavorites:!1,backgroundId:""}]},{timeStart:"11:00",timeEnd:"11:30",status:"coming",events:[{title:"SberQuiz",link:"#",categoryId:1,speakerName:"",speakerImage:"",speakerCompany:"",location:"Sberbank stand",isAddedToFavorites:!1,backgroundId:5}]},{timeStart:"11:30",timeEnd:"12:20",status:"coming",events:[{title:"Эволюция цифрового общения",link:"#",categoryId:7,speakerName:"Виктор Иванов",speakerImage:"https://2019.codefest.ru/upload/members/photo_1550080274_200.jpg",speakerCompany:"ВКонтакте",location:"Hangar",isAddedToFavorites:!1,backgroundId:""},{title:"Terraform на примере кластера Selenoid",link:"#",categoryId:4,speakerName:"Леонид Руденко",speakerImage:"https://2019.codefest.ru/upload/members/photo_1548440624_200.jpg",speakerCompany:"JetBrains",location:"Hall #6",isAddedToFavorites:!1,backgroundId:""},{title:"Android. Instant Apps — два года спустя",link:"#",categoryId:5,speakerName:"Евгений Сатуров",speakerImage:"https://2019.codefest.ru/upload/members/photo_1547746474_200.jpg",speakerCompany:"Surf",location:"Hall #7",isAddedToFavorites:!1,backgroundId:""}]},{timeStart:"12:00",timeEnd:"12:30",status:"coming",events:[{title:"Hundred to One",link:"#",categoryId:1,speakerName:"",speakerImage:"",speakerCompany:"",location:"VK stand",isAddedToFavorites:!0,backgroundId:6}]},{timeStart:"12:30",timeEnd:"13:20",status:"coming",events:[{title:"Ultimate React Component Patterns with TypeScript",link:"#",categoryId:2,speakerName:"Martin Hochel",speakerImage:"https://2019.codefest.ru/upload/members/photo_1548267264_200.jpg",speakerCompany:"Twisto.cz, ngParty",location:"Hall #5",isAddedToFavorites:!1,backgroundId:""},{title:"Тестирование мусорными данными с libFuzzer",link:"#",categoryId:4,speakerName:"Дмитрий Тримонов",speakerImage:"https://2019.codefest.ru/upload/members/photo_1548953275_200.jpg",speakerCompany:"2ГИС",location:"Hall #6",isAddedToFavorites:!1,backgroundId:""},{title:"iOS. Rx в современной мобильной разработке. Есть ли смысл?",link:"#",categoryId:5,speakerName:"Евгений Сатуров",speakerImage:"https://2019.codefest.ru/upload/members/photo_1550598154_200.jpg",speakerCompany:"Яндекс",location:"Hall #7",isAddedToFavorites:!1,backgroundId:""}]},{timeStart:"13:30",timeEnd:"13:45",status:"coming",events:[{title:"Сlosing and awarding of the winners",link:"#",categoryId:1,speakerName:"",speakerImage:"",speakerCompany:"",location:"Hall #1",isAddedToFavorites:!1,backgroundId:7}]}]}];
.app
//- offcanvas
.app__offcanvas.offcanvas(
id="offcanvas"
aria-hidden="true")
.offcanvas__overlay(
tabindex="-1"
data-micromodal-close)
//- sidepanel
.offcanvas__panel.sidepanel(
role="dialog"
aria-labelledby="navigation-title"
data-micromodal-dialog)
.sidepanel__container
h2.visually-hidden(
id="navigation-title") Navigation
svg.sidepanel__logo(
height="61" viewBox="0 0 54 61"
role="img"
aria-label="Codefest logo")
path(
fill="#33a7d8"
d="M39.4.31L8.15 16.34V49.7l3.4 1.2v8.81L17.5 53l22.2 7.86a2.5 2.5 0 003.3-2.4V2.58A2.48 2.48 0 0039.4.31")
path(
d="M32.12 17.8L2.83 14.02c-1.5-.2-2.83 1-2.83 2.54v31.88c0 1.5 1.26 2.68 2.73 2.55l29.3-2.61A2.18 2.18 0 0034 46.19V20c0-1.12-.8-2.05-1.88-2.19")
path(
fill="#fff"
d="M22.81 40.22c0 1.8-1.19 2.71-2.49 2.8-1.03.08-1.84-.11-2.4-.57v-2.48c.6.6 1.58.96 2.31.92.45-.03.68-.3.68-.57 0-1.06-3.05-.53-3.05-3.31 0-1.68 1-2.7 2.6-2.7a2.9 2.9 0 012.06.75v2.32c-.62-.58-1.28-.99-1.98-.97-.42 0-.63.29-.63.56 0 .96 2.9.25 2.9 3.25zM26 34.49l1.28-.01v2.07l-1.28.03v2.83c0 .69.17.94.6.92.23-.01.46-.12.68-.31v2.04c-.3.33-.73.52-1.28.56-1.05.07-1.79-.8-1.8-2.5v-3.5l-.92.02V34.5h.92v-2.16l1.8.03v2.12zM3.7 32.77l7.1.06v2.62l-4.61.05v1.87l3.47-.08v2.54l-3.47.15v3.84L3.7 44V32.77zm9.3 5.29c.09-1 .5-1.63 1.07-1.64.52 0 .95.63.96 1.57l-2.03.07zm1.17-3.74c-2.14 0-3.32 2.15-3.32 4.7 0 2.97 1.54 4.58 3.5 4.44a3.26 3.26 0 002.38-1.07v-2.28c-.62.52-1.27.8-1.92.84-.88.05-1.6-.36-1.8-1.27l4.05-.17v-.74c0-2.44-1-4.45-2.89-4.45zm-3.38-8.09v3.1a4.04 4.04 0 01-2.87 1.05c-2.7-.07-4.92-2.42-4.92-6 0-3.56 2.18-5.64 4.9-5.35a4.4 4.4 0 012.74 1.33v2.93a4.1 4.1 0 00-2.7-1.46c-1.4-.12-2.56.95-2.56 2.7 0 1.83 1.2 2.98 2.64 3.05a3 3 0 002.77-1.35zm17-.24c.06-.88.39-1.4.84-1.37.4.03.75.63.76 1.47l-1.6-.1zm3.2.96c0-2.17-.8-4.05-2.29-4.2-1.7-.15-2.62 1.66-2.62 3.92v.25c.01.31.04.61.09.9v.04l.03.15c.34 1.82 1.38 2.85 2.64 2.89.88.02 1.45-.24 1.9-.75v-2.04c-.5.42-1.01.62-1.53.6a1.45 1.45 0 01-1.42-1.28l3.21.17v-.65zm-8.7 1.5c-.67-.02-1.14-.91-1.14-2.08 0-1.16.47-2 1.14-1.94.48.03.82.37 1.07 1v2.15c-.24.6-.59.9-1.06.88zm1.07 2.1l1.82.05-.01-10.3-1.82-.2v3.27c-.37-.78-.91-1.2-1.6-1.27-1.57-.14-2.54 1.88-2.53 4.16 0 2.27.94 4.42 2.53 4.46.7.01 1.24-.34 1.61-1.08v.91zm-8.15-2.42c-.78-.03-1.35-.96-1.35-2.2 0-1.19.57-2.09 1.34-2.03.77.06 1.32 1.02 1.32 2.2 0 1.2-.55 2.06-1.31 2.03zm0-6.64c-2-.2-3.49 1.67-3.49 4.32 0 2.6 1.43 4.69 3.49 4.74 1.99.05 3.3-1.86 3.3-4.34 0-2.5-1.37-4.54-3.3-4.72z")
nav.sidepanel__menu.menu(
aria-label="Main")
ul.menu__list
li.menu__item
a.menu__link.menu__link--active(
href="#") Schedule
li.menu__item
a.menu__link(
href="#") Map
li.menu__item
a.menu__link(
href="#") Notifications
li.menu__item
a.menu__link(
href="#") Updates
.sidepanel__user.user
img.user__image(
src="https://randomuser.me/api/portraits/women/13.jpg"
width="48" height="48"
alt="")
.user__name
span.visually-hidden Username:
| snowflake
button.user__button Sign out
button.sidepanel__theme-switcher.theme-switcher(
type="button"
aria-label="Switch to dark theme")
svg.theme-switcher__icon(
width="16" height="16" viewBox="0 0 512 512"
aria-hidden="true")
path.theme-switcher__icon-sun(
d="M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z")
path.theme-switcher__icon-moon(
d="M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z")
button.sidepanel__close-button.visually-hidden-focusable(
type="button"
data-micromodal-close) Close navigation
//- content
.app__content.js-app-content
//- header
header.app__header.header
button.header__button.header__button-nav(
type="button"
aria-label="Open navigation"
data-micromodal-trigger="offcanvas")
span.header__button-icon.burger
span.burger__bar
button.header__button.header__button-search(
type="button"
aria-label="Open search field")
svg.header__button-icon(
width="16" height="16" viewBox="0 0 512 512"
aria-hidden="true")
path(
d="M508.5 468.9L387.1 347.5c-2.3-2.3-5.3-3.5-8.5-3.5h-13.2c31.5-36.5 50.6-84 50.6-136C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c52 0 99.5-19.1 136-50.6v13.2c0 3.2 1.3 6.2 3.5 8.5l121.4 121.4c4.7 4.7 12.3 4.7 17 0l22.6-22.6c4.7-4.7 4.7-12.3 0-17zM208 368c-88.4 0-160-71.6-160-160S119.6 48 208 48s160 71.6 160 160-71.6 160-160 160z")
h1.header__title Schedule
//- filters
fieldset.content__filters.filters
legend.visually-hidden
h2 Events display filter
.filters__wrapper
.filters__container
.filters__item
input.filters__input.js-filter(
id="filter-all"
type="radio"
name="filter"
value=""
checked)
label.filters__button(
for="filter-all") All
.filters__item
input.filters__input.js-filter(
id="filter-favorites"
type="radio"
name="filter"
value="favorites")
label.filters__button.filters__button--has-icon(
for="filter-favorites")
svg.filters__button-icon(
width="16" height="16" viewBox="0 0 576 512"
aria-hidden="true")
path(
d="M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z")
| Favorites
.filters__item
input.filters__input.js-filter(
id="filter-live"
type="radio"
name="filter"
value="live")
label.filters__button.filters__button--has-icon(
for="filter-live")
svg.filters__button-icon(
width="16" height="16" viewBox="0 0 576 512" aria-hidden="true")
path(
d="M186.87 157.25l-11.37-11.11a16.44 16.44 0 0 0-24 1.3 168.83 168.83 0 0 0 0 217.12 16.44 16.44 0 0 0 24 1.3l11.37-11.11a15.14 15.14 0 0 0 1.29-20.53 122.72 122.72 0 0 1 0-156.44 15.15 15.15 0 0 0-1.29-20.53zM107.33 79.6L96 68.53a16.41 16.41 0 0 0-23.56 1C25.59 121 0 186.58 0 256s25.59 135 72.44 186.52a16.41 16.41 0 0 0 23.56 1l11.33-11.07c6.11-6 6.06-15.39.36-21.71a230.28 230.28 0 0 1 0-309.37c5.7-6.37 5.75-15.81-.36-21.77zm396.23-10.12a16.41 16.41 0 0 0-23.56-1L468.67 79.6c-6.11 6-6.06 15.39-.36 21.72a230.28 230.28 0 0 1 0 309.37c-5.7 6.32-5.75 15.75.36 21.71L480 443.47a16.41 16.41 0 0 0 23.56-1C550.41 391 576 325.42 576 256s-25.59-135-72.44-186.52zM288 200a56 56 0 1 0 56 56 56 56 0 0 0-56-56zm112.5-53.86l-11.37 11.11a15.15 15.15 0 0 0-1.29 20.53 122.72 122.72 0 0 1 0 156.44 15.15 15.15 0 0 0 1.29 20.53l11.37 11.11a16.44 16.44 0 0 0 24-1.3 168.83 168.83 0 0 0 0-217.12 16.44 16.44 0 0 0-24-1.3z")
| Going now
each category in categories
.filters__item
input.filters__input.js-filter(
id=`filter-${category.id}`
type="radio"
name="filter"
value=`category-${category.id}`)
label.filters__button(
class= category.id == "1" ? "filters__button--has-icon" : false
class=`category--${category.id}`
for=`filter-${category.id}`)
if category.id == "1"
svg.filters__button-icon(
width="16" height="16" viewBox="0 0 640 512"
aria-hidden="true")
path(
d="M400 224a32 32 0 1 0 32 32 32 32 0 0 0-32-32zm238.57 114.4l-27.5-181.25C603.32 106 565.45 65 515.68 53.79a889.52 889.52 0 0 0-391.36 0C74.55 65 36.68 106 28.93 157.15L1.44 338.4C-9.86 412.85 46.94 480 121.21 480h.25a121 121 0 0 0 108.38-67.94L243.67 384h152.66l13.83 28.06A121 121 0 0 0 518.55 480h.25c74.27 0 131.06-67.15 119.77-141.6zm-64.85 68.19A71.66 71.66 0 0 1 518.55 432c-27.79 0-52.82-15.77-65.34-41.17l-13.83-28.05-13.2-26.78H213.82l-13.2 26.78-13.83 28.05c-12.52 25.4-37.55 41.17-65.58 41.17a71.55 71.55 0 0 1-54.93-25.41 76 76 0 0 1-17.39-61l27.49-181.24c4.83-31.8 27.79-56.82 58.5-63.74a841.73 841.73 0 0 1 370.25 0c30.71 6.92 53.66 31.94 58.49 63.74l27.49 181.25a76 76 0 0 1-17.39 60.99zM496 160a32 32 0 1 0 32 32 32 32 0 0 0-32-32zm-232 40h-48v-48a8 8 0 0 0-8-8h-32a8 8 0 0 0-8 8v48h-48a8 8 0 0 0-8 8v32a8 8 0 0 0 8 8h48v48a8 8 0 0 0 8 8h32a8 8 0 0 0 8-8v-48h48a8 8 0 0 0 8-8v-32a8 8 0 0 0-8-8z")
| #{category.name}
//- schedule
.content__schedule.schedule
//- day
each day in schedule
section.section-day
h2.section-day__title
time.section-day__title-text= day.date
.section-day__content
//- period
each period, index in day.periods
section.section-period
h3.period-time(
id=`period-${index}`
class=`period-time--${period.status}`)
time.period-time__text(
role="text")
span.period-time__start= period.timeStart
span.visually-hidden —
span.period-time__end= period.timeEnd
ul.section-period__events(
aria-labelledby=`period-${index}`)
//- event
each event in period.events
each category in categories
if category.id == event.categoryId
li.section-period__event.event(
class=`event--category-${category.id}`
class= category.id == "1" ? `event--activity event--background-${event.backgroundId}` : false
data-filter=`category-${category.id}`
data-favorite= event.isAddedToFavorites ? '' : false
data-live= period.status == 'active' ? '' : false)
//- title
h3.event__title
a.event__link(href= event.link)= event.title
//- meta
.event__meta.meta
.meta__item
span.visually-hidden Location:
| #{event.location}
if category.id != "1"
.meta__item(
aria-hidden="true") ·
.meta__item(
class=`category--${category.id}`)
span.visually-hidden Category:
| #{category.name}
else
.visually-hidden=`Category: ${category.name}`
//- author
if category.id != "1"
.author
img.author__image(
src= event.speakerImage
width="48" height="48"
alt="")
.author__name
span.visually-hidden Speaker:
| #{event.speakerName}
.author__company
span.visually-hidden Company:
| #{event.speakerCompany}
//- favorite button
button.event__favorite-button.favorite-button(
class= event.isAddedToFavorites ? "favorite-button--active" : null
data-favorite= event.isAddedToFavorites
aria-label= event.isAddedToFavorites ? `Remove "${event.title}" from favorites` : `Add "${event.title}" to favorites`
type="button")
svg(
class="favorite-button__icon"
width="16" height="16" viewBox="0 0 576 512"
aria-hidden="true")
path.favorite-button__icon-stroke(
d="M528.1 171.5L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6zM388.6 312.3l23.7 138.4L288 385.4l-124.3 65.3 23.7-138.4-100.6-98 139-20.2 62.2-126 62.2 126 139 20.2-100.6 98z")
path.favorite-button__icon-filled(
d="M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z")
@use postcss-preset-env {
features {
nesting-rules: false;
gap-properties: false;
place-properties: false;
}
}
@use postcss-nested;
@use postcss-simple-vars;
@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;700&display=swap");
/* --- variables --- */
$animation-duration: .3s;
$animation-ease-out: cubic-bezier(.215, .61, .355, 1);
$font-weight-normal: 400;
$font-weight-bold: 700;
$outline-width: .25rem;
$outline-offset: .25em;
$blur-radius: 4px;
/* --- themes --- */
:root {
--color-primary: #33a7d8;
--color-primary-offset: #62d3ee;
--text-primary: rgb(0 0 0 / 88%);
--text-primary-inverted: rgb(255 255 255 / 88%);
--text-secondary: rgb(0 0 0 / 56%);
--bg: rgb(255 255 255);
--bg-secondary: rgb(242 243 250);
--bg-secondary-blur: rgb(242 243 250 / 88%);
--bg-dot: rgb(0 0 0 / 32%);
--outline: rgb(51 216 144 / 88%);
--shadow: rgb(0 0 0 / 8%);
color-scheme: light;
}
:root.theme-dark {
--color-primary: #33a7d8;
--color-primary-offset: #62d3ee;
--text-primary: rgb(255 255 255 / 88%);
--text-primary-inverted: rgb(0 0 0 / 88%);
--text-secondary: rgb(255 255 255 / 56%);
--bg: rgb(10 10 10);
--bg-secondary: rgb(25 25 25);
--bg-secondary-blur: rgb(25 25 25 / 88%);
--bg-dot: rgb(255 255 255 / 32%);
--outline: rgb(51 216 144 / 88%);
--shadow: transparent;
color-scheme: dark;
}
/* category colors */
:root {
--green: #008000;
--blue: #3455db;
--red: #b22222;
--purple: #b500b5;
--gray: #4b6a88;
--teal: #00869c;
}
/* --- base --- */
*,
*::before,
*::after {
box-sizing: border-box;
}
:focus:not(:focus-visible) {
outline: none;
}
:focus-visible {
outline: $outline-width solid var(--outline);
outline-offset: $outline-offset;
}
/* button reset */
button {
padding: 0;
margin: 0;
border: none;
color: inherit;
font-family: inherit;
background: none;
cursor: pointer;
appearance: button;
user-select: none;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0;
}
[hidden] {
display: none !important;
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.001s !important;
transition-duration: 0.001s !important;
animation-delay: 0s !important;
animation-iteration-count: 1 !important;
}
}
/* --- utilities --- */
.visually-hidden,
.visually-hidden-focusable:not(:focus):not(:focus-within) {
position: absolute !important;
width: 1px !important;
height: 1px !important;
padding: 0 !important;
margin: -1px !important;
border: 0 !important;
overflow: hidden !important;
white-space: nowrap !important;
clip: rect(0, 0, 0, 0) !important;
}
/*--- page ---*/
.page {
height: 100%;
text-size-adjust: 100%;
}
body {
display: grid;
min-height: 100%;
margin: 0;
color: var(--text-primary);
font-family: "Manrope", system-ui, sans-serif;
background-color: var(--bg);
}
.page__body--offcanvas-open {
height: 100%;
overflow: hidden;
}
/* --- app --- */
.app {
position: relative;
width: 100%;
min-width: 0;
max-width: 25rem;
height: 100%;
margin: 0 auto;
font-family: "Manrope", system-ui, sans-serif;
background-color: var(--bg-secondary);
&--offcanvas-open {
height: 100%;
overflow: hidden;
}
}
.app__content {
height: 100%;
transition-property: border-radius, background-color, box-shadow, opacity, transform;
transition-duration: $animation-duration;
transition-timing-function: $animation-ease-out;
}
/* offcanvas */
.offcanvas {
display: none;
&.is-open {
display: block;
}
&:not([aria-hidden="true"]) + .app__content {
border-radius: 1rem;
overflow: hidden;
background-color: var(--bg);
box-shadow: 0 .25rem 1rem var(--shadow);
opacity: .64;
transform: translateX(70%) scale(.88);
}
}
.offcanvas__overlay {
position: absolute;
top: 0;
left: 0;
z-index: 10;
width: 100%;
height: 100%;
overflow: hidden;
}
.offcanvas__panel {
width: 75%;
height: 100%;
animation-duration: $animation-duration;
animation-timing-function: $animation-ease-out;
animation-fill-mode: forwards;
&.is-openning {
animation-name: offcanvasOpen;
}
&.is-closing {
animation-name: offcanvasClose;
}
}
@keyframes offcanvasOpen {
from {
opacity: 0;
transform: translateX(-100%);
}
to {
opacity: 1;
transform: translateX(0);
}
}
@keyframes offcanvasClose {
from {
opacity: 1;
transform: translateX(0);
}
to {
opacity: 0;
transform: translateX(-100%);
}
}
/* --- sidepanel --- */
$sidepanel-padding: 3rem;
.sidepanel {
display: grid;
overflow-y: auto;
}
.sidepanel__container {
position: relative;
display: grid;
grid-template:
"logo logo" auto
"menu menu" 1fr
"user switcher" auto / 1fr auto;
column-gap: 1rem;
padding: $sidepanel-padding;
}
.sidepanel__logo {
grid-area: logo;
height: 6rem;
}
.sidepanel__menu {
grid-area: menu;
margin: 0 -$sidepanel-padding;
align-self: center;
}
.sidepanel__user {
grid-area: user;
}
.sidepanel__theme-switcher {
grid-area: switcher;
align-self: center;
}
.sidepanel__close-button {
$inset: .5rem;
position: absolute;
bottom: $inset;
left: $inset;
width: calc(100% - ($inset * 2));
padding: 1em;
border: .125rem solid;
font-size: 1rem;
line-height: 1.5;
font-family: inherit;
background-color: var(--bg);
}
/* --- menu --- */
$menu-link-padding-h: $sidepanel-padding;
.menu__list {
padding: 0;
margin: 0;
list-style: none;
}
.menu__link {
display: block;
padding: 1.5em $menu-link-padding-h;
color: var(--text-secondary);
font-size: 1.25rem;
line-height: 1.5;
font-weight: $font-weight-bold;
text-decoration: none;
animation: menuLinkSlideIn $animation-duration $animation-ease-out both;
&--active {
display: flex;
align-items: center;
color: var(--text-primary);
&::before {
$size: .25em;
$gap: .5em;
flex-shrink: 0;
content: "";
display: block;
width: $size;
height: $size;
margin-right: $gap;
margin-left: -$gap;
border-radius: 50%;
background-color: var(--color-primary);
}
}
}
.menu__item {
&:nth-of-type(1) .menu__link {
animation-delay: .08s;
}
&:nth-of-type(2) .menu__link {
animation-delay: .12s;
}
&:nth-of-type(3) .menu__link {
animation-delay: .16s;
}
&:nth-of-type(4) .menu__link {
animation-delay: .20s;
}
}
@keyframes menuLinkSlideIn {
from {
opacity: 0;
transform: translateX(-5em);
}
to {
opacity: 1;
transform: translateX(0);
}
}
/* --- user --- */
.user {
display: grid;
grid-template:
"image name"
"image button" / auto 1fr;
gap: .25em .75em;
font-size: .875rem;
line-height: 1.5;
}
.user__image {
$size: 3em;
grid-area: image;
width: $size;
height: $size;
border-radius: 50%;
}
.user__name {
grid-area: name;
word-break: break-word;
}
.user__button {
grid-area: button;
justify-self: start;
color: var(--color-primary);
font-size: inherit;
line-height: inherit;
}
/* --- theme toggle --- */
.theme-switcher {
$size: 2rem;
display: inline-grid;
place-items: center;
min-width: $size;
min-height: $size;
color: var(--text-primary);
&--dark {
.theme-switcher__icon-sun {
display: none;
}
.theme-switcher__icon-moon {
display: block;
}
}
}
.theme-switcher__icon {
$size: 1.25rem;
width: $size;
height: $size;
fill: currentColor;
}
.theme-switcher__icon-moon {
display: none;
}
/* --- header --- */
$headerHeight: 3.5rem;
.header {
display: grid;
grid-template:
"button-nav title button-search" / auto 1fr auto;
column-gap: 1rem;
align-items: center;
min-height: $headerHeight;
}
.header__button {
$size: $headerHeight;
display: inline-grid;
place-items: center;
min-width: $size;
min-height: $size;
}
.header__button-icon {
$size: 1.25rem;
width: $size;
height: $size;
fill: currentColor;
}
.header__button-nav {
grid-area: button-nav;
}
.header__button-searh {
grid-area: button-search;
}
.header__title {
grid-area: title;
font-weight: $font-weight-bold;
font-size: 1.25rem;
line-height: 1;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* --- burger --- */
$burgerLineGap: -.5rem;
.burger {
display: flex;
align-items: center;
&--active {
.burger__bar {
transform: rotate(45deg);
&::before {
transform: rotate(-90deg) translateX($burgerLineGap);
}
&::after {
opacity: 0;
}
}
}
}
.burger__bar,
.burger__bar::before,
.burger__bar::after {
display: block;
width: 100%;
height: .125rem;
border-radius: .25rem;
background-color: currentColor;
}
.burger__bar {
position: relative;
&::before,
&::after {
content: "";
position: absolute;
}
&::before {
top: $burgerLineGap;
}
&::after {
bottom: $burgerLineGap;
}
}
/* --- filter --- */
.filters {
position: relative;
min-width: 0;
padding: 0;
margin: 0;
border: 0;
transition-property: background-color, opacity, backdrop-filter;
transition-duration: $animation-duration;
transition-timing-function: $animation-ease-out;
&::before,
&::after {
content: "";
position: absolute;
top: 0;
z-index: 1;
width: 1rem;
height: 100%;
}
&::before {
left: 0;
background-image: linear-gradient(to left, rgb(255 255 255 / 0), var(--bg-secondary));
}
&::after {
right: 0;
background-image: linear-gradient(to right, rgb(255 255 255 / 0), var(--bg-secondary));
}
&--sticky {
position: sticky;
top: 0;
z-index: 10;
background-color: var(--bg-secondary-blur);
opacity: 0;
backdrop-filter: blur($blur-radius);
transform: translateY(-100%);
transition-property: opacity, transform;
animation: filtersSlideDown $animation-duration $animation-ease-out;
}
&--sticky&--visible {
opacity: 1;
transform: translateY(0);
}
}
@keyframes filtersSlideDown {
from {
opacity: 0;
transform: translateY(-100%);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.filters__wrapper {
display: flex;
overflow-x: auto;
}
.filters__container {
flex-shrink: 0;
display: flex;
column-gap: .5rem;
padding: .75rem 1rem;
}
.filters__item {
flex-shrink: 0;
position: relative;
}
.filters__input {
position: absolute;
padding: 0;
margin: 0;
border: none;
appearance: none;
&:checked + .filters__button {
color: var(--text-primary-inverted);
background-image: linear-gradient(to right, var(--color-primary), var(--color-primary-offset));
}
&:focus-visible {
outline: none;
+ .filters__button {
outline: $outline-width dotted var(--outline);
outline-offset: $outline-offset;
}
}
}
.filters__button {
display: inline-flex;
align-items: center;
padding: .75em 1.25em;
border-radius: .5em;
color: var(--text-secondary);
font-weight: $font-weight-bold;
font-size: .875rem;
line-height: 1;
background-color: var(--bg);
box-shadow: 0 .125rem .75rem var(--shadow);
cursor: pointer;
user-select: none;
&--has-icon {
column-gap: .5em;
}
}
.filters__button-icon {
$size: 1em;
width: $size;
height: $size;
fill: currentColor;
}
/* --- schedule --- */
.schedule {
$padding: .5rem;
padding-right: $padding;
padding-bottom: $padding;
}
/* --- section day --- */
.section-day__title {
position: sticky;
top: 0;
z-index: 1;
padding: 1rem .5rem;
margin: 0;
color: var(--text-secondary);
font-weight: $font-weight-normal;
font-size: .875rem;
text-align: center;
}
.section-day__title-text {
display: inline-block;
padding: .25em .5em;
border-radius: 1em;
background-color: var(--bg-secondary-blur);
backdrop-filter: blur($blur-radius);
}
.section-day__content {
display: grid;
row-gap: .5rem;
}
/* --- section period --- */
.section-period {
display: grid;
grid-template-columns: auto 1fr;
column-gap: 1rem;
}
.section-period__events {
display: grid;
grid-row-gap: .5rem;
padding: 0;
margin: 0;
list-style: none;
}
/* --- period time --- */
$periodFontSize: 1rem;
$periodDotSize: 1.5px;
$periodDotGap: 16px;
$periodDotPosition: calc($periodDotGap / 2 + $periodDotSize);
.period-time {
--period-dot-color: var(--bg-dot);
display: flex;
padding: .75rem 0 .75rem .25rem;
margin: 0;
font-weight: 400;
font-size: $periodFontSize;
line-height: 1;
&::before {
content: "";
display: block;
width: calc($periodDotSize * 2);
background-image: radial-gradient(var(--period-dot-color) $periodDotSize, rgb(0 0 0 / 0) $periodDotSize);
background-position: $periodDotPosition $periodDotPosition;
background-size: $periodDotGap $periodDotGap;
}
&--completed {
--period-color: var(--text-secondary);
}
&--active {
--period-color: var(--color-primary);
--period-dot-color: var(--color-primary);
}
&--coming {
--period-color: var(--text-primary);
}
}
.period-time__text {
position: sticky;
top: 1rem;
align-self: flex-start;
display: grid;
grid-template-areas:
"line start"
"line end";
gap: .75em .5em;
margin-top: calc(($periodFontSize / 2) + $periodDotSize);
margin-left: calc($periodDotSize * -2);
color: var(--period-color);
font-size: 1rem;
line-height: 1;
font-variant-numeric: tabular-nums;
&::before {
$height: $periodDotSize * 2;
content: "";
grid-area: line;
width: 1rem;
height: calc($height);
margin-top: calc(($periodFontSize - ($height)) / 2);
border-radius: $periodFontSize;
background-color: currentColor;
}
}
.period-time__start,
.period-time__end {
min-width: 5ch;
}
.period-time__start {
grid-area: start;
font-weight: 600;
}
.period-time__end {
font-size: .875em;
grid-area: end;
color: var(--text-secondary);
}
/* --- event --- */
.event {
position: relative;
display: grid;
grid-template-areas:
"meta meta"
"title title"
"author button";
grid-template-columns: 1fr auto;
gap: .5rem;
padding: 1rem;
border-radius: .5rem;
background-color: var(--bg);
box-shadow: 0 .125rem 1.5rem var(--shadow);
&--activity {
$bg-size: 8rem;
grid-template-areas:
"meta meta"
"title button";
background-repeat: no-repeat;
background-position: right -15% bottom 75%;
background-size: $bg-size $bg-size;
}
&--background-1 {
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 113 103'><circle cx='64.5' cy='48.5' r='48.5' fill='%23ff5edd' opacity='.24'/><circle cx='24.5' cy='78' r='24.5' fill='%235e99ff' opacity='.12'/></svg>");
}
&--background-2 {
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 126 158'><path d='M81 37l45 77-77 44L5 81z' fill='%23ffef5e' opacity='.12'/><path d='M30 1l6 3L6 55l-6-3z' fill='%23feb0a5' opacity='.24'/><ellipse cx='39.9' cy='43.5' rx='12.5' ry='12' fill='%23a698fc' opacity='.32'/></svg>");
}
&--background-3 {
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 127 161'><path d='M82 41l44 76-76 44L6 85z' fill='%23cb7ef9' opacity='.12'/><path d='M43 1l52 52-42 42L1 43z' fill='%23feb0a5' opacity='.24'/></svg>");
}
&--background-4 {
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 134 162'><ellipse cx='72.6' cy='107' rx='54.5' ry='55' fill='%23ff5edd' opacity='.12'/><ellipse cx='92.6' cy='42' rx='41.5' ry='42' fill='%23cb7ef9' opacity='.24'/><path d='M0 73l28-16 16 28-28 16z' fill='%2398fcc1' opacity='.32'/></svg>");
}
&--background-5 {
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 115 115'><path d='M1 91l24-14 14 24-24 14z' fill='%23ffef5e' opacity='.24'/><path d='M17 39l41 11-11 41L6 80z' fill='%23ff625e' opacity='.24'/><path d='M70 1l45 45-45 45-45-45z' fill='%235effae' opacity='.32'/></svg>");
}
&--background-6 {
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 142 168'><path d='M31 51l69 47L0 121z' fill='%23cb7ef9' opacity='.12'/><path d='M127 24l15 81-87-55z' fill='%23ff5edd' opacity='.24'/><path d='M122 109l15 81-87-55z' fill='%235e99ff' opacity='.32'/></svg>");
}
&--background-7 {
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 144 95'><path d='M88 39l12 60L8 28 151 6z' fill='%235e99ff' opacity='.12'/><path d='M54 86l-4-4 70-71 5 4z' fill='%23ffef5e' opacity='.24'/></svg>");
}
}
.event__meta {
grid-area: meta;
}
.event__title {
grid-area: title;
font-size: 1rem;
line-height: 1.5;
font-weight: $font-weight-bold;
word-break: break-word;
}
.event__link {
color: var(--text-primary);
text-decoration: none;
&::before {
content: "";
position: absolute;
inset: 0;
}
}
.event__author {
grid-area: author;
}
.event__favorite-button {
z-index: 1;
grid-area: button;
align-self: end;
}
/* --- meta --- */
.meta {
display: flex;
flex-wrap: wrap;
column-gap: .3em;
color: var(--text-secondary);
font-size: .875rem;
line-height: 1.5;
word-break: break-word;
}
/* --- author --- */
.author {
display: grid;
grid-template:
"image name"
"image company" / auto 1fr;
gap: .125em .75em;
align-items: center;
font-size: .875rem;
line-height: 1.5;
}
.author__image {
$size: 3em;
grid-area: image;
width: $size;
height: $size;
border-radius: 50%;
}
.author__name {
grid-area: name;
word-wrap: break-word;
}
.author__company {
grid-area: company;
color: var(--text-secondary);
word-wrap: break-word;
}
/* --- category --- */
.category {
&--2 {
color: var(--green);
}
&--3 {
color: var(--blue);
}
&--4 {
color: var(--red);
}
&--5 {
color: var(--purple);
}
&--6 {
color: var(--gray);
}
&--7 {
color: var(--teal);
}
}
/* --- favorite button --- */
.favorite-button {
$size: 1.5rem;
position: relative;
display: grid;
place-items: center;
min-width: $size;
min-height: $size;
/* increase clickable zone */
&::before {
$size: 2.5rem;
content: "";
position: absolute;
width: $size;
height: $size;
}
&--active {
.favorite-button__icon-stroke {
display: none;
}
.favorite-button__icon-filled {
display: block;
}
}
&--active&--init {
.favorite-button__icon {
animation: scaleUp $animation-duration $animation-ease-out;
}
}
}
@keyframes scaleUp {
50% {
transform: scale(1.25);
}
}
.favorite-button__icon {
$size: 1.25rem;
width: $size;
height: $size;
fill: currentColor;
}
.favorite-button__icon-filled {
display: none;
}
function offcanvasAnimation(type, modal, trigger, className, animationName) {
const body = document.body;
const app = document.querySelector('.app');
const panel = modal.querySelector('.sidepanel');
const burger = trigger.querySelector('.burger');
if (type == 'open') {
body.classList.add('page__body--offcanvas-open');
app.classList.add('app--offcanvas-open');
}
panel.classList.add(className);
burger.classList.toggle('burger--active');
panel.onanimationend = (event) => {
if (event.animationName == animationName) {
panel.classList.remove(className);
if (type == 'close') {
body.classList.remove('page__body--offcanvas-open');
app.classList.remove('app--offcanvas-open');
}
}
}
}
// offcanvas
MicroModal.init({
onShow: (modal, trigger) => (offcanvasAnimation('open', modal, trigger, 'is-openning', 'offcanvasOpen')),
onClose: (modal, trigger) => (offcanvasAnimation('close', modal, trigger, 'is-closing', 'offcanvasClose')),
awaitCloseAnimation: true
});
// show filters on scroll up
window.addEventListener('DOMContentLoaded', () => {
const content = document.querySelector('.js-app-content');
const filters = document.querySelector('.filters');
let filtersTop = filters.offsetTop;
let filtersBottom = filters.offsetTop + filters.offsetHeight;
let scrollPosPrev = 0;
window.onscroll = () => {
let scrollPosCur = window.scrollY;
if (scrollPosCur > filtersBottom) {
if (scrollPosCur < scrollPosPrev) {
filters.classList.add('filters--sticky', 'filters--visible');
} else {
filters.classList.remove('filters--visible');
}
}
if (scrollPosCur < filtersTop) {
filters.classList.remove('filters--sticky', 'filters--visible');
}
scrollPosPrev = scrollPosCur;
}
});
// filter
window.addEventListener('DOMContentLoaded', () => {
const filters = document.querySelectorAll('.js-filter');
const events = document.querySelectorAll('.event');
const periods = document.querySelectorAll('.section-period');
const days = document.querySelectorAll('.section-day');
function hideSections(elements) {
elements.forEach(element => {
let shownevents = element.querySelectorAll('.event:not([hidden])').length;
if (shownevents == 0) {
element.hidden = true;
} else {
element.hidden = false;
}
})
}
filters.forEach(filter => {
const value = filter.value;
filter.onchange = () => {
events.forEach(event => {
switch (value) {
case '':
event.hidden = false;
break;
case 'favorites':
if (event.dataset.hasOwnProperty('favorite'))
event.hidden = false;
else
event.hidden = true;
break;
case 'live':
if (event.dataset.hasOwnProperty('live'))
event.hidden = false;
else
event.hidden = true;
break;
default:
let filterData = event.dataset.filter;
if (!filterData || filterData !== value)
event.hidden = true;
else
event.hidden = false;
}
})
hideSections(periods);
hideSections(days);
}
})
});
// favorite button
(() => {
const favoriteButtons = document.querySelectorAll('.favorite-button');
const isAddedAttribute = 'data-favorite';
favoriteButtons.forEach(button => {
const event = button.closest('.event');
const eventTitle = event.querySelector('.event__title');
const eventTitleText = eventTitle.textContent;
button.onclick = () => {
button.classList.add('favorite-button--init'); // allows animation for active state
button.classList.toggle('favorite-button--active');
event.toggleAttribute(isAddedAttribute);
button.setAttribute(
'aria-label',
event.hasAttribute(isAddedAttribute) ?
`Remove "${eventTitleText}" from favorites` : `Add "${eventTitleText}" to favorites`
);
}
})
})();
// theme switcher
(() => {
const themeButton = document.querySelector('.theme-switcher');
const defaultTheme = 'light';
const darkTheme = 'dark';
let currentTheme = defaultTheme;
themeButton.onclick = () => {
if (currentTheme == defaultTheme)
currentTheme = darkTheme
else
currentTheme = defaultTheme
document.documentElement.classList.toggle('theme-dark');
themeButton.classList.toggle('theme-switcher--dark');
themeButton.setAttribute(
'aria-label',
`Switch to ${currentTheme} theme`
);
}
})();
Also see: Tab Triggers