Skip to content

Commit

Permalink
Add types for react-add-to-calendar package (DefinitelyTyped#38751)
Browse files Browse the repository at this point in the history
  • Loading branch information
koss-lebedev authored and RyanCavanaugh committed Oct 2, 2019
1 parent 2ea517f commit e39fd75
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
35 changes: 35 additions & 0 deletions types/react-add-to-calendar/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Type definitions for react-add-to-calendar 0.1
// Project: https://github.com/jasonsalzman/react-add-to-calendar
// Definitions by: Konstantin Lebedev <https://github.com/koss-lebedev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8

import * as React from "react";

export interface AddToCalendarEvent {
title?: string;
description?: string;
location?: string;
startTime?: string | Date;
endTime?: string | Date;
}

export interface AddToCalendarProps {
buttonClassClosed?: string;
buttonClassOpen?: string;
buttonLabel?: string;
buttonTemplate?: any;
buttonIconClass?: string;
useFontAwesomeIcons?: boolean;
buttonWrapperClass?: string;
displayItemIcons?: boolean;
optionsOpen?: boolean;
dropdownClass?: string;
event: AddToCalendarEvent;
listItems?: any[];
rootClass?: string;
}

declare const ReactAddToCalendar: React.ComponentClass<AddToCalendarProps>;

export default ReactAddToCalendar;
34 changes: 34 additions & 0 deletions types/react-add-to-calendar/react-add-to-calendar-tests.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import AddToCalendar from "react-add-to-calendar";
import * as React from "react";

const sampleEvent = {
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'
};

const AddToCalendarRequiredOptions: JSX.Element = (
<AddToCalendar
event={sampleEvent}
/>
);

const AddToCalendarAllOptions: JSX.Element = (
<AddToCalendar
event={sampleEvent}
buttonClassClosed="test"
buttonClassOpen="test"
buttonLabel="test"
buttonTemplate=""
buttonIconClass="test"
useFontAwesomeIcons={false}
buttonWrapperClass="test"
displayItemIcons={false}
optionsOpen={false}
dropdownClass="test"
listItems={[]}
rootClass="test"
/>
);
26 changes: 26 additions & 0 deletions types/react-add-to-calendar/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"esModuleInterop": true
},
"files": [
"index.d.ts",
"react-add-to-calendar-tests.tsx"
]
}
1 change: 1 addition & 0 deletions types/react-add-to-calendar/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

0 comments on commit e39fd75

Please sign in to comment.