Skip to content

Commit

Permalink
add markings for 'inactive' state
Browse files Browse the repository at this point in the history
  • Loading branch information
lidord-wix committed Aug 11, 2021
1 parent a02bdeb commit 7ab81d6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/calendar/day/basic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import PropTypes from 'prop-types';
import React, {Component, Fragment} from 'react';
import {TouchableOpacity, Text, View} from 'react-native';

import {Theme, DateData} from '../../../types';
import {Theme, DateData, DayState} from '../../../types';
// @ts-expect-error
import {shouldUpdate} from '../../../component-updater';
import styleConstructor from './style';
import Marking, {MarkingTypes, MarkingProps} from '../marking';

export interface BasicDayProps {
state?: 'selected' | 'disabled' | 'inactive' | 'today';
state?: DayState;
/** The marking object */
marking?: MarkingProps;
/** Date marking style [simple/period/multi-dot/multi-period]. Default = 'simple' */
Expand Down
10 changes: 7 additions & 3 deletions src/calendar/day/period/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import * as defaultStyle from '../../../style';
import styleConstructor from './style';
import Dot from '../dot';
import {MarkingProps} from '../marking';
import {Theme} from '../../../types';
import {Theme, DayState} from '../../../types';

interface PeriodDayProps {
state?: 'selected' | 'disabled' | 'today' | '';
state?: DayState;
marking?: MarkingProps;
theme?: Theme;
onPress?: (date?: Date) => void;
Expand All @@ -27,7 +27,7 @@ export default class PeriodDay extends Component<PeriodDayProps> {
static displayName = 'IGNORE';

static propTypes = {
state: PropTypes.oneOf(['selected', 'disabled', 'today', '']),
state: PropTypes.oneOf(['selected', 'disabled', 'inactive', 'today', '']),
marking: PropTypes.any,
theme: PropTypes.object,
onPress: PropTypes.func,
Expand Down Expand Up @@ -75,6 +75,8 @@ export default class PeriodDay extends Component<PeriodDayProps> {

if (marking.disabled) {
defaultStyle.textStyle.color = this.style.disabledText.color;
} else if (marking.inactive) {
defaultStyle.textStyle.color = this.style.inactiveText.color;
} else if (marking.selected) {
defaultStyle.textStyle.color = this.style.selectedText.color;
}
Expand Down Expand Up @@ -141,6 +143,8 @@ export default class PeriodDay extends Component<PeriodDayProps> {
// TODO: refactor - move all styling logic out of render()
if (state === 'disabled') {
textStyle.push(this.style.disabledText);
} else if (state === 'inactive') {
textStyle.push(this.style.inactiveText);
} else if (state === 'today') {
containerStyle.push(this.style.today);
textStyle.push(this.style.todayText);
Expand Down
5 changes: 4 additions & 1 deletion src/calendar/day/period/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export default function styleConstructor(theme: Theme = {}) {
disabledText: {
color: appStyle.textDisabledColor
},

inactiveText: {
color: appStyle.textInactiveColor
},

// quickAction: {
// backgroundColor: 'white',
// borderWidth: 1,
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export type DateData = {
timestamp: number,
dateString: string
}
export type DayState = 'selected' | 'disabled' | 'inactive' | 'today' | '';

export interface Theme {
container?: object;
contentStyle?: ViewStyle;
Expand Down

0 comments on commit 7ab81d6

Please sign in to comment.