-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
unify DaySlot/TimeGutter #107
Conversation
woohoo! that looks great, minimal changes but definitely better split up internally. I just have a few comments and I think it's good to go |
|
||
let TimeGutter = React.createClass({ | ||
export default class TimeGutter extends Component { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think now that this is used for all the large slots, TimeGutter
is no longer a good name for this component. Perhaps TimeSegment, or TimeColumn (to go with TimeGrid?) makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TimeColumn: check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think we should rename the DaySlot and TimeSlice and TimeSliceGroup to DayColumn, TimeSlot, TimeSlotGroup
I should have it as a configured npm script but could you also run eslint on |
.rbc-timeslice-group { | ||
border-bottom: 1px solid @cell-border; | ||
min-height: 40px; | ||
height: 40px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the height may not be necessary here... at least not with min height. actually does this make more sense on TimeSlice vs the group?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is taking the css from rbc-time-slice, which was min-height/height: 20px (see comment below). If we do height on time-slice, then multiple slices breaks. We flex the height now with the new commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you envision the behavior of the slice to be? seems like there are two options,
- what is there now which is min heights on the Group which shrinks slices proportionally
- height on the slice which makes them scale bit better, but groups expand in height without bound.
I am not sure which makes the most sense honestly. It does seem like setting 20px min height on the slices and let the group have whatever height would be a good default as well. it sort of depends on how you envision the slices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire point of the slices was to shrink them, so that you can fit an entire day onto a single page without scrolling, to allow selecting a large time chunk. Otherwise you have to change the selection code to scroll the page when the mouse gets to the bottom. To do the behavior you're describing, all we have to do is change the step value. The slice (or time slot, as I'm about to rename it) value is about making it tinier. This is one of the simplybook.me-inspired features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh ok. So there is a bit of a conflict inherent in that, since some also would rather that the days not shrink below a certain size and scroll beyond that. We should make sure then we have css defaults that are easy to adjust/override for folks that want either behavior.
In your case getting everything to fit on a page should be a simple matter of setting the calendar height to the page size and the flexbox styles could handle everything from there for all the inner components. as it is that won't work without some adjustments up the line... in any case I can tweak that stuff later, nothing to be done here now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added 3 new storybook stories to show how I envisioned the thing working. The purpose is to take the same space that has 2 30 minute selectable time slots, and render it with different lengths. So, for instance, you change the step to 10, and use 6 time slots, or you change the step to 20 and have 3 time slots. The visual representation of an hour is the same for each.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(fyi i'm not suggesting this PR is not needed, just that I misunderstood it a bit :P you've opened up a bunch of fun new style options)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are on the same page, I would just say that at a minimum the columns should extend the heightof the calendar so we don't have have a mostly empty bordered box, Whether or not the columns "grow" the calendar itself or overflow with a scrollbar is up to the user and whether they apply min-heights on the slices/groups. From a default perspective tho I think the tweaks in my branch (minus the removal of the min-height) should be reasonable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. So we use simple flex for the time slice groups and let the Calendar box size them, with a min-height of 40 and no max height
} | ||
|
||
.rbc-time-slot { | ||
flex: 1 0 0; | ||
min-height: 20px; | ||
height: 20px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was where the 40px 40px comes from. rbc-time-slot was 20px, and we want the height of the group to equal 2 of these. I agree min-height and height is a weird redundancy, but it came from here. No problem correcting it if you want, just moving to height
…es, we need some new default values. In particular the now prop is needed to display the correct current date/time
try it now, all the issues you mentioned are fixed. I am going to rename the cosmetic DaySlot and so on. One question: css is still based on old component names, can we make aliases to the new component type and have the old ones just for backwards compatibility? so rbc-time-slot instead of rbc-time-slice, rbc-time-column instead of rbc-time-gutter, etc. |
oh and both docs and examples need to be updated once all the code is approved before you merge the commit, I can do that easily. |
I think there is a bug in the eslintrc. The semi rule is turned off, but set to never, I think it should be either 1 or 2 for warning or error?
I noticed semi-colons are inconsistent, probably because of this. Whatever you want though |
didn't find any other eslint issues |
|
||
switch (this.props.type) { | ||
case 'gutter' : | ||
baseCss = 'rbc-time-gutter' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why we can't let the parent DaySlot add the rbc-day-slot
class? I don't think the conflict with each other so having both might not matter in that case. It's a bit less magical then the type
.
I appreciate that you are trying to maintain the old markup, tho maybe the old markup was a bit off?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that may be the answer, yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, tried this, broke everything. rbc-time-gutter and rbc-day-slot conflict :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok then thats fine for now, I'll take a stab at cleaning up the styles after
|
||
render() { | ||
return ( | ||
<div className={cn('rbc-time-slot', this.props.isNow ? 'rbc-now' : '')} {...this.props.style}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cn('rbc-time-slot', this.props.isNow && 'rbc-now')
works as well here
now: new Date(), | ||
type: 'gutter', | ||
timeslots: 2 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me its a big confusing to define defaults for props that the component doesn't explicitly use. Its makes it a bit harder to understand which value will be used ultimately and harder to change the default in the right spot.
Can we remove them for these components?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the problem with re-using attributes from other components. These properties are absolutely required for TimeGrid to function. Thus, when clicking the buttons week/day in the toolbar, there are a slew of warnings that these proptypes are not present, and in fact the calendar fails to display the current time unless this is present.
2 choices (yours to make):
- also use TimeGrid's default props
getDefaultProps() {
return TimeGrid.defaultProps
} - declare these properties on the Calendar component with the proper defaults
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh right. I believe in that case it makes sense to not mark them as required (since they are actually provided), and provide the defaults at the lowest level they are needed. That shouldn't trigger warning right?
second choice for me would be 1, since it mirrors how we spread propsTypes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to go with the 2nd choice. The reason is that even though you don't wish to document the internals so we don't run into backwards compatibility hell, if anyone does need to make a change, it's much harder to do it unless all the needed props are documented and required ones explicitly marked as so. This is why I always mark props that are absolutely needed for the component to function as required, even if they have a default value supplied. It's redundant, but this stuff is only checked in development anyways, so I think of it as another layer of documentation for the developer. So is it cool to use the default props for that reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine with me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Noted a last few nits, can you also squash the PR down and then we should be good to go |
I think we're in syzygy now...? |
type: 'gutter', | ||
timeslots: 2 | ||
} | ||
return TimeGrid.defaultProps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case you didn't know, you could have done TimeGrid.getDefaultProps()
I believe. switching to a class is fine too
just the one last note about the event handlers that break when switching to es classes |
ok, ready |
oops it looks like you missed the _headerClick handler as well. |
(accidental close) |
👏 thank you! |
Success!
This pull request unifies DaySlot and TimeGutter, using new TimeSliceGroup and TimeSlice. It exposes new configurable properties on Calendar, "slices" and "now" for controlling the number of time slices, and what the calendar displays as today/right now. It defaults to 2 slices and the current date/time for backwards compatibility.