#rolesOriginal {display:none;}
:root {
--schedule-primary-color: #C15715;
--schedule-secondary-color: #FFFFFF;
--schedule-background-primary-color: #F5F5F5;
--schedule-border-color: #D9D9D9;
--schedule-text-small-color: #666666;
--schedule-text-medium-color: #141618;
--schedule-text-title: 11px;
--schedule-text-xl: 32px;
--schedule-text-l: 24px;
--schedule-text-m: 16px;
--schedule-text-s: 12px;
--schedule-text-sm: 14px;
--schedule-text-xs: 10px;
--schedule-text-hours: 15px;
--schedule-radious: 12px;
--schedule-radious-large: 24px;
--schedule-font-family-primary: "Itau Display - Extra Bold";
--schedule-font-family-secondary: "Itau Text - Regular";
--schedule-font-family-tertiary: "Itau Display - Regular";
--schedule-font-family-itau-text-ebold: "Itau Text - Extra Bold";
--schedule-font-family-itau-text-bold: "Itau Text - Bold";
}
class ScheduleLayout extends HTMLElement {
constructor() {
super();
this.shadow = this.attachShadow({ mode: 'open' });
this.data = [];
}
async connectedCallback() {
this.data = await this.fetchData();
this.render();
this.shadow.querySelector('.schedule-button-all').addEventListener('click', this.onClearFilter.bind(this));
this.shadow.querySelectorAll('.schedule-button-toggle').forEach(toggle => {
const button = toggle.querySelector('button');
button.addEventListener('click', this.onFilter.bind(this))
});
this.loadAd('#rolesOriginal', '.schedule-item-ad');
}
async fetchData() {
const url_staging = 'https://s45962.p1238.sites.pressdns.com/wp-json/wp/schedule/items';
const url_production = 'https://www.miamiopen.com/wp-json/wp/schedule/items';
const response = await fetch(url_production);
const data = await response.json();
return data;
}
loadAd(selectorOriginal, selector){
const el = this.shadow.querySelector(selector);
const original = document.querySelector(selectorOriginal);
if(original){
const div = document.createElement('div');
div.innerHTML = original.innerHTML;
if(el){
el.appendChild(div);
}
}
}
onActiveButton(target) {
const active = target.closest('.schedule-button-toggle');
if(active) {
active.classList.add('schedule-button-active');
}
this.shadow.querySelectorAll('.schedule-button-toggle, .schedule-button-all').forEach(button => {
if (button !== active) {
button.classList.remove('schedule-button-active');
}
});
}
onFilter(event) {
this.shadow.querySelectorAll('.schedule-item').forEach(item => item.dataset.show = false);
let target = event.target;
if (target.tagName !== 'BUTTON') {
target = target.closest('button');
}
const id = target.dataset.target;
this.shadow.querySelector(id).dataset.show = true;
this.onActiveButton(target);
this.shadow.querySelector('.schedule-grid').classList.add('schedule-grid--row-one');
}
onClearFilter() {
this.shadow.querySelector('.schedule-grid').classList.remove('schedule-grid--row-one');
this.shadow.querySelector('.schedule-button-all').classList.add('schedule-button-active');
this.shadow.querySelectorAll('.schedule-item').forEach(item => item.dataset.show = true);
this.shadow.querySelectorAll('.schedule-button-toggle').forEach(item => item.classList.remove('schedule-button-active'));
}
calcSizeString(value){
return new String(value).length;
}
render() {
this.shadow.innerHTML = /*html*/ `
:host * {
box-sizing: border-box;
}
.schedule-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
column-gap: 24px;
row-gap: 24px;
padding: 40px;
background-color: var(--schedule-secondary-color);
border-radius: var(--schedule-radious-large);
}
.schedule-grid.schedule-grid--row-one {
grid-template-columns: repeat(1, 1fr);
}
.schedule-grid.schedule-grid--row-one .schedule-item-ad {order: 2;}
.schedule-item {
background-color: var(--schedule-secondary-color);
border-radius: var(--schedule-radious);
border: solid 1px var(--schedule-border-color);
display: flex;
flex-direction: column;
height: fit-content;
}
.schedule-item-ad {
grid-column: 1 / -1;
display: flex;
justify-content: center;
}
.schedule-item-ad iframe {
max-width: 100% !important;
}
.schedule-item .schedule-item-date,
.schedule-item .schedule-item-date {
padding: 7.5px 10px 5.5px;
}
.schedule-item[data-show="false"] {
display: none;
}
.schedule-item .schedule-item-order a {
font-size: var(--schedule-text-s);
color: var(--schedule-primary-color);
font-weight: 700;
}
.schedule-item-date.schedule-button-toggle {
width: 68px;
height: 68px;
overflow: hidden;
}
.schedule-item-date.schedule-button-all {
width: 68px;
height: 68px;
border-radius: 0;
background-color: transparent;
border: none;
}
.schedule-item-date.schedule-button-toggle button,
.schedule-item-date.schedule-button-all button {
transition: all 0.3s;
cursor: pointer;
}
.schedule-item-date.schedule-button-toggle button:hover,
.schedule-item-date.schedule-button-all button:hover,
.schedule-item-date.schedule-button-all.schedule-button-active button {
background-color: var(--schedule-primary-color);
}
.schedule-item-date.schedule-button-toggle button:hover strong,
.schedule-item-date.schedule-button-toggle button:hover span,
.schedule-item-date.schedule-button-toggle.schedule-button-active button strong,
.schedule-item-date.schedule-button-toggle.schedule-button-active button span,
.schedule-item-date.schedule-button-all.schedule-button-active button,
.schedule-item-date.schedule-button-all button:hover {
color: var(--schedule-secondary-color);
}
.schedule-item-date.schedule-button-all button {
font-size: var(--schedule-text-sm);
padding: 10px 5px 10px 10px;
color: var(--schedule-text-medium-color);
border-radius: var(--schedule-radious);
}
.schedule-item-date {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
background-color: var(--schedule-secondary-color);
border: solid 1px var(--schedule-border-color);
flex: 0 0 auto;
width: 44px;
height: 44px;
border-radius: var(--schedule-radious);
text-align: left;
font-family: var(--schedule-font-family-primary);
}
.schedule-item-date span {
color: var(--schedule-text-small-color);
font-size: var(--schedule-text-s);
font-family: var(--schedule-font-family-tertiary);
display: inline-block;
margin: 0;
line-height: var(--schedule-text-s);
}
.schedule-item-date strong {
color: var(--schedule-text-medium-color);
font-size: var(--schedule-text-l);
display: inline-block;
margin: 0;
font-family: var(--schedule-font-family-primary);
line-height: var(--schedule-text-l);
}
.schedule-item-header {
background-color: var(--schedule-background-primary-color);
border-top-left-radius: var(--schedule-radious);
border-top-right-radius: var(--schedule-radious);
color: var(--schedule-text-medium-color);
display: grid;
grid-template-columns: auto 1fr auto;
column-gap: 24px;
align-items: center;
padding: 14px 16px;
}
.schedule-item-body {
padding: 0px 16px;
}
.schedule-item-body ul {
padding: 0;
list-style: none;
margin: 0;
position: relative;
}
.schedule-item-body ul li h4 {
font-family: var(--schedule-font-family-secondary);
font-size: var(--schedule-text-m);
margin: 0;
color: var(--schedule-text-medium-color);
}
.schedule-item-body ul li:not(.schedule-item-session-text) {
display: grid;
grid-template-columns: 1fr 1fr 1fr auto;
column-gap: 8px;
align-items: center;
padding: 14px 0;
column-gap: 8px;
}
.schedule-item-body ul li.schedule-item-session-text {
font-size: var(--schedule-text-s);
color: var(--schedule-text-small-color);
padding: 12px 0;
}
.schedule-item-body ul li.schedule-item-session-text:last-child {
padding-bottom: 0;
}
.schedule-item-body ul li:not(:last-child) {
border-bottom: solid 1px var(--schedule-border-color);
}
.schedule-item-body ul li .schedule-item-hours {
display: flex;
flex-direction: column;
}
.schedule-item-body ul li .schedule-item-hours span:nth-child(1) {
font-size: var(--schedule-text-title);
font-family: var(--schedule-font-family-itau-text-ebold);
color: var(--schedule-text-medium-color);
}
.schedule-item-body ul li .schedule-item-hours span:nth-child(2) {
font-size: var(--schedule-text-hours);
font-family: var(--schedule-font-family-tertiary);
color: var(--schedule-text-small-color);
}
.schedule-item-body ul li .schedule-item-buttons {
display: none; /* HIDING BUTTONS... */
flex-direction: column;
row-gap: 8px;
}
.schedule-item-button {
font-size: var(--schedule-text-title);
text-decoration: none;
border-radius: var(--schedule-radious-large);
padding: 5px 13px 3px;
text-align: center;
height: 24px;
display: flex;
justify-content: center;
align-items: center;
}
.schedule-item-button.schedule-item-button--primary {
background-color: var(--schedule-primary-color);
color: var(--schedule-secondary-color);
}
.schedule-item-button.schedule-item-button--secondary {
background-color: var(--schedule-secondary-color);
color: var(--schedule-primary-color);
border: solid 1px var(--schedule-primary-color);
cursor: pointer;
}
.schedule-item-header-title {
font-size: var(--schedule-text-m);
font-weight: 800;
font-family: var(--schedule-font-family-itau-text-ebold);
}
.schedule-filter {
width: 100%;
margin-bottom: 30px;
display: flex;
align-items: center;
justify-content: center;
}
.schedule-filter ul {
display: flex;
justify-content: flex-start;
margin-bottom: 0px;
column-gap: 8px;
padding: 0 0 0 10px;
margin-top: 0;
overflow: auto;
scrollbar-width: none;
position: relative;
}
.schedule-filter .schedule-button-all {
position: relative;
}
.schedule-button-all.schedule-item-date button {
background: #fff;
}
.schedule-filter .schedule-button-all::before {
content: "";
position: absolute;
width: 10px;
height: 74px;
top: -3px;
right: -10px;
background-color: rgb(247, 247, 247);
z-index: 999;
}
.schedule-filter ul li.schedule-button-active button {
background-color: var(--schedule-primary-color);
color: var(--schedule-secondary-color);
}
.schedule-filter button {
appearance: none;
background: transparent;
border: none;
outline: none;
font-family: var(--schedule-font-family-tertiary);
font-weight: 700;
padding: 13.5px 15.5px;
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
align-items: flex-start;
justify-content: center;
text-align: left;
}
.schedule-filter button strong {
font-size: var(--schedule-text-xl);
line-height: var(--schedule-text-xl);
}
.schedule-filter button span {
font-size: var(--schedule-text-sm);
line-height: var(--schedule-text-sm);
}
.space-button {
width: 89px;
}
@media screen and (max-width: 768px) {
.schedule-grid {
grid-template-columns: repeat(1, 1fr);
padding: 16px;
margin-right: 20px;
}
.schedule-item-header {
grid-template-columns: auto 1fr;
align-items: start;
}
.schedule-item-order {
grid-column: 2 / -1;
}
.schedule-item-order.schedule-item-order--empty {
display: none;
}
.schedule-item-body {
padding: 0px 12px;
}
.schedule-item-body ul li:not(.schedule-item-session-text) {
display: grid;
grid-template-columns: auto auto max-content;
grid-template-rows: auto auto;
gap: 8px;
align-items: center;
}
.schedule-item-body ul li:not(.schedule-item-session-text) h4 {
font-size: 16px;
grid-column: 1 / -1;
margin-bottom: 0;
margin-top: 0;
}
.schedule-item-body ul li:not(.schedule-item-session-text) .schedule-item-hours {
display: flex;
flex-direction: column;
font-size: 14px;
font-weight: bold;
color: #000;
}
.schedule-item-body ul li:not(.schedule-item-session-text) .schedule-item-hours span:last-child {
font-weight: normal;
color: #666;
font-size: 16px;
}
.schedule-item-body ul li:not(.schedule-item-session-text) .schedule-item-button {
font-size: 11px;
}
.schedule-item-header-title {
font-size: 14px;
}
.schedule-item .schedule-item-date {
grid-row: 1 / 10;
}
.schedule-item-header-title-large {
grid-row: auto;
}
}
@media screen and (min-width: 768px) {
.schedule-item-header {
height: 72px;
}
}
${this.data?.map((item, index) => /*html*/`
${index == 1 ? `
${item.day_session_number && item.day_campus_opens && item.day_match_play ? /*html*/`-
${item.day_session_number}
CAMPUS OPENS
${item.day_campus_opens}
MATCHES BEGIN
${item.day_match_play}
` : ''}
${item.day_session_text ? /*html*/`
-
${item.day_session_text}
` : ''}
${item.night_session_number && item.night_campus_opens && item.night_match_play ? /*html*/`-
${item.night_session_number}
CAMPUS OPENS
${item.night_campus_opens}
MATCHES BEGIN
${item.night_match_play}
` : ''}
${item.night_session_text ? /*html*/`
-
${item.night_session_text}
` : ''}
` : `
${item.day_session_number && item.day_campus_opens && item.day_match_play ? /*html*/`-
${item.all_day_icon === true ? `
` : `
`}
${item.day_session_number}
CAMPUS OPENS
${item.day_campus_opens}
MATCHES BEGIN
${item.day_match_play}
` : ''}
${item.day_session_text ? /*html*/`
-
${item.day_session_text}
` : ''}
${item.night_session_number && item.night_campus_opens && item.night_match_play ? /*html*/`-
${item.night_session_number}
CAMPUS OPENS
${item.night_campus_opens}
MATCHES BEGIN
${item.night_match_play}
` : ''}
${item.night_session_text ? /*html*/`
-
${item.night_session_text}
` : ''}
${item.stadium_opens && item.stadium_play_begins ? /*html*/`-
STADIUM OPENS
${item.stadium_opens}
STADIUM PLAY BEGINS
${item.stadium_play_begins}
` : ''}
${item.all_day_access_text ? /*html*/`
-
All Day Access: ${item.all_day_access_text}
` : ''}
`}
`).join('')}
`;
}
}
window.customElements.define('schedule-layout', ScheduleLayout);