Skip to content

[SWP-714] Components library #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4f44fe6
Project setup and WIP of button component
iamjohnpeet Aug 20, 2019
982cfc1
Button and Secondary button styles added
iamjohnpeet Aug 20, 2019
67f8100
Click event added to buttons
iamjohnpeet Aug 20, 2019
6bb772f
Tags added and minor Button updates
iamjohnpeet Aug 20, 2019
6491b6c
Button reworked
iamjohnpeet Aug 21, 2019
9a4ab71
Tags reworked
iamjohnpeet Aug 21, 2019
93788aa
PostCSS setup
iamjohnpeet Aug 22, 2019
75dfd97
Linter added and base typography added too
iamjohnpeet Aug 22, 2019
1cb95ba
Input and Select fields added
iamjohnpeet Aug 22, 2019
bec4047
Select arrow added
iamjohnpeet Aug 27, 2019
d5238aa
Link added
iamjohnpeet Aug 27, 2019
e2a825f
Checkbox added
iamjohnpeet Aug 27, 2019
2602c96
WIP: Tables added
iamjohnpeet Aug 27, 2019
f94294f
Parent class added for Checkbox component
iamjohnpeet Aug 28, 2019
8314d95
Header partial added
iamjohnpeet Aug 28, 2019
330307d
Layout Container documented
iamjohnpeet Aug 28, 2019
dddae07
Toggle switch component added
iamjohnpeet Aug 29, 2019
96c1774
Minor edits to toggle switch
iamjohnpeet Aug 29, 2019
c83295b
Table data added
iamjohnpeet Aug 30, 2019
23e25d3
WIP: Typescript added
iamjohnpeet Sep 2, 2019
2d1ae91
Form component files changed to typescript
iamjohnpeet Sep 2, 2019
1967c58
All component files changed to typescript
iamjohnpeet Sep 2, 2019
0eaf0bf
Button disable style changed and Button description added
iamjohnpeet Sep 3, 2019
b0cb924
Form descriptions added
iamjohnpeet Sep 3, 2019
18e95b9
Readme and project description added
iamjohnpeet Sep 4, 2019
3270820
Minor prop name edit
iamjohnpeet Sep 4, 2019
7520a7d
Style lint added, other minor edits
iamjohnpeet Sep 12, 2019
7ad08aa
Index files added
iamjohnpeet Sep 13, 2019
f2be350
Table select moved to table component
iamjohnpeet Sep 13, 2019
7ba77bf
Select selected prop added
iamjohnpeet Sep 13, 2019
28d6b84
Remove Bootstrap App assets
iamjohnpeet Sep 20, 2019
23b8634
Minor edits
iamjohnpeet Sep 23, 2019
8041db5
Sentry added
iamjohnpeet Sep 30, 2019
a1d67c2
Add lint script and fix lint issues
iamjohnpeet Sep 30, 2019
91faf50
Travis added
iamjohnpeet Oct 1, 2019
9f5566a
Type packages needed to be added
iamjohnpeet Oct 1, 2019
aa959c4
Update travis file to use yarn instead of npm
iamjohnpeet Oct 2, 2019
7c7c94f
Travis yml fix
iamjohnpeet Oct 2, 2019
0f77823
Add packages to highest level
iamjohnpeet Oct 2, 2019
171ea96
Remove travis coverage script for now
iamjohnpeet Oct 2, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add lint script and fix lint issues
  • Loading branch information
iamjohnpeet committed Sep 30, 2019
commit a1d67c22c232dd1a9795e24902ec90e61e3dd25e
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"tailwind:watch": "postcss src/styles/styles.css -o src/styles/output.css -w",
"tailwind:build": "postcss src/styles/styles.css -o src/styles/output.css",
"lint": "./node_modules/.bin/eslint src",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
Expand Down
26 changes: 17 additions & 9 deletions src/components/forms/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,30 @@ const InputField: FunctionComponent<InputFieldProps> = ({

return (
<div>
<FieldLabel
text={ label }
classList="mb-2"
/>
{
label && (
<FieldLabel
copy={ label }
classList="mb-2"
/>
)
}
<input
id={ id }
type={ type || 'text' }
className={ inputClasses }
placeholder={ placeholder }
disabled={ disabled }
/>
<FieldMessage
text={ message }
error={ error }
classList="mt-2"
/>
{
message && (
<FieldMessage
copy={ message }
error={ error }
classList="mt-2"
/>
)
}
</div>
);
}
Expand Down
26 changes: 17 additions & 9 deletions src/components/forms/SelectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ const SelectField: FunctionComponent<SelectFieldProps> = ({

return (
<div>
<FieldLabel
text={ label }
classList="mb-2"
/>
{
label && (
<FieldLabel
copy={ label }
classList="mb-2"
/>
)
}
<div className="relative">
<select
className={ selectClasses }
Expand All @@ -41,11 +45,15 @@ const SelectField: FunctionComponent<SelectFieldProps> = ({
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="7" viewBox="0 0 13 7"><path d="M 12 1 L 1 1 L 6.5 6.5 L 12 1 L 6.5 6.5" fill="rgb(25, 25, 26)" stroke="rgb(25, 25, 26)" stroke-linecap="round" stroke-linejoin="round"></path></svg>
</div>
</div>
<FieldMessage
text={ message }
error={ error }
classList="mt-2"
/>
{
message && (
<FieldMessage
copy={ message }
error={ error }
classList="mt-2"
/>
)
}
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/ToggleSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ToggleSwitch: FunctionComponent<ToggleSwitchProps> = ({
<span className={ switchClasses }></span>
</label>
{ label && <FieldLabel
text={ label }
copy={ label }
classList="flex-1"
/>
}
Expand Down
10 changes: 7 additions & 3 deletions src/components/tables/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import TableHeader from "./TableHeader";
import TableRow from "./TableRow";

class Table extends PureComponent<TableProps, TableState> {
constructor(props) {
constructor(props: any) {
super(props);

this.state = {
Expand All @@ -16,7 +16,7 @@ class Table extends PureComponent<TableProps, TableState> {
this.handleClick = this.handleClick.bind(this);
}

handleClick(id) {
handleClick(id: number) {
this.setState({
selectedId: id,
});
Expand All @@ -42,7 +42,11 @@ class Table extends PureComponent<TableProps, TableState> {

return (
<table className={ classes }>
<TableHeader headings={ headings } />
{
headings && (
<TableHeader headings={ headings } />
)
}
<tbody>
{
rowData.map((data, index) => <TableRow
Expand Down
11 changes: 6 additions & 5 deletions src/components/tables/TableColumn.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import React, { FunctionComponent } from 'react';
import TableColumnProps from '../../interfaces/components/tables/TableColumn';
import classNames from 'classnames';
import * as styles from './styles';
import columnBaseStyles from './styles';

function TableColumn({
const TableColumn: FunctionComponent<TableColumnProps> = ({
children,
classList,
}) {
}) => {
const classes = classNames(
styles.columnBaseStyles,
columnBaseStyles,
classList,
);

Expand Down
11 changes: 6 additions & 5 deletions src/components/tables/TableHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import React from 'react';
import React, { FunctionComponent } from 'react';
import TableHeaderProps from '../../interfaces/components/tables/TableHeader';
import _ from 'lodash';
import classNames from 'classnames';
import * as styles from './styles';
import columnBaseStyles from './styles';

function TableHeader({
const TableHeader: FunctionComponent<TableHeaderProps> = ({
headings,
}) {
}) => {
const columnClasses = (
'uppercase text-sm text-grey-primary'
);

const classes = classNames(
styles.columnBaseStyles,
columnBaseStyles,
columnClasses
);

Expand Down
2 changes: 1 addition & 1 deletion src/components/tables/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ const columnBaseStyles = (
'p-3 border-b border-grey-1 text-left'
);

export {
export default {
columnBaseStyles,
};
7 changes: 4 additions & 3 deletions src/components/tags/Tag.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import React, { FunctionComponent } from 'react';
import TagProps from '../../interfaces/components/Tags/Tag';
import classNames from 'classnames';
import * as styles from './styles';

function Tag({
const Tag: FunctionComponent<TagProps> = ({
kind,
title,
classList,
}) {
}) => {
let kindStyles;

switch (kind) {
Expand Down
11 changes: 6 additions & 5 deletions src/components/typography/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import React, { FunctionComponent } from 'react';
import LinkProps from '../../interfaces/components/Typography/Link';
import classNames from 'classnames';

function Button({
const Link: FunctionComponent<LinkProps> = ({
title,
url,
classList,
external,
}) {
}) => {
const baseStyles = (
'underline'
);
Expand All @@ -17,10 +18,10 @@ function Button({
);

return (
<a className={ classes } href={ url } target={ external && '_blank' }>
<a className={ classes } href={ url } target={ external ? '_blank' : '_self' }>
{ title }
</a>
);
}

export default Button;
export default Link;
6 changes: 0 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ import ReactDOM from 'react-dom';
import * as Sentry from '@sentry/browser';
import './styles/output.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.SENTRY_ENVIRONMENT,
});

ReactDOM.render(<App />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
4 changes: 2 additions & 2 deletions src/interfaces/components/tables/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export interface TableProps {
headings?: string,
headings?: Array<string>,
rowData: Array<Array<string>>,
classList?: string,
}

export interface TableState {
selectedId: number,
selectedId: number | null,
}
3 changes: 3 additions & 0 deletions src/interfaces/components/tables/TableHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default interface TableHeaderProps {
headings: Array<string>,
}
135 changes: 0 additions & 135 deletions src/serviceWorker.js

This file was deleted.