Skip to content

Commit

Permalink
feat: add ability to set custom resource headers (#1187)
Browse files Browse the repository at this point in the history
Add an ability to set a custom resource headers. For #1174
  • Loading branch information
healthycola authored and jquense committed Jan 23, 2019
1 parent 6b90182 commit 6708a45
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
14 changes: 14 additions & 0 deletions src/ResourceHeader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import PropTypes from 'prop-types'
import React from 'react'

const ResourceHeader = ({ label }) => {
return <React.Fragment>{label}</React.Fragment>
}

ResourceHeader.propTypes = {
label: PropTypes.node,
index: PropTypes.number,
resource: PropTypes.object,
}

export default ResourceHeader
16 changes: 12 additions & 4 deletions src/TimeGridHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React from 'react'
import dates from './utils/dates'
import DateContentRow from './DateContentRow'
import Header from './Header'
import ResourceHeader from './ResourceHeader'
import { notify } from './utils/helpers'

class TimeGridHeader extends React.Component {
Expand Down Expand Up @@ -116,7 +117,10 @@ class TimeGridHeader extends React.Component {
scrollRef,
localizer,
isOverflowing,
components: { timeGutterHeader: TimeGutterHeader },
components: {
timeGutterHeader: TimeGutterHeader,
resourceHeader: ResourceHeaderComponent = ResourceHeader,
},
} = this.props

let style = {}
Expand All @@ -142,9 +146,13 @@ class TimeGridHeader extends React.Component {
{resources.map(([id, resource], idx) => (
<div className="rbc-time-header-content" key={id || idx}>
{resource && (
<div className="rbc-row rbc-row-resource">
<div key={`resource_${idx}`} className="rbc-header">
{accessors.resourceTitle(resource)}
<div className="rbc-row rbc-row-resource" key={`resource_${idx}`}>
<div className="rbc-header">
<ResourceHeaderComponent
index={idx}
label={accessors.resourceTitle(resource)}
resource={resource}
/>
</div>
</div>
)}
Expand Down
5 changes: 5 additions & 0 deletions src/less/time-grid.less
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
border-left-width: 0;
border-right: 1px solid @cell-border;
}

>.rbc-row.rbc-row-resource {
border-bottom: 1px solid @cell-border;
flex-shrink: 0;
}
}

.rbc-time-content {
Expand Down

0 comments on commit 6708a45

Please sign in to comment.