Skip to content

Commit

Permalink
Blueprintjs - Add the ability to create many components at once.
Browse files Browse the repository at this point in the history
  • Loading branch information
csavelief committed Aug 20, 2024
1 parent cb720a5 commit 6c01980
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 4 deletions.
10 changes: 10 additions & 0 deletions dist/cjs/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/main.js.map

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions dist/esm/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/esm/main.js.map

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
<link href="blueprintjs/blueprint-datetime.css" rel="stylesheet"/>
</head>
<body>
<div id="form">
<div style="display:flex;flex-direction:row;align-items:center;background-color:yellow;">
<div id="form-text-input" style="width:50%;"></div>
<div id="form-radio-buttons" style="width:50%"></div>
</div>
<div style="display:flex;flex-direction:row;align-items:center;background-color:green;">
<div style="width:50%"></div>
<div id="form-button" style="width:50%"></div>
</div>
</div>
<div id="button-loading"></div>
<div id="button-left-icon"></div>
<div id="button-right-icon"></div>
Expand Down Expand Up @@ -606,6 +616,39 @@
});
}

function testPopulate() {

const textInput = {
type: 'TextInput', container: 'form-text-input', icon: 'filter', placeholder: 'Filter stuff...',
};

const radioButtons = {
type: 'RadioGroup',
container: 'form-radio-buttons',
label: 'Another Group of Radio Buttons :',
inline: true,
items: [{
label: 'Option A', value: 'a', disabled: false
}, {
label: 'Option B', value: 'b', disabled: true
}, {
label: 'Option C', value: 'c'
}],
selected_item: 'a',
};

const button = {
type: 'Button',
container: 'form-button',
label: 'Submit',
right_icon: 'chevron-right',
on_click: () => console.log(textInput.el.value, radioButtons.el.selectedItem),
};

com.computablefacts.blueprintjs.Blueprintjs.populate(document.getElementById('form'),
[textInput, radioButtons, button]);
}

testWhoAmI();
testTable();
testSelect1();
Expand Down Expand Up @@ -633,6 +676,7 @@
testButtonLeftIcon();
testButtonRightIcon();
testButtonLoading();
testPopulate();

</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion dist/main.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main.min.js.map

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/blueprintjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ blueprintjs.Blueprintjs = class extends widgets.Widget {
super(container);
}

/**
* Populate a DOM element with Blueprintjs components.
*
* @param template the DOM element.
* @param objs the components.
*/
static populate(template, objs) {
objs.forEach(obj => blueprintjs.Blueprintjs.component(template, obj));
}

/**
* Create a Blueprintjs component from a JSON object.
*
Expand Down

0 comments on commit 6c01980

Please sign in to comment.