Skip to content

Commit

Permalink
Convert existing components to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
cvuorinen committed Dec 13, 2017
1 parent f2438eb commit 035b249
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import 'preact-material-components/List/style.css';
import 'preact-material-components/Toolbar/style.css';
// import style from './style';

export default class Header extends Component {
interface State {
darkThemeEnabled: any;
}
export default class Header extends Component<{}, State> {
dialog: any;
drawer: any;
closeDrawer() {
this.drawer.MDComponent.open = false;
this.state = {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/home/index.js → src/routes/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { h, Component } from 'preact';
import Card from 'preact-material-components/Card';
import 'preact-material-components/Card/style.css';
import 'preact-material-components/Button/style.css';
import style from './style';
import * as style from './style.css';

export default class Home extends Component {
export default class Home extends Component<{}, {}> {
render() {
return (
<div class={style.home}>
Expand Down
1 change: 1 addition & 0 deletions src/routes/home/style.css.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const home: string;
16 changes: 13 additions & 3 deletions src/routes/profile/index.js → src/routes/profile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { h, Component } from 'preact';
import Button from 'preact-material-components/Button';
import 'preact-material-components/Button/style.css';
import style from './style';
import * as style from './style.css';

export default class Profile extends Component {
interface Props {
user?: any;
path: any;
}
interface State {
time: any;
count: any;
}
export default class Profile extends Component<Props, State> {
timer: any;
state = {
time: Date.now(),
count: 10
Expand All @@ -30,7 +39,8 @@ export default class Profile extends Component {
};

// Note: `user` comes from the URL, courtesy of our router
render({ user }, { time, count }) {
render(props, { time, count }) {
const user = props.user;
return (
<div class={style.profile}>
<h1>Profile: {user}</h1>
Expand Down
1 change: 1 addition & 0 deletions src/routes/profile/style.css.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const profile: string;

0 comments on commit 035b249

Please sign in to comment.