Skip to content

Commit 0df73d7

Browse files
jguo22dtemkin1
andauthored
Color picker (#228)
Co-authored-by: Diego Temkin <65834932+dtemkin1@users.noreply.github.com>
1 parent 4105db9 commit 0df73d7

27 files changed

+1729
-2244
lines changed

package-lock.json

Lines changed: 1143 additions & 1108 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scrapers/cim.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ def get_sections() -> Iterable[Tag]:
4040
Iterable[bs4.element.Tag]: The accordion sections that contain lists of CI-M
4141
subjects
4242
"""
43-
with urlopen(CIM_URL, timeout=5) as cim_req:
44-
soup = BeautifulSoup(cim_req.read().decode("utf-8"), "html.parser")
43+
try:
44+
with urlopen(CIM_URL, timeout=5) as cim_req:
45+
soup = BeautifulSoup(cim_req.read().decode("utf-8"), "html.parser")
46+
except (URLError, socket.timeout) as error:
47+
print(f"error in get_sections: {error}")
48+
raise error
4549

4650
return (
4751
item

src/components/ActivityButtons.tsx

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,32 @@
11
import {
2-
Group,
3-
createListCollection,
2+
Button,
3+
ButtonGroup,
44
Flex,
5+
Group,
6+
HStack,
57
Heading,
68
Input,
9+
Stack,
710
Text,
11+
createListCollection,
812
parseColor,
9-
HStack,
10-
Stack,
11-
Button,
12-
ButtonGroup,
13+
ColorPicker,
14+
Select,
15+
Portal,
1316
} from "@chakra-ui/react";
1417
import type { ComponentPropsWithoutRef, FormEvent } from "react";
1518
import { useContext, useLayoutEffect, useState } from "react";
1619

17-
import { Radio, RadioGroup } from "./ui/radio";
18-
import {
19-
SelectContent,
20-
SelectItem,
21-
SelectRoot,
22-
SelectTrigger,
23-
SelectValueText,
24-
} from "./ui/select";
25-
import { Field } from "./ui/field";
26-
import { Checkbox } from "./ui/checkbox";
27-
import {
28-
ColorPickerArea,
29-
ColorPickerContent,
30-
ColorPickerControl,
31-
ColorPickerEyeDropper,
32-
ColorPickerChannelSlider,
33-
ColorPickerInput,
34-
ColorPickerRoot,
35-
ColorPickerTrigger,
36-
} from "./ui/color-picker";
3720
import { LuCheck as CheckIcon, LuX as CloseIcon } from "react-icons/lu";
21+
import { Checkbox } from "./ui/checkbox";
22+
import { Field } from "./ui/field";
23+
import { Radio, RadioGroup } from "./ui/radio";
3824

3925
import type { Activity, NonClass } from "../lib/activity";
4026
import { Timeslot } from "../lib/activity";
4127
import type { Class, SectionLockOption, Sections } from "../lib/class";
4228
import { LockOption } from "../lib/class";
43-
import { WEEKDAY_STRINGS, TIMESLOT_STRINGS, Slot } from "../lib/dates";
29+
import { Slot, TIMESLOT_STRINGS, WEEKDAY_STRINGS } from "../lib/dates";
4430
import { HydrantContext } from "../lib/hydrant";
4531

4632
/**
@@ -219,24 +205,29 @@ function ActivityColor(props: { activity: Activity; onHide: () => void }) {
219205
return (
220206
<Flex gap={2}>
221207
<Flex direction="row" gap={2}>
222-
<ColorPickerRoot
208+
<ColorPicker.Root
223209
value={color}
224210
onValueChange={(e) => {
225211
setColor(e.value);
226212
}}
227213
>
228-
<ColorPickerControl>
229-
<ColorPickerInput autoFocus />
230-
<ColorPickerTrigger />
231-
</ColorPickerControl>
232-
<ColorPickerContent>
233-
<ColorPickerArea />
234-
<HStack>
235-
<ColorPickerEyeDropper />
236-
<ColorPickerChannelSlider channel="hue" />
237-
</HStack>
238-
</ColorPickerContent>
239-
</ColorPickerRoot>
214+
<ColorPicker.HiddenInput />
215+
<ColorPicker.Control>
216+
<ColorPicker.Input autoFocus />
217+
<ColorPicker.Trigger />
218+
</ColorPicker.Control>
219+
<Portal>
220+
<ColorPicker.Positioner>
221+
<ColorPicker.Content>
222+
<ColorPicker.Area />
223+
<HStack>
224+
<ColorPicker.EyeDropper />
225+
<ColorPicker.ChannelSlider channel="hue" />
226+
</HStack>
227+
</ColorPicker.Content>
228+
</ColorPicker.Positioner>
229+
</Portal>
230+
</ColorPicker.Root>
240231
<ButtonGroup>
241232
<Button onClick={onReset}>Reset</Button>
242233
<Button onClick={onCancel}>Cancel</Button>
@@ -347,7 +338,7 @@ function NonClassAddTime(props: { activity: NonClass }) {
347338
});
348339

349340
const renderTimeDropdown = (key: "start" | "end") => (
350-
<SelectRoot
341+
<Select.Root
351342
collection={timesCollection}
352343
size="sm"
353344
width="8rem"
@@ -356,17 +347,28 @@ function NonClassAddTime(props: { activity: NonClass }) {
356347
setTimes({ ...times, [key]: e.value[0] });
357348
}}
358349
>
359-
<SelectTrigger>
360-
<SelectValueText />
361-
</SelectTrigger>
362-
<SelectContent>
363-
{timesCollection.items.map((time) => (
364-
<SelectItem item={time} key={time}>
365-
{time}
366-
</SelectItem>
367-
))}
368-
</SelectContent>
369-
</SelectRoot>
350+
<Select.HiddenSelect />
351+
<Select.Control>
352+
<Select.Trigger>
353+
<Select.ValueText />
354+
</Select.Trigger>
355+
<Select.IndicatorGroup>
356+
<Select.Indicator />
357+
</Select.IndicatorGroup>
358+
</Select.Control>
359+
<Portal>
360+
<Select.Positioner>
361+
<Select.Content>
362+
{timesCollection.items.map((time) => (
363+
<Select.Item item={time} key={time}>
364+
{time}
365+
<Select.ItemIndicator />
366+
</Select.Item>
367+
))}
368+
</Select.Content>
369+
</Select.Positioner>
370+
</Portal>
371+
</Select.Root>
370372
);
371373

372374
return (

src/components/ClassTable.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,16 @@ import {
2323
type Module,
2424
} from "ag-grid-community";
2525

26-
import { Box, Flex, Image, Input, Button, ButtonGroup } from "@chakra-ui/react";
26+
import {
27+
Box,
28+
Flex,
29+
Image,
30+
Input,
31+
Button,
32+
ButtonGroup,
33+
InputGroup,
34+
} from "@chakra-ui/react";
2735
import { LuPlus, LuMinus, LuSearch, LuStar } from "react-icons/lu";
28-
import { InputGroup } from "./ui/input-group";
2936
import { LabelledButton } from "./ui/button";
3037
import { useColorMode } from "./ui/color-mode";
3138

src/components/FeedbackBanner.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import {
88
Float,
99
Presence,
1010
CloseButton,
11+
Button,
1112
} from "@chakra-ui/react";
12-
import { LinkButton } from "./ui/link-button";
1313

1414
import { HydrantContext } from "../lib/hydrant";
15+
import { Link } from "react-router";
1516

1617
export const FeedbackBanner = () => {
1718
const { state } = useContext(HydrantContext);
@@ -40,20 +41,20 @@ export const FeedbackBanner = () => {
4041
<Text fontWeight="medium" maxW={{ base: "32ch", md: "unset" }}>
4142
Do you have feedback on Hydrant? We'd love to hear it!
4243
</Text>
43-
<LinkButton
44+
<Button
4445
flexShrink={0}
4546
variant="plain"
46-
href={"mailto:sipb-hydrant@mit.edu"}
4747
ms="6"
4848
bg="blackAlpha.300"
4949
color="whiteAlpha.900"
5050
fontWeight="semibold"
5151
px="3"
5252
py="1"
5353
height="inherit"
54+
asChild
5455
>
55-
Contact us
56-
</LinkButton>
56+
<Link to={"mailto:sipb-hydrant@mit.edu"}>Contact us</Link>
57+
</Button>
5758
<CloseButton
5859
hideFrom="sm"
5960
variant="ghost"

0 commit comments

Comments
 (0)