@@ -8,134 +8,116 @@ postnumber: 37
88framework : react
99chapter : Building reusable components
1010---
11+
1112In this post we will create a couple of typography components that we will use throughout the App for all of our Typography.
1213
1314First create a folder in the components directory called ` typography ` . And create a file called ` HeadingOne.js ` and add the following:
1415
15-
16-
1716``` javascript
18- import React from " react" ;
19- import PropTypes from " prop-types" ;
17+ import React from " react"
18+ import PropTypes from " prop-types"
2019const HeadingOne = ({ className, children }) => {
2120 return (
2221 < h1 className= {` ${ className} text-4xl text-black text-bold font-display` }>
2322 {children}
2423 < / h1>
25- );
26- };
24+ )
25+ }
2726
2827HeadingOne .propTypes = {
2928 className: PropTypes .string ,
3029 children: PropTypes .oneOfType ([PropTypes .string , PropTypes .array ]),
31- };
30+ }
3231
3332HeadingOne .defaultProps = {
3433 className: " " ,
35- };
36- export default HeadingOne ;
37-
38-
34+ }
35+ export default HeadingOne
3936```
4037
41- 🛩️ We are creating a H1 component that will allow us to add additional content inside it via the children prop.
42-
43- 🛩️ Then we given it some styles.
44-
45- Then next up create a HeadingTwo.js file with the following:
38+ 🛩️ We are creating a ` H1 ` component that will allow us to add additional content inside it via the children prop.
4639
40+ 🛩️ Then we've given it some styles.
4741
42+ Then next up create a ` HeadingTwo.js ` file with the following:
4843
4944``` javascript
50- import React from " react" ;
51- import PropTypes from " prop-types" ;
45+ import React from " react"
46+ import PropTypes from " prop-types"
5247const HeadingTwo = ({ className, children }) => {
5348 return (
5449 < h1 className= {` ${ className} text-xl text-black text-bold font-display` }>
5550 {children}
5651 < / h1>
57- );
58- };
52+ )
53+ }
5954
6055HeadingTwo .propTypes = {
6156 className: PropTypes .string ,
6257 children: PropTypes .oneOfType ([PropTypes .string , PropTypes .array ]),
63- };
58+ }
6459
6560HeadingTwo .defaultProps = {
6661 className: " " ,
67- };
68- export default HeadingTwo ;
69-
70-
62+ }
63+ export default HeadingTwo
7164```
7265
73- Then create a HeadingThree.js component with the following:
74-
75-
66+ Then create a ` HeadingThree.js ` component with the following:
7667
7768``` javascript
78- import React from " react" ;
79- import PropTypes from " prop-types" ;
69+ import React from " react"
70+ import PropTypes from " prop-types"
8071const HeadingThree = ({ className, children }) => {
8172 return (
8273 < h1 className= {` ${ className} text-2xl text-black text-bold font-display` }>
8374 {children}
8475 < / h1>
85- );
86- };
76+ )
77+ }
8778
8879HeadingThree .propTypes = {
8980 className: PropTypes .string ,
9081 children: PropTypes .oneOfType ([PropTypes .string , PropTypes .array ]),
91- };
82+ }
9283
9384HeadingThree .defaultProps = {
9485 className: " " ,
95- };
96- export default HeadingThree ;
97-
98-
86+ }
87+ export default HeadingThree
9988```
10089
101- Next up create a BodyOne.js file and add the following:
102-
103-
90+ Next up create a ` BodyOne.js ` file and add the following:
10491
10592``` javascript
106- import React from " react" ;
107- import PropTypes from " prop-types" ;
93+ import React from " react"
94+ import PropTypes from " prop-types"
10895const BodyOne = ({ className, children }) => {
10996 return (
11097 < p className= {` ${ className} text-sm text-black text-bold font-display` }>
11198 {children}
11299 < / p>
113- );
114- };
100+ )
101+ }
115102
116103BodyOne .propTypes = {
117104 className: PropTypes .string ,
118105 children: PropTypes .oneOfType ([PropTypes .string , PropTypes .array ]),
119- };
106+ }
120107
121108BodyOne .defaultProps = {
122109 className: " " ,
123- };
124- export default BodyOne ;
125-
126-
110+ }
111+ export default BodyOne
127112```
128113
129-
130-
131114Last lets create an ` index.js ` file so we can import the components in one line through out the app:
132115
133116``` javascript
134- import HeadingOne from " ./HeadingOne" ;
135- import BodyOne from " ./BodyOne" ;
136- import HeadingTwo from " ./HeadingTwo" ;
137- import HeadingThree from " ./HeadingThree" ;
117+ import HeadingOne from " ./HeadingOne"
118+ import BodyOne from " ./BodyOne"
119+ import HeadingTwo from " ./HeadingTwo"
120+ import HeadingThree from " ./HeadingThree"
138121
139- export { HeadingOne , BodyOne , HeadingTwo , HeadingThree };
140-
141- ```
122+ export { HeadingOne , BodyOne , HeadingTwo , HeadingThree }
123+ ```
0 commit comments