Skip to content

Commit e7ca3e1

Browse files
committed
Added base navigation
1 parent 54766ab commit e7ca3e1

File tree

14 files changed

+2215
-1968
lines changed

14 files changed

+2215
-1968
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"node": true,
1616
"es6": true
1717
},
18-
"ignorePatterns": ["dist", "setupTests.ts", "babel.config.js"],
18+
"ignorePatterns": ["dist", "setupTests.ts", "babel.config.js", "www"],
1919
"rules": {
2020
"comma-dangle": "off",
2121
"class-methods-use-this": "off",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as React from 'react';
2+
3+
type NavigationDividerProps = React.HTMLAttributes<HTMLDivElement>;
4+
5+
const NavigationDivider = React.forwardRef<HTMLDivElement, NavigationDividerProps>((
6+
_,
7+
ref
8+
): React.ReactElement => (
9+
<div
10+
ref={ref}
11+
className="vertical-navigation-divider"
12+
/>
13+
));
14+
15+
NavigationDivider.displayName = 'NavigationDivider';
16+
17+
export default NavigationDivider;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as React from 'react';
2+
import PropTypes from 'prop-types';
3+
import clsx from 'clsx';
4+
5+
type NavigationListProps = React.HTMLAttributes<HTMLElement>;
6+
7+
const NavigationList = React.forwardRef<HTMLElement, NavigationListProps>((
8+
{
9+
children,
10+
className
11+
},
12+
ref
13+
): React.ReactElement => (
14+
<nav
15+
ref={ref}
16+
className={clsx(
17+
'vertical-navigation-list',
18+
className
19+
)}
20+
>
21+
{children}
22+
</nav>
23+
));
24+
25+
NavigationList.displayName = 'NavigationList';
26+
NavigationList.propTypes = {
27+
children: PropTypes.node,
28+
className: PropTypes.string
29+
};
30+
31+
export default NavigationList;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as React from 'react';
2+
import PropTypes from 'prop-types';
3+
import clsx from 'clsx';
4+
5+
interface NavigationListItemProps extends React.HTMLAttributes<HTMLDivElement> {
6+
active?: boolean;
7+
icon?: React.ReactElement;
8+
}
9+
10+
const NavigationListItem = React.forwardRef<HTMLDivElement, NavigationListItemProps>((
11+
{
12+
active,
13+
children,
14+
className,
15+
icon
16+
},
17+
ref
18+
): React.ReactElement => (
19+
<div
20+
ref={ref}
21+
className={clsx(
22+
'vertical-navigation-list-item',
23+
active && 'active',
24+
className
25+
)}
26+
>
27+
{icon && (
28+
<div className="vertical-navigation-list-item-icon">
29+
{icon}
30+
</div>
31+
)}
32+
{children}
33+
</div>
34+
));
35+
36+
NavigationListItem.displayName = 'NavigationListItem';
37+
NavigationListItem.propTypes = {
38+
active: PropTypes.bool,
39+
children: PropTypes.node,
40+
className: PropTypes.string,
41+
icon: PropTypes.element
42+
};
43+
44+
export default NavigationListItem;

src/components/Navigation/Navigation.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,16 @@ const Navigation = React.forwardRef<HTMLElement, NavigationProps>((
1515
},
1616
ref
1717
): React.ReactElement => (
18-
<Panel
19-
className="navigation"
18+
<nav
19+
ref={ref}
20+
className={clsx(
21+
'navigation-list',
22+
sticky && 'navigation-sticky',
23+
className
24+
)}
2025
>
21-
<nav
22-
ref={ref}
23-
className={clsx(
24-
'navigation-list',
25-
sticky && 'navigation-sticky',
26-
className
27-
)}
28-
>
29-
{children}
30-
</nav>
31-
</Panel>
26+
{children}
27+
</nav>
3228
));
3329

3430
Navigation.displayName = 'PageNavigation';

src/components/Page/Page.tsx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
import * as React from 'react';
22
import clsx from 'clsx';
3+
import PropTypes from 'prop-types';
34
import PageHeader from '@/components/Page/Header';
45
import PageContent from '@/components/Page/Content';
56
import PageMain from '@/components/Page/Main';
67
import Side from '@/components/Page/Side';
8+
import PageRight from '@/components/Page/PageRight';
9+
import PageLeft from '@/components/Page/PageLeft';
10+
import { ForwardComponentWithStatics } from '@/components/utils/ForwardComponentWithStatics';
11+
import PageSide from '@/components/Page/Side';
712

813
export interface PageProps extends React.HTMLAttributes<HTMLDivElement> {
914
sticky?: boolean;
1015
}
1116

12-
const Page = ({
17+
export interface PageStatics {
18+
Right: typeof PageRight;
19+
Left: typeof PageLeft;
20+
Header: typeof PageHeader;
21+
Content: typeof PageContent;
22+
Side: typeof PageSide;
23+
Main: typeof PageMain;
24+
}
25+
26+
// Static properties are not given yet, when declaring the card const. Therefore, the error saying
27+
// that Card is missing above CardStatics properties. These will defined after the card component
28+
// is defined.
29+
// @ts-ignore
30+
const Page: ForwardComponentWithStatics<HTMLDivElement, PageProps, PageStatics> = React.forwardRef(({
1331
children,
1432
className,
15-
}: React.PropsWithChildren<PageProps>): React.ReactElement => (
33+
}): React.ReactElement => (
1634
<div
1735
className={clsx(
1836
'page',
@@ -21,11 +39,18 @@ const Page = ({
2139
>
2240
{children}
2341
</div>
24-
);
25-
42+
));
43+
Page.displayName = 'Page';
44+
Page.Right = PageRight;
45+
Page.Left = PageLeft;
2646
Page.Header = PageHeader;
2747
Page.Content = PageContent;
2848
Page.Side = Side;
2949
Page.Main = PageMain;
3050

51+
Page.propTypes = {
52+
children: PropTypes.node,
53+
className: PropTypes.string
54+
}
55+
3156
export default Page;

src/components/Page/PageLeft.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Variant } from '@/components';
4+
import PageSide, { Position } from '@/components/Page/Side';
5+
6+
export interface PageLeftProps extends React.HTMLAttributes<HTMLDivElement> {
7+
fixed?: boolean;
8+
variant?: Variant | string;
9+
}
10+
11+
const PageLeft = React.forwardRef<HTMLDivElement, PageLeftProps>((
12+
{
13+
children,
14+
className,
15+
fixed,
16+
},
17+
ref
18+
): React.ReactElement => (
19+
<PageSide
20+
ref={ref}
21+
position={Position.LEFT}
22+
className={className}
23+
fixed={fixed}
24+
>
25+
{children}
26+
</PageSide>
27+
));
28+
29+
PageLeft.displayName = 'PageLeft';
30+
PageLeft.propTypes = {
31+
children: PropTypes.node,
32+
className: PropTypes.string,
33+
fixed: PropTypes.bool,
34+
variant: PropTypes.string
35+
}
36+
37+
export default PageLeft;

src/components/Page/PageRight.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import * as React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Variant } from '@/components';
4+
import PageSide, { Position } from '@/components/Page/Side';
5+
6+
export interface PageRightProps extends React.HTMLAttributes<HTMLDivElement> {
7+
spaced?: boolean;
8+
fixed?: boolean;
9+
variant?: Variant | string;
10+
}
11+
12+
const PageRight = React.forwardRef<HTMLDivElement, PageRightProps>((
13+
{
14+
children,
15+
className,
16+
fixed,
17+
},
18+
ref
19+
): React.ReactElement => (
20+
<PageSide
21+
ref={ref}
22+
position={Position.RIGHT}
23+
className={className}
24+
fixed={fixed}
25+
>
26+
{children}
27+
</PageSide>
28+
));
29+
30+
PageRight.displayName = 'PageRight';
31+
PageRight.propTypes = {
32+
children: PropTypes.node,
33+
className: PropTypes.string,
34+
fixed: PropTypes.bool,
35+
36+
}
37+
38+
export default PageRight;

src/components/Page/Side.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import PropTypes from 'prop-types';
33
import clsx from 'clsx';
4-
import { Panel, Variant } from '@/components';
4+
import { Variant } from '@/components';
55

66
export enum Position {
77
LEFT = 'left',
@@ -10,7 +10,6 @@ export enum Position {
1010

1111
export interface PageSideProps extends React.HTMLAttributes<HTMLDivElement> {
1212
position?: Position | string;
13-
spaced?: boolean;
1413
fixed?: boolean;
1514
variant?: Variant | string;
1615
}
@@ -20,33 +19,28 @@ const PageSide = React.forwardRef<HTMLDivElement, PageSideProps>((
2019
children,
2120
className,
2221
position,
23-
spaced,
2422
fixed,
25-
variant
2623
},
2724
ref
2825
): React.ReactElement => (
29-
<Panel
26+
<div
3027
ref={ref}
3128
className={clsx(
3229
'page-side',
3330
position && `page-side-${position}`,
3431
fixed && 'page-side-fixed',
3532
className
3633
)}
37-
spaced={spaced}
38-
variant={variant}
3934
>
4035
{children}
41-
</Panel>
36+
</div>
4237
));
4338

4439
PageSide.displayName = 'Side';
4540
PageSide.propTypes = {
4641
children: PropTypes.node,
4742
className: PropTypes.string,
4843
position: PropTypes.string,
49-
spaced: PropTypes.bool,
5044
fixed: PropTypes.bool,
5145
variant: PropTypes.string
5246
}

src/style/base/_typography.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,7 @@ h6 {
142142
.text-secondary {
143143
color: variables.color('gray', 'default');
144144
}
145+
146+
.text-center {
147+
text-align: center;
148+
}

0 commit comments

Comments
 (0)