Skip to content

Commit

Permalink
feat: color palette for calendar (#118)
Browse files Browse the repository at this point in the history
* feat: work on the palette

* feat: palette basically done?

* fix: lint warnings and errors

* fix: minor fixes

* fix: color patch colors and shades

* fix: prettier issue

* chore: use TS satisfies

* chore: remove eslint-disable comment

---------

Co-authored-by: doprz <[email protected]>
  • Loading branch information
abhinavchadaga and doprz authored Mar 4, 2024
1 parent ceb6c19 commit 38bfd75
Show file tree
Hide file tree
Showing 7 changed files with 702 additions and 0 deletions.
123 changes: 123 additions & 0 deletions src/shared/util/themeColors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const colors = {
offwhite: '#D6D2C4',
concrete: '#95A5A6',
red: '#B91C1C', // Not sure if this should be here, but it's used for remove course, and add course is ut-green
white: '#FFFFFF',
},
theme: {
red: '#AF2E2D',
Expand All @@ -31,6 +32,128 @@ export const colors = {
dminus: '#B91C1C',
f: '#B91C1C',
},
palette: {
slateBase: '#64748B',
slate200: '#e2e8f0',
slate300: '#cbd5e1',
slate400: '#94a3b8',
slate600: '#475569',
slate700: '#334155',
grayBase: '#6b7280',
gray200: '#e5e7eb',
gray300: '#d1d5db',
gray400: '#9ca3af',
gray600: '#4b5563',
gray700: '#374151',
stoneBase: '#78716c',
stone200: '#e7e5e4',
stone300: '#d6d3d1',
stone400: '#a8a29e',
stone600: '#57534e',
stone700: '#44403c',
redBase: '#ef4444',
red200: '#fecaca',
red300: '#fca5a5',
red400: '#f87171',
red600: '#dc2626',
red700: '#b91c1c',
orangeBase: '#f97316',
orange200: '#fed7aa',
orange300: '#fdba74',
orange400: '#fb923c',
orange600: '#ea580c',
orange700: '#c2410c',
amberBase: '#f59e0b',
amber200: '#fde68a',
amber300: '#fcd34d',
amber400: '#fbbf24',
amber600: '#d97706',
amber700: '#b45309',
yellowBase: '#eab308',
yellow200: '#fef08a',
yellow300: '#fde047',
yellow400: '#facc15',
yellow600: '#ca8a04',
yellow700: '#a16207',
limeBase: '#84cc16',
lime200: '#d9f99d',
lime300: '#bef264',
lime400: '#a3e635',
lime600: '#65a30d',
lime700: '#4d7c0f',
greenBase: '#22c55e',
green200: '#bbf7d0',
green300: '#86efac',
green400: '#4ade80',
green600: '#16a34a',
green700: '#15803d',
emeraldBase: '#10b981',
emerald200: '#a7f3d0',
emerald300: '#6ee7b7',
emerald400: '#34d399',
emerald600: '#059669',
emerald700: '#047857',
tealBase: '#14b8a6',
teal200: '#99f6e4',
teal300: '#5eead4',
teal400: '#2dd4bf',
teal600: '#0d9488',
teal700: '#0f766e',
cyanBase: '#06b6d4',
cyan200: '#a5f3fc',
cyan300: '#67e8f9',
cyan400: '#22d3ee',
cyan600: '#0891b2',
cyan700: '#0e7490',
skyBase: '#0ea5e9',
sky200: '#bae6fd',
sky300: '#7dd3fc',
sky400: '#38bdf8',
sky600: '#0284c7',
sky700: '#0369a1',
blueBase: '#3b82f6',
blue200: '#bfdbfe',
blue300: '#93c5fd',
blue400: '#60a5fa',
blue600: '#2563eb',
blue700: '#1d4ed8',
indigoBase: '#6366f1',
indigo200: '#c7d2fe',
indigo300: '#a5b4fc',
indigo400: '#818cf8',
indigo600: '#4f46e5',
indigo700: '#4338ca',
violetBase: '#8b5cf6',
violet200: '#ddd6fe',
violet300: '#c4b5fd',
violet400: '#a78bfa',
violet600: '#7c3aed',
violet700: '#6d28d9',
purpleBase: '#a855f7',
purple200: '#e9d5ff',
purple300: '#d8b4fe',
purple400: '#c084fc',
purple600: '#9333ea',
purple700: '#7e22ce',
fuschiaBase: '#d946ef',
fuschia200: '#f5d0fe',
fuschia300: '#f0abfc',
fuschia400: '#e879f9',
fuschia600: '#c026d3',
fuschia700: '#a21caf',
pinkBase: '#ec4899',
pink200: '#fbcfe8',
pink300: '#f9a8d4',
pink400: '#f472b6',
pink600: '#db2777',
pink700: '#be185d',
roseBase: '#f43f5e',
rose200: '#fecdd3',
rose300: '#fda4af',
rose400: '#fb7185',
rose600: '#e11d48',
rose700: '#be123c',
},
} as const satisfies Record<string, Record<string, string>>;

type NestedKeys<T> = {
Expand Down
19 changes: 19 additions & 0 deletions src/stories/components/CourseCellColorPicker.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Meta, StoryObj } from '@storybook/react';
import CourseCellColorPicker from '@views/components/common/CourseCellColorPicker/CourseCellColorPicker';
import React, { useState } from 'react';
import type { ThemeColor } from 'src/shared/util/themeColors';

const meta = {
title: 'Components/Common/CourseCellColorPicker',
component: CourseCellColorPicker,
} satisfies Meta<typeof CourseCellColorPicker>;

export default meta;
type Story = StoryObj<typeof CourseCellColorPicker>;

export const Default: Story = {
render: () => {
const [selectedColor, setSelectedColor] = useState<ThemeColor | null>(null);
return <CourseCellColorPicker setSelectedColor={setSelectedColor} />;
},
};
50 changes: 50 additions & 0 deletions src/views/components/common/CourseCellColorPicker/ColorPatch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Button } from '@views/components/common/Button/Button';
import React from 'react';
import type { ThemeColor } from 'src/shared/util/themeColors';

import CheckIcon from '~icons/material-symbols/check';

/**
* Props for the ColorPatch component
*/
interface ColorPatchProps {
color: ThemeColor;
index: number;
selectedColor: number;
handleSetSelectedColorPatch: (colorPatchIndex: number) => void;
}

/**
*
* @param {ColorPatchProps} props - the props for the component
* @param {ThemeColor} props.color - the color to display
* @param {number} props.index - the index of this color patch in the parent color palette
* @param {number} props.selectedColor - the index of the selected color patch in the parent color palette
* @param {(colorPatchIndex: number) => void} props.handleSetSelectedColorPatch - fn called when a color patch is selected. This function
* is passed from the parent and updates the necessary parent state when this color patch is selected.
* @returns {JSX.Element} - the color patch component
*/
const ColorPatch: React.FC<ColorPatchProps> = ({
color,
index,
selectedColor,
handleSetSelectedColorPatch,
}: ColorPatchProps): JSX.Element => {
const isSelected = selectedColor === index;
const handleClick = () => {
handleSetSelectedColorPatch(isSelected ? -1 : index);
};
return (
<Button
style={{ backgroundColor: color }}
className='h-[22px] w-[22px] p-0'
variant='filled'
onClick={handleClick}
color={color}
>
{isSelected && <CheckIcon className='h-[20px] w-[20px]' />}
</Button>
);
};

export default ColorPatch;
Loading

0 comments on commit 38bfd75

Please sign in to comment.