From 708a136a5cc4bd1d0494eef26dc9749f1c35aad3 Mon Sep 17 00:00:00 2001 From: Razboy20 Date: Fri, 9 Feb 2024 17:30:12 -0600 Subject: [PATCH 1/3] ci: chromatic builds (#84) * ci: chromatic builds * hotfix: add pnpm install to workflow * hotfix: add pnpm version --- .github/workflows/chromatic.yml | 26 ++++++++++++++++++++++++++ package.json | 1 + pnpm-lock.yaml | 16 ++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 .github/workflows/chromatic.yml diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml new file mode 100644 index 000000000..da6df08ab --- /dev/null +++ b/.github/workflows/chromatic.yml @@ -0,0 +1,26 @@ +name: "Chromatic" + +on: [push, pull_request] + +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@v2 + with: + version: 8.15.1 + + - name: Install dependencies + run: pnpm install + + - name: Publish to Chromatic + uses: chromaui/action@latest + with: + projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} + exitZeroOnChanges: true + autoAcceptChanges: "main" diff --git a/package.json b/package.json index 1ed328d00..f9a374c41 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "@unocss/transformer-directives": "^0.58.4", "@unocss/transformer-variant-group": "^0.58.4", "@vitejs/plugin-react-swc": "^3.6.0", + "chromatic": "^10.9.1", "cssnano": "^6.0.3", "cssnano-preset-advanced": "^6.0.3", "dotenv": "^16.4.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4f6217648..27a985f98 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -135,6 +135,9 @@ devDependencies: '@vitejs/plugin-react-swc': specifier: ^3.6.0 version: 3.6.0(vite@5.0.12) + chromatic: + specifier: ^10.9.1 + version: 10.9.1 cssnano: specifier: ^6.0.3 version: 6.0.3(postcss@8.4.33) @@ -6084,6 +6087,19 @@ packages: engines: {node: '>=10'} 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: resolution: {integrity: sha512-XzOOE2+/aYG43bJOwuJT4oWcn80jBJr5mwGyrSzKKFoqALixT15AsPcfZId/UOoc4pIavu2XcHeJga6ng0m1jQ==} dependencies: From c122e744ef4561b556fbb3eafdc4e69212c51bd5 Mon Sep 17 00:00:00 2001 From: Razboy20 Date: Fri, 9 Feb 2024 18:39:20 -0600 Subject: [PATCH 2/3] ci: update pnpm action (#86) * ci: update pnpm action * hotfix: change action type --- .github/workflows/chromatic.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index da6df08ab..ae5482b60 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -1,6 +1,6 @@ name: "Chromatic" -on: [push, pull_request] +on: [push, pull_request_target] jobs: chromatic: @@ -11,9 +11,9 @@ jobs: with: fetch-depth: 0 - name: Setup pnpm - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@v3 with: - version: 8.15.1 + version: 8 - name: Install dependencies run: pnpm install From fa1d7374bcafbe19673dc31f33b3f8075e45f37a Mon Sep 17 00:00:00 2001 From: Som Gupta <78577376+knownotunknown@users.noreply.github.com> Date: Sat, 10 Feb 2024 21:26:21 -0600 Subject: [PATCH 3/3] feat: CourseStatus Component implemented (#83) Co-authored-by: Razboy20 --- .../components/CourseStatus.stories.tsx | 48 +++++++++++++++++++ .../common/CourseStatus/CourseStatus.tsx | 36 ++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/stories/components/CourseStatus.stories.tsx create mode 100644 src/views/components/common/CourseStatus/CourseStatus.tsx diff --git a/src/stories/components/CourseStatus.stories.tsx b/src/stories/components/CourseStatus.stories.tsx new file mode 100644 index 000000000..0e35fd26f --- /dev/null +++ b/src/stories/components/CourseStatus.stories.tsx @@ -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; +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; + +export const Variants: Story = { + render: args => ( +
+ + +
+ ), +}; diff --git a/src/views/components/common/CourseStatus/CourseStatus.tsx b/src/views/components/common/CourseStatus/CourseStatus.tsx new file mode 100644 index 000000000..8615fbd03 --- /dev/null +++ b/src/views/components/common/CourseStatus/CourseStatus.tsx @@ -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 ( +
+
+ +
+ {status} +
+ ); +}