Skip to content

Commit 08c1b6c

Browse files
Merge pull request #706 from dxc-technology/rarrojolopez-box-component
Added box types
2 parents f7be76f + cd048eb commit 08c1b6c

File tree

3 files changed

+63
-16
lines changed

3 files changed

+63
-16
lines changed

projects/dxc-ngx-cdk-site/src/app/components/examples/box/properties/box-table-properties/box-table-properties.component.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
<dxc-heading [level]="4" weight="normal" text="Properties" [margin]="{bottom:'small'}"></dxc-heading>
1+
<dxc-heading
2+
[level]="4"
3+
weight="normal"
4+
text="Properties"
5+
[margin]="{ bottom: 'small' }"
6+
></dxc-heading>
27
<dxc-table>
38
<tr>
49
<th>Name</th>
510
<th>Default</th>
611
<th>Description</th>
712
</tr>
813
<tr>
9-
<td>shadowDepth: number (0 | 1 | 2)</td>
14+
<td>shadowDepth: 0 | 1 | 2</td>
1015
<td><code>2</code></td>
1116
<td>The size of the shadow to be displayed around the box.</td>
1217
</tr>
@@ -15,10 +20,10 @@
1520
<td>
1621
<code>'inline-flex'</code>
1722
</td>
18-
<td>Changes the display CSS property of the Box div.</td>
23+
<td>Changes the display CSS property of the box div.</td>
1924
</tr>
2025
<tr>
21-
<td>margin: any (string | object)</td>
26+
<td>margin: string | object</td>
2227
<td></td>
2328
<td>
2429
Size of the margin to be applied to the component ('xxsmall' | 'xsmall' |
@@ -28,7 +33,7 @@
2833
</td>
2934
</tr>
3035
<tr>
31-
<td>padding: any (string | object)</td>
36+
<td>padding: string | object</td>
3237
<td></td>
3338
<td>
3439
Size of the padding to be applied to the component ('xxsmall' | 'xsmall' |

projects/dxc-ngx-cdk/src/lib/dxc-box/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The API properties are the following:
3737
<th>Description</th>
3838
</tr>
3939
<tr>
40-
<td>@Input<br>shadowDepth: number (0 | 1 | 2)</td>
40+
<td>@Input<br>shadowDepth: 0 | 1 | 2</td>
4141
<td><code>2</code></td>
4242
<td>The size of the shadow to be displayed around the box.</td>
4343
</tr>
@@ -46,10 +46,10 @@ The API properties are the following:
4646
<td>
4747
<code>'inline-flex'</code>
4848
</td>
49-
<td>Changes the display CSS property of the Box div.</td>
49+
<td>Changes the display CSS property of the box div.</td>
5050
</tr>
5151
<tr>
52-
<td>@Input<br>margin: any (string | object)</td>
52+
<td>@Input<br>margin: string | object</td>
5353
<td></td>
5454
<td>
5555
Size of the margin to be applied to the component ('xxsmall' | 'xsmall' |
@@ -59,7 +59,7 @@ The API properties are the following:
5959
</td>
6060
</tr>
6161
<tr>
62-
<td>@Input<br>padding: any (string | object)</td>
62+
<td>@Input<br>padding: string | object</td>
6363
<td></td>
6464
<td>
6565
Size of the padding to be applied to the component ('xxsmall' | 'xsmall' |

projects/dxc-ngx-cdk/src/lib/dxc-box/dxc-box.component.ts

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,59 @@ import {
88
import { BehaviorSubject } from "rxjs";
99
import { css } from "emotion";
1010
import { CssUtils } from "../utils";
11-
import { BackgroundProviderService } from '../background-provider/service/background-provider.service';
11+
import { BackgroundProviderService } from "../background-provider/service/background-provider.service";
12+
13+
type Size = "small" | "medium" | "large" | "fillParent" | "fitContent";
14+
type Space =
15+
| "xxsmall"
16+
| "xsmall"
17+
| "small"
18+
| "medium"
19+
| "large"
20+
| "xlarge"
21+
| "xxlarge";
22+
type Margin = {
23+
top?: Space;
24+
bottom?: Space;
25+
left?: Space;
26+
right?: Space;
27+
};
28+
type Padding = {
29+
top?: Space;
30+
bottom?: Space;
31+
left?: Space;
32+
right?: Space;
33+
};
34+
1235
@Component({
1336
selector: "dxc-box",
1437
templateUrl: "./dxc-box.component.html",
1538
providers: [CssUtils, BackgroundProviderService],
1639
})
1740
export class DxcBoxComponent implements OnInit {
1841
@HostBinding("class") className;
19-
@Input() shadowDepth: number;
20-
@Input() display: string;
21-
@Input() margin: any;
22-
@Input() padding: any;
23-
@Input() size: string;
42+
/**
43+
* The size of the shadow to be displayed around the box.
44+
*/
45+
@Input() shadowDepth: 0 | 1 | 2 = 2;
46+
/**
47+
* Changes the display CSS property of the box div.
48+
*/
49+
@Input() display: string = "inline-flex";
50+
/**
51+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
52+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
53+
*/
54+
@Input() margin: Space | Margin;
55+
/**
56+
* Size of the padding to be applied to the custom area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
57+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
58+
*/
59+
@Input() padding: Space | Padding;
60+
/**
61+
* Size of the component.
62+
*/
63+
@Input() size: Size = "fitContent";
2464
currentBackgroundColor;
2565

2666
sizes = {
@@ -59,7 +99,9 @@ export class DxcBoxComponent implements OnInit {
5999
result[item] = changes[item].currentValue;
60100
return result;
61101
}, {});
62-
this.currentBackgroundColor = this.utils.readProperty('--box-backgroundColor');
102+
this.currentBackgroundColor = this.utils.readProperty(
103+
"--box-backgroundColor"
104+
);
63105
this.defaultInputs.next({ ...this.defaultInputs.getValue(), ...inputs });
64106
this.className = `${this.getDynamicStyle(this.defaultInputs.getValue())}`;
65107
}

0 commit comments

Comments
 (0)