-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TASK: rewrite react-ui-components in TypeScript (#2128)
* TASK: prepare typescript dev env * FEATURE: badge in typescript * FEATURE: bar in typescript * FEATURE: checkbox in typescript * FEATURE: headline in typescript * FEATURE: sidebar in typescript * FEATURE: tabs/panel in typescript * FEATURE: IconButtonDropDown/dropDownItem in typescript * FEATURE: Button in typescript * FEATURE: Icon in typescript * FEATURE: IconButton & IconButtonDropDown in typescript * TASK: remove verbosity of some import statements * TASK: fix linting error * BUGFIX: defaultProps do not work with type annotation! So we can not benefit from intellisense and automatic type checking in defaultProps. * TASK: stage fixes * TASK: revert frontendDevelopmentMode setting * REFACTOR: remove capital I from interface names, introduce better way to type defaultProps, minor fixes * TASK: resolve //TODOs * TASK: use only one typescript laoder
- Loading branch information
1 parent
713387c
commit 53fa53a
Showing
155 changed files
with
2,105 additions
and
1,905 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
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 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
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,41 @@ | ||
import mergeClassNames from 'classnames'; | ||
import React, {PureComponent} from 'react'; | ||
|
||
interface BadgeTheme { | ||
readonly badge: string; | ||
} | ||
|
||
interface BadgeProps { | ||
/** | ||
* An optional `className` to attach to the wrapper. | ||
*/ | ||
readonly className?: string; | ||
|
||
/** | ||
* Badge's label. | ||
*/ | ||
readonly label: string; | ||
|
||
/** | ||
* An optional css theme to be injected. | ||
*/ | ||
readonly theme?: BadgeTheme; | ||
} | ||
|
||
class Badge extends PureComponent<BadgeProps> { | ||
public render(): JSX.Element { | ||
const { | ||
className, | ||
theme, | ||
label, | ||
...rest | ||
} = this.props; | ||
const finalClassName = mergeClassNames(theme!.badge, className); | ||
|
||
return ( | ||
<div {...rest} className={finalClassName}>{label}</div> | ||
); | ||
} | ||
} | ||
|
||
export default Badge; |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import {themr} from '@friendsofreactjs/react-css-themr'; | ||
import identifiers from './../identifiers'; | ||
import identifiers from '../identifiers'; | ||
import style from './style.css'; | ||
import Badge from './badge.js'; | ||
import Badge from './badge'; | ||
|
||
export default themr(identifiers.badge, style)(Badge); |
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 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
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,59 @@ | ||
import mergeClassNames from 'classnames'; | ||
import React, {PureComponent} from 'react'; | ||
|
||
type BarPosition = 'top' | 'bottom'; | ||
|
||
interface BarTheme { | ||
readonly 'bar': string; | ||
readonly 'bar--top': string; | ||
readonly 'bar--bottom': string; | ||
} | ||
|
||
interface BarProps { | ||
/** | ||
* This prop controls the vertical positioning of the Bar. | ||
*/ | ||
readonly position: BarPosition; | ||
|
||
/** | ||
* An optional css theme to be injected. | ||
*/ | ||
readonly theme?: BarTheme; | ||
|
||
/** | ||
* An optional `className` to attach to the wrapper. | ||
*/ | ||
readonly className?: string; | ||
|
||
/** | ||
* The contents to be rendered within the `Bar`. | ||
*/ | ||
readonly children: React.ReactNode; | ||
} | ||
|
||
class Bar extends PureComponent<BarProps> { | ||
public render(): JSX.Element { | ||
const {position, className, theme, children, ...rest} = this.props; | ||
const finalClassName = mergeClassNames( | ||
className, | ||
theme!.bar, | ||
{ | ||
[theme!['bar--top']]: position === 'top', | ||
[theme!['bar--bottom']]: position === 'bottom' | ||
} | ||
); | ||
|
||
// TODO: | ||
// The prop 'rest' is empty here. I suppose it contains all the attributes that are not part of the Badge Api/Interface. | ||
// Consider enxtending Bagde with React.HTMLAttributes<HTMLDivElement> like we did in the Button component. | ||
// It also enables autocomplete for the whole div Api. | ||
// Consider this for the other components. | ||
return ( | ||
<div className={finalClassName} {...rest}> | ||
{children} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Bar; |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import {themr} from '@friendsofreactjs/react-css-themr'; | ||
import identifiers from './../identifiers'; | ||
import identifiers from '../identifiers'; | ||
import style from './style.css'; | ||
import Bar from './bar.js'; | ||
import Bar from './bar'; | ||
|
||
export default themr(identifiers.bar, style)(Bar); |
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
Oops, something went wrong.