Skip to content

Customization of the Day component based on the day of the week #2679

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/calendar/day/basic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {Theme, DayState, MarkingTypes, DateData} from '../../../types';
import Marking, {MarkingProps} from '../marking';
import styleConstructor from './style';


export interface BasicDayProps extends ViewProps {
/** Theme object */
theme?: Theme;
Expand Down Expand Up @@ -57,7 +56,15 @@ const BasicDay = (props: BasicDayProps) => {
const isMultiDot = markingType === Marking.markings.MULTI_DOT;
const isMultiPeriod = markingType === Marking.markings.MULTI_PERIOD;
const isCustom = markingType === Marking.markings.CUSTOM;

const weekDayStyles = {
0: 'sunday',
1: 'monday',
2: 'tuesday',
3: 'wednesday',
4: 'thursday',
5: 'friday',
6: 'saturday'
};
const shouldDisableTouchEvent = () => {
const {disableTouchEvent} = _marking;
let disableTouch = false;
Expand All @@ -83,6 +90,8 @@ const BasicDay = (props: BasicDayProps) => {
}
} else if (isToday) {
styles.push(style.current.today);
} else if (typeof dateData?.weekDay === 'number' && weekDayStyles[dateData?.weekDay]) {
styles.push(style.current[weekDayStyles[dateData?.weekDay]]);
}

//Custom marking type
Expand Down Expand Up @@ -111,6 +120,11 @@ const BasicDay = (props: BasicDayProps) => {
styles.push(style.current.todayText);
} else if (isInactive) {
styles.push(style.current.inactiveText);
} else if (typeof dateData?.weekDay === 'number' && weekDayStyles[dateData?.weekDay]) {
const weekDayNumberTextStyle = `${weekDayStyles[dateData?.weekDay]}Text`;
if (style.current[weekDayNumberTextStyle]) {
styles.push(style.current[weekDayNumberTextStyle]);
}
}

// Custom marking type
Expand Down
16 changes: 14 additions & 2 deletions src/calendar/day/basic/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default function styleConstructor(theme: Theme = {}) {
backgroundColor: appStyle.selectedDayBackgroundColor,
borderRadius: 16
},

text: {
fontSize: appStyle.textDayFontSize,
fontFamily: appStyle.textDayFontFamily,
Expand All @@ -45,7 +44,20 @@ export default function styleConstructor(theme: Theme = {}) {
inactiveText: {
color: appStyle.textInactiveColor
},

sunday: {},
sundayText: {},
monday: {},
mondayText: {},
tuesday: {},
tuesdayText: {},
wednesday: {},
wednesdayText: {},
thursday: {},
thursdayText: {},
friday: {},
fridayText: {},
saturday: {},
saturdayText: {},
...(theme['stylesheet.day.basic'] || {})
});
}
3 changes: 2 additions & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export function xdateToData(date: XDate | string) {
month: d.getMonth() + 1,
day: d.getDate(),
timestamp: new XDate(dateString, true).getTime(),
dateString: dateString
dateString: dateString,
weekDay: d.getDay()
};
}

Expand Down