-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Migrate Reset & Strong to TypeScript (#48)
- Loading branch information
1 parent
7545b00
commit 8b01f9b
Showing
4 changed files
with
66 additions
and
59 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,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 | ||
}); | ||
} | ||
} | ||
); |
This file was deleted.
Oops, something went wrong.
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,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)} | ||
/> | ||
); | ||
} | ||
} | ||
); |