reza added utils

master
Reza_ashrafi 3 years ago
commit 506641a96d
  1. 4
      src/components/Calendar/index.css
  2. 5
      src/components/Calendar/index.js
  3. 1
      src/components/RangeDatePicker/index.js
  4. 9
      src/components/SimpleDatePicker/index.js

@ -407,7 +407,7 @@
font-size: 1.4em; font-size: 1.4em;
min-width: 85%; min-width: 85%;
padding: 0.2em 0.5em; padding: 0.2em 0.5em;
border-radius: 8.5px; border-radius: 5px;
} }
.Calendar__monthSelector.-open, .Calendar__monthSelector.-open,
@ -453,7 +453,7 @@
.Calendar__monthSelectorItem.-active .Calendar__monthSelectorItemText, .Calendar__monthSelectorItem.-active .Calendar__monthSelectorItemText,
.Calendar__yearSelectorItem.-active .Calendar__yearSelectorText { .Calendar__yearSelectorItem.-active .Calendar__yearSelectorText {
background-color: var(--cl-color-primary); background-color: #006C94;
color: #fff; color: #fff;
} }

@ -6,6 +6,10 @@ import './index.css';
const SimpleCalendar = () =>{ const SimpleCalendar = () =>{
const [selectedDay, setSelectedDay] = useState(null); const [selectedDay, setSelectedDay] = useState(null);
const gotoToday = () =>{
setSelectedDay(utils('fa').getToday());
}
return( return(
<div className="flex items-center justify-center w-full my-2"> <div className="flex items-center justify-center w-full my-2">
@ -13,6 +17,7 @@ const SimpleCalendar = () =>{
value={selectedDay} value={selectedDay}
onChange={setSelectedDay} onChange={setSelectedDay}
shouldHighlightWeekends shouldHighlightWeekends
renderFooter={() => <center><button onClick={gotoToday}>برو به امروز</button></center>}
locale="fa" // add this locale="fa" // add this
/> />
</div> </div>

@ -10,6 +10,7 @@ const RangeDatePicker = () => {
return ( return (
<DatePicker <DatePicker
value={selectedDayRange} value={selectedDayRange}
calendarClassName="range-date-picker"
onChange={setSelectedDayRange} onChange={setSelectedDayRange}
inputPlaceholder="یک بازه زمانی انتخاب کنید" inputPlaceholder="یک بازه زمانی انتخاب کنید"
shouldHighlightWeekends shouldHighlightWeekends

@ -1,8 +1,12 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import DatePicker from "react-modern-calendar-datepicker"; import DatePicker, {utils} from "react-modern-calendar-datepicker";
import '../Calendar/index.css'; import '../Calendar/index.css';
const SimpleDatePicker = () =>{ const SimpleDatePicker = (props) =>{
const [selectedDay, setSelectedDay] = useState(null); const [selectedDay, setSelectedDay] = useState(null);
const gotoToday = () =>{
setSelectedDay(utils('fa').getToday());
}
return( return(
<div className='flex items-center justify-center w-full my-2'> <div className='flex items-center justify-center w-full my-2'>
<DatePicker <DatePicker
@ -10,6 +14,7 @@ const SimpleDatePicker = () =>{
onChange={setSelectedDay} onChange={setSelectedDay}
inputPlaceholder="انتخاب تاریخ" inputPlaceholder="انتخاب تاریخ"
shouldHighlightWeekends shouldHighlightWeekends
renderFooter={() => <button onClick={gotoToday}>برو به امروز</button>}
locale='fa' locale='fa'
/> />
</div> </div>

Loading…
Cancel
Save