Skip to content

Commit 40ca77c

Browse files
committed
Added layer story
1 parent 0cdedb2 commit 40ca77c

File tree

5 files changed

+59
-19
lines changed

5 files changed

+59
-19
lines changed
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Meta, Story, Preview, Props } from "@storybook/addon-docs/blocks";
2-
import { CommonHeader } from "../Utils";
2+
import { CommonHeader, PropsTable, StandardProps } from "../Utils";
33

44
<CommonHeader />
55

@@ -9,12 +9,6 @@ import { CommonHeader } from "../Utils";
99

1010
Applies to `<Fill />` `<Left />` `<Top />` `<Right />` `<Bottom />` `<LeftResizable />` `<TopResizable />` `<RightResizable />` `<BottomResizable />` `<Positioned />` `<Custom />`
1111

12-
| Property | Type | Default | Description |
13-
| --- | --- | --- | --- |
14-
| as | *string* | div | Allows control over the outputted HTML element allowing HTML 5 semantic markup to be created. |
15-
| centerContent | *CenterType.Vertical* or *CenterType.HorizontalVertical* or *"vertical"* or *"horizontalVertical"* | | Apply centering to children. |
16-
| className | *string* | | A class name to apply to the space element. |
17-
| id | *string* or *number* | *Randomly generated `id`* | By default a space outputs an element with a randomly generated `id`. You can specify your own `id`. It is preferable to specify an `id` on a space that is being added and removed based on state changes. |
18-
| scrollable | *boolean* | false | Makes the space scrollable. By default content that overflows the space will be hidden. This will allow the space to add a scroll bar if the content overflows. |
19-
| trackSize | *boolean* | false | Tells the space to report it's size when it changes size to the `<Info />` component. With this turned off the space will only report the initial size. |
20-
| zIndex | *number* | 0 | A number representing which layer the space sits within. If not specified the space is place in layer 0. Higher numbers appear in front of lower numbers. This is intended to be an alternative to using `<Layer />` as a wrapper and preferable for spaces moving between different layers to avoid remounting of child components. |
12+
<PropsTable>
13+
<StandardProps />
14+
</PropsTable>

react-spaces/src/components/stories/00-docs/03-UsefulEvents.stories.mdx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import { CommonHeader } from "../Utils";
77

88
## Useful events
99

10-
### Space specific events
11-
12-
#### onResizeStart
10+
### onResizeStart
1311

1412
Applies to `<LeftResizable />` `<TopResizable />` `<RightResizable />` `<BottomResizable />`
1513

@@ -29,7 +27,7 @@ const Example = () => {
2927
}
3028
```
3129

32-
#### onResizeEnd
30+
### onResizeEnd
3331

3432
Applies to `<LeftResizable />` `<TopResizable />` `<RightResizable />` `<BottomResizable />`
3533

@@ -52,7 +50,7 @@ const Example = () => {
5250
}
5351
```
5452

55-
### Passthrough events
53+
### Element events
5654

5755
Applies to `<Fill />` `<Left />` `<Top />` `<Right />` `<Bottom />` `<LeftResizable />` `<TopResizable />` `<RightResizable />` `<BottomResizable />` `<Positioned />` `<Custom />`
5856

react-spaces/src/components/stories/00-docs/04-ChangeHistory.stories.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import { CommonHeader } from "../Utils";
77

88
## Change history
99

10-
### 0.1.23
10+
### 0.1.23 - 0.1.24
1111

1212
- Fixed generation of head styles height and z-index which were missing a semi-colon.
13+
- Fixed NPM readme
1314

1415
### 0.1.22
1516

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Meta, Story, Preview, Props } from "@storybook/addon-docs/blocks";
2+
import { withKnobs } from "@storybook/addon-knobs";
3+
import { ViewPort } from "../../ViewPort";
4+
import { Layer } from "../../Layer";
5+
import { Centered } from "../../Centered";
6+
import { Positioned } from "../../Space";
7+
import { blue, red } from "../Utils";
8+
import { CommonHeader, description, PropsTable, Prop } from "../Utils";
9+
10+
<CommonHeader />
11+
12+
<Meta title="Components|Layer" component={Layer} />
13+
14+
## Layer
15+
16+
Groups child spaces and places them all at a certain `zIndex`.
17+
18+
<Preview>
19+
<Story name="Default">
20+
<ViewPort>
21+
<Layer zIndex={1}>
22+
<Positioned style={blue} left={100} top={100} width={200} height={200}>
23+
{description("Positioned in layer with zIndex 1")}
24+
</Positioned>
25+
<Positioned style={blue} left={350} top={100} width={200} height={200}>
26+
{description("Positioned in layer with zIndex 1")}
27+
</Positioned>
28+
</Layer>
29+
<Layer zIndex={2}>
30+
<Positioned style={red} left={200} top={250} width={200} height={200}>
31+
{description("Positioned in layer with zIndex 2")}
32+
</Positioned>
33+
<Positioned style={red} left={450} top={250} width={200} height={200}>
34+
{description("Positioned in layer with zIndex 2")}
35+
</Positioned>
36+
</Layer>
37+
</ViewPort>
38+
</Story>
39+
</Preview>
40+
41+
### Properties
42+
43+
<Story name="Properties">
44+
<PropsTable>
45+
<Prop name="zIndex" type="number" description="zIndex to apply to all child spaces." />
46+
</PropsTable>
47+
</Story>

react-spaces/src/components/stories/Utils.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ export const DemoUI = () => {
188188
);
189189
};
190190

191-
export const blue: CSSProperties = { backgroundColor: "#e0eeee" };
192-
export const red: CSSProperties = { backgroundColor: "#eee0e0" };
193-
export const green: CSSProperties = { backgroundColor: "#e0eee0" };
191+
export const blue: CSSProperties = { backgroundColor: "#e0eeee", opacity: 0.7 };
192+
export const red: CSSProperties = { backgroundColor: "#eee0e0", opacity: 0.7 };
193+
export const green: CSSProperties = { backgroundColor: "#e0eee0", opacity: 0.7 };
194194

195195
export const description = (props: string, additional?: React.ReactNode) => (
196196
<Info>

0 commit comments

Comments
 (0)