From f7a904a938aa71f7932a49e515bf91559995bcec Mon Sep 17 00:00:00 2001 From: Kobe Wulteputte <44460772+Kobe-Wulteputte@users.noreply.github.com> Date: Wed, 5 Oct 2022 00:42:39 +0200 Subject: [PATCH] feat: add missing attributes * added bindable gs-item attributes * added min size example Co-authored-by: Kobe Wulteputte --- README.md | 2 +- .../grid-stack-item/grid-stack-item.ts | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ec2e4b6..dd35b7f 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ export function configure(aurelia: Aurelia) {
Item1
- +
Item2
diff --git a/packages/aurelia-gridstack/src/elements/grid-stack-item/grid-stack-item.ts b/packages/aurelia-gridstack/src/elements/grid-stack-item/grid-stack-item.ts index cf971fe..d5e0aed 100644 --- a/packages/aurelia-gridstack/src/elements/grid-stack-item/grid-stack-item.ts +++ b/packages/aurelia-gridstack/src/elements/grid-stack-item/grid-stack-item.ts @@ -50,6 +50,56 @@ export class GridStackItem { this.root.removeAttribute('gs-h'); } } + + @bindable.number({ defaultBindingMode: bindingMode.twoWay }) + minW?: number; + minWChanged() { + if (this.minW !== undefined) { + this.root.setAttribute("gs-min-w", this.minW.toString()); + } else { + this.root.removeAttribute("gs-min-w"); + } + } + + @bindable.number({ defaultBindingMode: bindingMode.twoWay }) + minH?: number; + minHChanged() { + if (this.minH !== undefined) { + this.root.setAttribute("gs-min-h", this.minH.toString()); + } else { + this.root.removeAttribute("gs-min-h"); + } + } + + @bindable.number({ defaultBindingMode: bindingMode.twoWay }) + maxW?: number; + maxWChanged() { + if (this.maxW !== undefined) { + this.root.setAttribute("gs-max-w", this.maxW.toString()); + } else { + this.root.removeAttribute("gs-max-w"); + } + } + + @bindable.number({ defaultBindingMode: bindingMode.twoWay }) + maxH?: number; + maxHChanged() { + if (this.maxH !== undefined) { + this.root.setAttribute("gs-max-h", this.maxH.toString()); + } else { + this.root.removeAttribute("gs-max-h"); + } + } + + @bindable.number({ defaultBindingMode: bindingMode.twoWay }) + id?: number; + idChanged() { + if (this.id !== undefined) { + this.root.setAttribute("gs-id", this.id.toString()); + } else { + this.root.removeAttribute("gs-id"); + } + } @bindable.booleanAttr noMove: boolean;