@nurvus/ui 0.1.0-alpha.1

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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -0
  3. package/dist/index.js +6 -0
  4. package/package.json +68 -0
  5. package/src/app.js +29 -0
  6. package/src/components/Button/Button.jsx +61 -0
  7. package/src/components/Button/Button.md +79 -0
  8. package/src/components/Button/Button.scss +104 -0
  9. package/src/components/ButtonGroup/ButtonGroup.jsx +17 -0
  10. package/src/components/ButtonGroup/ButtonGroup.md +25 -0
  11. package/src/components/ButtonGroup/ButtonGroup.scss +19 -0
  12. package/src/components/FullPageModal/FullPageModal.jsx +108 -0
  13. package/src/components/FullPageModal/FullPageModal.md +32 -0
  14. package/src/components/FullPageModal/FullPageModal.scss +102 -0
  15. package/src/components/Layout/Layout.jsx +30 -0
  16. package/src/components/Layout/Layout.md +55 -0
  17. package/src/components/Layout/Layout.scss +91 -0
  18. package/src/components/Link/Link.jsx +39 -0
  19. package/src/components/Link/Link.md +5 -0
  20. package/src/components/Link/Link.scss +18 -0
  21. package/src/components/Menu/Menu.jsx +109 -0
  22. package/src/components/Menu/Menu.md +135 -0
  23. package/src/components/Menu/Menu.scss +36 -0
  24. package/src/components/Progress/Progress.jsx +58 -0
  25. package/src/components/Progress/Progress.md +32 -0
  26. package/src/components/Progress/Progress.scss +54 -0
  27. package/src/components/Table/Table.jsx +92 -0
  28. package/src/components/Table/Table.md +211 -0
  29. package/src/components/Table/Table.scss +63 -0
  30. package/src/components/Text/Text.jsx +24 -0
  31. package/src/components/Text/Text.md +25 -0
  32. package/src/components/Title/Title.jsx +51 -0
  33. package/src/components/Title/Title.md +24 -0
  34. package/src/components/Title/Title.scss +44 -0
  35. package/src/constants.js +3 -0
  36. package/src/font/Inter-Black.ttf +0 -0
  37. package/src/font/Inter-Bold.ttf +0 -0
  38. package/src/font/Inter-ExtraBold.ttf +0 -0
  39. package/src/font/Inter-ExtraLight.ttf +0 -0
  40. package/src/font/Inter-Light.ttf +0 -0
  41. package/src/font/Inter-Medium.ttf +0 -0
  42. package/src/font/Inter-Regular.ttf +0 -0
  43. package/src/font/Inter-SemiBold.ttf +0 -0
  44. package/src/font/Inter-Thin.ttf +0 -0
  45. package/src/index.js +11 -0
  46. package/src/managers/ThemeManager.js +0 -0
  47. package/src/styles/tokens.scss +459 -0
  48. package/src/styles/variables.scss +23 -0
@@ -0,0 +1,135 @@
1
+ Basic Example
2
+ ```jsx
3
+ import { Menu } from '@nurvus/ui';
4
+
5
+ const initialPath = [1];
6
+ const items = [
7
+ {
8
+ label: 'Item 1',
9
+ },
10
+ {
11
+ label: 'Item 2'
12
+ },
13
+ {
14
+ label: 'Item 3'
15
+ },
16
+ {
17
+ label: 'Item 4'
18
+ }
19
+ ];
20
+
21
+ const MyApp = ({initialPath}) => {
22
+ const [activePath, setActivePath] = React.useState(initialPath);
23
+
24
+ return (
25
+ <Menu
26
+ activePath={ activePath }
27
+ items={ items }
28
+ onClick={ (e, path) => setActivePath(path) }
29
+ />
30
+ );
31
+ }
32
+ <MyApp initialPath={ initialPath } />
33
+ ```
34
+
35
+ Using Sub Menus
36
+ ```jsx
37
+ import { Menu } from '@nurvus/ui';
38
+
39
+ const initialPath = [0, 0, 0];
40
+ const items = [
41
+ {
42
+ label: 'Item 1',
43
+ items: [
44
+ {
45
+ label: 'Sub 1',
46
+ items: [
47
+ {
48
+ label: 'Sub Item 1'
49
+ },
50
+ {
51
+ label: 'Sub Item 2'
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ label: 'Sub 2'
57
+ }
58
+ ]
59
+ },
60
+ {
61
+ label: 'Item 2'
62
+ }
63
+ ];
64
+
65
+ const MyApp = ({initialPath}) => {
66
+ const [activePath, setActivePath] = React.useState(initialPath);
67
+
68
+ return (
69
+ <Menu
70
+ activePath={ activePath }
71
+ items={ items }
72
+ onClick={ (e, path) => setActivePath(path) }
73
+ />
74
+ );
75
+ }
76
+ <MyApp initialPath={ initialPath } />
77
+ ```
78
+
79
+ Using itemRenderer
80
+ ```jsx
81
+ import RemoveRedEyeIcon from '@material-ui/icons/RemoveRedEye';
82
+ import LockOpenIcon from '@material-ui/icons/LockOpen';
83
+ import { Layout, Menu, Text } from '@nurvus/ui';
84
+
85
+ const itemRenderer = ({ label }) => {
86
+ return (
87
+ <Layout display="flex" alignItems="center" justifyContent="space-between">
88
+ <Text>{ label }</Text>
89
+ <Layout display="flex" alignItems="center" justifyContent="space-between">
90
+ <RemoveRedEyeIcon />
91
+ <LockOpenIcon />
92
+ </Layout>
93
+ </Layout>
94
+ );
95
+ };
96
+ const initialPath = [0, 0, 0];
97
+ const items = [
98
+ {
99
+ label: 'Item 1',
100
+ items: [
101
+ {
102
+ label: 'Sub 1',
103
+ items: [
104
+ {
105
+ label: 'Sub Item 1'
106
+ },
107
+ {
108
+ label: 'Sub Item 2'
109
+ }
110
+ ]
111
+ },
112
+ {
113
+ label: 'Sub 2'
114
+ }
115
+ ]
116
+ },
117
+ {
118
+ label: 'Item 2'
119
+ }
120
+ ];
121
+
122
+ const MyApp = ({initialPath}) => {
123
+ const [activePath, setActivePath] = React.useState(initialPath);
124
+
125
+ return (
126
+ <Menu
127
+ activePath={ activePath }
128
+ items={ items }
129
+ itemRenderer={ itemRenderer }
130
+ onClick={ (e, path) => setActivePath(path) }
131
+ />
132
+ );
133
+ }
134
+ <MyApp initialPath={ initialPath } />
135
+ ```
@@ -0,0 +1,36 @@
1
+ @import "../../styles/variables.scss";
2
+
3
+ .#{$cls-prefix}.menu {
4
+ background: #403960;
5
+
6
+ .menu-item {
7
+ position: relative;
8
+ padding: 10px;
9
+ color: #e6e6e6;
10
+ cursor: pointer;
11
+
12
+ // Hover / Pressed
13
+ &:hover,
14
+ &[data-active="true"] {
15
+ color: white;
16
+ }
17
+
18
+ &[data-active="true"] {
19
+ &::before {
20
+ content: '';
21
+ height: 100%;
22
+ width: 2px;
23
+ position: absolute;
24
+ left: 0;
25
+ top: 0;
26
+ background: #48c3f4;
27
+ }
28
+ // border-left: 2px solid #48c3f4;
29
+ background: linear-gradient(90deg, rgba(72,195,244, 0.5) 0%, rgba(64,57,96,1) 100%);
30
+ }
31
+
32
+ > [data-type="group"] {
33
+ margin-left: 20px;
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+ import CONSTANT from '../../constants.js';
5
+ import './Progress.scss';
6
+
7
+ /**
8
+ * Progress component. Use it to track progress!
9
+ * @returns {ReactElement} of Progress component.
10
+ */
11
+ function Progress(props) {
12
+ const {
13
+ className,
14
+ percent = 0,
15
+ size = 'medium',
16
+ status = 'active'
17
+ } = props;
18
+
19
+ return (
20
+ <div
21
+ className={ classNames(`${CONSTANT.CLASS_PREFIX}`, 'progress', className) }
22
+ data-size={ size }
23
+ data-status={ status }
24
+ >
25
+ <div className="bar" style={{ width: `${percent}%` }} />
26
+ </div>
27
+ );
28
+ }
29
+
30
+ Progress.propTypes = {
31
+ /**
32
+ * Custom class name.
33
+ */
34
+ className: PropTypes.string,
35
+ /**
36
+ * Progress percent.
37
+ */
38
+ percent: PropTypes.number,
39
+ /**
40
+ * Progress percent.
41
+ */
42
+ size: PropTypes.oneOf([
43
+ 'small',
44
+ 'medium',
45
+ 'large'
46
+ ]),
47
+ /**
48
+ * Progress status.
49
+ */
50
+ size: PropTypes.oneOf([
51
+ 'active',
52
+ 'success',
53
+ 'warning',
54
+ 'critical'
55
+ ])
56
+ };
57
+
58
+ export default Progress;
@@ -0,0 +1,32 @@
1
+ Basic Example
2
+ ```jsx
3
+ import Layout from '../Layout/Layout.jsx';
4
+
5
+ <Layout itemSpacing={ 40 }>
6
+ <Layout itemSpacing={ 13 } style={ { maxWidth: 90 } }>
7
+ <Progress size="small" />
8
+ <Progress size="small" percent={ 50 } />
9
+ <Progress size="small" percent={ 100 } />
10
+ </Layout>
11
+ <Layout itemSpacing={ 13 } style={ { maxWidth: 105 } }>
12
+ <Progress size="medium" />
13
+ <Progress size="medium" percent={ 50 } />
14
+ <Progress size="medium" percent={ 100 } />
15
+ </Layout>
16
+ <Layout itemSpacing={ 13 } style={ { maxWidth: 226 } }>
17
+ <Progress size="large" />
18
+ <Progress size="large" percent={ 50 } />
19
+ <Progress size="large" percent={ 100 } />
20
+ </Layout>
21
+ </Layout>
22
+ ```
23
+
24
+ Status Example
25
+ ```jsx
26
+ import Layout from '../Layout/Layout.jsx';
27
+ <Layout itemSpacing={ 13 } style={ { maxWidth: 90 } }>
28
+ <Progress status="critical" percent={ 10 } />
29
+ <Progress status="warning" percent={ 50 } />
30
+ <Progress status="success" percent={ 100 } />
31
+ </Layout>
32
+ ```
@@ -0,0 +1,54 @@
1
+ // Styles for Progress.jsx
2
+ @import "../../styles/variables.scss";
3
+ @import "../../styles/tokens.scss";
4
+
5
+ .#{$cls-prefix}.progress {
6
+ background: $--orange-opacity--8;
7
+
8
+ &,
9
+ > .bar {
10
+ border-radius: 12px;
11
+ }
12
+
13
+ > .bar {
14
+ height: 100%;
15
+ }
16
+
17
+ // Size
18
+ &[data-size="small"] {
19
+ height: 4px;
20
+ }
21
+
22
+ &[data-size="medium"] {
23
+ height: 6px;
24
+ }
25
+
26
+ &[data-size="large"] {
27
+ height: 8px;
28
+ }
29
+
30
+ // Size
31
+ &[data-status="active"] {
32
+ > .bar {
33
+ background-color: $--primary--500;
34
+ }
35
+ }
36
+
37
+ &[data-status="success"] {
38
+ > .bar {
39
+ background-color: $--green--500;
40
+ }
41
+ }
42
+
43
+ &[data-status="warning"] {
44
+ > .bar {
45
+ background-color: $--yellow--200;
46
+ }
47
+ }
48
+
49
+ &[data-status="critical"] {
50
+ > .bar {
51
+ background-color: $--red--500;
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,92 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+ import CONSTANT from '../../constants.js';
5
+ import './Table.scss';
6
+
7
+ class Table extends React.Component {
8
+ renderCells(rowProps) {
9
+ const { columns } = this.props;
10
+
11
+ return columns.map((columnProps, i) => {
12
+ const { dataKey, render, ...props } = columnProps;
13
+ const value = rowProps[columnProps.dataKey];
14
+
15
+ let children = value;
16
+ if (render) {
17
+ children = render(value, dataKey, rowProps);
18
+ }
19
+
20
+ return (
21
+ <td key={ dataKey || i } { ...props }>
22
+ { children }
23
+ </td>
24
+ );
25
+ });
26
+ }
27
+
28
+ renderHeader() {
29
+ const { columns } = this.props;
30
+
31
+ return columns.map((columnProps, i) => {
32
+ const { dataKey, title, ...props } = columnProps;
33
+
34
+ return (
35
+ <th key={ dataKey || i } { ...props }>
36
+ { title || dataKey }
37
+ </th>
38
+ );
39
+ });
40
+ }
41
+
42
+ renderRows() {
43
+ const{ data } = this.props;
44
+
45
+ return data.map((rowProps, i) => {
46
+ const { key } = rowProps;
47
+
48
+ const isEven = i % 2 == 0;
49
+
50
+ return (
51
+ <tr key={ key || i } data-even={ isEven }>
52
+ { this.renderCells(rowProps) }
53
+ </tr>
54
+ );
55
+ });
56
+ }
57
+
58
+ render() {
59
+ const { className } = this.props;
60
+ return (
61
+ <table
62
+ className={ classNames(`${CONSTANT.CLASS_PREFIX}`, 'table', className) }
63
+ >
64
+ <thead>
65
+ <tr>
66
+ { this.renderHeader() }
67
+ </tr>
68
+ </thead>
69
+ <tbody>
70
+ { this.renderRows() }
71
+ </tbody>
72
+ </table>
73
+ );
74
+ }
75
+ }
76
+
77
+ Table.propTypes = {
78
+ /**
79
+ * Custom class name.
80
+ */
81
+ className: PropTypes.string,
82
+ /**
83
+ * Columns to render in table.
84
+ */
85
+ columns: PropTypes.array,
86
+ /**
87
+ * Data to render in table.
88
+ */
89
+ data: PropTypes.array
90
+ };
91
+
92
+ export default Table;
@@ -0,0 +1,211 @@
1
+ Basic Usage
2
+ ```jsx
3
+ import React from 'react';
4
+ import { Table } from '@nurvus/ui';
5
+
6
+ // mock data provided from https://www.mockaroo.com/
7
+ const data = [
8
+ {
9
+ id: "1",
10
+ first_name: "Danya",
11
+ last_name: "Tuberfield",
12
+ email: "dtuberfield0@blogspot.com",
13
+ ip_address: "155.124.39.178"
14
+ },
15
+ {
16
+ id: "2",
17
+ first_name: "Halette",
18
+ last_name: "Kiltie",
19
+ email: "hkiltie1@google.com.br",
20
+ ip_address: "68.194.170.222"
21
+ },
22
+ {
23
+ id: "3",
24
+ first_name: "Dene",
25
+ last_name: "Frary",
26
+ email: "dfrary2@shinystat.com",
27
+ ip_address: "125.232.160.118"
28
+ },
29
+ {
30
+ id: "4",
31
+ first_name: "Keeley",
32
+ last_name: "Fullard",
33
+ email: "kfullard3@chronoengine.com",
34
+ ip_address: "111.189.5.201"
35
+ },
36
+ {
37
+ id: "5",
38
+ first_name: "Culver",
39
+ last_name: "O'Lahy",
40
+ email: "colahy4@wordpress.org",
41
+ ip_address: "136.24.198.12"
42
+ },
43
+ {
44
+ id: "6",
45
+ first_name: "Myriam",
46
+ last_name: "Szanto",
47
+ email: "mszanto5@posterous.com",
48
+ ip_address: "230.65.200.78"
49
+ },
50
+ {
51
+ id: "7",
52
+ first_name: "Matilda",
53
+ last_name: "Hadkins",
54
+ email: "mhadkins6@phoca.cz",
55
+ ip_address: "163.15.137.114"
56
+ },
57
+ {
58
+ id: "8",
59
+ first_name: "Hephzibah",
60
+ last_name: "Mothersole",
61
+ email: "hmothersole7@ning.com",
62
+ ip_address: "50.56.113.104"
63
+ },
64
+ {
65
+ id: "9",
66
+ first_name: "Hayley",
67
+ last_name: "Hayers",
68
+ email: "hhayers8@dagondesign.com",
69
+ ip_address: "240.18.69.87"
70
+ },
71
+ {
72
+ id: "10",
73
+ first_name: "Rheba",
74
+ last_name: "Bedbrough",
75
+ email: "rbedbrough9@diigo.com",
76
+ ip_address: "142.100.46.215"
77
+ }
78
+ ];
79
+
80
+ const columns = [
81
+ {
82
+ title: 'First Name',
83
+ dataKey: 'first_name'
84
+ },
85
+ {
86
+ title: 'Last Name',
87
+ dataKey: 'last_name'
88
+ },
89
+ {
90
+ title: 'IP Address',
91
+ dataKey: 'ip_address'
92
+ }
93
+ ];
94
+
95
+ <Table
96
+ columns={ columns }
97
+ data={ data }
98
+ />
99
+ ```
100
+
101
+ Custom Column renderer
102
+ ```jsx
103
+ import React from 'react';
104
+ import { Table } from '@nurvus/ui';
105
+
106
+ // mock data provided from https://www.mockaroo.com/
107
+
108
+ const data = [
109
+ {
110
+ id: 1,
111
+ Car: "Lexus",
112
+ Amount: 3347
113
+ },
114
+ {
115
+ id: 2,
116
+ Car: "Buick",
117
+ Amount: 3632
118
+ },
119
+ {
120
+ id: 3,
121
+ Car: "Dodge",
122
+ Amount: 1464
123
+ },
124
+ {
125
+ id: 4,
126
+ Car: "MINI",
127
+ Amount: -2887
128
+ },
129
+ {
130
+ id: 5,
131
+ Car: "Pontiac",
132
+ Amount: 1317
133
+ },
134
+ {
135
+ id: 6,
136
+ Car: "Maserati",
137
+ Amount: 2814
138
+ },
139
+ {
140
+ id: 7,
141
+ Car: "Scion",
142
+ Amount: -4233
143
+ },
144
+ {
145
+ id: 8,
146
+ Car: "Infiniti",
147
+ Amount: 2188
148
+ },
149
+ {
150
+ id: 9,
151
+ Car: "GMC",
152
+ Amount: 4898
153
+ },
154
+ {
155
+ id: 10,
156
+ Car: "Infiniti",
157
+ Amount: 3023
158
+ }
159
+ ];
160
+
161
+ const dataWithBalance = data.reduce((acc, obj, i) => {
162
+ let Balance = 0;
163
+ if (acc.length) {
164
+ Balance = acc[acc.length-1].Balance;
165
+ }
166
+
167
+ return [
168
+ ...acc,
169
+ {
170
+ ...obj,
171
+ Balance: Balance + obj.Amount
172
+ }
173
+ ]
174
+ }, []);
175
+
176
+ const columns = [
177
+ {
178
+ dataKey: 'Car'
179
+ },
180
+ {
181
+ dataKey: 'Amount',
182
+ style: {
183
+ textAlign: 'right'
184
+ },
185
+ render: (val, key, props) => {
186
+ let color = 'rgba(4, 170, 53, 1)';
187
+
188
+ if (val < 0) {
189
+ color = 'rgba(239, 2, 9, 1)';
190
+ }
191
+
192
+ return (
193
+ <span style={{ color }}>
194
+ { val }
195
+ </span>
196
+ );
197
+ }
198
+ },
199
+ {
200
+ dataKey: 'Balance',
201
+ style: {
202
+ textAlign: 'right'
203
+ }
204
+ }
205
+ ];
206
+
207
+ <Table
208
+ columns={ columns }
209
+ data={ dataWithBalance }
210
+ />
211
+ ```
@@ -0,0 +1,63 @@
1
+ // Table.scss
2
+ @import "../../styles/variables.scss";
3
+ @import "../../styles/tokens.scss";
4
+
5
+ .#{$cls-prefix}.table {
6
+ width: 100%;
7
+ background-color: #2e2442;
8
+ color: $white;
9
+ border-spacing: 0;
10
+
11
+ thead {
12
+ tr {
13
+ background-color: $--base--100;
14
+ color: $--base--600;
15
+
16
+ th {
17
+ border-top: 1px solid $--base--300;
18
+ border-bottom: 1px solid $--base--300;
19
+
20
+ &:first-child {
21
+ border-left: 1px solid $--base--300;
22
+ }
23
+
24
+ &:last-child {
25
+ border-right: 1px solid $--base--300;
26
+ }
27
+ }
28
+ }
29
+ }
30
+
31
+ tr {
32
+ background-color: $--pure--white;
33
+ color: $--base--1200;
34
+ }
35
+
36
+ th, td {
37
+ box-sizing: border-box;
38
+ padding: 10px;
39
+ }
40
+
41
+ th {
42
+ text-align: left;
43
+ text-align: left;
44
+ text-transform: uppercase;
45
+ font-size: 11px;
46
+ min-height: 34px;
47
+ height: 34px;
48
+ }
49
+
50
+ td {
51
+ min-height: 40px;
52
+ height: 40px;
53
+ border-bottom: 1px solid $--base--100;
54
+
55
+ &:first-child {
56
+ border-left: 1px solid $--base--300;
57
+ }
58
+
59
+ &:last-child {
60
+ border-right: 1px solid $--base--300;
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+ import CONSTANT from '../../constants.js';
4
+
5
+ /**
6
+ * Text component.
7
+ * @returns {ReactElement} of Text component.
8
+ */
9
+ export default function Text(props) {
10
+ const {
11
+ children,
12
+ className,
13
+ ...restProps
14
+ } = props;
15
+
16
+ return (
17
+ <span
18
+ className={ classNames(`${CONSTANT.CLASS_PREFIX}`, 'text', className) }
19
+ { ...restProps }
20
+ >
21
+ { children }
22
+ </span>
23
+ );
24
+ }