|
1 | 1 | # React Spaces |
2 | 2 |
|
3 | | -React Spaces allows you to divide a page or container HTML element into spaces. These spaces know how to behave in relation to each other and can also be divided into further nested spaces. |
| 3 | + |
4 | 4 |
|
5 | | -[View examples here](http://www.allaneagle.com/react-spaces/demo/) |
| 5 | +React Spaces allow you to divide a page or container HTML element into spaces. These spaces know how to behave in relation to each other and can also be divided into further nested spaces. |
6 | 6 |
|
7 | 7 | ### Top level spaces |
8 | 8 |
|
9 | 9 | Used at the top level of all other spaces. |
10 | 10 |
|
11 | | -* **ViewPort** - this space will take over the full viewport of the browser window. Resizing the browser window will automatically adjust the size of this space and all the nested spaces. |
12 | | - |
13 | | -* **Fixed** - this space can be given a height and optionally a width (by default it will size to 100% of it's container). All nested spaces will be contained within this fixed size space. |
14 | | - |
15 | | -### Inner spaces |
16 | | - |
17 | | -These can be used within the top-level spaces **ViewPort** and **Fixed** or nested within other spaces. |
18 | | - |
19 | | -* **Left** / **Right** - a space anchored to the left or right of the parent container/space. A size can be specified in pixels to determine its width. |
| 11 | +**ViewPort** |
20 | 12 |
|
21 | | -* **Top** / **Bottom** - a space anchored to the top or bottom of the parent container/space. A size can be specified in pixels to determine its height. |
22 | | - |
23 | | -* **Fill** - a space which consumes any available area left in the parent container/space taking into account any anchored spaces on every side. |
24 | | - |
25 | | -## Getting started |
26 | | - |
27 | | -Spaces can be used by using the following: |
28 | | - |
29 | | -```typescript |
30 | | -npm i react-spaces |
31 | | -``` |
| 13 | +This space will take over the full viewport of the browser window. Resizing the browser window will automatically adjust the size of this space and all the nested spaces. |
32 | 14 |
|
33 | | -```typescript |
34 | | -import * as Spaces from 'react-spaces'; |
35 | | -``` |
36 | | - |
37 | | -## Non-resizable spaces |
38 | | - |
39 | | -Non-resizable spaces provide layout but can not be resized by user interaction. |
40 | | - |
41 | | -### Left and right spaces |
42 | | - |
43 | | -```typescript |
44 | | -const App = () => ( |
45 | | - <Space.Fixed height={400}> |
46 | | - <Space.Left size={200} /> |
47 | | - <Space.Fill /> |
48 | | - <Space.Right size={200} /> |
49 | | - </Space.Fixed> |
50 | | -) |
51 | | -``` |
52 | | - |
53 | | -### Top and bottom spaces |
54 | | - |
55 | | -```typescript |
56 | | -const App = () => ( |
57 | | - <Space.Fixed height={400}> |
58 | | - <Space.Top size={100} /> |
59 | | - <Space.Fill /> |
60 | | - <Space.Bottom size={100} /> |
61 | | - </Space.Fixed> |
62 | | -) |
63 | | -``` |
| 15 | +**Fixed** |
64 | 16 |
|
65 | | -## Resizable spaces |
| 17 | +This space can be given a height and optionally a width (by default it will size to 100% of it's container). All nested spaces will be contained within this fixed size space. |
66 | 18 |
|
67 | | -Resizable spaces allow the space to be resized by dragging with the mouse. The size specified is the initial width/height of the space. There are resizable variations of the spaces above called **LeftResizable**, **RightResizable**, **TopResizable**, and **BottomResizable**. |
68 | | - |
69 | | -### Left and right resizable spaces |
70 | | - |
71 | | -```typescript |
72 | | -const App = () => ( |
73 | | - <Space.ViewPort> |
74 | | - <Space.LeftResizable size={200} /> |
75 | | - <Space.Fill /> |
76 | | - <Space.RightResizable size={200} /> |
77 | | - </Space.ViewPort> |
78 | | -) |
79 | | -``` |
80 | | - |
81 | | -### Top and bottom resizable spaces |
82 | | - |
83 | | -```typescript |
84 | | -const App = () => ( |
85 | | - <Space.Fixed height={400}> |
86 | | - <Space.TopResizable size={100} /> |
87 | | - <Space.Fill /> |
88 | | - <Space.BottomResizable size={100} /> |
89 | | - </Space.Fixed> |
90 | | -) |
91 | | -``` |
| 19 | +### Inner spaces |
92 | 20 |
|
93 | | -Additional properties can be specified to constrain the resizing: |
| 21 | +These can be used within the top-level spaces **ViewPort** and **Fixed** or nested within other spaces. |
94 | 22 |
|
95 | | -* **minimumSize** - minimum size the space can be resized (default is 10px) |
96 | | -* **maximumSize** - maximum size the space can be resized |
| 23 | +**Left** / **Right** |
97 | 24 |
|
98 | | -### Resizable spaces with constrained minimum and maximum sizes |
| 25 | +A space anchored to the left or right of the parent container/space. A size can be specified in pixels to determine its width. |
99 | 26 |
|
100 | | -```typescript |
101 | | -const App = () => ( |
102 | | - <Space.Fixed height={400}> |
103 | | - <Space.LeftResizable size={200} minimumSize={150} maximumSize={250} /> |
104 | | - <Space.Fill /> |
105 | | - <Space.RightResizable size={200} minimumSize={150} maximumSize={250} /> |
106 | | - </Space.Fixed> |
107 | | -) |
108 | | -``` |
| 27 | +**Top** / **Bottom** |
109 | 28 |
|
110 | | -## Nested spaces |
| 29 | +A space anchored to the top or bottom of the parent container/space. A size can be specified in pixels to determine its height. |
111 | 30 |
|
112 | | -Spaces can be nested within other spaces to create complex layouts. |
| 31 | +**Fill** |
113 | 32 |
|
114 | | -### Left/right spaces nested within top/full/bottom spaces |
| 33 | +A space which consumes any available area left in the parent container/space taking into account any anchored spaces on every side. |
115 | 34 |
|
116 | | -```typescript |
117 | | -const App = () => ( |
118 | | - <Space.Fixed height={400}> |
119 | | - <Space.TopResizable size={100} /> |
120 | | - <Space.Fill> |
121 | | - <Space.LeftResizable size={150} /> |
122 | | - <Space.Fill /> |
123 | | - <Space.RightResizable size={150} /> |
124 | | - </Space.Fill> |
125 | | - <Space.BottomResizable size={100} /> |
126 | | - </Space.Fixed> |
127 | | -) |
128 | | -``` |
| 35 | +## Getting started |
129 | 36 |
|
130 | | -### Top/bottom spaces nested within left/full/right spaces |
| 37 | +To get started with React Spaces you need: |
131 | 38 |
|
132 | 39 | ```typescript |
133 | | -const App = () => ( |
134 | | - <Space.Fixed height={400}> |
135 | | - <Space.LeftResizable size={150} /> |
136 | | - <Space.Fill> |
137 | | - <Space.TopResizable size={100} /> |
138 | | - <Space.Fill /> |
139 | | - <Space.BottomResizable size={100} /> |
140 | | - </Space.Fill> |
141 | | - <Space.RightResizable size={150} /> |
142 | | - </Space.Fixed> |
143 | | -) |
| 40 | +npm install react-spaces --save |
144 | 41 | ``` |
145 | 42 |
|
146 | | -## Stacked spaces |
147 | | - |
148 | | -Anchored spaces can be stacked to provide more than one space on each side. To guarantee ordering from the outside of the container / parent space, you should specify an order. |
149 | | - |
150 | | -### Stacked left spaces |
151 | | - |
152 | 43 | ```typescript |
153 | | -const App = () => ( |
154 | | - <Space.Fixed height={400}> |
155 | | - <Space.LeftResizable size={125} order={1} /> |
156 | | - <Space.LeftResizable size={125} order={2} /> |
157 | | - <Space.Fill /> |
158 | | - </Space.Fixed> |
159 | | -) |
| 44 | +import * as Spaces from 'react-spaces'; |
160 | 45 | ``` |
161 | 46 |
|
162 | | -## Scrollable spaces |
163 | | - |
164 | | -By default, all spaces hide content that overflows the space. To make a particular space scrollable, set the **scrollable** property to **true**. The space will then be scrollable horizontally or vertically if the content overflows the space. |
165 | | - |
166 | | -## Getting size information for a space |
167 | | - |
168 | | -Using the **Info** component, you can get size information on the containing space. |
169 | | - |
170 | | -```typescript |
171 | | -const App = () => ( |
172 | | - <Space.Fixed height={400}> |
173 | | - <Space.Fill> |
174 | | - <Space.Info> |
175 | | - {info => <span>{info.width}px x {info.height}px</span>} |
176 | | - </Space.Info> |
177 | | - </Space.Fill> |
178 | | - </Space.Fixed> |
179 | | -) |
180 | | -``` |
| 47 | +View full documentation here: |
| 48 | +[View examples here](http://www.allaneagle.com/react-spaces/demo/) |
0 commit comments