File tree Expand file tree Collapse file tree 2 files changed +45
-29
lines changed Expand file tree Collapse file tree 2 files changed +45
-29
lines changed Original file line number Diff line number Diff line change @@ -54,35 +54,6 @@ This avoids creating styles as nested components (`.profile-card > .profile-info
5454</div >
5555``` 
5656
57- ## Simplifying nested components  
58- Sometimes, when nesting components, your markup can get dirty:
59- 
60- ``` html 
61- <div  class =' search-form' 
62-   <input  class =' input' type =' text' 
63-   <button  class =' search-button -red -large' button >
64- </div >
65- ``` 
66- 
67- You can simplify this by using your CSS preprocessor's ` @extend `  mechanism:
68- 
69- ``` html 
70- <div  class =' search-form' 
71-   <input  class =' input' type =' text' 
72-   <button  class =' submit' button >
73- </div >
74- ``` 
75- 
76- ``` scss 
77- .search-form  {
78-   > .submit  {
79-     @extend  .search-button ;
80-     @extend  .search-button.-red ;
81-     @extend  .search-button.-large ;
82-   }
83- }
84- ``` 
85- 
8657What about repeating elements like lists? Learn about Layouts.
8758[ Continue →] ( layouts.md ) 
8859<!--  {p:.pull-box} --> 
Original file line number Diff line number Diff line change 1+ # Simplifying nested components  
2+ 
3+ Sometimes, when nesting components, your markup can get dirty:
4+ 
5+ ``` html 
6+ <div  class =' search-form' 
7+   <input  class =' input' type =' text' 
8+   <button  class =' search-button -red -large' button >
9+ </div >
10+ ``` 
11+ 
12+ You can simplify this by refactoring your common component into mixins.
13+ 
14+ ``` scss 
15+ .search-button  {
16+   @include  search-button ;
17+ 
18+   & .-red  {
19+     @include  search-button-red ;
20+   }
21+ 
22+   & .-large  {
23+     @include  search-button-large ;
24+   }
25+ }
26+ ``` 
27+ 
28+ You can then use the mixins to style elements in your component.
29+ 
30+ ``` html 
31+ <div  class =' search-form' 
32+   <input  class =' input' type =' text' 
33+   <button  class =' submit' button >
34+ </div >
35+ ``` 
36+ 
37+ ``` scss 
38+ .search-form  {
39+   > .submit  {
40+     @include  search-button ;
41+     @include  search-button-red ;
42+     @include  search-button-large ;
43+   }
44+ }
45+ ``` 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments