graphen 1.10.5 → 1.10.7
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.
- package/dist/css.js +1 -1
- package/dist/scripts.js +1 -1
- package/package.json +5 -5
- package/src/components/Accordion/styles/_styles.scss +0 -1
- package/src/components/Button/index.tsx +9 -5
- package/src/components/Card/index.tsx +29 -0
- package/src/components/Dropdown/index.tsx +17 -6
- package/src/components/Dropdown/styles/_styles.scss +5 -0
- package/src/components/Flex/index.tsx +35 -0
- package/src/components/Flex/styles/_styles.scss +12 -4
- package/src/components/FlexItem/index.tsx +29 -0
- package/src/components/FlexItem/styles/_styles.scss +11 -0
- package/src/components/Link/index.tsx +8 -8
- package/src/components/Logo/index.tsx +0 -1
- package/src/components/Panel/index.tsx +29 -0
- package/src/components/PanelContent/index.tsx +22 -0
- package/src/components/PanelContent/styles/_styles.scss +6 -0
- package/src/components/PanelFooter/index.tsx +22 -0
- package/src/components/PanelFooter/styles/_styles.scss +5 -0
- package/src/components/PanelTitle/index.tsx +22 -0
- package/src/components/PanelTitle/styles/_styles.scss +6 -0
- package/src/components/Separator/index.tsx +20 -0
- package/src/example.tsx +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.ts +18 -1
- package/src/style.scss +4 -0
- package/src/variables/constants.ts +4 -0
- package/src/variables/constants.js +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphen",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.7",
|
|
4
4
|
"description": "Graphen is a small library, that keeps reusable blocks of UI and helps making application design consistent across multiple projects.",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -40,16 +40,16 @@
|
|
|
40
40
|
"@babel/preset-react": "^7.12.13",
|
|
41
41
|
"@babel/preset-typescript": "^7.13.0",
|
|
42
42
|
"@types/react": "^18.2.0",
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
44
|
-
"@typescript-eslint/parser": "^
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
44
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
45
45
|
"babel-eslint": "^10.1.0",
|
|
46
46
|
"babel-loader": "^8.1.0",
|
|
47
47
|
"classnames": "^2.2.6",
|
|
48
48
|
"css-loader": "^3.6.0",
|
|
49
49
|
"cypress": "^13.6.4",
|
|
50
|
-
"eslint": "^
|
|
50
|
+
"eslint": "^8.56.0",
|
|
51
51
|
"eslint-config-airbnb-typescript": "^12.3.1",
|
|
52
|
-
"eslint-config-codait": "^1.1.
|
|
52
|
+
"eslint-config-codait": "^1.1.3",
|
|
53
53
|
"eslint-config-prettier": "^8.10.0",
|
|
54
54
|
"eslint-import-resolver-typescript": "^2.4.0",
|
|
55
55
|
"eslint-plugin-cypress": "^2.11.2",
|
|
@@ -2,15 +2,18 @@ import React from "react";
|
|
|
2
2
|
import classNames from "classnames";
|
|
3
3
|
|
|
4
4
|
type Props = {
|
|
5
|
-
className?: string
|
|
6
|
-
children: string
|
|
7
|
-
onClick?: () => void
|
|
5
|
+
className?: string;
|
|
6
|
+
children: string;
|
|
7
|
+
onClick?: () => void;
|
|
8
|
+
isFull?: boolean;
|
|
8
9
|
};
|
|
9
10
|
|
|
10
11
|
function Button(props: Props) {
|
|
11
|
-
const { onClick, children, className } = props;
|
|
12
|
+
const { onClick, children, className, isFull } = props;
|
|
12
13
|
|
|
13
|
-
const buttonClasses = classNames(className, "gc-btn"
|
|
14
|
+
const buttonClasses = classNames(className, "gc-btn", {
|
|
15
|
+
"gc-btn--full": isFull,
|
|
16
|
+
});
|
|
14
17
|
|
|
15
18
|
return (
|
|
16
19
|
<button onClick={onClick} className={buttonClasses} type='button'>
|
|
@@ -22,6 +25,7 @@ function Button(props: Props) {
|
|
|
22
25
|
Button.defaultProps = {
|
|
23
26
|
className: '',
|
|
24
27
|
onClick: () => {},
|
|
28
|
+
isFull: false,
|
|
25
29
|
};
|
|
26
30
|
|
|
27
31
|
export default Button;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
className?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
skin?: string;
|
|
8
|
+
isGradient?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function Card(props: Props) {
|
|
12
|
+
const { children, className, skin, isGradient } = props;
|
|
13
|
+
const dialogClasses = classNames(className, "gc-card", {
|
|
14
|
+
'gc-card--default': skin === 'default',
|
|
15
|
+
'gc-card--gradient': isGradient,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return <div className={dialogClasses}>{children}</div>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
Card.defaultProps = {
|
|
23
|
+
className: '',
|
|
24
|
+
children: null,
|
|
25
|
+
skin: "default",
|
|
26
|
+
isGradient: false,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default Card;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React, { useState, useCallback } from "react";
|
|
2
|
-
import * as _ from "lodash";
|
|
1
|
+
import React, { useState, useCallback, useEffect } from "react";
|
|
3
2
|
import classNames from "classnames";
|
|
4
3
|
|
|
5
4
|
type Props = {
|
|
@@ -11,20 +10,30 @@ type Props = {
|
|
|
11
10
|
|
|
12
11
|
function Dropdown(props: Props) {
|
|
13
12
|
const { initValue, label, items, onChange } = props;
|
|
13
|
+
|
|
14
14
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
15
15
|
const [selectedItem, setSelectedItem] = useState(initValue);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setSelectedItem(initValue);
|
|
19
|
+
}, [initValue, setSelectedItem]);
|
|
20
|
+
|
|
16
21
|
const expandMenu = useCallback(() => {
|
|
17
22
|
setIsExpanded((isShown) => !isShown);
|
|
18
23
|
}, [setIsExpanded]);
|
|
24
|
+
|
|
19
25
|
const selectItem = useCallback(
|
|
20
26
|
(item) => {
|
|
21
27
|
onChange(item.value);
|
|
22
28
|
setIsExpanded(false);
|
|
23
|
-
setSelectedItem(
|
|
29
|
+
setSelectedItem(items.find((i) => i.value === item.value));
|
|
24
30
|
},
|
|
25
31
|
[setIsExpanded, setSelectedItem, items]
|
|
26
32
|
);
|
|
27
|
-
|
|
33
|
+
|
|
34
|
+
const buttonClasses = classNames('gc-dropdown__btn', {
|
|
35
|
+
'gc-dropdown__btn--with-label': label,
|
|
36
|
+
});
|
|
28
37
|
|
|
29
38
|
return (
|
|
30
39
|
<div className="gc-dropdown">
|
|
@@ -44,10 +53,12 @@ function Dropdown(props: Props) {
|
|
|
44
53
|
<div className="gc-dropdown__content">
|
|
45
54
|
<ul className="gc-dropdown__list">
|
|
46
55
|
{/* eslint-disable jsx-a11y/no-static-element-interactions */}
|
|
47
|
-
{
|
|
56
|
+
{items.map((item, index) => {
|
|
48
57
|
const dropdownItemClasses = classNames("gc-dropdown__item", {
|
|
49
|
-
"gc-dropdown__item--first":
|
|
58
|
+
"gc-dropdown__item--first": index === 0,
|
|
59
|
+
"gc-dropdown__item--selected": item.value === selectedItem.value,
|
|
50
60
|
});
|
|
61
|
+
|
|
51
62
|
return (
|
|
52
63
|
/* eslint-disable react/button-has-type */
|
|
53
64
|
<li
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
className?: string,
|
|
6
|
+
children?: React.ReactNode,
|
|
7
|
+
isVertical?: boolean,
|
|
8
|
+
alignItems?: string,
|
|
9
|
+
alignContent?: string,
|
|
10
|
+
wrap?: string,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function Flex(props: Props) {
|
|
14
|
+
const { children, className, isVertical, alignItems, alignContent, wrap } = props;
|
|
15
|
+
const dialogClasses = classNames(className, "gc-flex", {
|
|
16
|
+
'gc-flex--vertical': isVertical,
|
|
17
|
+
'gc-flex--align-items-center': alignItems === 'center',
|
|
18
|
+
'gc-flex--align-content-center': alignContent === 'center',
|
|
19
|
+
'gc-flex--wrap': wrap === 'wrap',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return <div className={dialogClasses}>{children}</div>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
Flex.defaultProps = {
|
|
27
|
+
className: '',
|
|
28
|
+
children: null,
|
|
29
|
+
isVertical: false,
|
|
30
|
+
alignItems: undefined,
|
|
31
|
+
alignContent: undefined,
|
|
32
|
+
wrap: undefined,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default Flex;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
.gc-flex {
|
|
2
2
|
display: flex;
|
|
3
3
|
|
|
4
|
-
&--
|
|
5
|
-
flex-
|
|
4
|
+
&--vertical {
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
&--align-items-center {
|
|
9
|
+
align-items: center;
|
|
6
10
|
}
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
&--align-content-center {
|
|
13
|
+
align-content: center;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&--wrap {
|
|
17
|
+
flex-wrap: wrap;
|
|
10
18
|
}
|
|
11
19
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
className?: string,
|
|
6
|
+
children?: React.ReactNode,
|
|
7
|
+
isGrow?: boolean;
|
|
8
|
+
isShrink?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function FlexItem(props: Props) {
|
|
12
|
+
const { children, className, isGrow, isShrink } = props;
|
|
13
|
+
const dialogClasses = classNames(className, "gc-flex__item", {
|
|
14
|
+
'gc-flex__item--grow': isGrow,
|
|
15
|
+
'gc-flex__item--shrink': isShrink,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return <div className={dialogClasses}>{children}</div>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
FlexItem.defaultProps = {
|
|
23
|
+
className: '',
|
|
24
|
+
children: null,
|
|
25
|
+
isGrow: false,
|
|
26
|
+
isShrink: false,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default FlexItem;
|
|
@@ -3,21 +3,21 @@ import classNames from "classnames";
|
|
|
3
3
|
import * as constants from "src/variables/constants";
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
|
-
link: string
|
|
7
|
-
className?: string
|
|
8
|
-
children?: React.ReactNode
|
|
9
|
-
skin?: constants.Skin
|
|
6
|
+
link: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
skin?: constants.Skin;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
function Link({
|
|
13
13
|
link,
|
|
14
14
|
className,
|
|
15
15
|
children,
|
|
16
|
-
skin
|
|
16
|
+
skin,
|
|
17
17
|
}: Props) {
|
|
18
18
|
const classes = classNames("gc-link", className, {
|
|
19
|
-
"gc-link--primary": skin === constants.
|
|
20
|
-
"gc-link--default": skin === constants.
|
|
19
|
+
"gc-link--primary": skin === constants.SKIN_PRIMARY,
|
|
20
|
+
"gc-link--default": skin === constants.SKIN_DEFAULT,
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
return (
|
|
@@ -31,7 +31,7 @@ function Link({
|
|
|
31
31
|
Link.defaultProps = {
|
|
32
32
|
className: '',
|
|
33
33
|
children: null,
|
|
34
|
-
skin:
|
|
34
|
+
skin: constants.SKIN_DEFAULT,
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
export default Link;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
className?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
isSeparator?: boolean;
|
|
8
|
+
isBordered?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function Panel(props: Props) {
|
|
12
|
+
const { children, className, isSeparator, isBordered } = props;
|
|
13
|
+
const dialogClasses = classNames(className, "gc-panel", {
|
|
14
|
+
'gc-panel--separator': isSeparator,
|
|
15
|
+
'gc-panel--bordered': isBordered,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return <div className={dialogClasses}>{children}</div>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
Panel.defaultProps = {
|
|
23
|
+
className: '',
|
|
24
|
+
children: null,
|
|
25
|
+
isSeparator: false,
|
|
26
|
+
isBordered: false,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default Panel;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
className?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function PanelContent(props: Props) {
|
|
10
|
+
const { children, className} = props;
|
|
11
|
+
const dialogClasses = classNames(className, "gc-panel__content");
|
|
12
|
+
|
|
13
|
+
return <article className={dialogClasses}>{children}</article>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
PanelContent.defaultProps = {
|
|
18
|
+
className: '',
|
|
19
|
+
children: null,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default PanelContent;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
className?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function PanelFooter(props: Props) {
|
|
10
|
+
const { children, className} = props;
|
|
11
|
+
const dialogClasses = classNames(className, "gc-panel__footer");
|
|
12
|
+
|
|
13
|
+
return <div className={dialogClasses}>{children}</div>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
PanelFooter.defaultProps = {
|
|
18
|
+
className: '',
|
|
19
|
+
children: null,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default PanelFooter;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
className?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function PanelTitle(props: Props) {
|
|
10
|
+
const { children, className} = props;
|
|
11
|
+
const dialogClasses = classNames(className, "gc-panel__title");
|
|
12
|
+
|
|
13
|
+
return <header className={dialogClasses}>{children}</header>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
PanelTitle.defaultProps = {
|
|
18
|
+
className: '',
|
|
19
|
+
children: null,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default PanelTitle;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
className?: string,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
function Separator(props: Props) {
|
|
9
|
+
const { className} = props;
|
|
10
|
+
const dialogClasses = classNames(className, "gc-separator");
|
|
11
|
+
|
|
12
|
+
return <div className={dialogClasses} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
Separator.defaultProps = {
|
|
17
|
+
className: '',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default Separator;
|
package/src/example.tsx
CHANGED
|
@@ -125,7 +125,7 @@ class ExampleApp extends React.PureComponent<Props, State> {
|
|
|
125
125
|
<header className="gc-panel__title">Link</header>
|
|
126
126
|
<div className="gc-panel__content">
|
|
127
127
|
<Link link="http://some-url">Primary Link</Link> ,{" "}
|
|
128
|
-
<Link link="http://some-url" skin={constants.
|
|
128
|
+
<Link link="http://some-url" skin={constants.SKIN_DEFAULT}>
|
|
129
129
|
Default Link
|
|
130
130
|
</Link>
|
|
131
131
|
</div>
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'src/components/*';
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import Accordion from "src/components/Accordion";
|
|
3
2
|
import Button from "src/components/Button";
|
|
3
|
+
import Card from "src/components/Card";
|
|
4
4
|
import Dialog from "src/components/Dialog";
|
|
5
5
|
import Icon from "src/components/Icon";
|
|
6
6
|
import Input from "src/components/Input";
|
|
@@ -9,15 +9,23 @@ import Joystick from "src/components/Joystick";
|
|
|
9
9
|
import Link from "src/components/Link";
|
|
10
10
|
import Loader from "src/components/Loader";
|
|
11
11
|
import Scroller from "src/components/Scroller";
|
|
12
|
+
import Separator from "src/components/Separator";
|
|
12
13
|
import Tooltip from "src/components/Tooltip";
|
|
13
14
|
import Validation from "src/components/Validation";
|
|
14
15
|
import Logo from "src/components/Logo";
|
|
15
16
|
import Dropdown from "src/components/Dropdown";
|
|
17
|
+
import Flex from "src/components/Flex";
|
|
18
|
+
import FlexItem from "src/components/FlexItem";
|
|
19
|
+
import Panel from "src/components/Panel";
|
|
20
|
+
import PanelContent from "src/components/PanelContent";
|
|
21
|
+
import PanelFooter from "src/components/PanelFooter";
|
|
22
|
+
import PanelTitle from "src/components/PanelTitle";
|
|
16
23
|
import * as constants from "src/variables/constants";
|
|
17
24
|
|
|
18
25
|
export {
|
|
19
26
|
Accordion,
|
|
20
27
|
Button,
|
|
28
|
+
Card,
|
|
21
29
|
Dialog,
|
|
22
30
|
Icon,
|
|
23
31
|
Input,
|
|
@@ -25,10 +33,19 @@ export {
|
|
|
25
33
|
Link,
|
|
26
34
|
Loader,
|
|
27
35
|
Scroller,
|
|
36
|
+
Separator,
|
|
28
37
|
Tooltip,
|
|
29
38
|
Validation,
|
|
30
39
|
Logo,
|
|
31
40
|
Image,
|
|
32
41
|
Dropdown,
|
|
42
|
+
Flex,
|
|
43
|
+
FlexItem,
|
|
44
|
+
Panel,
|
|
45
|
+
PanelContent,
|
|
46
|
+
PanelFooter,
|
|
47
|
+
PanelTitle,
|
|
33
48
|
constants
|
|
34
49
|
};
|
|
50
|
+
|
|
51
|
+
|
package/src/style.scss
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
@import "components/Card/styles/styles";
|
|
19
19
|
@import "components/Dialog/styles/styles";
|
|
20
20
|
@import "components/Flex/styles/styles";
|
|
21
|
+
@import "components/FlexItem/styles/styles";
|
|
21
22
|
@import "components/Input/styles/styles";
|
|
22
23
|
@import "components/Image/styles/styles";
|
|
23
24
|
@import "components/Joystick/styles/styles";
|
|
@@ -29,6 +30,9 @@
|
|
|
29
30
|
@import "components/Navigation/styles/styles";
|
|
30
31
|
@import "components/Navigation/styles/submenu";
|
|
31
32
|
@import "components/Panel/styles/styles";
|
|
33
|
+
@import "components/PanelContent/styles/styles";
|
|
34
|
+
@import "components/PanelFooter/styles/styles";
|
|
35
|
+
@import "components/PanelTitle/styles/styles";
|
|
32
36
|
@import "components/Sample/styles/mixins";
|
|
33
37
|
@import "components/Sample/styles/styles";
|
|
34
38
|
@import "components/Separator/styles/styles";
|