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

How to unstyle the weekend days? #353

Closed
wojtekmaj opened this issue Apr 4, 2020 · 3 comments
Closed

How to unstyle the weekend days? #353

wojtekmaj opened this issue Apr 4, 2020 · 3 comments
Labels
question Further information is requested

Comments

@wojtekmaj
Copy link
Owner

@wojtekmaj Greetings. I have to unstyle the weekend days (remove the red color) would it be possible?
Thanks a lot for your attention and cool calendar

Originally posted by @pedro-surf in #334 (comment)

@wojtekmaj wojtekmaj added the question Further information is requested label Apr 4, 2020
@wojtekmaj
Copy link
Owner Author

@pedro-surf You have several options:

  • Remove default styling and build your own based on the original one available in this repository
  • Remove default styling and build your own from the ground up
  • Overwrite .react-calendar__month-view__days__day--weekend class with your own styling.

@MichaelLiss
Copy link

Hi,

I have added

.react-calendar__month-view__days__day--weekend{
  color: #2361a8;
}

to my App.css file, but the weekends are still showing up as the default color (red)

Here is the file that uses your calendar control

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

import 'react-calendar/dist/Calendar.css';
import '../../App.css';
import ReactCalendar from 'react-calendar';

var calendar_all_debugThis = true;
var msgPrefix = 'Calendar';

class Calendar extends Component {
  constructor(props) {
    super(props);

    this.state = {};
  }

  // we want this to be called and loaded as soon as possible
  componentDidMount() {
    var debugThis = false || calendar_all_debugThis;
    if (debugThis) {
      console.log(msgPrefix, 'componentDidMount');
    }
  }

  tileDisabled = ({ date, view }) => {
    console.log(JSON.stringify(this.props.auth));

    var isGYPDN = this.props.auth.user.isGYPDN;

    if (isGYPDN) {
      return false; // allow any date selection by GYPDN user !
    } else {
      if (view === 'month') {
        // only allow selecting today's date and future dates
        var q = new Date();
        var m = q.getMonth();
        var d = q.getDate() - 1;
        var y = q.getFullYear();
        var compare = new Date(y, m, d);

        //console.log('incoming date', JSON.stringify(date));
        //console.log('today date', JSON.stringify(q));
        //console.log('day', JSON.stringify(d));
        //console.log('compare date', JSON.stringify(compare));

        return date <= compare;
      }
    }
  };

  tileClassName = ({ date, view }) => {
    // Add class to tiles in month view only
    if (view === 'month') {
      return 'calendar_day';
    }
  };

  render() {
    var debugThis = false || calendar_all_debugThis;
    if (debugThis) {
      console.log(msgPrefix, 'render ');
    }

    return (
      <div className='Calendar'>
        <h1>Calendar</h1>
        <div className='container'>
          <div>
            <ReactCalendar calendarType='US' tileDisabled={this.tileDisabled} tileClassName={this.tileClassName} />
          </div>
        </div>
      </div>
    );
  }
}

Calendar.propTypes = {
  auth: PropTypes.object.isRequired,
};

const mapStateToProps = (state) => ({
  auth: state.Auth,
});

export default connect(mapStateToProps)(Calendar);

@onethps
Copy link

onethps commented Nov 5, 2023

.react-calendar__month-view__days__day--weekend {
color: inherit
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants