question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi again! Im just new to react so Im kinda confuse how to work it around, anyway I read the documentation of react-big-calendar and it says that you can make custom components. In my case I need to customize the toolbar and make it like this toolbar

and my custom calendar toolbar code look like this:

import React from 'react';
import {BackIcon, NextIcon} from '../Icons/Icons';
import {ButtonGroup, Button} from 'react-bootstrap';

const CalendarToolbar = () => {
    return (
        <div className="toolbar-container">

            <div className="back-next-buttons">
                <button className="btn btn-back">
                    <BackIcon/>
                    <NextIcon/>
                </button>
                <label className='label-date'>Aug-Sept 2016</label>
            </div>

            <div className="filter-container">
                <ButtonGroup>
                    <Button className="bg-filter-off"><span className="label-filter-off">Day</span></Button>
                    <Button className="bg-filter-off"><span className="label-filter-off">Week</span></Button>
                    <Button className="bg-filter-off"><span className="label-filter-off">Month</span></Button>
                    <Button className="bg-filter-off"><span className="label-filter-off">Year</span></Button>
                </ButtonGroup>


            </div>
        </div >
    );
}

export default CalendarToolbar;

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

25reactions
pixelomocommented, Oct 9, 2018

In case anyone else needs help creating their own toolbar and found their way here, this is my code for creating custom toolbar and event components:

import React from "react"
import BigCalendar from 'react-big-calendar'
import '!style-loader!css-loader!react-big-calendar/lib/css/react-big-calendar.css'
import moment from 'moment'

export let navigate = {
    PREVIOUS: 'PREV',
    NEXT: 'NEXT',
    TODAY: 'TODAY',
    DATE: 'DATE',
}
let events = [
  {
    id: 14,
    title: 'Maths',
    start: new Date(new Date().setHours(new Date().getHours() - 3)),
    end: new Date(new Date().setHours(new Date().getHours() + 3)),
  },
  {
    id: 15,
    title: 'English',
    start: new Date(new Date().setHours(new Date().getHours() - 2)),
    end: new Date(new Date().setHours(new Date().getHours() + 2)),
  },
]

const localizer = BigCalendar.momentLocalizer(moment) 

function Event({ event }) {
    return (
        <span>
            <strong>{event.title}</strong>
            {event.desc && ':  ' + event.desc}
        </span>
    )
}

function Book({ event }) {
    return (
        <div className="rbc-day-bg">
            <button>Book Class</button>
        </div>
    )
}

class CustomToolbar extends React.Component {
    render() {
        let { localizer: { messages }, label } = this.props
        return(
            <div className="rbc-toolbar">
                <span className="rbc-btn-group">
                    <button type="button" onClick={this.navigate.bind(null, navigate.PREVIOUS)}>Prev</button>
                </span>
                <span className="rbc-toolbar-label">{label}</span>
                <span className="rbc-btn-group">
                    <button type="button" onClick={this.navigate.bind(null, navigate.NEXT)}>Next</button>
                </span>
            </div>
        )
    }
    navigate = action => {
        this.props.onNavigate(action)
    }
}

const Calendar = props => (
  <div>
    <BigCalendar
      localizer={localizer}
      events={events}
      popup
      startAccessor="start"
      endAccessor="end"
      className={ props.calendarIsOpen ? 'open' : '' } 
      components={{
        event: Event,
        toolbar: CustomToolbar,
        dateCellWrapper: Book
      }}
    />
  </div>
)

export default Calendar;
0reactions
adityay-perpetualnycommented, Jan 17, 2020

image

Hi alansutherland , I just saw your code it was awesome. I need one help regarding the same but it is slightly different. I want a custom component which can be hovered or clickable . This is not a toolbar oe event component. Completely new component as shown above in the screenshot( the dotted one in circle on date 17 box ) .

I tried your book example , but I am not able to pass the event data tot it.

Could you please help me in this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customize the Quick Access Toolbar - Microsoft Support
Customize the Quick Access Toolbar by using the Options command · Open the Quick Access Toolbar short-cut menu, and then select Customize Quick...
Read more >
Custom Toolbar in Android - Ayaz Qureshi - Medium
Change text size; Edit toolbar text on runtime, etc. Let's start by creating our custom layout; in Android Studio, create a new project...
Read more >
Creating custom toolbars - Corel
1 Choose View Customize. ; 2 Click the Toolbars tab. ; 3 Click New. ; 4 Type a name for the new toolbar,...
Read more >
How to create and add a new custom toolbar in AutoCAD
Run the CUI command. Right Click the Toolbars section, and select New Toolbar. Give the toolbar a name. Click and drag commands from...
Read more >
Set up the app bar - Android Developers
Add a Toolbar to an Activity · Add the v7 appcompat support library to your project, as described in Support Library Setup. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found