Added types for react-leaflet-sidebarv2

This commit is contained in:
vikram-gsu 2019-04-11 07:22:12 -04:00
parent 87b286543f
commit 3e9f4d543b
4 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,41 @@
// Type definitions for react-leaflet-sidebarv2
// Project: https://github.com/condense/react-leaflet-sidebarv2
// Definitions by: Vikram Pareddy <https://github.com/vikram-gsu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import React from 'react';
type Icon = string | React.ElementType;
type Anchor = 'top' | 'bottom';
type Position = 'left' | 'right';
interface TabProps{
id: string,
header: string,
icon:Icon,
anchor?: Anchor,
disabled?: boolean,
onClose?: () => void,
closeIcon?: Icon,
position?: Position,
active?: boolean
}
declare class Tab extends React.Component<TabProps, any>{}
type TabType = React.Element<Tab> | React.Element<Tab>[]
interface SidebarProps {
id: string,
collapsed: boolean,
position: Position,
selected: string,
closeIcon?: Icon,
onClose?:() => void,
onOpen?: () => void,
children: TabType
}
declare class Sidebar extends React.Component<SidebarProps, any>{}
export {Tab, Sidebar}

View File

@ -0,0 +1,14 @@
import * as React from 'react';
import {Sidebar, Tab} from 'react-leaflet-sidebarv2';
export const MetroSidebar = () => {
return (
<Sidebar id='sidebar' collapsed={false} selected={'home'} closeIcon='fa' position='right'>
<Tab id='home' header='Home' icon='fa fa-home'>
No place like home!
</Tab>
<Tab id='settings' header='Settings' icon='fa fa-cog' anchor='bottom'>
In Settings.
</Tab>
</Sidebar>);
}

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-leaflet-sidebarv2-tests.tsx"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }