From 12fdec13fff382bd4cfe8197a8bdbe43783d3c66 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Fri, 4 Sep 2020 03:01:08 -0700 Subject: [PATCH] feat: add the rest of the responsive styles for the agenda --- src/components/Agenda/Agenda.js | 46 ++++++++++++++++--------- src/components/Agenda/Session.js | 48 ++++++++++++++++++++++++-- src/pages/nerd-days.js | 59 +++++++++----------------------- src/pages/nerd-days.module.scss | 10 +----- 4 files changed, 93 insertions(+), 70 deletions(-) diff --git a/src/components/Agenda/Agenda.js b/src/components/Agenda/Agenda.js index 06d5b729b..e1b999ac2 100644 --- a/src/components/Agenda/Agenda.js +++ b/src/components/Agenda/Agenda.js @@ -1,14 +1,15 @@ -import React, { Children, Fragment } from 'react'; +import React, { cloneElement, Children, Fragment } from 'react'; import PropTypes from 'prop-types'; import { css } from '@emotion/core'; import Heading from './Heading'; import Session from './Session'; import Time from './Time'; +import useMedia from 'use-media'; -const Agenda = ({ children, className, tracks }) => { - const childrenArray = Children.toArray(children); +const Agenda = ({ children, className, tracks, mobileBreakpoint }) => { + const isMobileScreen = useMedia({ maxWidth: mobileBreakpoint }); - const sessionsByTime = childrenArray + const sessionsByTime = Children.toArray(children) .filter((child) => child.type === Session) .reduce((memo, child) => { const { time } = child.props; @@ -25,24 +26,34 @@ const Agenda = ({ children, className, tracks }) => { css={css` display: grid; grid-template-columns: 0.75fr repeat(${tracks.length}, 1fr); + + @media screen and (max-width: ${mobileBreakpoint}) { + grid-template-columns: 1fr; + } `} > - - {tracks[0]} - - - {tracks.slice(1).map((track) => ( - {track} - ))} + {!isMobileScreen && ( + <> + + {tracks[0]} + + + {tracks.slice(1).map((track) => ( + {track} + ))} + + )} {Array.from(sessionsByTime).map(([time, sessions]) => ( - - {sessions} + {!isMobileScreen && ( + + )} + {sessions.map((session) => cloneElement(session, { isMobileScreen }))} ))} @@ -53,6 +64,7 @@ Agenda.propTypes = { className: PropTypes.string, children: PropTypes.node, tracks: PropTypes.arrayOf(PropTypes.string).isRequired, + mobileBreakpoint: PropTypes.string, }; Agenda.Session = Session; diff --git a/src/components/Agenda/Session.js b/src/components/Agenda/Session.js index 8ce5ef232..9cc8d0527 100644 --- a/src/components/Agenda/Session.js +++ b/src/components/Agenda/Session.js @@ -3,11 +3,19 @@ import PropTypes from 'prop-types'; import { css } from '@emotion/core'; import Cell from './Cell'; -const Session = ({ inactive, time, speaker, title, span }) => ( +const Session = ({ + inactive, + time, + speaker, + title, + track, + span, + isMobileScreen, +}) => ( @@ -32,15 +40,51 @@ const Session = ({ inactive, time, speaker, title, span }) => ( > {speaker} + {isMobileScreen && ( + + )} ); +const Badge = (props) => ( +
  • +); + Session.propTypes = { inactive: PropTypes.bool, time: PropTypes.string, speaker: PropTypes.string, title: PropTypes.string, span: PropTypes.number, + track: PropTypes.string, + isMobileScreen: PropTypes.bool, }; Session.defaultProps = { diff --git a/src/pages/nerd-days.js b/src/pages/nerd-days.js index 99917fc52..13bff759e 100644 --- a/src/pages/nerd-days.js +++ b/src/pages/nerd-days.js @@ -357,6 +357,7 @@ const NerdDaysPage = () => { max-width: 1000px; margin: 0 auto; `} + mobileBreakpoint="1000px" tracks={[ 'Observability', 'Cloud migration', @@ -369,134 +370,108 @@ const NerdDaysPage = () => { time="8:00 AM" title="Welcome" speaker="Jemiah Sius" + track="DevOps journey" span={5} /> -
    -
    - Observability -
    -
    - Cloud Migration -
    -
    - Open Source -
    -
    - DevOps Journey -
    -
    - Fundamentals -
    -

    8:00 AM