@@ -23,6 +23,7 @@ that a placeholder is the perfect use case for them.
2323### Props
2424The ` <Placehodl /> ` component has the following props:
2525- seed => Seed for the size randomizer. (Powered by _ fast-random_ ).
26+ - sizes => Array of size classNames that will be applies to each word.
2627- prefix => Prefix used in all elements classes.
2728- className => Root level class name.
2829- children => Function that gets passed the generator methods.
@@ -49,52 +50,77 @@ getLine(words: int, size: int) => (line: jsx)
4950getSize (size: int) => (className: string)
5051```
5152
52- ### Example
53+ ## Examples
54+
55+ ### Use of getParagraph (works out of the box use case)
5356``` jsx
5457 import Placehodl from ' react-placehodl' ;
55-
58+
59+ // outputs paragraph with 10 lines, 3 words, 5 sizes
5660 const Placeholder = props => {
5761 return (
5862 < Placehodl seed= {props .seed } prefix= " my-placeholder" >
59- {({ getParagraph, getLine, getSize }) => (
60- < React .Fragment >
61- {/* outputs paragraph with 10 lines, 3 words, 5 sizes */ }
62- {getParagraph (10 , 3 , 5 )}
63- < div className= " placeholder-paragraph" >
64- {Array (10 )
65- .fill (0 )
66- .map ((line , i ) => (
67- < div
68- key= {` placeholder-line-container-${ i} ` }
69- className= " placeholder-line-container"
70- >
71- {/* outputs line with 3 words, 5 sizes */ }
72- {getLine (3 , 5 )}
73- < Icon name= " info" / >
74- < / div>
75- ))}
76- < / div>
77- < div className= " placeholder-paragraph" >
78- {Array (10 )
79- .fill (0 )
80- .map ((line , i ) => (
81- < div key= {` placeholer-line-${ i} ` } className= " placeholder-line" >
82- {Array (3 )
83- .fill (0 )
84- .map ((word , j ) => (
85- < div
86- key= {` placeholder-word-${ j} ` }
87- className= {` placeholder-line-container ${ getSize (5 )} ` }
88- >
89- {/* outputs word 5 possible sizes */ }
90- < / div>
91- ))}
92- < / div>
93- ))}
94- < / div>
95- < / React .Fragment >
96- )}
63+ {({ getParagraph }) => getParagraph (10 , 3 , 5 )}
9764 < / Placehodl>
9865 );
9966 };
10067```
68+
69+ ### Use of getLine (medium customization use case)
70+ ``` jsx
71+ import Placehodl from ' react-placehodl' ;
72+
73+ // outputs line with 3 words, 5 sizes
74+ const Placeholder = props => {
75+ return (
76+ < Placehodl seed= {props .seed } prefix= " my-placeholder" >
77+ {({ getLine }) => (
78+ < div className= " my-placeholder-paragraph" >
79+ {Array (10 )
80+ .fill (0 )
81+ .map ((line , i ) => (
82+ < div
83+ key= {` placeholder-line-container-${ i} ` }
84+ className= " my-placeholder-line-container"
85+ >
86+ {getLine (3 , 5 )}
87+ < Icon name= " info" / >
88+ < / div>
89+ ))}
90+ < / div>
91+ )}
92+ < / Placehodl>
93+ );
94+ };
95+ ```
96+
97+ ### Use of getSize (advanced customization use case)
98+ ``` jsx
99+ import Placehodl from ' react-placehodl' ;
100+
101+ // outputs word 5 possible sizes
102+ const Placeholder = props => {
103+ return (
104+ < Placehodl seed= {props .seed } prefix= " my-placeholder" >
105+ {({ getLine }) => (
106+ < div className= " my-placeholder-paragraph" >
107+ {Array (10 )
108+ .fill (0 )
109+ .map ((line , i ) => (
110+ < div key= {` placeholer-line-${ i} ` } className= " my-placeholder-line" >
111+ {Array (3 )
112+ .fill (0 )
113+ .map ((word , j ) => (
114+ < div
115+ key= {` placeholder-word-${ j} ` }
116+ className= {` my-placeholder-line-container ${ getSize (5 )} ` }
117+ / >
118+ ))}
119+ < / div>
120+ ))}
121+ < / div>
122+ )}
123+ < / Placehodl>
124+ );
125+ };
126+ ```
0 commit comments