graphen 2.0.7 → 2.0.8
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 +1 -1
- package/src/components/Navigation/index.tsx +19 -0
- package/src/components/Navigation/styles/_styles.scss +6 -9
- package/src/components/Navigation/styles/_submenu.scss +2 -5
- package/src/components/NavigationOption/index.tsx +83 -0
- package/src/example/styles/_docs.scss +57 -0
- package/src/example.tsx +397 -47
- package/src/index.ts +4 -0
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
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 Navigation({ className = "", children = null }: Props) {
|
|
10
|
+
const navigationClasses = classNames(
|
|
11
|
+
className,
|
|
12
|
+
"gc-navigation",
|
|
13
|
+
"gc-navigation--default"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return <ul className={navigationClasses}>{children}</ul>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default Navigation;
|
|
@@ -7,24 +7,21 @@
|
|
|
7
7
|
|
|
8
8
|
&__option {
|
|
9
9
|
display: inline-block;
|
|
10
|
-
position: relative;
|
|
11
10
|
border-bottom: 3px solid transparent;
|
|
12
11
|
|
|
13
12
|
&--active {
|
|
14
13
|
border-color: $gb-color-primary;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
&:hover {
|
|
18
|
-
.gc-submenu {
|
|
19
|
-
display: block;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
15
|
}
|
|
23
16
|
|
|
24
17
|
&__link {
|
|
25
18
|
display: block;
|
|
26
|
-
padding
|
|
27
|
-
|
|
19
|
+
padding: 0 $spacing-large;
|
|
20
|
+
border: 0;
|
|
21
|
+
background: none;
|
|
22
|
+
color: inherit;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
font: inherit;
|
|
28
25
|
line-height: 54px;
|
|
29
26
|
font-weight: 600;
|
|
30
27
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { useCallback, useState } from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
className?: string;
|
|
6
|
+
label: React.ReactNode;
|
|
7
|
+
href?: string;
|
|
8
|
+
isActive?: boolean;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function NavigationOption({
|
|
13
|
+
className = "",
|
|
14
|
+
label,
|
|
15
|
+
href = undefined,
|
|
16
|
+
isActive = false,
|
|
17
|
+
children = null,
|
|
18
|
+
}: Props) {
|
|
19
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
20
|
+
|
|
21
|
+
const toggleSubmenu = useCallback(() => {
|
|
22
|
+
setIsOpened((previousIsOpened) => !previousIsOpened);
|
|
23
|
+
}, [setIsOpened]);
|
|
24
|
+
|
|
25
|
+
const closeSubmenuOnBlur = useCallback(
|
|
26
|
+
(event: React.FocusEvent<HTMLLIElement>) => {
|
|
27
|
+
if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {
|
|
28
|
+
setIsOpened(false);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
[setIsOpened]
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const closeSubmenuOnEscape = useCallback(
|
|
35
|
+
(event: React.KeyboardEvent<HTMLLIElement>) => {
|
|
36
|
+
if (event.key === "Escape") {
|
|
37
|
+
setIsOpened(false);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
[setIsOpened]
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const optionClasses = classNames(className, "gc-navigation__option", {
|
|
44
|
+
"gc-navigation__option--active": isActive,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (!children) {
|
|
48
|
+
return (
|
|
49
|
+
<li className={optionClasses}>
|
|
50
|
+
<a className="gc-navigation__link" href={href}>
|
|
51
|
+
{label}
|
|
52
|
+
</a>
|
|
53
|
+
</li>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const submenuClasses = classNames("gc-submenu", {
|
|
58
|
+
"gc-submenu--opened": isOpened,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<li
|
|
63
|
+
className={optionClasses}
|
|
64
|
+
onBlur={closeSubmenuOnBlur}
|
|
65
|
+
onKeyDown={closeSubmenuOnEscape}
|
|
66
|
+
>
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
className="gc-navigation__link"
|
|
70
|
+
aria-haspopup="true"
|
|
71
|
+
aria-expanded={isOpened}
|
|
72
|
+
onClick={toggleSubmenu}
|
|
73
|
+
>
|
|
74
|
+
{label}
|
|
75
|
+
</button>
|
|
76
|
+
<div className={submenuClasses}>
|
|
77
|
+
<div className="gc-submenu__content">{children}</div>
|
|
78
|
+
</div>
|
|
79
|
+
</li>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default NavigationOption;
|
|
@@ -605,6 +605,63 @@ body.docs-body {
|
|
|
605
605
|
overflow: hidden;
|
|
606
606
|
}
|
|
607
607
|
|
|
608
|
+
.docs-flex-demo {
|
|
609
|
+
width: 100%;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
.docs-flex-box {
|
|
613
|
+
padding: 10px 16px;
|
|
614
|
+
border: 1px solid var(--border);
|
|
615
|
+
border-radius: var(--radius);
|
|
616
|
+
background: var(--surface-2);
|
|
617
|
+
font-size: 13px;
|
|
618
|
+
color: var(--text);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
.docs-loader-stage {
|
|
622
|
+
display: flex;
|
|
623
|
+
align-items: center;
|
|
624
|
+
justify-content: center;
|
|
625
|
+
width: 120px;
|
|
626
|
+
height: 96px;
|
|
627
|
+
border-radius: var(--radius-lg);
|
|
628
|
+
background: #23272e;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
.docs-skeleton-demo {
|
|
632
|
+
width: 260px;
|
|
633
|
+
|
|
634
|
+
.gc-skeleton:nth-child(2) {
|
|
635
|
+
width: 80%;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.gc-skeleton:nth-child(3) {
|
|
639
|
+
width: 55%;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
.docs-tooltip-anchor {
|
|
644
|
+
position: relative;
|
|
645
|
+
width: 180px;
|
|
646
|
+
height: 56px;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.docs-list-demo {
|
|
650
|
+
width: 100%;
|
|
651
|
+
max-width: 360px;
|
|
652
|
+
margin: 0;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
.docs-scroller-track {
|
|
656
|
+
width: 240px;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
.docs-demo-value {
|
|
660
|
+
font-family: var(--font-mono);
|
|
661
|
+
font-size: 12.5px;
|
|
662
|
+
color: var(--text-muted);
|
|
663
|
+
}
|
|
664
|
+
|
|
608
665
|
.docs-type-row {
|
|
609
666
|
display: grid;
|
|
610
667
|
grid-template-columns: 80px 80px 1fr;
|