Browse Source

KERNEL-13521 refactor: segment使用grid布局,使其默认使用最长项宽度等分

es6
Zhenfei.Li 2 years ago
parent
commit
0ac1e8483c
  1. 8
      demo/js/case/demo.segment.js
  2. 11
      src/case/segment/segment.js
  3. 2
      src/less/base/segment/segment.less

8
demo/js/case/demo.segment.js

@ -5,20 +5,20 @@ Demo.Func = BI.inherit(BI.Widget, {
render: function () { render: function () {
BI.createWidget({ BI.createWidget({
type: "bi.vertical", type: "bi.horizontal",
element: this, element: this,
vgap: 20, vgap: 20,
hgap: 30, hgap: 30,
items: [{ items: [{
type: "bi.segment", type: "bi.segment",
items: [{ items: [{
text: "1", text: "较长的选项1",
value: 1 value: 1
}, { }, {
text: "2", text: "选项2",
value: 2 value: 2
}, { }, {
text: "3", text: "选项3",
value: 3 value: 3
}] }]
}] }]

11
src/case/segment/segment.js

@ -23,13 +23,12 @@ BI.Segment = BI.inherit(BI.Widget, {
items: BI.createItems(o.items, { items: BI.createItems(o.items, {
type: "bi.segment_button", type: "bi.segment_button",
height: BI.toPix(o.height, 2), height: BI.toPix(o.height, 2),
whiteSpace: o.whiteSpace whiteSpace: o.whiteSpace,
}), }),
layout: [ layouts: o.layouts || [{
{ type: "bi.table",
type: "bi.center" columnSize: BI.makeArrayByArray(o.items, "fill"),
} }],
]
}); });
this.buttonGroup.on(BI.Controller.EVENT_CHANGE, function () { this.buttonGroup.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);

2
src/less/base/segment/segment.less

@ -7,7 +7,7 @@
border-top: 1px solid @color-bi-split-segment; border-top: 1px solid @color-bi-split-segment;
border-bottom: 1px solid @color-bi-split-segment; border-bottom: 1px solid @color-bi-split-segment;
} }
& > .first-element{ & > .first-element, & > .first-row{
border-left: 1px solid @color-bi-split-segment; border-left: 1px solid @color-bi-split-segment;
.border-corner-radius(2px,0px,0px,2px) .border-corner-radius(2px,0px,0px,2px)
} }

Loading…
Cancel
Save