From 9a5b313ea12bdb9dc3e3873ca3a2639bd7483e46 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Mon, 28 Jan 2019 11:35:25 +0100 Subject: Update packages --- packages/ui/src/badge/index.tsx | 75 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 packages/ui/src/badge/index.tsx (limited to 'packages/ui/src/badge/index.tsx') diff --git a/packages/ui/src/badge/index.tsx b/packages/ui/src/badge/index.tsx new file mode 100644 index 000000000..241e778e7 --- /dev/null +++ b/packages/ui/src/badge/index.tsx @@ -0,0 +1,75 @@ +import { Theme } from '@meetfranz/theme'; +import classnames from 'classnames'; +import React, { Component } from 'react'; +import injectStyle from 'react-jss'; + +import { IWithStyle } from '../typings/generic'; + +interface IProps extends IWithStyle { + type: string; + className?: string; + children: React.ReactNode; +} + +const badgeStyles = (theme: Theme) => { + const styles = {}; + Object.keys(theme.styleTypes).map((style) => { + Object.assign(styles, { + [style]: { + background: theme.styleTypes[style].accent, + color: theme.styleTypes[style].contrast, + border: theme.styleTypes[style].border, + }, + }); + }); + + return styles; +}; + +const styles = (theme: Theme) => ({ + badge: { + display: 'inline-block', + padding: [3, 8, 4], + fontSize: theme.badgeFontSize, + borderRadius: theme.badgeBorderRadius, + margin: [0, 4], + + '&:first-child': { + marginLeft: 0, + }, + + '&:last-child': { + marginRight: 0, + }, + }, + ...badgeStyles(theme), +}); + +class BadgeComponent extends Component { + public static defaultProps = { + type: 'primary', + }; + + render() { + const { + classes, + children, + type, + className, + } = this.props; + + return ( +
+ {children} +
+ ); + } +} + +export const Badge = injectStyle(styles)(BadgeComponent); -- cgit v1.2.3-70-g09d2