Skip to content

Commit db1c00e

Browse files
author
farhoudshapouran
committed
fix: styling problems in web
1 parent cee599c commit db1c00e

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

src/components/Calendar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import YearSelector from './YearSelector';
88
import MonthSelector from './MonthSelector';
99
import DaySelector from './DaySelector';
1010
import TimeSelector from './TimeSelector';
11+
import { CALENDAR_HEIGHT } from '../enums';
1112

1213
const CalendarView: Record<CalendarViews, ReactNode> = {
1314
year: <YearSelector />,
@@ -39,7 +40,7 @@ const styles = StyleSheet.create({
3940
width: '100%',
4041
},
4142
calendarContainer: {
42-
height: 300,
43+
height: CALENDAR_HEIGHT,
4344
alignItems: 'center',
4445
},
4546
});

src/components/DaySelector.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { memo, useMemo } from 'react';
22
import { Text, View, TouchableOpacity, StyleSheet } from 'react-native';
33
import { useCalendarContext } from '../CalendarContext';
4+
import { CALENDAR_HEIGHT } from '../enums';
45

56
const DaySelector = () => {
67
const { utils, currentDate, selectedDate, onSelectDate, theme } =
@@ -111,6 +112,7 @@ const styles = StyleSheet.create({
111112
container: {
112113
flex: 1,
113114
paddingTop: 5,
115+
width: '100%',
114116
},
115117
weekDaysContainer: {
116118
width: '100%',
@@ -128,14 +130,17 @@ const styles = StyleSheet.create({
128130
justifyContent: 'center',
129131
},
130132
daysContainer: {
133+
flex: 1,
131134
width: '100%',
132135
height: '100%',
133136
flexWrap: 'wrap',
134137
flexDirection: 'row',
138+
justifyContent: 'center',
139+
alignContent: 'flex-start',
135140
},
136141
dayCell: {
137142
width: '14.2%',
138-
height: '14.2%',
143+
height: CALENDAR_HEIGHT / 7 - 1,
139144
},
140145
dayContainer: {
141146
flex: 1,

src/components/MonthSelector.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const styles = StyleSheet.create({
5757
monthsContainer: {
5858
flexDirection: 'row',
5959
flexWrap: 'wrap',
60-
margin: 5,
6160
},
6261
monthCell: {
6362
width: '33.3%',

src/components/YearSelector.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ const styles = StyleSheet.create({
6565
alignItems: 'center',
6666
justifyContent: 'center',
6767
margin: 5,
68+
width: '100%',
6869
},
6970
yearCell: {
7071
width: '33.3%',
7172
},
7273
yearsRow: {
7374
flexDirection: 'row',
75+
width: '100%',
7476
},
7577
year: {
7678
paddingVertical: 15,

src/enums.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ export enum CalendarActionKind {
1010
CHANGE_CURRENT_DATE = 'CHANGE_CURRENT_DATE',
1111
CHANGE_SELECTED_DATE = 'CHANGE_SELECTED_DATE',
1212
}
13+
14+
export const CALENDAR_HEIGHT = 300;

0 commit comments

Comments
 (0)