chore: merge branch 'main' into sgunter/button-component

This commit is contained in:
Samuel Gunter
2024-02-13 16:54:36 -06:00
5 changed files with 127 additions and 0 deletions

26
.github/workflows/chromatic.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: "Chromatic"
on: [push, pull_request_target]
jobs:
chromatic:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8
- name: Install dependencies
run: pnpm install
- name: Publish to Chromatic
uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
exitZeroOnChanges: true
autoAcceptChanges: "main"

View File

@@ -59,6 +59,7 @@
"@unocss/transformer-directives": "^0.58.4", "@unocss/transformer-directives": "^0.58.4",
"@unocss/transformer-variant-group": "^0.58.4", "@unocss/transformer-variant-group": "^0.58.4",
"@vitejs/plugin-react-swc": "^3.6.0", "@vitejs/plugin-react-swc": "^3.6.0",
"chromatic": "^10.9.1",
"cssnano": "^6.0.3", "cssnano": "^6.0.3",
"cssnano-preset-advanced": "^6.0.3", "cssnano-preset-advanced": "^6.0.3",
"dotenv": "^16.4.1", "dotenv": "^16.4.1",

16
pnpm-lock.yaml generated
View File

@@ -135,6 +135,9 @@ devDependencies:
'@vitejs/plugin-react-swc': '@vitejs/plugin-react-swc':
specifier: ^3.6.0 specifier: ^3.6.0
version: 3.6.0(vite@5.0.12) version: 3.6.0(vite@5.0.12)
chromatic:
specifier: ^10.9.1
version: 10.9.1
cssnano: cssnano:
specifier: ^6.0.3 specifier: ^6.0.3
version: 6.0.3(postcss@8.4.33) version: 6.0.3(postcss@8.4.33)
@@ -6084,6 +6087,19 @@ packages:
engines: {node: '>=10'} engines: {node: '>=10'}
dev: true dev: true
/chromatic@10.9.1:
resolution: {integrity: sha512-6Ypho74fQu45ns48KaBuIMKqlzik0fJo//dLB3lkiphz8vCiMm75uU3xhkfZh4NbOS51MbWZKjPfefM53bIHpg==}
hasBin: true
peerDependencies:
'@chromatic-com/cypress': ^0.5.2 || ^1.0.0
'@chromatic-com/playwright': ^0.5.2 || ^1.0.0
peerDependenciesMeta:
'@chromatic-com/cypress':
optional: true
'@chromatic-com/playwright':
optional: true
dev: true
/chrome-extension-toolkit@0.0.51: /chrome-extension-toolkit@0.0.51:
resolution: {integrity: sha512-XzOOE2+/aYG43bJOwuJT4oWcn80jBJr5mwGyrSzKKFoqALixT15AsPcfZId/UOoc4pIavu2XcHeJga6ng0m1jQ==} resolution: {integrity: sha512-XzOOE2+/aYG43bJOwuJT4oWcn80jBJr5mwGyrSzKKFoqALixT15AsPcfZId/UOoc4pIavu2XcHeJga6ng0m1jQ==}
dependencies: dependencies:

View File

@@ -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>
),
};

View File

@@ -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>
);
}