Skip to content

Commit b9e3836

Browse files
committed
Added centerContent property on space as shorthand instead of using Space.Centered or Space.CenteredVertically components
1 parent f008651 commit b9e3836

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

react-spaces/src/components/Globals.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,10 @@ export enum AnchorType {
33
Right = " anchor-right",
44
Top = " anchor-top",
55
Bottom = " anchor-bottom"
6+
}
7+
8+
export enum CenterType {
9+
None,
10+
Vertical,
11+
HorizontalVertical
612
}

react-spaces/src/components/Space.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
z-index: 1;
55

66
.spaces-space-inner {
7-
z-index: 2;
7+
z-index: 1;
88
position: absolute;
99
left: 0;
1010
top: 0;

react-spaces/src/components/Space.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import * as React from 'react';
22
import './Space.scss';
3-
import { AnchorType } from './Globals';
3+
import { AnchorType, CenterType } from './Globals';
44
import { ResizeSensor, ResizeSensorCallback } from 'css-element-queries';
55
import { SpaceContext, ISpaceContext, ISpaceTaker } from './SpaceContext';
66
import { Guid } from "guid-typescript";
77
import { Resizable, ResizeType } from './Resizable';
8+
import { CenteredVertically, Centered } from './Centered';
89

910
interface IPublicProps {
1011
id?: string,
1112
className?: string,
1213
style?: React.CSSProperties,
1314
scrollable?: boolean,
1415
trackSize?: boolean,
16+
centerContent?: CenterType,
1517
as?: string
1618
}
1719

@@ -258,6 +260,11 @@ class Space extends React.Component<AllProps, IState> {
258260
parentContext.updateSpaceTakerAdjustedSize(this.state.id, adjustedSize);
259261
});
260262
}} />;
263+
264+
if (this.props.centerContent === CenterType.Vertical) {
265+
children = <CenteredVertically>{children}</CenteredVertically>;
266+
} else if (this.props.centerContent === CenterType.HorizontalVertical) {
267+
children = <Centered>{children}</Centered>;
261268
}
262269

263270
const adjustedStyle =

0 commit comments

Comments
 (0)