瀏覽代碼

feat: button in `actions` support custom color

wangweimin 4 年之前
父節點
當前提交
03c053c90c
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      webiojs/src/models/input/actions.ts

+ 2 - 1
webiojs/src/models/input/actions.ts

@@ -5,7 +5,7 @@ const buttons_tpl = `
 <div class="form-group">
     {{#label}}<label>{{label}}</label>  <br> {{/label}} 
     {{#buttons}}
-    <button type="{{btn_type}}" data-type="{{type}}" aria-describedby="{{name}}_help" {{#disabled}}disabled data-pywebio-disabled{{/disabled}} class="btn btn-primary">{{label}}</button>
+    <button type="{{btn_type}}" data-type="{{type}}" aria-describedby="{{name}}_help" {{#disabled}}disabled data-pywebio-disabled{{/disabled}} class="btn btn-{{color}}">{{label}}</button>
     {{/buttons}}
     <div class="invalid-feedback">{{invalid_feedback}}</div>  <!-- input 添加 is-invalid 类 -->
     <div class="valid-feedback">{{valid_feedback}}</div> <!-- input 添加 is-valid 类 -->
@@ -24,6 +24,7 @@ export class Actions extends InputItem {
     create_element(): JQuery {
         for (let b of this.spec.buttons) b['btn_type'] = b.type === "submit" ? "submit" : "button";
 
+        this.spec.color = "primary";  // default button color
         const html = Mustache.render(buttons_tpl, this.spec);
         this.element = $(html);
         let btns = this.element.find('button');