twinssbc / Ionic2-Calendar

A calendar component based on Ionic framework
https://ionic-calendar-demo.stackblitz.io
MIT License
388 stars 198 forks source link

Use only weekview and coloring events #2

Closed baxeico closed 8 years ago

baxeico commented 8 years ago

More than an issue, this is a question. Sorry if this is not the right place, in that case please tell me what is the best way to ask questions.

I'm considering your component for a new Ionic2 based project. I've a couple of questions:

Thank you very much for your work!

twinssbc commented 8 years ago

@baxeico If you check the demo page, the buttons in the header bar are not part of the calendar. You can simply remove these buttons, and configure the calendar to use the week mode, then it won't be switched to other modes.

To color events differently, there's no exposed option right now. You have to modify the source code. In weekview.ts, below code snippet display each event, note that calendar-event-inner is the css class make the background color blue. You can modify it to use ngClass to control the css class applied based on the event type.

<div *ngFor="let displayEvent of tm.events" class="calendar-event"
                                                 (click)="eventSelected(displayEvent.event)"
                                                 [ngStyle]="{top: (37*displayEvent.startOffset/hourParts)+'px',left: 100/displayEvent.overlapNumber*displayEvent.position+'%', width: 100/displayEvent.overlapNumber+'%', height: 37*(displayEvent.endIndex -displayEvent.startIndex - (displayEvent.endOffset + displayEvent.startOffset)/hourParts)+'px'}">
                                                <div class="calendar-event-inner">{{displayEvent.event.title}}</div>
                                            </div>
baxeico commented 8 years ago

Thank you very much for your help! I'm closing the "issue".