@universal-tennis/ui-shared 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/.eslintignore +1 -1
  2. package/.eslintrc.js +10 -3
  3. package/dist/components.d.ts +1 -0
  4. package/dist/components.js +1 -0
  5. package/dist/components.js.map +1 -1
  6. package/dist/stories/atoms/Button/Button.js.map +1 -1
  7. package/dist/stories/atoms/Typography/Typography.d.ts +44 -5
  8. package/dist/stories/atoms/Typography/Typography.js +54 -10
  9. package/dist/stories/atoms/Typography/Typography.js.map +1 -1
  10. package/dist/stories/molecules/Cards/Cards.stories.js +4 -4
  11. package/dist/stories/molecules/Cards/Cards.stories.js.map +1 -1
  12. package/dist/stories/molecules/Cards/ContactCard.js.map +1 -1
  13. package/dist/stories/molecules/Cards/DrawCard.d.ts +1 -1
  14. package/dist/stories/molecules/Cards/DrawCard.js +15 -15
  15. package/dist/stories/molecules/Cards/DrawCard.js.map +1 -1
  16. package/dist/stories/molecules/Cards/TeamCard.js.map +1 -1
  17. package/dist/stories/molecules/Cards/sharedTypes.d.ts +11 -7
  18. package/dist/stories/organisms/DrawCardTable.js +1 -1
  19. package/dist/stories/organisms/DrawCardTable.js.map +1 -1
  20. package/dist/stories/organisms/SortableTable.d.ts +23 -0
  21. package/dist/stories/organisms/SortableTable.js +32 -0
  22. package/dist/stories/organisms/SortableTable.js.map +1 -0
  23. package/dist/stories/organisms/Tables.stories.d.ts +1 -0
  24. package/dist/stories/organisms/Tables.stories.js +58 -4
  25. package/dist/stories/organisms/Tables.stories.js.map +1 -1
  26. package/dist/types/tableDataTypes.d.ts +38 -0
  27. package/dist/types/tableDataTypes.js +2 -0
  28. package/dist/types/tableDataTypes.js.map +1 -0
  29. package/package.json +1 -1
  30. package/src/components.jsx +1 -0
  31. package/src/stories/atoms/Button/Button.tsx +19 -19
  32. package/src/stories/atoms/Typography/Typography.tsx +86 -49
  33. package/src/stories/molecules/Cards/Cards.stories.tsx +8 -8
  34. package/src/stories/molecules/Cards/ContactCard.tsx +23 -25
  35. package/src/stories/molecules/Cards/DrawCard.tsx +50 -51
  36. package/src/stories/molecules/Cards/TeamCard.tsx +4 -6
  37. package/src/stories/molecules/Cards/sharedTypes.ts +12 -7
  38. package/src/stories/organisms/DrawCardTable.tsx +20 -21
  39. package/src/stories/organisms/SortableTable.tsx +110 -0
  40. package/src/stories/organisms/Tables.stories.tsx +91 -10
  41. package/src/types/tableDataTypes.ts +42 -0
  42. package/tsconfig.json +19 -21
  43. package/workflows/package-release-1.yml +3 -3
@@ -0,0 +1,110 @@
1
+ import React, { ComponentType, SyntheticEvent } from "react";
2
+
3
+ import Table from "@mui/material/Table";
4
+ import TableBody from "@mui/material/TableBody";
5
+ import TableCell from "@mui/material/TableCell";
6
+ import TableContainer from "@mui/material/TableContainer";
7
+ import TableHead from "@mui/material/TableHead";
8
+ import MuiTableRow from "@mui/material/TableRow";
9
+ import TableSortLabel from "@mui/material/TableSortLabel";
10
+ import Toolbar from "@mui/material/Toolbar";
11
+ import Paper from "@mui/material/Paper";
12
+
13
+ import { TableData } from "types/tableDataTypes";
14
+ import Typography from '../atoms/Typography/Typography';
15
+
16
+ type Order = 'asc' | 'desc';
17
+ type OrderProperty = string | number;
18
+
19
+ interface HeadCell {
20
+ id: string;
21
+ label?: string;
22
+ isSortingDisabled: boolean
23
+ }
24
+
25
+ export type SortableTableProps = {
26
+ headCells: Array<HeadCell>;
27
+ tableData: Array<TableData>;
28
+ sortOrder: Order;
29
+ sortByProperty: OrderProperty;
30
+ rowComponent: ComponentType<{rowData: TableData, labelId: string}>;
31
+ title?: string;
32
+ onOrderPropertyChange: (property: OrderProperty) => VoidFunction
33
+ }
34
+
35
+ function SortableTable({
36
+ headCells,
37
+ tableData,
38
+ rowComponent,
39
+ sortOrder,
40
+ sortByProperty,
41
+ title = '',
42
+ onOrderPropertyChange,
43
+ }: SortableTableProps) {
44
+ const TableRow = rowComponent;
45
+
46
+ const handleRequestSort = (property: OrderProperty) => (event: SyntheticEvent) => {
47
+ event.preventDefault();
48
+ onOrderPropertyChange(property);
49
+ };
50
+
51
+ return (
52
+ <Paper sx={{ width: "100%", mb: 2 }}>
53
+ {title && (
54
+ <Toolbar sx={{ pl: { sm: 2 }, pr: { xs: 1, sm: 1 } }}>
55
+ <Typography
56
+ category="secondary"
57
+ size="large-medium"
58
+ id="tableTitle"
59
+ >
60
+ {title}
61
+ </Typography>
62
+ </Toolbar>
63
+ )}
64
+ <TableContainer>
65
+ <Table
66
+ sx={{ minWidth: 750 }}
67
+ aria-labelledby="tableTitle"
68
+ size="medium"
69
+ >
70
+ <TableHead>
71
+ <MuiTableRow>
72
+ {headCells.map((headCell) => (
73
+ <TableCell
74
+ key={headCell.id}
75
+ align="left"
76
+ padding="normal"
77
+ sortDirection={sortByProperty === headCell.id ? sortOrder : false}
78
+ >
79
+ <TableSortLabel
80
+ disabled={headCell.isSortingDisabled}
81
+ hideSortIcon={!headCell?.label}
82
+ active={sortByProperty === headCell.id}
83
+ direction={sortByProperty === headCell.id ? sortOrder : 'asc'}
84
+ onClick={handleRequestSort(headCell.id)}
85
+ >
86
+ {headCell?.label}
87
+ </TableSortLabel>
88
+ </TableCell>
89
+ ))}
90
+ </MuiTableRow>
91
+ </TableHead>
92
+ <TableBody>
93
+ {tableData && tableData.map((data: TableData, index: number) => {
94
+ const labelId = `table-${index}`;
95
+ return (
96
+ <TableRow
97
+ key={data.id}
98
+ rowData={data}
99
+ labelId={labelId}
100
+ />
101
+ );
102
+ })}
103
+ </TableBody>
104
+ </Table>
105
+ </TableContainer>
106
+ </Paper>
107
+ );
108
+ }
109
+
110
+ export default SortableTable;
@@ -1,10 +1,80 @@
1
1
  import React from 'react';
2
+ import { TableRow, TableCell, Typography } from '@mui/material';
2
3
  import DrawCard from '../molecules/Cards/DrawCard';
3
4
  import DrawCardTable from './DrawCardTable';
4
- import {DrawCardTableProps } from './sharedTypes';
5
+ import { DrawCardTableProps } from './sharedTypes';
6
+
7
+ interface RowData {
8
+ player: string;
9
+ team: string;
10
+ session: string;
11
+ }
12
+
13
+ interface RowProps {
14
+ rowData: RowData,
15
+ labelId: string;
16
+ }
17
+
18
+ const rowComponent = ({ rowData, labelId }: RowProps) => {
19
+ const { player, session, team } = rowData;
20
+ return (
21
+ <TableRow>
22
+ <TableCell
23
+ component="th"
24
+ id={labelId}
25
+ scope="row"
26
+ padding="normal"
27
+ >
28
+ <Typography>{player}</Typography>
29
+ </TableCell>
30
+ <TableCell align="left">
31
+ <Typography>{team}</Typography>
32
+ </TableCell>
33
+ <TableCell align="left">
34
+ <Typography>{session}</Typography>
35
+ </TableCell>
36
+ </TableRow>
37
+
38
+ );
39
+ };
40
+
41
+ const headCells = [
42
+ { id: 'player', label: 'Player Name', isSortingDisabled: false },
43
+ { id: 'team', label: 'Team Name', isSortingDisabled: true },
44
+ { id: 'session', label: 'Session', isSortingDisabled: false }];
45
+
46
+ const tableData = [
47
+ {
48
+ player: 'John Smith',
49
+ team: 'Mavericks',
50
+ session: 'NorCal Adults',
51
+ },
52
+ {
53
+ player: 'Megan Brown',
54
+ team: 'Mini Mavericks',
55
+ session: 'SoCal Juniors',
56
+ },
57
+ {
58
+ player: 'George Fox',
59
+ team: 'Grey Foxes',
60
+ session: 'North Bay Junios',
61
+ },
62
+ {
63
+ player: 'Alison Green',
64
+ team: 'Lions',
65
+ session: 'Outer Bay UTR 2-5',
66
+ },
67
+ {
68
+ player: 'Linda Belinda',
69
+ team: 'Green Hornets',
70
+ session: 'Tri-State UTR 1-3',
71
+ },
72
+ ];
73
+
74
+ const onOrderPropertyChange = () => {};
5
75
 
6
76
  const SAMPLE_CARD_DATA = {
7
- choices: [
77
+ options: [
8
78
  {
9
79
  id: 1,
10
80
  label: 'Team 1',
@@ -14,9 +84,9 @@ const SAMPLE_CARD_DATA = {
14
84
  label: 'Team 2',
15
85
  }
16
86
  ],
17
- selectedTeams: {
18
- teamOne: 1,
19
- teamTwo: 2,
87
+ selectedOptions: {
88
+ optionOne: 1,
89
+ optionTwo: 2,
20
90
  },
21
91
  dateLabel: 'Dec 20 at 9:00am',
22
92
  locationLabel: 'Taube Tennis Center',
@@ -33,9 +103,9 @@ function DrawCardTableTemplate(args: DrawCardTableProps) {
33
103
  }
34
104
 
35
105
  const headerRows = [
36
- {name: 'Round 1' },
37
- {name: 'Quarterfinal' },
38
- {name: 'SemiFinal' },
106
+ { name: 'Round 1' },
107
+ { name: 'Quarterfinal' },
108
+ { name: 'SemiFinal' },
39
109
  ];
40
110
 
41
111
  const tableRows = [
@@ -56,8 +126,8 @@ const tableRows = [
56
126
  <DrawCard {...SAMPLE_CARD_DATA} />,
57
127
  ],
58
128
  [
59
- <DrawCard {...SAMPLE_CARD_DATA} />,
60
- <DrawCard {...SAMPLE_CARD_DATA} />,
129
+ <DrawCard {...SAMPLE_CARD_DATA} />,
130
+ <DrawCard {...SAMPLE_CARD_DATA} />,
61
131
  ],
62
132
  ];
63
133
 
@@ -67,3 +137,14 @@ DrawTable.args = {
67
137
  headerRows,
68
138
  tableRows,
69
139
  };
140
+
141
+ export const SortableTable = DrawCardTableTemplate.bind({});
142
+ SortableTable.args = {
143
+ headCells,
144
+ sortOrder: 'asc',
145
+ sortByProperty: 'player',
146
+ title: 'Player Table',
147
+ tableData,
148
+ rowComponent,
149
+ onOrderPropertyChange,
150
+ };
@@ -0,0 +1,42 @@
1
+ export interface Location {
2
+ placeId: string;
3
+ formattedAddress: string;
4
+ placeName: string;
5
+ lat: number;
6
+ lng: number
7
+ }
8
+
9
+ export interface Captain {
10
+ id: number;
11
+ teamId: number;
12
+ memberId: number;
13
+ playerId: number;
14
+ gender?: string;
15
+ firstName: string;
16
+ lastName: string;
17
+ email?: string;
18
+ phone?: string;
19
+ phoneCountryCode?: string;
20
+ profileImage?: string;
21
+ location?: Location
22
+ }
23
+
24
+ export interface AddTeamsData {
25
+ id: number;
26
+ name: string;
27
+ teamMemberCount: number;
28
+ captains: Array<Captain>;
29
+ sessionId: number;
30
+ sessionName: string;
31
+ sessionStartDateUtc: string;
32
+ sessionEndDateUtc: string;
33
+ wins: number;
34
+ losses: number;
35
+ rank?: number;
36
+ isSelected?: boolean;
37
+ record?: string;
38
+ sessionDates?: string;
39
+
40
+ }
41
+
42
+ export type TableData = AddTeamsData
package/tsconfig.json CHANGED
@@ -1,25 +1,23 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "noImplicitThis": true,
4
- "preserveConstEnums": true,
5
- "strictNullChecks": true,
6
- "sourceMap": true,
7
- "declaration": true,
8
- "esModuleInterop": true,
9
- "outDir": "dist",
10
- "target": "es6",
11
- "module": "es6",
12
- "allowJs": true,
13
- "moduleResolution": "node",
14
- "skipLibCheck": true,
15
- "jsx": "react",
16
- "lib": ["ES2017", "DOM"],
17
- "baseUrl": "src",
18
- "allowSyntheticDefaultImports": true,
19
- "noImplicitAny": true,
3
+ "noImplicitThis": true,
4
+ "preserveConstEnums": true,
5
+ "strictNullChecks": true,
6
+ "sourceMap": true,
7
+ "declaration": true,
8
+ "esModuleInterop": true,
9
+ "outDir": "dist",
10
+ "target": "es6",
11
+ "module": "es6",
12
+ "allowJs": true,
13
+ "moduleResolution": "node",
14
+ "skipLibCheck": true,
15
+ "jsx": "react",
16
+ "lib": ["ES2017", "DOM"],
17
+ "baseUrl": "src",
18
+ "allowSyntheticDefaultImports": true,
19
+ "noImplicitAny": true
20
20
  },
21
- "exclude": [
22
- "node_modules",
23
- ],
21
+ "exclude": ["node_modules"],
24
22
  "include": ["src", "src/custom.d.ts"]
25
- }
23
+ }
@@ -1,10 +1,10 @@
1
1
  trigger:
2
2
  tags:
3
3
  include:
4
- - '*'
4
+ - '0/*'
5
5
  branches:
6
- exclude:
7
- - '*'
6
+ include:
7
+ - 'master'
8
8
 
9
9
  pool:
10
10
  vmImage: ubuntu-latest