mirror of
https://github.com/encounter/react-add-to-calendar.git
synced 2026-07-10 21:18:44 -07:00
adding more examples and updating the docs
This commit is contained in:
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
[](https://badge.fury.io/js/react-add-to-calendar)
|
[](https://badge.fury.io/js/react-add-to-calendar)
|
||||||
[](https://travis-ci.org/jasonsalzman/react-add-to-calendar)
|
[](https://travis-ci.org/jasonsalzman/react-add-to-calendar)
|
||||||
[](https://david-dm.org/jasonsalzman/react-add-to-calendar)
|
[](https://david-dm.org/jasonsalzman/react-add-to-calendar)
|
||||||
[](https://codecov.io/gh/jasonsalzman/react-add-to-calendar)
|
[](https://codecov.io/gh/jasonsalzman/react-add-to-calendar)
|
||||||
[](https://npmjs.org/package/react-add-to-calendar)
|
[](https://npmjs.org/package/react-add-to-calendar)
|
||||||
|
|
||||||
A simple and reusable Add to Calendar component for React ([Demo](https://jasonsalzman.github.io/react-add-to-calendar/))
|
A simple, customizable, and reusable Add to Calendar button component for React ([Demo](https://jasonsalzman.github.io/react-add-to-calendar/))
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|||||||
+9721
-2334
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
<title>React Add to Calendar Button crafted by Jason Salzman</title>
|
<title>React Add to Calendar Button crafted by Jason Salzman</title>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="description" content="A simple and reusable Add to Calendar component for React.">
|
<meta name="description" content="A simple, customizable, and reusable Add to Calendar button component for React.">
|
||||||
<meta name="keywords" content="React, HTML, CSS, JavaScript, JSX, date, calendar, add to calendar, event">
|
<meta name="keywords" content="React, HTML, CSS, JavaScript, JSX, date, calendar, add to calendar, event">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import hljs from 'highlight.js'
|
import hljs from 'highlight.js'
|
||||||
import Default from './examples/default'
|
import Default from './examples/default'
|
||||||
|
import ChangeLabel from './examples/changeLabel'
|
||||||
|
import ChangeTemplate from './examples/changeTemplate'
|
||||||
|
import TextOnlyTemplate from './examples/textOnlyTemplate'
|
||||||
|
import TextOnlyDropdown from './examples/textOnlyDropdown'
|
||||||
|
import ChangeDropdownOrder from './examples/changeDropdownOrder'
|
||||||
|
import RemoveDropdownItem from './examples/removeDropdownItem'
|
||||||
|
import ChangeDropdownLabels from './examples/changeDropdownLabels'
|
||||||
import CodeExampleComponent from './code_example_component'
|
import CodeExampleComponent from './code_example_component'
|
||||||
|
|
||||||
import 'react-add-to-calendar/dist/react-add-to-calendar.css'
|
import 'react-add-to-calendar/dist/react-add-to-calendar.css'
|
||||||
@@ -17,6 +24,34 @@ export default React.createClass({
|
|||||||
{
|
{
|
||||||
title: 'Default',
|
title: 'Default',
|
||||||
component: <Default />
|
component: <Default />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Change Button Label',
|
||||||
|
component: <ChangeLabel />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Change Button Template',
|
||||||
|
component: <ChangeTemplate />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Text Only Button Template',
|
||||||
|
component: <TextOnlyTemplate />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Text Only Dropdown Items',
|
||||||
|
component: <TextOnlyDropdown />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Change Dropdown Order',
|
||||||
|
component: <ChangeDropdownOrder />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Remove Dropdown Item',
|
||||||
|
component: <RemoveDropdownItem />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Change Dropdown Labels',
|
||||||
|
component: <ChangeDropdownLabels />
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -39,7 +74,8 @@ export default React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
return <div>
|
return (
|
||||||
|
<div>
|
||||||
<h1>Examples</h1>
|
<h1>Examples</h1>
|
||||||
<ul className="examples__navigation">
|
<ul className="examples__navigation">
|
||||||
{this.renderLeftColumn()}
|
{this.renderLeftColumn()}
|
||||||
@@ -48,5 +84,6 @@ export default React.createClass({
|
|||||||
{this.renderExamples()}
|
{this.renderExamples()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import AddToCalendar from 'react-add-to-calendar'
|
||||||
|
|
||||||
|
export default React.createClass({
|
||||||
|
displayName: 'Change Dropdown Labels',
|
||||||
|
|
||||||
|
render () {
|
||||||
|
let event = {
|
||||||
|
title: 'Sample Event',
|
||||||
|
description: 'This is the sample event provided as an example only',
|
||||||
|
location: 'Portland, OR',
|
||||||
|
startTime: '2016-09-16T20:15:00-04:00',
|
||||||
|
endTime: '2016-09-16T21:45:00-04:00'
|
||||||
|
};
|
||||||
|
|
||||||
|
let items = [
|
||||||
|
{ outlook: 'Outlook' },
|
||||||
|
{ apple: 'iCal' },
|
||||||
|
{ yahoo: 'Yahoo!' },
|
||||||
|
{ google: 'Google' }
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="row">
|
||||||
|
<pre className="column example__code">
|
||||||
|
<code className="js">
|
||||||
|
{"let items = ["}<br/>
|
||||||
|
|
||||||
|
{"\{ outlook: 'Outlook' \}"}<br/>
|
||||||
|
|
||||||
|
{"\{ apple: 'iCal' \}"}<br/>
|
||||||
|
|
||||||
|
{"\{ yahoo: 'Yahoo!' \}"}<br/>
|
||||||
|
|
||||||
|
{"\{ google: 'Google' \}"}<br/>
|
||||||
|
{"];"}<br/><br/>
|
||||||
|
</code>
|
||||||
|
<code className="jsx">
|
||||||
|
{"<AddToCalendar"}<br/>
|
||||||
|
|
||||||
|
{"event={event}"}<br/>
|
||||||
|
|
||||||
|
{"listItems=\{items\} />"}
|
||||||
|
</code>
|
||||||
|
</pre>
|
||||||
|
<div className="column">
|
||||||
|
<AddToCalendar event={event} listItems={items} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import AddToCalendar from 'react-add-to-calendar'
|
||||||
|
|
||||||
|
export default React.createClass({
|
||||||
|
displayName: 'Change Dropdown Order',
|
||||||
|
|
||||||
|
render () {
|
||||||
|
let event = {
|
||||||
|
title: 'Sample Event',
|
||||||
|
description: 'This is the sample event provided as an example only',
|
||||||
|
location: 'Portland, OR',
|
||||||
|
startTime: '2016-09-16T20:15:00-04:00',
|
||||||
|
endTime: '2016-09-16T21:45:00-04:00'
|
||||||
|
};
|
||||||
|
|
||||||
|
let items = [
|
||||||
|
{ outlook: 'Outlook' },
|
||||||
|
{ apple: 'Apple Calendar' },
|
||||||
|
{ yahoo: 'Yahoo' },
|
||||||
|
{ google: 'Google' }
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="row">
|
||||||
|
<pre className="column example__code">
|
||||||
|
<code className="js">
|
||||||
|
{"let items = ["}<br/>
|
||||||
|
|
||||||
|
{"\{ outlook: 'Outlook' \}"}<br/>
|
||||||
|
|
||||||
|
{"\{ apple: 'Apple Calendar' \}"}<br/>
|
||||||
|
|
||||||
|
{"\{ yahoo: 'Yahoo' \}"}<br/>
|
||||||
|
|
||||||
|
{"\{ google: 'Google' \}"}<br/>
|
||||||
|
{"];"}<br/><br/>
|
||||||
|
</code>
|
||||||
|
<code className="jsx">
|
||||||
|
{"<AddToCalendar"}<br/>
|
||||||
|
|
||||||
|
{"event={event}"}<br/>
|
||||||
|
|
||||||
|
{"listItems=\{items\} />"}
|
||||||
|
</code>
|
||||||
|
</pre>
|
||||||
|
<div className="column">
|
||||||
|
<AddToCalendar event={event} listItems={items} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import AddToCalendar from 'react-add-to-calendar'
|
||||||
|
|
||||||
|
export default React.createClass({
|
||||||
|
displayName: 'ChangeLabel',
|
||||||
|
|
||||||
|
render () {
|
||||||
|
let event = {
|
||||||
|
title: 'Sample Event',
|
||||||
|
description: 'This is the sample event provided as an example only',
|
||||||
|
location: 'Portland, OR',
|
||||||
|
startTime: '2016-09-16T20:15:00-04:00',
|
||||||
|
endTime: '2016-09-16T21:45:00-04:00'
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="row">
|
||||||
|
<pre className="column example__code">
|
||||||
|
<code className="jsx">
|
||||||
|
{"<AddToCalendar"}<br/>
|
||||||
|
|
||||||
|
{"event={event}"}<br/>
|
||||||
|
|
||||||
|
{"buttonLabel=\"Put on my calendar\" />"}
|
||||||
|
</code>
|
||||||
|
</pre>
|
||||||
|
<div className="column">
|
||||||
|
<AddToCalendar event={event} buttonLabel="Put on my calendar" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import AddToCalendar from 'react-add-to-calendar'
|
||||||
|
|
||||||
|
export default React.createClass({
|
||||||
|
displayName: 'ChangeTemplate',
|
||||||
|
|
||||||
|
render () {
|
||||||
|
let event = {
|
||||||
|
title: 'Sample Event',
|
||||||
|
description: 'This is the sample event provided as an example only',
|
||||||
|
location: 'Portland, OR',
|
||||||
|
startTime: '2016-09-16T20:15:00-04:00',
|
||||||
|
endTime: '2016-09-16T21:45:00-04:00'
|
||||||
|
};
|
||||||
|
|
||||||
|
let icon = { 'calendar-plus-o': 'left' };
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="row">
|
||||||
|
<pre className="column example__code">
|
||||||
|
<code className="js">
|
||||||
|
{"let icon = \{ 'calendar-plus-o': 'left' \};"}<br/><br/>
|
||||||
|
{"/*"}<br/>
|
||||||
|
|
||||||
|
{"object property can be any Font Awesome icon"}<br/>
|
||||||
|
|
||||||
|
{"and value can be 'left' or 'right'"}<br/>
|
||||||
|
{"*/"}<br/><br/>
|
||||||
|
</code>
|
||||||
|
<code className="jsx">
|
||||||
|
{"<AddToCalendar"}<br/>
|
||||||
|
|
||||||
|
{"event={event}"}<br/>
|
||||||
|
|
||||||
|
{"buttonTemplate=\{icon\} />"}
|
||||||
|
</code>
|
||||||
|
</pre>
|
||||||
|
<div className="column">
|
||||||
|
<AddToCalendar event={event} buttonTemplate={icon} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -5,15 +5,45 @@ export default React.createClass({
|
|||||||
displayName: 'Default',
|
displayName: 'Default',
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
return <div className="row">
|
let event = {
|
||||||
|
title: 'Sample Event',
|
||||||
|
description: 'This is the sample event provided as an example only',
|
||||||
|
location: 'Portland, OR',
|
||||||
|
startTime: '2016-09-16T20:15:00-04:00',
|
||||||
|
endTime: '2016-09-16T21:45:00-04:00'
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="row">
|
||||||
<pre className="column example__code">
|
<pre className="column example__code">
|
||||||
|
<code className="js">
|
||||||
|
{"let event = \{"}<br/>
|
||||||
|
|
||||||
|
{" title: 'Sample Event',"}<br/>
|
||||||
|
|
||||||
|
{" description: 'This is the sample event provided as an example only',"}<br/>
|
||||||
|
|
||||||
|
{" location: 'Portland, OR',"}<br/>
|
||||||
|
|
||||||
|
{" startTime: '2016-09-16T20:15:00-04:00',"}<br/>
|
||||||
|
|
||||||
|
{" endTime: '2016-09-16T21:45:00-04:00'"}<br/>
|
||||||
|
{"\};"}<br/><br/>
|
||||||
|
{"/*"}<br/>
|
||||||
|
|
||||||
|
{"startTime and endTime can use any datetime"}<br/>
|
||||||
|
|
||||||
|
{"string that is acceptable by MomentJS"}<br/>
|
||||||
|
{"*/"}
|
||||||
|
</code>
|
||||||
<code className="jsx">
|
<code className="jsx">
|
||||||
{"<AddToCalendar/>"}
|
{"<AddToCalendar event={event} />"}
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
<div className="column">
|
<div className="column">
|
||||||
<AddToCalendar/>
|
<AddToCalendar event={event} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import AddToCalendar from 'react-add-to-calendar'
|
||||||
|
|
||||||
|
export default React.createClass({
|
||||||
|
displayName: 'Remove Dropdown Item',
|
||||||
|
|
||||||
|
render () {
|
||||||
|
let event = {
|
||||||
|
title: 'Sample Event',
|
||||||
|
description: 'This is the sample event provided as an example only',
|
||||||
|
location: 'Portland, OR',
|
||||||
|
startTime: '2016-09-16T20:15:00-04:00',
|
||||||
|
endTime: '2016-09-16T21:45:00-04:00'
|
||||||
|
};
|
||||||
|
|
||||||
|
let items = [
|
||||||
|
{ outlook: 'Outlook' },
|
||||||
|
{ google: 'Google' }
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="row">
|
||||||
|
<pre className="column example__code">
|
||||||
|
<code className="js">
|
||||||
|
{"let items = ["}<br/>
|
||||||
|
|
||||||
|
{"\{ outlook: 'Outlook' \}"}<br/>
|
||||||
|
|
||||||
|
{"\{ google: 'Google' \}"}<br/>
|
||||||
|
{"];"}<br/><br/>
|
||||||
|
</code>
|
||||||
|
<code className="jsx">
|
||||||
|
{"<AddToCalendar"}<br/>
|
||||||
|
|
||||||
|
{"event={event}"}<br/>
|
||||||
|
|
||||||
|
{"listItems=\{items\} />"}
|
||||||
|
</code>
|
||||||
|
</pre>
|
||||||
|
<div className="column">
|
||||||
|
<AddToCalendar event={event} listItems={items} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import AddToCalendar from 'react-add-to-calendar'
|
||||||
|
|
||||||
|
export default React.createClass({
|
||||||
|
displayName: 'TextOnlyDropdown',
|
||||||
|
|
||||||
|
render () {
|
||||||
|
let event = {
|
||||||
|
title: 'Sample Event',
|
||||||
|
description: 'This is the sample event provided as an example only',
|
||||||
|
location: 'Portland, OR',
|
||||||
|
startTime: '2016-09-16T20:15:00-04:00',
|
||||||
|
endTime: '2016-09-16T21:45:00-04:00'
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="row">
|
||||||
|
<pre className="column example__code">
|
||||||
|
<code className="jsx">
|
||||||
|
{"<AddToCalendar"}<br/>
|
||||||
|
|
||||||
|
{"event={event}"}<br/>
|
||||||
|
|
||||||
|
{"displayItemIcons=\{false\} />"}
|
||||||
|
</code>
|
||||||
|
</pre>
|
||||||
|
<div className="column">
|
||||||
|
<AddToCalendar event={event} displayItemIcons={false} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import AddToCalendar from 'react-add-to-calendar'
|
||||||
|
|
||||||
|
export default React.createClass({
|
||||||
|
displayName: 'TextOnlyTemplate',
|
||||||
|
|
||||||
|
render () {
|
||||||
|
let event = {
|
||||||
|
title: 'Sample Event',
|
||||||
|
description: 'This is the sample event provided as an example only',
|
||||||
|
location: 'Portland, OR',
|
||||||
|
startTime: '2016-09-16T20:15:00-04:00',
|
||||||
|
endTime: '2016-09-16T21:45:00-04:00'
|
||||||
|
};
|
||||||
|
|
||||||
|
let icon = { textOnly: 'none' };
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="row">
|
||||||
|
<pre className="column example__code">
|
||||||
|
<code className="js">
|
||||||
|
{"let icon = \{ textOnly: 'none' \};"}<br/><br/>
|
||||||
|
</code>
|
||||||
|
<code className="jsx">
|
||||||
|
{"<AddToCalendar"}<br/>
|
||||||
|
|
||||||
|
{"event={event}"}<br/>
|
||||||
|
|
||||||
|
{"buttonTemplate=\{icon\} />"}
|
||||||
|
</code>
|
||||||
|
</pre>
|
||||||
|
<div className="column">
|
||||||
|
<AddToCalendar event={event} buttonTemplate={icon} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
+14
-17
@@ -25,24 +25,21 @@ export default React.createClass({
|
|||||||
</div>
|
</div>
|
||||||
<div className="wrapper">
|
<div className="wrapper">
|
||||||
<h1>React Add to Calendar Button</h1>
|
<h1>React Add to Calendar Button</h1>
|
||||||
{ /* <p>
|
<p>
|
||||||
<a href="https://npmjs.org/package/react-datepicker">
|
<a href="https://npmjs.org/package/react-add-to-calendar">
|
||||||
<img src="https://badge.fury.io/js/react-datepicker.svg" className="badge" />
|
<img src="https://badge.fury.io/js/react-add-to-calendar.svg" className="badge" />
|
||||||
|
</a>
|
||||||
|
<a href="https://travis-ci.org/jasonsalzman/react-add-to-calendar">
|
||||||
|
<img src="https://travis-ci.org/jasonsalzman/react-add-to-calendar.svg?branch=master" className="badge" />
|
||||||
|
</a>
|
||||||
|
<a href="https://david-dm.org/jasonsalzman/react-add-to-calendar">
|
||||||
|
<img src="https://img.shields.io/david/peer/webcomponents/generator-element.svg?maxAge=2592000" className="badge" />
|
||||||
|
</a>
|
||||||
|
<a href={'https://npmjs.org/package/react-add-to-calendar'}>
|
||||||
|
<img src="https://img.shields.io/npm/dm/react-add-to-calendar.svg" className="badge" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://travis-ci.org/Hacker0x01/react-datepicker">
|
</p>
|
||||||
<img src="https://travis-ci.org/Hacker0x01/react-datepicker.svg?branch=master" className="badge" />
|
<p>A simple, customizable, and reusable Add to Calendar button component for React.</p>
|
||||||
</a>
|
|
||||||
<a href="https://david-dm.org/Hacker0x01/react-datepicker">
|
|
||||||
<img src="https://david-dm.org/Hacker0x01/react-datepicker.svg" className="badge" />
|
|
||||||
</a>
|
|
||||||
<a href={'https://npmjs.org/package/react-datepicker' +
|
|
||||||
'?__hstc=72727564.ca821b01b5b29b1831f0936a681f0483.1428679773810.1435582678273.1438354735499.5' +
|
|
||||||
'&__hssc=72727564.1.1438354735499' +
|
|
||||||
'&__hsfp=2497064007'}>
|
|
||||||
<img src="https://img.shields.io/npm/dm/react-datepicker.svg" className="badge" />
|
|
||||||
</a>
|
|
||||||
</p> */}
|
|
||||||
<p>A simple and reusable Add to Calendar component for React.</p>
|
|
||||||
|
|
||||||
<h2>Installation</h2>
|
<h2>Installation</h2>
|
||||||
<p>The package can be installed via NPM:</p>
|
<p>The package can be installed via NPM:</p>
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
`0` (component)
|
|
||||||
===============
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Props
|
|
||||||
-----
|
|
||||||
|
|
||||||
### `buttonLabel`
|
|
||||||
|
|
||||||
type: `string`
|
|
||||||
defaultValue: `'Add to My Calendar'`
|
|
||||||
|
|
||||||
|
|
||||||
### `buttonTemplate`
|
|
||||||
|
|
||||||
type: `object`
|
|
||||||
defaultValue: `{ caret: 'right' }`
|
|
||||||
|
|
||||||
|
|
||||||
### `displayItemIcons`
|
|
||||||
|
|
||||||
type: `bool`
|
|
||||||
defaultValue: `true`
|
|
||||||
|
|
||||||
|
|
||||||
### `event` (required)
|
|
||||||
|
|
||||||
type: `object`
|
|
||||||
defaultValue: `{
|
|
||||||
title: 'Sample Event',
|
|
||||||
description: 'This is the sample event provided as an example only',
|
|
||||||
location: 'Portland, OR',
|
|
||||||
startTime: '2016-09-16T20:15:00-04:00',
|
|
||||||
endTime: '2016-09-16T21:45:00-04:00'
|
|
||||||
}`
|
|
||||||
|
|
||||||
|
|
||||||
### `listItems`
|
|
||||||
|
|
||||||
type: `array`
|
|
||||||
defaultValue: `[
|
|
||||||
{ apple: 'Apple Calendar' },
|
|
||||||
{ google: 'Google' },
|
|
||||||
{ outlook: 'Outlook' },
|
|
||||||
{ yahoo: 'Yahoo' }
|
|
||||||
]`
|
|
||||||
|
|
||||||
@@ -1,11 +1,23 @@
|
|||||||
`ReactAddToCalendar` (component)
|
`0` (component)
|
||||||
================================
|
===============
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Props
|
Props
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
### `buttonClassClosed`
|
||||||
|
|
||||||
|
type: `string`
|
||||||
|
defaultValue: `'react-add-to-calendar__button'`
|
||||||
|
|
||||||
|
|
||||||
|
### `buttonClassOpen`
|
||||||
|
|
||||||
|
type: `string`
|
||||||
|
defaultValue: `'react-add-to-calendar__button--light'`
|
||||||
|
|
||||||
|
|
||||||
### `buttonLabel`
|
### `buttonLabel`
|
||||||
|
|
||||||
type: `string`
|
type: `string`
|
||||||
@@ -18,12 +30,24 @@ type: `object`
|
|||||||
defaultValue: `{ caret: 'right' }`
|
defaultValue: `{ caret: 'right' }`
|
||||||
|
|
||||||
|
|
||||||
|
### `buttonWrapperClass`
|
||||||
|
|
||||||
|
type: `string`
|
||||||
|
defaultValue: `'react-add-to-calendar__wrapper'`
|
||||||
|
|
||||||
|
|
||||||
### `displayItemIcons`
|
### `displayItemIcons`
|
||||||
|
|
||||||
type: `bool`
|
type: `bool`
|
||||||
defaultValue: `true`
|
defaultValue: `true`
|
||||||
|
|
||||||
|
|
||||||
|
### `dropdownClass`
|
||||||
|
|
||||||
|
type: `string`
|
||||||
|
defaultValue: `'react-add-to-calendar__dropdown'`
|
||||||
|
|
||||||
|
|
||||||
### `event` (required)
|
### `event` (required)
|
||||||
|
|
||||||
type: `object`
|
type: `object`
|
||||||
@@ -46,3 +70,9 @@ defaultValue: `[
|
|||||||
{ yahoo: 'Yahoo' }
|
{ yahoo: 'Yahoo' }
|
||||||
]`
|
]`
|
||||||
|
|
||||||
|
|
||||||
|
### `rootClass`
|
||||||
|
|
||||||
|
type: `string`
|
||||||
|
defaultValue: `'react-add-to-calendar'`
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"author": "Jason Salzman",
|
"author": "Jason Salzman",
|
||||||
"name": "react-add-to-calendar",
|
"name": "react-add-to-calendar",
|
||||||
"description": "A simple and reusable add to calendar button component for React",
|
"description": "A simple and reusable add to calendar button component for React",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://github.com/jasonsalzman/react-add-to-calendar",
|
"homepage": "https://github.com/jasonsalzman/react-add-to-calendar",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ process.stdin.on('end', function() {
|
|||||||
function buildDocs(api) {
|
function buildDocs(api) {
|
||||||
// api is an object keyed by filepath. We use the file name as component name.
|
// api is an object keyed by filepath. We use the file name as component name.
|
||||||
for (var filepath in api) {
|
for (var filepath in api) {
|
||||||
|
process.stdout.write(filepath + '\n\n');
|
||||||
var name = getComponentName(filepath);
|
var name = getComponentName(filepath);
|
||||||
var markdown = generateMarkdown(name, api[filepath]);
|
var markdown = generateMarkdown(name, api[filepath]);
|
||||||
var outputLocation = './docs/';
|
var outputLocation = './docs/';
|
||||||
@@ -37,6 +38,7 @@ function getComponentName(filepath) {
|
|||||||
var name = path.basename(filepath);
|
var name = path.basename(filepath);
|
||||||
var ext;
|
var ext;
|
||||||
while ((ext = path.extname(name))) {
|
while ((ext = path.extname(name))) {
|
||||||
|
process.stdout.write(name + '\n\n');
|
||||||
name = name.substring(0, name.length - ext.length);
|
name = name.substring(0, name.length - ext.length);
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ git checkout .
|
|||||||
|
|
||||||
npm version $1
|
npm version $1
|
||||||
|
|
||||||
react-docgen ./src/ReactAddToCalendar.js --resolver findAllComponentDefinitions | ./scripts/buildDocs.sh
|
react-docgen ./src/*.js --resolver findAllComponentDefinitions | ./scripts/buildDocs.sh
|
||||||
|
|
||||||
git add .
|
git add .
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, {
|
|||||||
Component,
|
Component,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
|
|
||||||
import helpersClass from './helpers.js';
|
import helpersClass from './helpers';
|
||||||
const helpers = new helpersClass();
|
const helpers = new helpersClass();
|
||||||
|
|
||||||
export default class ReactAddToCalendar extends React.Component {
|
export default class ReactAddToCalendar extends React.Component {
|
||||||
@@ -80,7 +80,7 @@ export default class ReactAddToCalendar extends React.Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="react-add-to-calendar__dropdown">
|
<div className={this.props.dropdownClass}>
|
||||||
<ul>
|
<ul>
|
||||||
{items}
|
{items}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -119,11 +119,10 @@ export default class ReactAddToCalendar extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let buttonClass = (this.state.optionsOpen) ? 'react-add-to-calendar__button react-add-to-calendar__button--light' :
|
let buttonClass = (this.state.optionsOpen) ? this.props.buttonClassClosed + ' ' + this.props.buttonClassOpen : this.props.buttonClassClosed;
|
||||||
'react-add-to-calendar__button';
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="react-add-to-calendar__wrapper">
|
<div className={this.props.buttonWrapperClass}>
|
||||||
<a id={this.state.componentId} className={buttonClass}
|
<a id={this.state.componentId} className={buttonClass}
|
||||||
onClick={this.toggleCalendarDropdown}>{buttonLabel}</a>
|
onClick={this.toggleCalendarDropdown}>{buttonLabel}</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -142,7 +141,7 @@ export default class ReactAddToCalendar extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="react-add-to-calendar">
|
<div className={this.props.rootClass}>
|
||||||
{addToCalendarBtn}
|
{addToCalendarBtn}
|
||||||
{options}
|
{options}
|
||||||
</div>
|
</div>
|
||||||
@@ -153,17 +152,32 @@ export default class ReactAddToCalendar extends React.Component {
|
|||||||
ReactAddToCalendar.displayName = 'Add To Calendar';
|
ReactAddToCalendar.displayName = 'Add To Calendar';
|
||||||
|
|
||||||
ReactAddToCalendar.propTypes = {
|
ReactAddToCalendar.propTypes = {
|
||||||
|
buttonClassClosed: React.PropTypes.string,
|
||||||
|
buttonClassOpen: React.PropTypes.string,
|
||||||
buttonLabel: React.PropTypes.string,
|
buttonLabel: React.PropTypes.string,
|
||||||
buttonTemplate: React.PropTypes.object,
|
buttonTemplate: React.PropTypes.object,
|
||||||
|
buttonWrapperClass: React.PropTypes.string,
|
||||||
displayItemIcons: React.PropTypes.bool,
|
displayItemIcons: React.PropTypes.bool,
|
||||||
event: React.PropTypes.object.isRequired,
|
dropdownClass: React.PropTypes.string,
|
||||||
listItems: React.PropTypes.array
|
event: React.PropTypes.shape({
|
||||||
|
title: React.PropTypes.string,
|
||||||
|
description: React.PropTypes.string,
|
||||||
|
location: React.PropTypes.string,
|
||||||
|
startTime: React.PropTypes.string,
|
||||||
|
endTime: React.PropTypes.string
|
||||||
|
}).isRequired,
|
||||||
|
listItems: React.PropTypes.arrayOf(React.PropTypes.object),
|
||||||
|
rootClass: React.PropTypes.string
|
||||||
};
|
};
|
||||||
|
|
||||||
ReactAddToCalendar.defaultProps = {
|
ReactAddToCalendar.defaultProps = {
|
||||||
|
buttonClassClosed: 'react-add-to-calendar__button',
|
||||||
|
buttonClassOpen: 'react-add-to-calendar__button--light',
|
||||||
buttonLabel: 'Add to My Calendar',
|
buttonLabel: 'Add to My Calendar',
|
||||||
buttonTemplate: { caret: 'right' },
|
buttonTemplate: { caret: 'right' },
|
||||||
|
buttonWrapperClass: 'react-add-to-calendar__wrapper',
|
||||||
displayItemIcons: true,
|
displayItemIcons: true,
|
||||||
|
dropdownClass: 'react-add-to-calendar__dropdown',
|
||||||
event: {
|
event: {
|
||||||
title: 'Sample Event',
|
title: 'Sample Event',
|
||||||
description: 'This is the sample event provided as an example only',
|
description: 'This is the sample event provided as an example only',
|
||||||
@@ -176,5 +190,6 @@ ReactAddToCalendar.defaultProps = {
|
|||||||
{ google: 'Google' },
|
{ google: 'Google' },
|
||||||
{ outlook: 'Outlook' },
|
{ outlook: 'Outlook' },
|
||||||
{ yahoo: 'Yahoo' }
|
{ yahoo: 'Yahoo' }
|
||||||
]
|
],
|
||||||
|
rootClass: 'react-add-to-calendar'
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user