Skip to content

Commit

Permalink
refactor: change a file name (#447)
Browse files Browse the repository at this point in the history
* refactor: file upload component

* refactor: changed name of a function and added a new line
  • Loading branch information
DereC4 authored Nov 23, 2024
1 parent a5e921f commit 3abb117
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/pages/background/lib/addCourse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default async function addCourse(scheduleId: string, course: Course, hasC
if (!hasColor) {
course.colors = getUnusedColor(activeSchedule, course);
}

activeSchedule.courses.push(course);
activeSchedule.updatedAt = Date.now();
await UserScheduleStore.set('schedules', schedules);
Expand Down
1 change: 0 additions & 1 deletion src/pages/background/lib/importSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default async function importSchedule(scheduleData: unknown): Promise<voi
const course = new Course(c);
// eslint-disable-next-line no-await-in-loop
await addCourse(newScheduleId, course, true);
console.log(course.colors);
}
console.log('Course schedule successfully parsed!');
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import { colorsFlattened } from '@shared/util/themeColors';
import type { Meta, StoryObj } from '@storybook/react';
import InputButton from '@views/components/common/InputButton';
import FileUpload from '@views/components/common/FileUpload';
import React from 'react';

import AddIcon from '~icons/material-symbols/add';
import CalendarMonthIcon from '~icons/material-symbols/calendar-month';
import DescriptionIcon from '~icons/material-symbols/description';
import ImagePlaceholderIcon from '~icons/material-symbols/image';
import HappyFaceIcon from '~icons/material-symbols/mood';
import ReviewsIcon from '~icons/material-symbols/reviews';

/**
* Stole this straight from Button.stories.tsx to test the input
*/
const meta = {
title: 'Components/Common/InputButton',
component: InputButton,
title: 'Components/Common/FileUpload',
component: FileUpload,
parameters: {
layout: 'centered',
},
Expand All @@ -39,7 +34,7 @@ const meta = {
},
onChange: { action: 'file selected' }, // action to show when file is selected
},
} satisfies Meta<typeof InputButton>;
} satisfies Meta<typeof FileUpload>;

export default meta;
type Story = StoryObj<typeof meta>;
Expand All @@ -64,17 +59,17 @@ export const Grid: Story = {
render: props => (
<div style={{ display: 'flex', flexDirection: 'column', gap: '15px' }}>
<div style={{ display: 'flex', gap: '15px' }}>
<InputButton {...props} variant='filled' color='ut-black' />
<InputButton {...props} variant='outline' color='ut-black' />
<InputButton {...props} variant='single' color='ut-black' />
<FileUpload {...props} variant='filled' color='ut-black' />
<FileUpload {...props} variant='outline' color='ut-black' />
<FileUpload {...props} variant='single' color='ut-black' />
</div>

<hr />

<div style={{ display: 'flex', gap: '15px' }}>
<InputButton {...props} variant='filled' color='ut-black' disabled />
<InputButton {...props} variant='outline' color='ut-black' disabled />
<InputButton {...props} variant='single' color='ut-black' disabled />
<FileUpload {...props} variant='filled' color='ut-black' disabled />
<FileUpload {...props} variant='outline' color='ut-black' disabled />
<FileUpload {...props} variant='single' color='ut-black' disabled />
</div>
</div>
),
Expand All @@ -92,15 +87,15 @@ export const PrettyColors: Story = {
<div style={{ display: 'flex', flexDirection: 'column', gap: '15px' }}>
{colorsNames.map(color => (
<div style={{ display: 'flex', gap: '15px' }} key={color}>
<InputButton {...props} variant='filled' color={color}>
<FileUpload {...props} variant='filled' color={color}>
Button
</InputButton>
<InputButton {...props} variant='outline' color={color}>
</FileUpload>
<FileUpload {...props} variant='outline' color={color}>
Button
</InputButton>
<InputButton {...props} variant='single' color={color}>
</FileUpload>
<FileUpload {...props} variant='single' color={color}>
Button
</InputButton>
</FileUpload>
</div>
))}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface Props {
*
* @returns
*/
export default function InputButton({
export default function FileUpload({
className,
style,
variant,
Expand Down
6 changes: 3 additions & 3 deletions src/views/components/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import IconoirGitFork from '~icons/iconoir/git-fork';
// import { ExampleCourse } from 'src/stories/components/ConflictsWithWarning.stories';
import DeleteForeverIcon from '~icons/material-symbols/delete-forever';

import InputButton from '../common/InputButton';
import FileUpload from '../common/FileUpload';
import { useMigrationDialog } from '../common/MigrationDialog';
// import RefreshIcon from '~icons/material-symbols/refresh';
import DevMode from './DevMode';
Expand Down Expand Up @@ -383,9 +383,9 @@ export default function Settings(): JSX.Element {
</Text>
<p className='text-sm text-gray-600'>Import from a schedule file</p>
</div>
<InputButton variant='filled' color='ut-burntorange' onChange={handleImportClick}>
<FileUpload variant='filled' color='ut-burntorange' onChange={handleImportClick}>
Import Schedule
</InputButton>
</FileUpload>
</div>

<Divider size='auto' orientation='horizontal' />
Expand Down

0 comments on commit 3abb117

Please sign in to comment.