Skip to content

Commit

Permalink
fix: Migrate Reset & Strong to TypeScript (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltaranto authored Nov 19, 2018
1 parent 7545b00 commit 8b01f9b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 59 deletions.
33 changes: 0 additions & 33 deletions lib/components/Reset/Reset.js

This file was deleted.

42 changes: 42 additions & 0 deletions lib/components/Reset/Reset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React, { Component, ReactType } from 'react';
import classnames from 'classnames';
import withTheme, { WithThemeProps } from '../private/withTheme';
import { ResetTags, Theme } from '../../themes/theme';

interface Props extends WithThemeProps {
component: ReactType;
className?: string;
}

const isResettable = (
theme: Theme,
component: ReactType
): component is ResetTags =>
typeof component === 'string' &&
Object.keys(theme.atoms.reset).indexOf(component) > -1;

export default withTheme(
class Reset extends Component<Props> {
static displayName = 'Reset';

static defaultProps = {
component: 'div'
};

render() {
const { theme, component, className = '', ...restProps } = this.props;

const resetClass = isResettable(theme, component)
? { [theme.atoms.reset[component]]: theme.atoms.reset[component] }
: {};

return React.createElement(component, {
className: classnames({
[className]: className,
...resetClass
}),
...restProps
});
}
}
);
26 changes: 0 additions & 26 deletions lib/components/Strong/Strong.js

This file was deleted.

24 changes: 24 additions & 0 deletions lib/components/Strong/Strong.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { Component } from 'react';
import classnames from 'classnames';
import withTheme, { WithThemeProps } from '../private/withTheme';

interface Props extends WithThemeProps {
className?: string;
}

export default withTheme(
class Strong extends Component<Props> {
static displayName = 'Strong';

render() {
const { theme, className = '', ...restProps } = this.props;

return (
<strong
{...restProps}
className={classnames(className, theme.atoms.fontWeight.strong)}
/>
);
}
}
);

0 comments on commit 8b01f9b

Please sign in to comment.