@@ -16,6 +16,22 @@ import { responsiveSizes } from "../../variables";
16
16
import { coerceBooleanProperty } from "@angular/cdk/coercion" ;
17
17
import { SidenavService } from "./services/sidenav.service" ;
18
18
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
+
19
35
@Component ( {
20
36
selector : "dxc-application-layout-sidenav" ,
21
37
templateUrl : "./dxc-application-layout-sidenav.component.html" ,
@@ -24,8 +40,20 @@ import { SidenavService } from "./services/sidenav.service";
24
40
} )
25
41
export class DxcApplicationLayoutSidenavComponent implements OnInit , OnChanges {
26
42
@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
+ */
29
57
@Input ( )
30
58
get displayArrow ( ) : boolean {
31
59
return this . _displayArrow ;
@@ -51,7 +79,7 @@ export class DxcApplicationLayoutSidenavComponent implements OnInit, OnChanges {
51
79
constructor (
52
80
private utils : CssUtils ,
53
81
private sidenavService : SidenavService
54
- ) { }
82
+ ) { }
55
83
56
84
@HostListener ( "window:resize" , [ "$event" ] )
57
85
onResize ( event ) {
@@ -113,8 +141,8 @@ export class DxcApplicationLayoutSidenavComponent implements OnInit, OnChanges {
113
141
this . isShown !== undefined
114
142
? this . isShown
115
143
: this . innerWidth <= responsiveSizes . tablet
116
- ? false
117
- : true ;
144
+ ? false
145
+ : true ;
118
146
this . sidenavService . showMenu ( this . isShown ) ;
119
147
}
120
148
@@ -133,7 +161,7 @@ export class DxcApplicationLayoutSidenavComponent implements OnInit, OnChanges {
133
161
return css `
134
162
z-index : 400 ;
135
163
position : ${ ( inputs . mode === "overlay" && this . displayArrow ) ||
136
- inputs . isResponsive
164
+ inputs . isResponsive
137
165
? "absolute"
138
166
: "relative" } ;
139
167
height : ${ inputs . mode === "overlay" || inputs . isResponsive ? "100%" : "" } ;
@@ -145,22 +173,22 @@ export class DxcApplicationLayoutSidenavComponent implements OnInit, OnChanges {
145
173
.sidenavMenu {
146
174
${ this . isShown ? this . utils . getPaddings ( inputs . padding ) : "" }
147
175
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" } ;
152
180
overflow-y : auto;
153
181
overflow-x : hidden;
154
182
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
+ : "" } ;
159
187
opacity : ${ inputs . isShown ? "1" : "0" } ;
160
188
visibility : ${ inputs . isShown ? "visible" : "hidden" } ;
161
189
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" } ;
164
192
& ::-webkit-scrollbar {
165
193
width : 2px ;
166
194
}
@@ -186,24 +214,24 @@ export class DxcApplicationLayoutSidenavComponent implements OnInit, OnChanges {
186
214
left : ${ this . isShown ? "calc(300px - 21px)" : "calc(0px - 21px)" } ;
187
215
top : calc (50% - 21px );
188
216
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
+ : "" } ;
191
219
cursor : pointer;
192
220
z-index : ${ inputs . mode === "overlay" || this . isResponsive
193
- ? "401"
194
- : "auto" } ;
221
+ ? "401"
222
+ : "auto" } ;
195
223
.sidenavArrowImage {
196
224
height : 18px ;
197
225
width : 18px ;
198
226
display : flex;
199
227
align-items : center;
200
228
margin-left : ${ inputs . isShown ? "0px" : "10px" } ;
201
229
transform : ${ inputs . isShown
202
- ? "rotate(-180deg)"
203
- : "rotate(0deg) !important" } ;
230
+ ? "rotate(-180deg)"
231
+ : "rotate(0deg) !important" } ;
204
232
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
+ : "" } ;
207
235
fill : var (--sidenav-arrowColor );
208
236
}
209
237
}
0 commit comments