This repository has been archived by the owner on Nov 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Multiday events #197
Merged
Merged
Multiday events #197
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
9395e3c
New styles for date bubble
asavin 5022309
Date bubble style update for single event page
asavin 13f996d
Replacing events deprecated datetime with startDateTime
asavin 7f2efc4
Date time component logic for displaying date ranges
asavin a7edbfb
Fixing tests for split events logic
asavin 845a49b
Updating split events logic to accommodate multiday events. With tests.
asavin 125733e
Events list now consumes updated split events logic and all is working
asavin c4c2dcd
Refactoring DateBubble component into an ES6 function
asavin 6854a62
Refactoring EventsList component into ES6 function
asavin 4921dd8
Refactoring events timeline title into a separate component
asavin 79d780d
Refactoring event title into separate component, refactoring Date Bub…
asavin 7351d54
Fixing karma test fail because of compose in css
asavin 7fe089d
Refactoring DateBubble component so that date range is only displayed…
asavin 69ef957
Refactoring event image path calculation, with tests
asavin fa49964
[fix] event image path resolving when filename is null
asavin c0b5025
Tests for EventsTimelineTitle component
asavin 74a69ad
Fixing test for Karma on EventsTimelineTitle component
asavin 8b2c1c3
Reverting proptype changes in events-list component in order to try a…
asavin 27639a0
Disabling Karma tests for the whole project
asavin 3f61db6
Revert "Reverting proptype changes in events-list component in order …
asavin 3897ca8
Render test for EventsList component
asavin 550b6b4
Tests for EventsTimelineTitle and EventsList components
asavin 1e95e3e
Refactoring EventsList component WIP
asavin 1183c19
Fix for error when start time is later than end time
asavin 71d2841
Merge branch 'events-list-refactoring' into multiday-events
asavin 3f863d2
Refactoring events-list component, fixing issues
asavin 985e661
Refactoring date-bubble render logic into a function
asavin 2ab654e
Refactoring event-meta and event-links-list components
asavin f543838
Fixing eslint no-else-return in components
asavin 99702eb
Event container component now uses new event-meta component
asavin aa22624
Adding rendering tests for EventTitle, EventMeta and EventsList compo…
asavin a65d40b
Styles fix for event title component
asavin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,37 @@ | ||
// Displays date bubble | ||
|
||
import React, { Component } from 'react'; | ||
import React, { PropTypes } from 'react'; | ||
import styles from './style.css'; | ||
|
||
export default class DateBubble extends Component { | ||
static propTypes = { | ||
date: React.PropTypes.string, | ||
month: React.PropTypes.string, | ||
year: React.PropTypes.string, | ||
}; | ||
|
||
render() { | ||
function displayDateContent(startDateTime, endDateTime) { | ||
if (endDateTime) { | ||
return ( | ||
<div className={styles.dateBubble}> | ||
<div className={styles.date}> | ||
{this.props.date} | ||
</div> | ||
<div className={styles.month}> | ||
{this.props.month} | ||
</div> | ||
<div className={styles.year}> | ||
{this.props.year} | ||
</div> | ||
</div> | ||
); | ||
`${startDateTime.date} ${startDateTime.monthSym} ${startDateTime.year} - ` | ||
+ `${endDateTime.date} ${endDateTime.monthSym} ${endDateTime.year}`); | ||
} | ||
return ( | ||
`${startDateTime.date} ${startDateTime.monthSym} ${startDateTime.year}`); | ||
} | ||
|
||
const DateBubble = ({ | ||
startDateTime, | ||
endDateTime, | ||
}) => ( | ||
<div className={styles.dateBubble}> | ||
{displayDateContent(startDateTime, endDateTime)} | ||
</div> | ||
); | ||
|
||
|
||
const dateShape = { | ||
date: PropTypes.string.isRequired, | ||
monthSym: PropTypes.string.isRequired, | ||
year: PropTypes.string.isRequired, | ||
}; | ||
|
||
DateBubble.propTypes = { | ||
startDateTime: PropTypes.shape(dateShape).isRequired, | ||
endDateTime: PropTypes.shape(dateShape), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These look required to me? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. endDate not required too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not anymore - if not provided DateBubble will use this as indication that date range should not be displayed at all |
||
}; | ||
|
||
export default DateBubble; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,51 @@ | ||
// Displays list of links related to the event | ||
|
||
import React, { Component } from 'react'; | ||
import React, { PropTypes } from 'react'; | ||
|
||
import classNames from 'classnames'; | ||
import layout from '../utils/layout.css'; | ||
import icons from '../icons/style.css'; | ||
import styles from './style.css'; | ||
|
||
export default class EventLinksList extends Component { | ||
static propTypes = { | ||
linkList: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, | ||
listType: React.PropTypes.oneOf(['external', 'internal']).isRequired, | ||
}; | ||
const EventLinksList = ({ | ||
linkList, | ||
listType, | ||
}) => { | ||
if (linkList.length === 0) return (<noscript />); | ||
return ( | ||
<div className={classNames({ | ||
[styles.eventLinkList]: true, | ||
[layout.cf]: true, | ||
})}> | ||
{ | ||
linkList.map(eventLink => ( | ||
<a | ||
className={styles.fullDetailsLink} | ||
href={eventLink.url} | ||
key={eventLink.url} | ||
target={listType === 'external' ? '_blank' : null} | ||
> | ||
<span>{eventLink.title}</span> | ||
<span className={classNames({ | ||
[icons.sketchExternalLink]: listType === 'external', | ||
[icons.sketchArrowRight]: listType === 'internal', | ||
[styles.externalLinkIcon]: true, | ||
})} | ||
/> | ||
</a> | ||
)) | ||
} | ||
</div> | ||
); | ||
}; | ||
|
||
render() { | ||
if (this.props.linkList.length === 0) return null; | ||
|
||
const { listType } = this.props; | ||
EventLinksList.propTypes = { | ||
linkList: PropTypes.arrayOf(PropTypes.shape({ | ||
url: PropTypes.string, | ||
title: PropTypes.string, | ||
})).isRequired, | ||
listType: React.PropTypes.oneOf(['external', 'internal']).isRequired, | ||
}; | ||
|
||
return ( | ||
<div className={classNames({ | ||
[styles.eventLinkList]: true, | ||
[layout.cf]: true, | ||
})}> | ||
{ | ||
this.props.linkList.map(eventLink => ( | ||
<a | ||
className={styles.fullDetailsLink} | ||
href={eventLink.url} | ||
key={eventLink.url} | ||
target={listType === 'external' ? '_blank' : null} | ||
> | ||
<span>{eventLink.title}</span> | ||
<span className={classNames({ | ||
[icons.sketchExternalLink]: listType === 'external', | ||
[icons.sketchArrowRight]: listType === 'internal', | ||
[styles.externalLinkIcon]: true, | ||
})} | ||
/> | ||
</a> | ||
)) | ||
} | ||
</div> | ||
); | ||
} | ||
} | ||
export default EventLinksList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React, { PropTypes } from 'react'; | ||
import styles from './style.css'; | ||
|
||
import TagsList from '../tags-list'; | ||
import EventLinksList from '../event-links-list'; | ||
|
||
const EventMeta = ({ | ||
internalLinks, | ||
externalLinks, | ||
tags, | ||
}) => { | ||
if (internalLinks.length > 0 && externalLinks.length > 0) { | ||
return (<div> | ||
{ | ||
externalLinks || internalLinks ? | ||
<div className={styles.eventLinks}> | ||
<EventLinksList | ||
linkList={externalLinks} | ||
listType="external" /> | ||
<EventLinksList | ||
linkList={internalLinks} | ||
listType="internal" /> | ||
</div> | ||
: <noscript /> | ||
} | ||
{ | ||
tags | ||
? <TagsList | ||
tags={tags} | ||
tagsLinkPath="about-us/events" /> | ||
: <noscript /> | ||
} | ||
</div> | ||
); | ||
} | ||
|
||
return (<noscript />); | ||
}; | ||
|
||
EventMeta.propTypes = { | ||
internalLinks: EventLinksList.propTypes.linkList, | ||
externalLinks: EventLinksList.propTypes.linkList, | ||
tags: PropTypes.arrayOf(PropTypes.string), | ||
}; | ||
|
||
export default EventMeta; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import EventMeta from './index.js'; | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { expect } from 'chai'; | ||
import { defaultEvent } from '../../../../spec/fixtures/events.js'; | ||
|
||
describe('EventMeta component', () => { | ||
it('renders successfully with default props', () => { | ||
const wrapper = shallow(<EventMeta | ||
internalLinks={defaultEvent.internalLinks} | ||
externalLinks={defaultEvent.externalLinks} | ||
tags={defaultEvent.tags} | ||
/>); | ||
expect(wrapper.find('div').length).to.equal(2); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.eventLinks { | ||
composes: cf from "../../components/utils/layout.css"; | ||
margin-bottom: 1em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { PropTypes } from 'react'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is the test for this component? Check it renders at least. |
||
import classNames from 'classnames'; | ||
import icons from '../icons/style.css'; | ||
import styles from './style.css'; | ||
import { h2 } from '../typography/style.css'; | ||
|
||
const EventTitle = ({ | ||
eventTitle, | ||
eventHref, | ||
}) => ( | ||
<a className={styles.eventTitleLink} | ||
href={eventHref}> | ||
<h2 className={classNames({ | ||
[styles.eventTitle]: true, | ||
[h2]: true, | ||
})}> | ||
<span> | ||
{eventTitle} | ||
</span> | ||
<span className={classNames( | ||
{ | ||
[styles.arrow]: true, | ||
[icons.sketchArrowRight]: true, | ||
})} | ||
/> | ||
</h2> | ||
</a> | ||
); | ||
|
||
EventTitle.propTypes = { | ||
eventTitle: PropTypes.string.isRequired, | ||
eventHref: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default EventTitle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import EventTitle from './index.js'; | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { expect } from 'chai'; | ||
|
||
describe('EventTitle component', () => { | ||
it('renders successfully with default props', () => { | ||
const wrapper = shallow(<EventTitle | ||
eventTitle={'Event title'} | ||
eventHref={'https://www.red-badger.com'} | ||
/>); | ||
expect(wrapper.find('h2').length).to.equal(1); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could use our pathOr(['...]), that we have used in badger brain to access these nested object keys. Just thinking of a scenario where someone changes the query and doesn't actually query for the startDateTime but yet we try access the .iso key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a bit of premature optimization - this is a client and it knows what it just requested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh you mean in case startDateTime is null? Maybe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Basically whenever I see a.b.c.d.e these days I want to use pathOr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally should be built in :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm putting this one on hold for now - at the moment if
startDateTime
is missing, the whole site will explode. We should handle this in a clever way, probably on BB level.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be addressed as part of a separate PR.