Skip to content

Commit

Permalink
feat: add container background in custom-layout (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Jul 7, 2023
1 parent 734e7e9 commit fcb53d5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ export function createTable() {
showBounds: false,
direction: 'column',
alignContent: 'center',
justifyContent: 'center'
justifyContent: 'center',
background: {
fill: 'blue',
stroke: 'red'
}
});
container.add(containerLeft);

Expand Down
9 changes: 9 additions & 0 deletions packages/vtable/examples/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ export const menus = [
}
]
},
{
menu: 'custom',
children: [
{
path: 'custom',
name: 'custom-layout'
}
]
},
{
menu: '调试使用',
children: [
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable/examples/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ body p {
}

.container .sidebar {
width: 100px;
width: 200px;
/* height: 100%; */
border-right: 1px solid rgba(0, 0, 0, 0.06);
}
Expand Down
13 changes: 13 additions & 0 deletions packages/vtable/src/render/layout/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ export class Container extends BaseElement {
this.updateYAlign();

const elements = [];
if (this.background && this.background.fill) {
const backgroundRect = new Rect({
width: this.width,
height: this.height,
stroke: this.background.stroke ?? false,
fill: this.background.fill,
cornerRadius: this.background.cornerRadius ?? 0,
lineWidth: this.background.lineWidth ?? 1
});
backgroundRect.x += this.x + parentPos.parentX;
backgroundRect.y += this.y + parentPos.parentY;
elements.push(backgroundRect);
}
if (this.showBounds) {
const boundsRect = new Rect({
width: this.width,
Expand Down

0 comments on commit fcb53d5

Please sign in to comment.