Skip to content

Commit 4b2a7e3

Browse files
committed
make class colors
1 parent 0b50477 commit 4b2a7e3

File tree

9 files changed

+419
-333
lines changed

9 files changed

+419
-333
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"engines": {
4141
"node": ">=18"
4242
},
43-
"packageManager": "pnpm@9.14.4+sha512.c8180b3fbe4e4bca02c94234717896b5529740a6cbadf19fa78254270403ea2f27d4e1d46a08a0f56c89b63dc8ebfd3ee53326da720273794e6200fcf0d184ab",
43+
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0",
4444
"devDependencies": {
4545
"@biomejs/biome": "1.9.4",
4646
"@pandacss/dev": "^0.51.1",
@@ -54,7 +54,7 @@
5454
"postcss": "^8.5.1",
5555
"solid-devtools": "^0.33.0",
5656
"typescript": "^5.7.3",
57-
"vite": "^5.4.11",
57+
"vite": "^5.4.12",
5858
"vitest": "^3.0.2"
5959
},
6060
"bugs": {

pnpm-lock.yaml

+179-178
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Class.tsx

+42-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,51 @@
1-
import type { Component } from "solid-js";
1+
import { type Component, Show, createMemo } from "solid-js";
22

3-
import type { Subject } from "~/context/types";
3+
import { courseColor, getColorClass } from "~/lib/colors";
4+
5+
import { Box } from "styled-system/jsx";
6+
import { Card } from "~/components/ui/card";
7+
import { Text } from "~/components/ui/text";
8+
9+
import type { SelectedSubjects } from "~/context/types";
10+
import { Button } from "./ui/button";
411

512
const Class: Component<{
613
classIndex: number;
7-
classInfo: "placeholder" | Subject;
14+
classInfo: "placeholder" | SelectedSubjects;
815
semesterIndex: number;
9-
// warnings: string[];
16+
warnings: string[];
1017
}> = (props) => {
11-
return <div />;
18+
const classInfo = createMemo(() => {
19+
if (props.classInfo === "placeholder") {
20+
return undefined;
21+
}
22+
return props.classInfo;
23+
});
24+
25+
return (
26+
<Show when={classInfo()} fallback={"placeholder"}>
27+
{(shownClassInfo) => (
28+
<Button
29+
width="48"
30+
height="24"
31+
variant="solid"
32+
overflowY="hidden"
33+
textWrap="wrap"
34+
className={getColorClass(courseColor(shownClassInfo()))}
35+
>
36+
<Text>
37+
<Text as="span" fontWeight="bold">
38+
{shownClassInfo().subject_id}{" "}
39+
</Text>
40+
41+
<Text as="span" fontWeight="medium">
42+
{shownClassInfo().title}
43+
</Text>
44+
</Text>
45+
</Button>
46+
)}
47+
</Show>
48+
);
1249
};
1350

1451
export default Class;

src/components/Semester.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ const Semester: Component<{
131131
};
132132
});
133133

134+
// TODO: implement warnings
135+
const warnings = createMemo(() => {
136+
return [] as string[][];
137+
});
138+
134139
return (
135140
<Accordion.Item
136141
value={props.index.toString()}
@@ -163,7 +168,7 @@ const Semester: Component<{
163168
<Class
164169
classInfo={subj}
165170
semesterIndex={props.index}
166-
// warnings={warnings()[props.index]}
171+
warnings={warnings()[props.index]}
167172
classIndex={index()}
168173
/>
169174
)}

src/components/ui/card.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * as Card from './styled/card'

src/components/ui/styled/card.tsx

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { type Assign, type PolymorphicProps, ark } from '@ark-ui/solid'
2+
import type { ComponentProps } from 'solid-js'
3+
import { card } from 'styled-system/recipes'
4+
import type { HTMLStyledProps } from 'styled-system/types'
5+
import { createStyleContext } from './utils/create-style-context'
6+
7+
const { withProvider, withContext } = createStyleContext(card)
8+
9+
export type RootProps = ComponentProps<typeof Root>
10+
export const Root = withProvider<Assign<HTMLStyledProps<'div'>, PolymorphicProps<'div'>>>(
11+
ark.div,
12+
'root',
13+
)
14+
15+
export const Body = withContext<Assign<HTMLStyledProps<'div'>, PolymorphicProps<'div'>>>(
16+
ark.div,
17+
'body',
18+
)
19+
20+
export const Description = withContext<Assign<HTMLStyledProps<'div'>, PolymorphicProps<'div'>>>(
21+
ark.div,
22+
'description',
23+
)
24+
25+
export const Footer = withContext<Assign<HTMLStyledProps<'div'>, PolymorphicProps<'div'>>>(
26+
ark.div,
27+
'footer',
28+
)
29+
30+
export const Header = withContext<Assign<HTMLStyledProps<'div'>, PolymorphicProps<'div'>>>(
31+
ark.div,
32+
'header',
33+
)
34+
35+
export const Title = withContext<Assign<HTMLStyledProps<'h3'>, PolymorphicProps<'h3'>>>(
36+
ark.h3,
37+
'title',
38+
)

src/context/component.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ const CourseDataProvider: ParentComponent = (props) => {
113113
setStore(
114114
"roads",
115115
produce((roads) => {
116-
delete roads[id];
116+
// biome-ignore lint/style/noNonNullAssertion: <explanation>
117+
roads[id] = undefined!;
117118
}),
118119
);
119120
},
@@ -422,7 +423,9 @@ const CourseDataProvider: ParentComponent = (props) => {
422423
},
423424

424425
getRoadKeys: () => {
425-
return Object.getOwnPropertyNames(store.roads);
426+
return Object.getOwnPropertyNames(store.roads).filter(
427+
(key) => store.roads[key] !== undefined,
428+
);
426429
},
427430

428431
getMatchingAttributes: (gir, hass, ci) => {

0 commit comments

Comments
 (0)