aboutsummaryrefslogtreecommitdiffstats
path: root/packages/forms/src/wrapper/index.tsx
blob: cf179bc5ea8c8cd6f5fcfd5b51801b036036fa0b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import classnames from 'classnames';
import React, { Component } from 'react';
import injectStyle from 'react-jss';
import { IWithStyle } from '../typings/generic';

interface IProps extends IWithStyle {
  children: React.ReactNode;
  className?: string;
  identifier: string;
  noMargin?: boolean;
}

const styles = {
  container: {
    marginBottom: (props: IProps) => props.noMargin ? 0 : 20,
  },
};

class WrapperComponent extends Component<IProps> {
  render() {
    const {
      children,
      classes,
      className,
      identifier,
    } = this.props;

    return (
      <div
        className={classnames({
          [`${classes.container}`]: true,
          [`${className}`]: className,
        })}
        data-type={identifier}
      >
        {children}
      </div>
    );
  }
}

export const Wrapper = injectStyle(styles)(WrapperComponent);