mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fix Shift react breadcrumbs to use flexbox for placement
This commit is contained in:
parent
747c0770e7
commit
4e257435df
15
admin/client/dist/js/bundle.js
vendored
15
admin/client/dist/js/bundle.js
vendored
@ -765,13 +765,16 @@ e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,wri
|
|||||||
}}Object.defineProperty(t,"__esModule",{value:!0}),t.Breadcrumb=void 0
|
}}Object.defineProperty(t,"__esModule",{value:!0}),t.Breadcrumb=void 0
|
||||||
var l=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n]
|
var l=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n]
|
||||||
i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=n(5),d=i(u),c=n(20),f=i(c),p=n(106),h=n(142),m=function(e){
|
i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=n(5),d=i(u),c=n(20),f=i(c),p=n(106),h=n(142),m=function(e){
|
||||||
function t(){return r(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"render",value:function n(){return d["default"].createElement("ol",{className:"breadcrumb"
|
function t(){return r(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"getLastCrumb",value:function n(){return this.props.crumbs&&this.props.crumbs[this.props.crumbs.length-1]
|
||||||
},this.getBreadcrumbs())}},{key:"getBreadcrumbs",value:function i(){return"undefined"==typeof this.props.crumbs?null:[].concat(this.props.crumbs.slice(0,-1).map(function(e,t){return[d["default"].createElement("li",{
|
|
||||||
className:"breadcrumb__item"},d["default"].createElement(h.Link,{key:t,className:"breadcrumb__item-title",to:e.href,onClick:e.onClick},e.text))]}),this.props.crumbs.slice(-1).map(function(e,t){var n=["breadcrumb__icon",e.icon?e.icon.className:""].join(" "),i=["breadcrumb__item","breadcrumb__item--last"]
|
|
||||||
|
|
||||||
|
}},{key:"renderBreadcrumbs",value:function i(){return this.props.crumbs?this.props.crumbs.slice(0,-1).map(function(e,t){return d["default"].createElement("li",{key:t,className:"breadcrumb__item"},d["default"].createElement(h.Link,{
|
||||||
return e.noCrumb&&i.push("breadcrumb__item--no-crumb"),[d["default"].createElement("li",{className:i.join(" ")},d["default"].createElement("h2",{className:"breadcrumb__item-title breadcrumb__item-title--last",
|
className:"breadcrumb__item-title",to:e.href,onClick:e.onClick},e.text))}).concat([d["default"].createElement("li",{key:this.props.crumbs.length-1,className:"breadcrumb__item"})]):null}},{key:"renderLastCrumb",
|
||||||
key:t},e.text,e.icon&&d["default"].createElement("span",{className:n,onClick:e.icon.action})))]}))}}]),t}(f["default"])
|
value:function s(){var e=this.getLastCrumb()
|
||||||
|
if(!e)return null
|
||||||
|
var t=["breadcrumb__icon"]
|
||||||
|
return e.icon&&t.push(e.icon.className),d["default"].createElement("div",{className:"breadcrumb__item breadcrumb__item--last"},d["default"].createElement("h2",{className:"breadcrumb__item-title"},e.text,e.icon&&d["default"].createElement("span",{
|
||||||
|
className:t.join(" "),onClick:e.icon.action})))}},{key:"render",value:function u(){return d["default"].createElement("div",{className:"breadcrumb__container fill-height"},d["default"].createElement("ol",{
|
||||||
|
className:"breadcrumb"},this.renderBreadcrumbs()),this.renderLastCrumb())}}]),t}(f["default"])
|
||||||
m.propTypes={crumbs:d["default"].PropTypes.array},t.Breadcrumb=m,t["default"]=(0,p.connect)(s)(m)},function(e,t){e.exports=ReactRouter},function(e,t,n){(function(t){e.exports=t.BreadcrumbsActions=n(144)
|
m.propTypes={crumbs:d["default"].PropTypes.array},t.Breadcrumb=m,t["default"]=(0,p.connect)(s)(m)},function(e,t){e.exports=ReactRouter},function(e,t,n){(function(t){e.exports=t.BreadcrumbsActions=n(144)
|
||||||
|
|
||||||
}).call(t,function(){return this}())},function(e,t,n){"use strict"
|
}).call(t,function(){return this}())},function(e,t,n){"use strict"
|
||||||
|
3
admin/client/dist/styles/bundle.css
vendored
3
admin/client/dist/styles/bundle.css
vendored
@ -15022,6 +15022,9 @@ div.TreeDropdownField a.jstree-loading .jstree-pageicon{
|
|||||||
line-height:14px;
|
line-height:14px;
|
||||||
margin-bottom:0;
|
margin-bottom:0;
|
||||||
float:left;
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.breadcrumb,.breadcrumb__container{
|
||||||
max-height:52px;
|
max-height:52px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,53 +5,64 @@ import { Link } from 'react-router';
|
|||||||
|
|
||||||
class Breadcrumb extends SilverStripeComponent {
|
class Breadcrumb extends SilverStripeComponent {
|
||||||
|
|
||||||
render() {
|
getLastCrumb() {
|
||||||
return (
|
return this.props.crumbs && this.props.crumbs[this.props.crumbs.length - 1];
|
||||||
<ol className="breadcrumb">
|
|
||||||
{this.getBreadcrumbs()}
|
|
||||||
</ol>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getBreadcrumbs() {
|
renderBreadcrumbs() {
|
||||||
if (typeof this.props.crumbs === 'undefined') {
|
if (!this.props.crumbs) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [].concat(
|
return this.props.crumbs.slice(0, -1).map((crumb, index) => (
|
||||||
this.props.crumbs.slice(0, -1).map((crumb, index) => [
|
<li key={index} className="breadcrumb__item">
|
||||||
<li className="breadcrumb__item">
|
|
||||||
<Link
|
<Link
|
||||||
key={index}
|
|
||||||
className="breadcrumb__item-title"
|
className="breadcrumb__item-title"
|
||||||
to={crumb.href}
|
to={crumb.href}
|
||||||
onClick={crumb.onClick}
|
onClick={crumb.onClick}
|
||||||
>{crumb.text}</Link>
|
>{crumb.text}</Link>
|
||||||
</li>,
|
</li>
|
||||||
]),
|
)).concat([
|
||||||
this.props.crumbs.slice(-1).map((crumb, index) => {
|
<li
|
||||||
const iconClassNames = ['breadcrumb__icon', crumb.icon ? crumb.icon.className : '']
|
key={this.props.crumbs.length - 1}
|
||||||
.join(' ');
|
className="breadcrumb__item"
|
||||||
const itemClassNames = ['breadcrumb__item', 'breadcrumb__item--last'];
|
/>,
|
||||||
|
]);
|
||||||
if (crumb.noCrumb) {
|
|
||||||
itemClassNames.push('breadcrumb__item--no-crumb');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
renderLastCrumb() {
|
||||||
<li className={itemClassNames.join(' ')}>
|
const crumb = this.getLastCrumb();
|
||||||
<h2 className="breadcrumb__item-title breadcrumb__item-title--last" key={index}>
|
if (!crumb) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const iconClassNames = ['breadcrumb__icon'];
|
||||||
|
if (crumb.icon) {
|
||||||
|
iconClassNames.push(crumb.icon.className);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="breadcrumb__item breadcrumb__item--last">
|
||||||
|
<h2 className="breadcrumb__item-title">
|
||||||
{crumb.text}
|
{crumb.text}
|
||||||
{crumb.icon &&
|
{crumb.icon &&
|
||||||
<span className={iconClassNames} onClick={crumb.icon.action} />
|
<span className={iconClassNames.join(' ')} onClick={crumb.icon.action} />
|
||||||
}
|
}
|
||||||
</h2>
|
</h2>
|
||||||
</li>,
|
</div>
|
||||||
];
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div className="breadcrumb__container fill-height">
|
||||||
|
<ol className="breadcrumb">
|
||||||
|
{this.renderBreadcrumbs()}
|
||||||
|
</ol>
|
||||||
|
{this.renderLastCrumb()}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Breadcrumb.propTypes = {
|
Breadcrumb.propTypes = {
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
max-height: $toolbar-height;
|
max-height: $toolbar-height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.breadcrumb__container {
|
||||||
|
max-height: $toolbar-height;
|
||||||
|
}
|
||||||
|
|
||||||
.breadcrumb>li.breadcrumb__item--last, // TODO Fix Bootstrap clash
|
.breadcrumb>li.breadcrumb__item--last, // TODO Fix Bootstrap clash
|
||||||
.breadcrumb__item--last {
|
.breadcrumb__item--last {
|
||||||
display: block;
|
display: block;
|
||||||
|
@ -14,7 +14,7 @@ describe('BreadcrumbsComponent', () => {
|
|||||||
props = {};
|
props = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getBreadcrumbs()', () => {
|
describe('renderBreadcrumbs()', () => {
|
||||||
let breadcrumbs = null;
|
let breadcrumbs = null;
|
||||||
|
|
||||||
it('should convert the props.crumbs array into jsx to be rendered', () => {
|
it('should convert the props.crumbs array into jsx to be rendered', () => {
|
||||||
@ -32,11 +32,15 @@ describe('BreadcrumbsComponent', () => {
|
|||||||
breadcrumbs = ReactTestUtils.renderIntoDocument(
|
breadcrumbs = ReactTestUtils.renderIntoDocument(
|
||||||
<Breadcrumb {...props} />
|
<Breadcrumb {...props} />
|
||||||
);
|
);
|
||||||
const listEls = breadcrumbs.getBreadcrumbs();
|
const listEls = breadcrumbs.renderBreadcrumbs();
|
||||||
expect(listEls[0][0].props.children.props.children).toBe('breadcrumb1');
|
console.log(listEls[2].props.children);
|
||||||
expect(listEls[1][0].props.children.props.children).toBe('breadcrumb2');
|
expect(listEls[0].props.children.props.children).toBe('breadcrumb1');
|
||||||
expect(listEls[2][0].props.children.props.children[0]).toBe('breadcrumb3');
|
expect(listEls[1].props.children.props.children).toBe('breadcrumb2');
|
||||||
expect(listEls[2][0].props.children.props.children[1].props.className.split(' '))
|
expect(listEls[2].props.children).toBe(undefined);
|
||||||
|
|
||||||
|
const lastEl = breadcrumbs.renderLastCrumb();
|
||||||
|
expect(lastEl.props.children.props.children[0]).toBe('breadcrumb3');
|
||||||
|
expect(lastEl.props.children.props.children[1].props.className.split(' '))
|
||||||
.toContain('breadcrumb3icon');
|
.toContain('breadcrumb3icon');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -45,7 +49,7 @@ describe('BreadcrumbsComponent', () => {
|
|||||||
<Breadcrumb {...props} />
|
<Breadcrumb {...props} />
|
||||||
);
|
);
|
||||||
|
|
||||||
const listEls = breadcrumbs.getBreadcrumbs();
|
const listEls = breadcrumbs.renderBreadcrumbs();
|
||||||
expect(listEls).toBe(null);
|
expect(listEls).toBe(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user