@khanacademy/wonder-blocks-grid 1.0.24

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.
@@ -0,0 +1,105 @@
1
+ **Example:**
2
+
3
+ A row inside of a grid containing two [Cells](#cell). The row has some styling
4
+ applied giving it a white background, a gold border, and some vertical padding.
5
+ Note that the margins and gutter have been inserted automatically.
6
+
7
+ ```jsx
8
+ import {Cell} from "@khanacademy/wonder-blocks-grid";
9
+ import Color from "@khanacademy/wonder-blocks-color";
10
+ import {View, Text} from "@khanacademy/wonder-blocks-core";
11
+ import {StyleSheet} from "aphrodite";
12
+
13
+ const styles = StyleSheet.create({
14
+ background: {
15
+ background: Color.offBlack,
16
+ },
17
+
18
+ row: {
19
+ padding: "16px 0",
20
+ border: `1px solid ${Color.gold}`,
21
+ background: Color.white,
22
+ },
23
+
24
+ cell: {
25
+ height: 100,
26
+ padding: 5,
27
+ background: Color.gold,
28
+ },
29
+ });
30
+
31
+ <View style={styles.background}>
32
+ <Row style={styles.row}>
33
+ <Cell smallCols={2} mediumCols={4} largeCols={6} style={styles.cell}>
34
+ <Text>Cell</Text>
35
+ </Cell>
36
+ <Cell smallCols={2} mediumCols={4} largeCols={6} style={styles.cell}>
37
+ <Text>Cell</Text>
38
+ </Cell>
39
+ </Row>
40
+ </View>;
41
+ ```
42
+
43
+ Another example – If the height of the [Cell's](#cell) contents is taller than
44
+ the [Row](#row) it will allow vertical scrolling.
45
+
46
+ ```jsx
47
+ import {Cell} from "@khanacademy/wonder-blocks-grid";
48
+ import Color from "@khanacademy/wonder-blocks-color";
49
+ import {Body} from "@khanacademy/wonder-blocks-typography";
50
+ import {View, Text} from "@khanacademy/wonder-blocks-core";
51
+ import {StyleSheet} from "aphrodite";
52
+
53
+ const styles = StyleSheet.create({
54
+ view: {
55
+ background: Color.offBlack,
56
+ height: "400px",
57
+ },
58
+
59
+ row: {
60
+ alignItems: "stretch",
61
+ background: Color.white,
62
+ border: `1px solid ${Color.gold}`,
63
+ display: "flex",
64
+ height: "100%",
65
+ padding: "16px 0",
66
+ },
67
+
68
+ cell: {
69
+ background: Color.gold,
70
+ overflowY: "auto",
71
+ padding: 5,
72
+ },
73
+ });
74
+
75
+ <View style={styles.view}>
76
+ <Row style={styles.row}>
77
+ <Cell
78
+ smallCols={2}
79
+ mediumCols={4}
80
+ largeCols={4}
81
+ style={styles.cell}
82
+ >
83
+ <Text>Sidebar</Text>
84
+ <ul>
85
+ <li>Chapter 1: Loomings</li>
86
+ <li>Chapter 2: The Carpet-Bag</li>
87
+ <li>Chapter 3: The Spouter-Inn</li>
88
+ <li>Chapter 4: The Counterpane</li>
89
+ <li>Chapter 5: Breakfast</li>
90
+ <li>Chapter 6: The Street</li>
91
+ </ul>
92
+ </Cell>
93
+ <Cell
94
+ smallCols={2}
95
+ mediumCols={4}
96
+ largeCols={8}
97
+ style={styles.cell}
98
+ >
99
+ <Body tag="p">Call me Ishmael. Some years ago- never mind how long precisely- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people's hats off- then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.</Body>
100
+
101
+ <Body tag="p">There now is your insular city of the Manhattoes, belted round by wharves as Indian isles by coral reefs- commerce surrounds it with her surf. Right and left, the streets take you waterward. Its extreme downtown is the battery, where that noble mole is washed by waves, and cooled by breezes, which a few hours previous were out of sight of land. Look at the crowds of water-gazers there.</Body>
102
+ </Cell>
103
+ </Row>
104
+ </View>
105
+ ```
package/src/index.js ADDED
@@ -0,0 +1,3 @@
1
+ // @flow
2
+ export {default as Cell} from "./components/cell.js";
3
+ export {default as Row} from "./components/row.js";
@@ -0,0 +1,29 @@
1
+ // @flow
2
+ import {StyleSheet} from "aphrodite";
3
+ import type {StyleDeclaration} from "aphrodite";
4
+
5
+ const WIDE_SCREEN = "@media (min-width: 1168px)";
6
+
7
+ const styles: StyleDeclaration = StyleSheet.create({
8
+ row: {
9
+ flexDirection: "row",
10
+ alignItems: "center",
11
+ width: "100%",
12
+ },
13
+
14
+ rowMaxWidth: {
15
+ [WIDE_SCREEN]: {
16
+ margin: "0 auto",
17
+ },
18
+ },
19
+
20
+ cellGrow: {
21
+ flexGrow: 1,
22
+ },
23
+
24
+ cellFixed: {
25
+ flexShrink: 0,
26
+ },
27
+ });
28
+
29
+ export default styles;
@@ -0,0 +1,11 @@
1
+ // @flow
2
+ import type {StyleType} from "@khanacademy/wonder-blocks-core";
3
+
4
+ export const flexBasis = (size: number | string): StyleType => {
5
+ return {
6
+ MsFlexBasis: size,
7
+ MsFlexPreferredSize: size,
8
+ WebkitFlexBasis: size,
9
+ flexBasis: size,
10
+ };
11
+ };