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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from redbadger/multiday-events
Multiday events
- Loading branch information
Showing
27 changed files
with
898 additions
and
443 deletions.
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), | ||
}; | ||
|
||
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'; | ||
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.