Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set custom resource headers #1187

Merged
merged 6 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <span>{label}</span>
healthycola marked this conversation as resolved.
Show resolved Hide resolved
}

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;
healthycola marked this conversation as resolved.
Show resolved Hide resolved
}
}

.rbc-time-content {
Expand Down