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

Allow styling of week numbers #2457

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
7 changes: 7 additions & 0 deletions src/calendar/day/basic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const BasicDay = (props: BasicDayProps) => {
const isDisabled = typeof _marking.disabled !== 'undefined' ? _marking.disabled : state === 'disabled';
const isInactive = _marking?.inactive;
const isToday = state === 'today';
const isWeekNumber = state === 'weekNumber';
const isMultiDot = markingType === Marking.markings.MULTI_DOT;
const isMultiPeriod = markingType === Marking.markings.MULTI_PERIOD;
const isCustom = markingType === Marking.markings.CUSTOM;
Expand Down Expand Up @@ -84,6 +85,8 @@ const BasicDay = (props: BasicDayProps) => {
}
} else if (isToday) {
styles.push(style.current.today);
} else if (isWeekNumber) {
styles.push(style.current.weekNumberContainer);
}

//Custom marking type
Expand Down Expand Up @@ -112,6 +115,10 @@ const BasicDay = (props: BasicDayProps) => {
styles.push(style.current.todayText);
} else if (isInactive) {
styles.push(style.current.inactiveText);
}

if (isWeekNumber) {
styles.push(style.current.weekNumberText);
}

//Custom marking type
Expand Down
3 changes: 3 additions & 0 deletions src/calendar/day/basic/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export default function styleConstructor(theme: Theme = {}) {
inactiveText: {
color: appStyle.textInactiveColor
},
weekNumberText: {
color: appStyle.textDisabledColor
},
dot: {
width: 4,
height: 4,
Expand Down
2 changes: 1 addition & 1 deletion src/calendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const Calendar = (props: CalendarProps & ContextProp) => {
<BasicDay
key={`week-${weekNumber}`}
marking={weekNumberMarking.current}
// state='disabled'
state='weekNumber'
theme={theme}
testID={`${testID}.weekNumber_${weekNumber}`}
>
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type MarkingTypes = 'dot' | 'multi-dot' | 'period' | 'multi-period' | 'cu
export type MarkedDates = {
[key: string]: MarkingProps;
};
export type DayState = 'selected' | 'disabled' | 'inactive' | 'today' | '';
export type DayState = 'selected' | 'disabled' | 'inactive' | 'today' | 'weekNumber' | '';
export type Direction = 'left' | 'right';
export type DateData = {
year: number;
Expand Down