GithubHelp home page GithubHelp logo

react-calendar's Introduction

Final project design

bloggist website

Optimization

  • Migrate and restructure redux code into using Redux toolkit
  • Add an edit button so that users can edit reminders
  • Allow users to create reminders in year 2023
  • Make UI look more appealing.
  • Fix bug that doesn't allow users to save their reminders after switching months.
  • Clean up the universally unique identifier file

Component Hierarchy

<Calendar>
  <CalendarNavContainer>
    <CalendarNav/>
  </CalendarNavContainer>
  <CalendarHeader/>
  <CalendarMonthContainer>
    <CalendarMonth>
      <ReminderItem>
        <ReminderLabel/>
        <ReminderForm/>
      </ReminderItem>      
    </CalendarMonth>
  </CalendarMonthContainer>
</Calendar>

Actions

Let's recall that an action in Redux is a single, granular, specific piece of information that changes the app's state. Actions are made up of JavaScript Objects that always have a type.

In src/actions/index.js we can see the amount of actions we have.

export const prevMonth = () => ({
  type: types.CALENDAR_PREV_MONTH
})

export const nextMonth = () => ({
  type: types.CALENDAR_NEXT_MONTH
})

export const addReminder = (weekIndex, weekdayIndex) => ({
  type: types.ADD_REMINDER,
  payload: { weekIndex, weekdayIndex }
})

export const editReminder = (weekIndex, weekdayIndex, reminder) => ({
  type: types.EDIT_REMINDER,
  payload: { weekIndex, weekdayIndex, reminder }
})

export const deleteReminder = (weekIndex, weekdayIndex, reminder) => ({
  type: types.DELETE_REMINDER,
  payload: { weekIndex, weekdayIndex, reminder }
})

Our actions take the necessary information to create an event. That event should be returned and dispatched into the store.

Reducers

Remember that a reducer is a pure function. It takes in the current state and an action. Then returns an updated state.

function calendarReducer (state = initialState, action) {
  switch (action.type) {
    case 'CALENDAR_PREV_MONTH': {
      ...
    }
    case 'CALENDAR_NEXT_MONTH': {
     ...
    }
    case 'ADD_REMINDER': {
      ...
    }
    case 'DELETE_REMINDER': {
      ...
    }
    default:
      return state
  }
}

If the reducer cares about the action then it makes a copy of the state and updates it. Otherwise return the existing state unchanged.

react-calendar's People

Contributors

jayrkyd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.