Skip to content

Commit bc8bcd9

Browse files
committed
changed time tags on task item to display in a row for better UI, added TopicTagAlt with similar styling to github labels for better UI, changed topic input to use TopicTagAlt for existing topics to match viewing display
1 parent 8610a11 commit bc8bcd9

4 files changed

Lines changed: 60 additions & 22 deletions

File tree

client/src/components/task_item.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { FaRegTrashCan } from "react-icons/fa6";
55
import { TimeInput } from "@/components/time_input";
66
import TimeTag, { DayTag } from "@/components/time_tag";
77
import { TopicInput } from "@/components/topic_input";
8-
import TopicTag from "@/components/topic_tag";
8+
import { TopicTagAlt } from "@/components/topic_tag";
99

1010
interface Time {
1111
id: number;
@@ -126,7 +126,7 @@ export function TaskItem({
126126
/* Item Display */
127127
}
128128
return (
129-
<div className="task flex h-fit w-full max-w-[28rem] flex-col gap-3 rounded-lg bg-slate-400 p-5 text-slate-200 shadow-xl">
129+
<div className="task flex h-fit w-full max-w-[48rem] flex-col gap-3 rounded-lg bg-slate-400 p-5 text-slate-200 shadow-xl">
130130
<div className="task-title-container flex w-full flex-row items-center justify-start gap-2 text-3xl font-bold text-slate-100 hover:text-slate-100">
131131
{/* Task Name and Completion */}
132132
<input
@@ -161,14 +161,14 @@ export function TaskItem({
161161
</div>
162162

163163
{/* Task Times */}
164-
<div className="task-times-container flex flex-col items-start">
164+
<div className="task-times-container flex flex-row flex-wrap items-start justify-start gap-x-8 gap-y-1">
165165
{isEditing ? (
166166
<TimeInput times={draftTimes} setTimes={setDraftTimes} />
167167
) : item.times?.length > 0 ? (
168168
item.times.map((time) => (
169169
<div
170170
key={time.id}
171-
className="day-time-tags flex w-full flex-row gap-3"
171+
className="day-time-tags flex w-fit flex-row gap-3 rounded-full bg-slate-400 px-3 py-1 hover:brightness-110"
172172
>
173173
<DayTag day={formatDay(time.day)} />
174174
<TimeTag start_time={time.start_time} end_time={time.end_time} />
@@ -189,7 +189,7 @@ export function TaskItem({
189189
/>
190190
) : item.topics.length > 0 ? (
191191
item.topics.map((topic) => (
192-
<TopicTag
192+
<TopicTagAlt
193193
key={topic.id}
194194
name={topic.name}
195195
color_hex={topic.color_hex}

client/src/components/topic_input.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { FaRegTrashCan } from "react-icons/fa6";
2+
import { RxCross2 } from "react-icons/rx";
3+
4+
import { TopicTagAlt } from "@/components/topic_tag";
25

36
interface Topic {
47
id: number;
@@ -25,34 +28,25 @@ export function TopicInput({
2528
<div className="topic-input flex w-full flex-col items-center justify-center gap-2 text-slate-200">
2629
<h1 className="topic-input-title text-xl hover:brightness-110">Topics</h1>
2730
{/* Selected Topics Display */}
28-
<div className="topics-container flex w-full flex-col items-center justify-center gap-2">
31+
<div className="topics-container flex w-full flex-row flex-wrap items-center justify-start gap-2">
2932
{topics.map((topic, index) => {
3033
if (topic.type === "existing") {
3134
const topicData = availableTopics.find((t) => t.id === topic.id);
3235
if (!topicData) return null;
3336
return (
34-
<div
35-
key={index}
36-
className="flex w-full items-center justify-evenly gap-2 rounded-lg bg-slate-400 p-2 brightness-90 hover:brightness-95"
37-
>
38-
<div
39-
className="topic-color aspect-square h-5"
40-
style={{
41-
backgroundColor:
42-
"#" + topicData.color_hex.toString(16).padStart(6, "0"),
43-
}}
44-
></div>
45-
<span className="topic-name w-full max-w-[75%] text-justify">
46-
{topicData.name}
47-
</span>
37+
<div key={index} className="flex w-fit flex-row gap-2 rounded-lg">
38+
<TopicTagAlt
39+
name={topicData.name}
40+
color_hex={topicData.color_hex}
41+
/>
4842
<button
4943
className="hover:brightness-90"
5044
type="button"
5145
onClick={() =>
5246
setTopics(topics.filter((_, i) => i !== index))
5347
}
5448
>
55-
<FaRegTrashCan className="hover:text-red-500" />
49+
<RxCross2 className="hover:text-red-500" />
5650
</button>
5751
</div>
5852
);

client/src/components/topic_tag.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,47 @@ function TopicTag({ name, color_hex }: TopicTagProps) {
2626
}
2727

2828
export default TopicTag;
29+
30+
function getHexColorValues(hex: string) {
31+
const r = parseInt(hex.substring(1, 3), 16);
32+
const g = parseInt(hex.substring(3, 5), 16);
33+
const b = parseInt(hex.substring(5, 7), 16);
34+
35+
return { r: r, g: g, b: b };
36+
}
37+
38+
function modifyBrightness(hex: string, brightness: number): string {
39+
const { r, g, b } = getHexColorValues(hex);
40+
41+
const brightness_modifier = Math.floor((256 * (brightness - 100)) / 100);
42+
43+
const new_r = Math.min(255, Math.max(0, r + brightness_modifier));
44+
const new_g = Math.min(255, Math.max(0, g + brightness_modifier));
45+
const new_b = Math.min(255, Math.max(0, b + brightness_modifier));
46+
47+
const r_str = new_r.toString(16).padStart(2, "0");
48+
const g_str = new_g.toString(16).padStart(2, "0");
49+
const b_str = new_b.toString(16).padStart(2, "0");
50+
51+
return "#" + r_str + g_str + b_str;
52+
}
53+
54+
export function TopicTagAlt({ name, color_hex }: TopicTagProps) {
55+
const color_hex_code = "#" + color_hex.toString(16).padStart(6, "0");
56+
57+
const foreground_hex_code = modifyBrightness(color_hex_code, 125);
58+
const background_hex_code = modifyBrightness(color_hex_code, 60);
59+
60+
return (
61+
<div
62+
className="topic-tag flex w-fit flex-row items-center overflow-hidden rounded-full border px-2 py-1 text-sm hover:brightness-110"
63+
style={{
64+
borderColor: foreground_hex_code,
65+
color: foreground_hex_code,
66+
backgroundColor: background_hex_code,
67+
}}
68+
>
69+
<p className="topic-tag-text truncate">{name}</p>
70+
</div>
71+
);
72+
}

client/src/pages/[id]/tasks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default function TasksPage() {
145145
availableTopics={availableTopics}
146146
/>
147147
</div>
148-
<div className="add-task-container hidden h-full flex-col items-center justify-start rounded-lg bg-slate-400 p-3 shadow-xl">
148+
<div className="add-task-container flex h-full flex-col items-center justify-start rounded-lg bg-slate-400 p-3 shadow-xl">
149149
<h1 className="text-3xl font-bold text-slate-100">Add Task</h1>
150150
<div className="task-form-wrapper h-full overflow-auto">
151151
<TaskForm

0 commit comments

Comments
 (0)