Skip to content

Commit

Permalink
Add components/Card, File, Select, Textarea, Typography
Browse files Browse the repository at this point in the history
  • Loading branch information
heimdallrj authored and thinkholic committed Aug 11, 2020
1 parent 764b6f3 commit 800caac
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/Card/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';

export default function Card({ style, children, ...restProps }) {
return (
<div {...restProps} style={style}>
{children}
</div>
);
}

Card.propTypes = {
style: PropTypes.object,
children: PropTypes.element.isRequired,
};
15 changes: 15 additions & 0 deletions src/components/File/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';

import Input from '../Input';

export default function File({ name, accept, ...restProps }) {
return (
<Input {...restProps} type="file" id={name} name={name} accept={accept} />
);
}

File.propTypes = {
name: PropTypes.string,
accept: PropTypes.string,
};
23 changes: 23 additions & 0 deletions src/components/Select/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import PropTypes from 'prop-types';

export default function Select({ name, options }) {
return (
<select name={name} id={name}>
{options.map(({ value, label }) => (
<option key={`${name}-${label}`} value={value}>
{label}
</option>
))}
</select>
);
}

Select.propTypes = {
name: PropTypes.string,
options: PropTypes.array,
};

Select.defaultProps = {
options: [],
};
21 changes: 21 additions & 0 deletions src/components/Textarea/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import PropTypes from 'prop-types';

export default function Textarea({ name, text, rows, cols, ...restProps }) {
return (
<textarea {...restProps} id={name} name={name} rows={rows} cols={cols}>
{text}
</textarea>
);
}

Textarea.propTypes = {
name: PropTypes.string,
text: PropTypes.string,
rows: PropTypes.number,
cols: PropTypes.number,
};

Textarea.defaultProps = {
checked: false,
};
15 changes: 15 additions & 0 deletions src/components/Typography/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';

export default function Typography({ type, text, ...restProps }) {
return React.createElement(`${type}`, { ...restProps }, text);
}

Typography.propTypes = {
type: PropTypes.string,
text: PropTypes.string.isRequired,
};

Typography.defaultProps = {
type: 'div',
};

0 comments on commit 800caac

Please sign in to comment.