Skip to content

Commit f34880e

Browse files
authored
Merge pull request #677 from dxc-technology/jialecl-appLayout-types
Adding app layout types
2 parents 446fe54 + 73f94f7 commit f34880e

File tree

2 files changed

+93
-64
lines changed

2 files changed

+93
-64
lines changed

projects/dxc-ngx-cdk-site/src/app/components/examples/layout/app-layout-api/app-layout-api.component.html

+41-40
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,7 @@
5151
<p>
5252
Everything in this component will be displayed as content inside a sidenav at
5353
the left. This is optional and if not specified, the sidenav will not be
54-
shown. Check
55-
<dxc-link
56-
text="DxcSidenav"
57-
href=""
58-
underlined="false"
59-
(click)="navigateToRoute('sidenav'); $event.preventDefault()"
60-
></dxc-link>
61-
for more information regarding its props. This also applies to the themming.
62-
</p>
63-
64-
65-
<dxc-heading
66-
[level]="5"
67-
weight="normal"
68-
text="DxcApplicationLayoutFooter"
69-
[margin]="{ bottom: 'small' }"
70-
></dxc-heading>
71-
<p>
72-
This component has to be a child of DxcApplicationLayoutMain. Everything in
73-
this component will be displayed as a footer, at the bottom of the screen. If
74-
you want to show a
75-
<dxc-link
76-
text="DxcFooter"
77-
href=""
78-
underlined="false"
79-
(click)="navigateToRoute('footer'); $event.preventDefault()"
80-
></dxc-link
81-
>, as a shortcut, you can directly use it without DxcApplicationLayoutFooter.
82-
This is optional and if it is not specified, the DxcFooter will be shown by
83-
default.
54+
shown.
8455
</p>
8556

8657
<dxc-heading
@@ -90,31 +61,65 @@
9061
[margin]="{ bottom: 'small' }"
9162
></dxc-heading>
9263

93-
<dxc-table>
64+
<dxc-table [margin]="{ bottom: 'medium' }">
9465
<tr>
9566
<th>Name</th>
9667
<th>Default</th>
9768
<th>Description</th>
9869
</tr>
9970
<tr>
100-
<td>mode: 'overlay' | 'push' </td>
71+
<td>mode: 'overlay' | 'push'</td>
10172
<td>
102-
<code>'overlay'</code>
73+
<code>'push'</code>
10374
</td>
10475
<td>
105-
Default action over the content of the page, overlay the content or
106-
push to the right.
76+
Default action over the content of the page, overlay the content or push
77+
to the right. In lower resolutions the mode will always be overlay.
10778
</td>
10879
</tr>
10980
<tr>
11081
<td>displayArrow: boolean</td>
11182
<td>
11283
<code>true</code>
11384
</td>
114-
<td>If false, the arrow button is hidden.</td>
85+
<td>
86+
If false, the arrow button is hidden. In lower resolutions the arrow will
87+
be always displayed.
88+
</td>
89+
</tr>
90+
<tr>
91+
<td>padding: string | object</td>
92+
<td></td>
93+
<td>
94+
Size of the padding to be applied to the custom area ('xxsmall' | 'xsmall'
95+
| 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge'). You can pass an
96+
object with 'top', 'bottom', 'left' and 'right' properties in order to
97+
specify different padding sizes.
98+
</td>
11599
</tr>
116100
</dxc-table>
117101

102+
<dxc-heading
103+
[level]="5"
104+
weight="normal"
105+
text="DxcApplicationLayoutFooter"
106+
[margin]="{ bottom: 'small' }"
107+
></dxc-heading>
108+
<p>
109+
This component has to be a child of DxcApplicationLayoutMain. Everything in
110+
this component will be displayed as a footer, at the bottom of the screen. If
111+
you want to show a
112+
<dxc-link
113+
text="DxcFooter"
114+
href=""
115+
underlined="false"
116+
(click)="navigateToRoute('footer'); $event.preventDefault()"
117+
></dxc-link
118+
>, as a shortcut, you can directly use it without DxcApplicationLayoutFooter.
119+
This is optional and if it is not specified, the DxcFooter will be shown by
120+
default.
121+
</p>
122+
118123
<dxc-heading
119124
[level]="5"
120125
weight="normal"
@@ -126,7 +131,6 @@
126131
container at the center.
127132
</p>
128133

129-
130134
<dxc-heading
131135
[level]="4"
132136
weight="normal"
@@ -138,7 +142,4 @@
138142
want to use it from your Angular project. You have the following example:
139143
</p>
140144

141-
142-
143-
144145
<app-code-playground [code]="bindCode" type="TS"></app-code-playground>

projects/dxc-ngx-cdk/src/lib/dxc-application-layout/dxc-application-layout-sidenav/dxc-application-layout-sidenav.component.ts

+52-24
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ import { responsiveSizes } from "../../variables";
1616
import { coerceBooleanProperty } from "@angular/cdk/coercion";
1717
import { 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
})
2541
export 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

Comments
 (0)