1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-09 08:40:40 +02:00
This commit is contained in:
Arik Chakma
2025-06-13 12:30:29 +06:00
parent f55b4bdfb0
commit 4871bb9ffd
4 changed files with 65 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ import {
import { useId, useState } from 'react'; import { useId, useState } from 'react';
import { FormatItem } from './FormatItem'; import { FormatItem } from './FormatItem';
import { GuideOptions } from './GuideOptions'; import { GuideOptions } from './GuideOptions';
import { FineTuneCourse } from '../GenerateCourse/FineTuneCourse';
const allowedFormats = ['course', 'guide', 'roadmap'] as const; const allowedFormats = ['course', 'guide', 'roadmap'] as const;
type AllowedFormat = (typeof allowedFormats)[number]; type AllowedFormat = (typeof allowedFormats)[number];
@@ -16,7 +17,17 @@ export function ContentGenerator() {
const [title, setTitle] = useState(''); const [title, setTitle] = useState('');
const [selectedFormat, setSelectedFormat] = useState<AllowedFormat>('course'); const [selectedFormat, setSelectedFormat] = useState<AllowedFormat>('course');
// guide options
const [depth, setDepth] = useState('essentials');
// fine-tune options
const [showFineTuneOptions, setShowFineTuneOptions] = useState(false);
const [about, setAbout] = useState('');
const [goal, setGoal] = useState('');
const [customInstructions, setCustomInstructions] = useState('');
const titleFieldId = useId(); const titleFieldId = useId();
const fineTuneOptionsId = useId();
const allowedFormats: { const allowedFormats: {
label: string; label: string;
@@ -78,7 +89,40 @@ export function ContentGenerator() {
})} })}
</div> </div>
</div> </div>
<GuideOptions />
{selectedFormat === 'guide' && (
<GuideOptions depth={depth} setDepth={setDepth} />
)}
{selectedFormat !== 'roadmap' && (
<>
<div className="flex h-9 items-center gap-2 rounded-lg border border-gray-200 px-3 text-sm">
<input
type="checkbox"
id={fineTuneOptionsId}
checked={showFineTuneOptions}
onChange={(e) => setShowFineTuneOptions(e.target.checked)}
/>
<label htmlFor={fineTuneOptionsId} className="text-sm">
Show fine-tune options
</label>
</div>
{showFineTuneOptions && (
<FineTuneCourse
hasFineTuneData={showFineTuneOptions}
about={about}
goal={goal}
customInstructions={customInstructions}
setAbout={setAbout}
setGoal={setGoal}
setCustomInstructions={setCustomInstructions}
className="overflow-hidden rounded-lg border border-gray-200 [&_div:first-child_label]:border-t-0 [&_textarea]:text-sm"
/>
)}
</>
)}
<button <button
type="submit" type="submit"
className="flex h-9 w-full items-center justify-center gap-2 rounded-lg bg-black text-sm text-white focus:outline-none" className="flex h-9 w-full items-center justify-center gap-2 rounded-lg bg-black text-sm text-white focus:outline-none"

View File

@@ -7,8 +7,13 @@ import {
SelectValue, SelectValue,
} from '../Select'; } from '../Select';
export function GuideOptions() { type GuideOptionsProps = {
const [depth, setDepth] = useState<string>('essentials'); depth: string;
setDepth: (depth: string) => void;
};
export function GuideOptions(props: GuideOptionsProps) {
const { depth, setDepth } = props;
const depthSelectId = useId(); const depthSelectId = useId();
const depthOptions = [ const depthOptions = [
@@ -37,7 +42,7 @@ export function GuideOptions() {
htmlFor={depthSelectId} htmlFor={depthSelectId}
className="inline-block text-sm text-gray-500" className="inline-block text-sm text-gray-500"
> >
Choose the guide options Choose depth of content
</label> </label>
<Select value={depth} onValueChange={setDepth}> <Select value={depth} onValueChange={setDepth}>
<SelectTrigger id={depthSelectId}> <SelectTrigger id={depthSelectId}>

View File

@@ -175,7 +175,6 @@ export function AICourse(props: AICourseProps) {
<FineTuneCourse <FineTuneCourse
hasFineTuneData={hasFineTuneData} hasFineTuneData={hasFineTuneData}
setHasFineTuneData={setHasFineTuneData}
about={about} about={about}
goal={goal} goal={goal}
customInstructions={customInstructions} customInstructions={customInstructions}

View File

@@ -1,3 +1,6 @@
import { useId } from 'react';
import { cn } from '../../lib/classname';
type QuestionProps = { type QuestionProps = {
label: string; label: string;
placeholder: string; placeholder: string;
@@ -8,13 +11,18 @@ type QuestionProps = {
function Question(props: QuestionProps) { function Question(props: QuestionProps) {
const { label, placeholder, value, onChange, autoFocus = false } = props; const { label, placeholder, value, onChange, autoFocus = false } = props;
const questionId = useId();
return ( return (
<div className="flex flex-col"> <div className="flex flex-col">
<label className="border-y bg-gray-100 px-4 py-2.5 text-sm font-medium text-gray-700"> <label
htmlFor={questionId}
className="border-y bg-gray-100 px-4 py-2.5 text-sm font-medium text-gray-700"
>
{label} {label}
</label> </label>
<textarea <textarea
id={questionId}
placeholder={placeholder} placeholder={placeholder}
className="min-h-[80px] w-full resize-none px-4 py-3 text-gray-700 placeholder:text-gray-400 focus:outline-hidden" className="min-h-[80px] w-full resize-none px-4 py-3 text-gray-700 placeholder:text-gray-400 focus:outline-hidden"
value={value} value={value}
@@ -31,10 +39,10 @@ type FineTuneCourseProps = {
goal: string; goal: string;
customInstructions: string; customInstructions: string;
setHasFineTuneData: (hasMetadata: boolean) => void;
setAbout: (about: string) => void; setAbout: (about: string) => void;
setGoal: (goal: string) => void; setGoal: (goal: string) => void;
setCustomInstructions: (customInstructions: string) => void; setCustomInstructions: (customInstructions: string) => void;
className?: string;
}; };
export function FineTuneCourse(props: FineTuneCourseProps) { export function FineTuneCourse(props: FineTuneCourseProps) {
@@ -46,7 +54,7 @@ export function FineTuneCourse(props: FineTuneCourseProps) {
setAbout, setAbout,
setGoal, setGoal,
setCustomInstructions, setCustomInstructions,
setHasFineTuneData, className,
} = props; } = props;
if (!hasFineTuneData) { if (!hasFineTuneData) {
@@ -54,7 +62,7 @@ export function FineTuneCourse(props: FineTuneCourseProps) {
} }
return ( return (
<div className="mt-0 flex flex-col"> <div className={cn('mt-0 flex flex-col', className)}>
<Question <Question
label="Tell us about yourself" label="Tell us about yourself"
placeholder="e.g. I am a frontend developer and have good knowledge of HTML, CSS, and JavaScript." placeholder="e.g. I am a frontend developer and have good knowledge of HTML, CSS, and JavaScript."