Skip to content

Commit

Permalink
fix: SlotTitle에만 slotUnit prop 내려주기
Browse files Browse the repository at this point in the history
  • Loading branch information
simeunseo committed Jul 27, 2024
1 parent 5b17604 commit 572045f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/components/timetableComponents/Timetable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Timetable({ timeSlots, availableDates, slotUnit, children, bottomItem }
const dateKey = Object.values(date).join('/');
return (
<ColumnWrapper key={dateKey}>
{children({ date: dateKey, timeSlots, slotUnit })}
{children({ date: dateKey, timeSlots })}
</ColumnWrapper>
);
})}
Expand Down
5 changes: 2 additions & 3 deletions src/components/timetableComponents/parts/Slot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import styled from 'styled-components';

interface SlotProps {
customSlotStyle?: string;
slotUnit: 'HALF' | 'HOUR';
onClick?: () => void;
children?: ReactNode;
}

function Slot({ customSlotStyle, slotUnit, onClick, children }: SlotProps) {
function Slot({ customSlotStyle, onClick, children }: SlotProps) {
const defaultSlotStyle = `
width: 4.4rem;
height: ${slotUnit === 'HALF' ? '2.2rem' : '1.2rem'};
height: 2.2rem;
display: flex;
justify-content: center;
`;
Expand Down
1 change: 0 additions & 1 deletion src/components/timetableComponents/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export interface TimetableStructure extends BaseStructure {

export interface ColumnStructure extends BaseStructure {
date: string;
slotUnit: 'HALF' | 'HOUR';
}

export interface DateType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function OverallScheduleColumn({ date, timeSlots, availableSlotInfo }: OverallSc
const { colorLevel = 0, userNames = [] } = availableSlotInfo.find((info) => info.time === timeSlot) ?? {};
const slotId = `${date}/${timeSlot}`;

return <Slot key={slotId} slotUnit='HALF' customSlotStyle={getTimeSlotStyle(colorLevel, slotId)} onClick={()=>onClickSlot(slotId, userNames)}/>;
return <Slot key={slotId} customSlotStyle={getTimeSlotStyle(colorLevel, slotId)} onClick={()=>onClickSlot(slotId, userNames)}/>;
})}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function OverallScheduleTable({
<OverallScheduleColumn
date={date}
timeSlots={timeSlots}
slotUnit="HALF"
availableSlotInfo={getAvailableTimesPerDate(
dataOverallSchedule.availableDateTimes,
date,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/selectSchedule/components/SelectScheduleTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ function SelectScheduleTable({ timeSlots, availableDates }: TimetableStructure)

const stepColumns: StepSlotsType = {
selectTimeSlot: ({ date, timeSlots }: ColumnStructure) => (
<SelectionColumn date={date} timeSlots={timeSlots} slotUnit={slotUnit} />
<SelectionColumn date={date} timeSlots={timeSlots} />
),
selectPriority: ({ date, timeSlots }: ColumnStructure) => (
<PriorityColumn date={date} timeSlots={timeSlots} slotUnit={slotUnit} />
<PriorityColumn date={date} timeSlots={timeSlots} />
),
};
const stepColumn = stepColumns[scheduleStep];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { theme } from 'styles/theme';

import Slot from '../../../../components/timetableComponents/parts/Slot';

function PriorityColumn({ date, timeSlots, slotUnit }: ColumnStructure) {
function PriorityColumn({ date, timeSlots }: ColumnStructure) {
const { selectedSlots } = useSelectContext();

const selectedSlotsPerDate = Object.entries(selectedSlots).filter(
Expand Down Expand Up @@ -48,10 +48,12 @@ function PriorityColumn({ date, timeSlots, slotUnit }: ColumnStructure) {
const borderTopStyle = slotId.endsWith(':30') ? 'none' : 'solid';
const borderTop = isSelectedSlot ? 'none' : `1px ${borderTopStyle} ${theme.colors.grey7}`;
const backgroundColor = isSelectedSlot ? slotColor : 'transparent';
const height = '1.2rem';

return `
border-top: ${borderTop};
background-color : ${backgroundColor};
background-color: ${backgroundColor};
height: ${height};
`;
};

Expand All @@ -76,7 +78,6 @@ function PriorityColumn({ date, timeSlots, slotUnit }: ColumnStructure) {
return (
<Slot
key={slotId}
slotUnit={slotUnit}
customSlotStyle={getPriorityColumnStyle(slotId, priority, selectedEntryId)}
>
<Text font="body1" color={theme.colors.white}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { theme } from 'styles/theme';
import useSlotSeletion from './hooks/useSlotSelection';
import Slot from '../../../../components/timetableComponents/parts/Slot';

function SelectionColumn({ date, timeSlots, slotUnit }: ColumnStructure) {
function SelectionColumn({ date, timeSlots }: ColumnStructure) {
const { selectedSlots } = useSelectContext();
const selectedSlotsPerDate = Object.entries(selectedSlots).filter(
([, slot]) => slot.date === date,
Expand Down Expand Up @@ -48,7 +48,6 @@ function SelectionColumn({ date, timeSlots, slotUnit }: ColumnStructure) {
return (
<Slot
key={slotId}
slotUnit={slotUnit}
customSlotStyle={getTimeSlotStyle(slotId, selectedEntryId)}
onClick={() => onClickSlot(slotId, selectedEntryId)}
/>
Expand Down

0 comments on commit 572045f

Please sign in to comment.