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

feat: CourseStatus Component implemented #83

Merged
merged 6 commits into from
Feb 11, 2024
Merged
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
48 changes: 48 additions & 0 deletions src/stories/components/CourseStatus.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react';

import { Status } from '@shared/types/Course';
import { Meta, StoryObj } from '@storybook/react';
import CourseStatus from '@views/components/common/CourseStatus/CourseStatus';

const meta = {
title: 'Components/Common/CourseStatus',
component: CourseStatus,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
args: {
status: Status.WAITLISTED,
size: 'small',
},
argTypes: {
status: {
options: Object.values(Status),
mapping: Object.values(Status),
control: {
type: 'select',
labels: Object.keys(Status),
},
},
size: {
options: ['small', 'mini'],
control: {
type: 'radio',
},
},
},
} satisfies Meta<typeof CourseStatus>;
export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {};

export const Variants: Story = {
render: args => (
<div className='flex flex-col gap-4 items-center'>
<CourseStatus {...args} size='small' />
<CourseStatus {...args} size='mini' />
</div>
),
};
36 changes: 36 additions & 0 deletions src/views/components/common/CourseStatus/CourseStatus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Status } from '@shared/types/Course';
import { StatusIcon } from '@shared/util/icons';
import clsx from 'clsx';
import React from 'react';
import Text from '../Text/Text';

type SizeType = 'small' | 'mini';

/**
* Props for CourseStatus
*/
export interface CourseStatusProps {
status: Status;
size: SizeType;
}

/**
* The CourseStatus component as per the Labels and Details Figma section
*
* @param props CourseStatusProps
*/
export default function CourseStatus({ status, size }: CourseStatusProps): JSX.Element {
const statusIconSizeClass = clsx({
'h-5 w-5': size === 'small',
'h-4 w-4': size === 'mini',
});

return (
<div className={`inline-flex items-center ${size === 'small' ? 'gap-2' : 'gap-1.5'}`}>
<div className='ml-1 flex items-center justify-center rounded bg-slate-700 p-1px text-white'>
<StatusIcon status={status} className={statusIconSizeClass} />
</div>
<Text variant={size}>{status}</Text>
</div>
);
}
Loading