@@ -16,6 +16,22 @@ import { responsiveSizes } from "../../variables";
1616import { coerceBooleanProperty } from "@angular/cdk/coercion" ;
1717import { SidenavService } from "./services/sidenav.service" ;
1818
19+ type Space =
20+ | "xxsmall"
21+ | "xsmall"
22+ | "small"
23+ | "medium"
24+ | "large"
25+ | "xlarge"
26+ | "xxlarge" ;
27+
28+ type Padding = {
29+ top ?: Space ;
30+ bottom ?: Space ;
31+ left ?: Space ;
32+ right ?: Space ;
33+ } ;
34+
1935@Component ( {
2036 selector : "dxc-application-layout-sidenav" ,
2137 templateUrl : "./dxc-application-layout-sidenav.component.html" ,
@@ -24,8 +40,20 @@ import { SidenavService } from "./services/sidenav.service";
2440} )
2541export class DxcApplicationLayoutSidenavComponent implements OnInit , OnChanges {
2642 @HostBinding ( "class" ) sidenavStyles ;
27- @Input ( ) mode : string = "push" ;
28- @Input ( ) padding : any ;
43+ /**
44+ * Default action over the content of the page, overlay the content or push to the right ('push' | 'overlay').
45+ * In lower resolutions the mode will always be overlay.
46+ */
47+ @Input ( ) mode : "push" | "overlay" = "push" ;
48+ /**
49+ * Size of the padding to be applied to the custom area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
50+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
51+ */
52+ @Input ( ) padding : Space | Padding ;
53+ /**
54+ * If false, the arrow button is hidden.
55+ * In lower resolutions the arrow will be always displayed.
56+ */
2957 @Input ( )
3058 get displayArrow ( ) : boolean {
3159 return this . _displayArrow ;
@@ -51,7 +79,7 @@ export class DxcApplicationLayoutSidenavComponent implements OnInit, OnChanges {
5179 constructor (
5280 private utils : CssUtils ,
5381 private sidenavService : SidenavService
54- ) { }
82+ ) { }
5583
5684 @HostListener ( "window:resize" , [ "$event" ] )
5785 onResize ( event ) {
@@ -113,8 +141,8 @@ export class DxcApplicationLayoutSidenavComponent implements OnInit, OnChanges {
113141 this . isShown !== undefined
114142 ? this . isShown
115143 : this . innerWidth <= responsiveSizes . tablet
116- ? false
117- : true ;
144+ ? false
145+ : true ;
118146 this . sidenavService . showMenu ( this . isShown ) ;
119147 }
120148
@@ -133,7 +161,7 @@ export class DxcApplicationLayoutSidenavComponent implements OnInit, OnChanges {
133161 return css `
134162 z-index : 400 ;
135163 position : ${ ( inputs . mode === "overlay" && this . displayArrow ) ||
136- inputs . isResponsive
164+ inputs . isResponsive
137165 ? "absolute"
138166 : "relative" } ;
139167 height : ${ inputs . mode === "overlay" || inputs . isResponsive ? "100%" : "" } ;
@@ -145,22 +173,22 @@ export class DxcApplicationLayoutSidenavComponent implements OnInit, OnChanges {
145173 .sidenavMenu {
146174 ${ this . isShown ? this . utils . getPaddings ( inputs . padding ) : "" }
147175 width : ${ inputs . isShown
148- ? "calc(300px" +
149- this . utils . getPaddingOrMargin ( null , inputs . padding ) +
150- ")"
151- : "0px" } ;
176+ ? "calc(300px" +
177+ this . utils . getPaddingOrMargin ( null , inputs . padding ) +
178+ ")"
179+ : "0px" } ;
152180 overflow-y : auto;
153181 overflow-x : hidden;
154182 transform : ${ inputs . isShown
155- ? "translateX(0)"
156- : ! inputs . isShown
157- ? "translateX(-100%) !important"
158- : "" } ;
183+ ? "translateX(0)"
184+ : ! inputs . isShown
185+ ? "translateX(-100%) !important"
186+ : "" } ;
159187 opacity : ${ inputs . isShown ? "1" : "0" } ;
160188 visibility : ${ inputs . isShown ? "visible" : "hidden" } ;
161189 transition : ${ this . firstClick
162- ? "transform 0.4s ease-in-out, opacity 0.4s ease-in-out, visibility 0.4s ease-in-out, width 0.4s ease-in-out, padding 0.4s ease-in-out;"
163- : "width 0.4s ease-in-out" } ;
190+ ? "transform 0.4s ease-in-out, opacity 0.4s ease-in-out, visibility 0.4s ease-in-out, width 0.4s ease-in-out, padding 0.4s ease-in-out;"
191+ : "width 0.4s ease-in-out" } ;
164192 & ::-webkit-scrollbar {
165193 width : 2px ;
166194 }
@@ -186,24 +214,24 @@ export class DxcApplicationLayoutSidenavComponent implements OnInit, OnChanges {
186214 left : ${ this . isShown ? "calc(300px - 21px)" : "calc(0px - 21px)" } ;
187215 top : calc (50% - 21px );
188216 transition : ${ this . firstClick
189- ? "transform 0.4s ease-in-out, left 0.4s ease-in-out;"
190- : "" } ;
217+ ? "transform 0.4s ease-in-out, left 0.4s ease-in-out;"
218+ : "" } ;
191219 cursor : pointer;
192220 z-index : ${ inputs . mode === "overlay" || this . isResponsive
193- ? "401"
194- : "auto" } ;
221+ ? "401"
222+ : "auto" } ;
195223 .sidenavArrowImage {
196224 height : 18px ;
197225 width : 18px ;
198226 display : flex;
199227 align-items : center;
200228 margin-left : ${ inputs . isShown ? "0px" : "10px" } ;
201229 transform : ${ inputs . isShown
202- ? "rotate(-180deg)"
203- : "rotate(0deg) !important" } ;
230+ ? "rotate(-180deg)"
231+ : "rotate(0deg) !important" } ;
204232 transition : ${ this . firstClick
205- ? "margin 0.4s ease-in, transform 0.4s ease-in-out; "
206- : "" } ;
233+ ? "margin 0.4s ease-in, transform 0.4s ease-in-out; "
234+ : "" } ;
207235 fill : var (--sidenav-arrowColor );
208236 }
209237 }
0 commit comments