forked from react-toolbox/react-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Typescript definitions validation (react-toolbox#1163)
* initial attempt to validate ts definitions * ignore .vscode * Add other spect & some fixes: - Add target prop to Button - Add value prop to MenuItem - Make label optional in Tab - Improve Tooltip types * Add tsc validation to travis * fix typo in travis build step
- Loading branch information
1 parent
8b7fc07
commit 91cb46d
Showing
37 changed files
with
1,801 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ node_modules | |
npm-debug.log | ||
.idea | ||
.DS_Store | ||
.vscode |
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 |
---|---|---|
|
@@ -8,4 +8,5 @@ node_js: | |
|
||
script: | ||
- npm run lint | ||
- npm run ts | ||
- npm test |
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from 'react'; | ||
import AppBar, {AppBar as NamedAppBar} from 'components/app_bar'; | ||
|
||
const AppBarTest: React.SFC<any> = () => ( | ||
<section> | ||
<h5>AppBar</h5> | ||
<br /> | ||
<AppBar title='Title' /> | ||
<br /> | ||
<AppBar leftIcon='menu' title='Title' /> | ||
<br /> | ||
<AppBar leftIcon='arrow_back' title='Title' rightIcon='close' /> | ||
<br /> | ||
<AppBar> | ||
Custom content | ||
</AppBar> | ||
<br/> | ||
<NamedAppBar title='NamedAppBar' /> | ||
</section> | ||
) | ||
|
||
export default AppBarTest; |
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,96 @@ | ||
import * as React from 'react'; | ||
import Autocomplete from 'components/autocomplete'; | ||
|
||
class AutocompleteTest extends React.Component<any, any> { | ||
state: any = { | ||
simple: 'Spain', | ||
simpleShowAll: 'England', | ||
multipleArray: ['ES-es', 'TH-th'], | ||
multipleObject: {'ES-es': 'Spain', 'TH-th': 'Thailand'}, | ||
countriesArray: ['Spain', 'England', 'USA', 'Thailand', 'Tongo', 'Slovenia'], | ||
countriesObject: { | ||
'EN-gb': 'England', | ||
'EN-en': 'United States of America', 'EN-nz': 'New Zealand' | ||
} | ||
}; | ||
|
||
handleFocus = (event: React.MouseEvent<any>) => { | ||
console.log('This is focused'); | ||
console.log(event); | ||
}; | ||
|
||
handleMultipleArrayChange = (value: any) => { | ||
this.setState({ | ||
multipleArray: value, | ||
countriesObject: { | ||
...this.state.countriesObject, | ||
...(value[0] && !this.state.countriesObject[value[0]]) ? {[value[0]]: value[0]} : {} | ||
} | ||
}); | ||
}; | ||
|
||
handleMultipleObjectChange = (value: any) => { | ||
this.setState({ | ||
multipleObject: value | ||
}); | ||
}; | ||
|
||
handleSimpleChange = (value: any) => { | ||
this.setState({simple: value}); | ||
}; | ||
|
||
handleSimpleShowAllChange = (value: any) => { | ||
this.setState({simpleShowAll: value}); | ||
}; | ||
|
||
render () { | ||
return ( | ||
<section> | ||
<h5>Autocomplete</h5> | ||
<p>You can have a multiple or simple autocomplete.</p> | ||
|
||
<Autocomplete | ||
allowCreate | ||
keepFocusOnChange | ||
label="Pick multiple elements..." | ||
onFocus={this.handleFocus} | ||
onChange={this.handleMultipleArrayChange} | ||
source={this.state.countriesObject} | ||
suggestionMatch="anywhere" | ||
value={this.state.multipleArray} | ||
/> | ||
|
||
<Autocomplete | ||
allowCreate | ||
label="Pick multiple elements with object value..." | ||
onChange={this.handleMultipleObjectChange} | ||
showSelectedWhenNotInSource | ||
source={this.state.countriesObject} | ||
suggestionMatch="anywhere" | ||
value={this.state.multipleObject} | ||
/> | ||
|
||
<Autocomplete | ||
hint="Elements up to you..." | ||
label="Choose a country" | ||
multiple={false} | ||
onChange={this.handleSimpleChange} | ||
source={this.state.countriesArray} | ||
value={this.state.simple} | ||
/> | ||
|
||
<Autocomplete | ||
hint="Elements up to you..." | ||
label="Choose a country (showing all suggestions)" | ||
multiple={false} | ||
onChange={this.handleSimpleShowAllChange} | ||
showSuggestionsWhenValueIsSet | ||
source={this.state.countriesArray} | ||
value={this.state.simpleShowAll} | ||
/> | ||
</section> | ||
); | ||
} | ||
} | ||
|
||
export default AutocompleteTest; |
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,22 @@ | ||
import * as React from 'react'; | ||
import Avatar from '../../components/avatar'; | ||
import GithubIcon from './github_icon'; | ||
|
||
const AvatarTest = () => ( | ||
<section> | ||
<h5>Avatars</h5> | ||
<p>Provide an image source or object, a font icon, children or a title to use its first letter.</p> | ||
<Avatar style={{ backgroundColor: 'deepskyblue' }} icon="folder" alt="icon folder" /> | ||
<Avatar icon={<GithubIcon />} /> | ||
<Avatar><img src="https://placeimg.com/80/80/animals" alt="foobar" /></Avatar> | ||
<Avatar image="https://placeimg.com/80/80/animals" alt="foobar" /> | ||
<Avatar | ||
alt="foobar" | ||
image="http://www.thewrap.com/wp-content/uploads/2015/08/margot-robbie-harley-quinn_main.jpg" cover | ||
/> | ||
<Avatar title="Javier" /> | ||
<Avatar style={{ backgroundColor: 'yellowgreen' }}><GithubIcon /></Avatar> | ||
</section> | ||
); | ||
|
||
export default AvatarTest; |
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,51 @@ | ||
import * as React from 'react'; | ||
import GithubIcon from './github_icon'; | ||
import { Button, IconButton, BrowseButton } from '../../components/button'; | ||
|
||
const ButtonTest = () => ( | ||
<section> | ||
<h5>Buttons</h5> | ||
<p>lorem ipsum...</p> | ||
|
||
<Button href="http://github.com/javivelasco" target="_blank" raised> | ||
<GithubIcon /> Github | ||
</Button> | ||
<Button icon="bookmark" label="Bookmark" accent onRippleEnded={rippleEnded} /> | ||
<Button icon="bookmark" label="Bookmark" raised primary rippleMultiple={false} onRippleEnded={rippleEnded} /> | ||
<Button icon="inbox" label="Inbox" flat /> | ||
<Button icon="add" floating /> | ||
<Button icon="add" floating primary /> | ||
<Button href="http://github.com/javivelasco" target="_blank" icon="link" floating accent /> | ||
<Button icon="add" floating primary disabled /> | ||
<Button icon="add" floating accent mini /> | ||
<IconButton icon="favorite" accent /> | ||
<IconButton icon="favorite" inverse /> | ||
<IconButton icon="favorite" /> | ||
<IconButton icon="favorite" disabled /> | ||
<IconButton primary><GithubIcon /></IconButton> | ||
<Button icon="add" label="Add this" flat primary /> | ||
<Button icon="add" label="Add this" flat disabled /> | ||
<h5>Icon Button Alignment</h5> | ||
<p> | ||
Icon Buttons should align in the vertical center, to see this we need to | ||
put them next to text or highlight thier background color. | ||
</p> | ||
<IconButton icon="menu" style={{ backgroundColor: 'red' }} inverse /> | ||
<span style={{ verticalAlign: 'middle' }}>Menu</span> | ||
<IconButton icon="menu" /> | ||
<span style={{ verticalAlign: 'middle' }}>Menu</span> | ||
<IconButton><GithubIcon /></IconButton> | ||
<span style={{ verticalAlign: 'middle' }}>Github</span> | ||
<h5>Browse Button</h5> | ||
<br /> | ||
<BrowseButton icon="folder_open" label="BROWSE" raised primary /> | ||
| ||
<BrowseButton label="BROWSE" raised /> | ||
</section> | ||
); | ||
|
||
function rippleEnded() { | ||
console.log('Ripple animation ended!'); | ||
} | ||
|
||
export default ButtonTest; |
Oops, something went wrong.