graphen 2.0.6 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphen",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
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": [
@@ -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;
@@ -12,18 +12,16 @@
12
12
  &--active {
13
13
  border-color: $gb-color-primary;
14
14
  }
15
-
16
- &:hover {
17
- .gc-navigation__suboption {
18
- display: block;
19
- }
20
- }
21
15
  }
22
16
 
23
17
  &__link {
24
18
  display: block;
25
- padding-left: $spacing-large;
26
- padding-right: $spacing-large;
19
+ padding: 0 $spacing-large;
20
+ border: 0;
21
+ background: none;
22
+ color: inherit;
23
+ cursor: pointer;
24
+ font: inherit;
27
25
  line-height: 54px;
28
26
  font-weight: 600;
29
27
  }
@@ -4,6 +4,10 @@
4
4
  background-color: transparent;
5
5
  z-index: $zlayer-top;
6
6
 
7
+ &--opened {
8
+ display: block;
9
+ }
10
+
7
11
  &__content {
8
12
  padding: 10px;
9
13
  border-radius: $radius-medium;
@@ -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;