1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-25 16:39:02 +02:00
This commit is contained in:
Arik Chakma
2025-06-13 12:10:33 +06:00
parent 16de168751
commit f55b4bdfb0
3 changed files with 98 additions and 94 deletions

View File

@@ -6,14 +6,8 @@ import {
type LucideIcon, type LucideIcon,
} from 'lucide-react'; } from 'lucide-react';
import { useId, useState } from 'react'; import { useId, useState } from 'react';
import { cn } from '../../lib/classname'; import { FormatItem } from './FormatItem';
import { import { GuideOptions } from './GuideOptions';
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '../Select';
const allowedFormats = ['course', 'guide', 'roadmap'] as const; const allowedFormats = ['course', 'guide', 'roadmap'] as const;
type AllowedFormat = (typeof allowedFormats)[number]; type AllowedFormat = (typeof allowedFormats)[number];
@@ -95,89 +89,3 @@ export function ContentGenerator() {
</form> </form>
); );
} }
type FormatItemProps = {
label: string;
onClick: () => void;
icon: LucideIcon;
isSelected: boolean;
};
function FormatItem(props: FormatItemProps) {
const { label, onClick, icon: Icon, isSelected } = props;
return (
<button
type="button"
className={cn(
'flex w-full flex-col items-center justify-center gap-2 rounded-lg border border-gray-200 p-2 py-6',
isSelected
? 'border-gray-200 bg-gray-100'
: 'text-gray-400 hover:bg-gray-50',
)}
onClick={onClick}
>
<Icon className="size-6" />
<span>{label}</span>
</button>
);
}
function GuideOptions() {
const [depth, setDepth] = useState<string>('essentials');
const depthSelectId = useId();
const depthOptions = [
{
label: 'Essentials',
value: 'essentials',
description: 'Just the code concepts',
},
{
label: 'Detailed',
value: 'detailed',
description: 'In-depth explanation',
},
{
label: 'Complete',
value: 'complete',
description: 'Cover the topic fully',
},
];
const selectedDepth = depthOptions.find((option) => option.value === depth);
return (
<div className="flex flex-col gap-2">
<label
htmlFor={depthSelectId}
className="inline-block text-sm text-gray-500"
>
Choose the guide options
</label>
<Select value={depth} onValueChange={setDepth}>
<SelectTrigger id={depthSelectId}>
{selectedDepth && (
<div className="flex flex-col gap-1">
<span>{selectedDepth.label}</span>
</div>
)}
{!selectedDepth && <SelectValue placeholder="Select a depth" />}
</SelectTrigger>
<SelectContent>
{depthOptions.map((option) => (
<SelectItem key={option.value} value={option.value}>
<div className="flex flex-col gap-1">
<span>{option.label}</span>
<span className="text-xs text-gray-500">
{option.description}
</span>
</div>
</SelectItem>
))}
</SelectContent>
</Select>
</div>
);
}

View File

@@ -0,0 +1,29 @@
import { type LucideIcon } from 'lucide-react';
import { cn } from '../../lib/classname';
type FormatItemProps = {
label: string;
onClick: () => void;
icon: LucideIcon;
isSelected: boolean;
};
export function FormatItem(props: FormatItemProps) {
const { label, onClick, icon: Icon, isSelected } = props;
return (
<button
type="button"
className={cn(
'flex w-full flex-col items-center justify-center gap-2 rounded-lg border border-gray-200 p-2 py-6',
isSelected
? 'border-gray-200 bg-gray-100'
: 'text-gray-400 hover:bg-gray-50',
)}
onClick={onClick}
>
<Icon className="size-6" />
<span>{label}</span>
</button>
);
}

View File

@@ -0,0 +1,67 @@
import { useId, useState } from 'react';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '../Select';
export function GuideOptions() {
const [depth, setDepth] = useState<string>('essentials');
const depthSelectId = useId();
const depthOptions = [
{
label: 'Essentials',
value: 'essentials',
description: 'Just the code concepts',
},
{
label: 'Detailed',
value: 'detailed',
description: 'In-depth explanation',
},
{
label: 'Complete',
value: 'complete',
description: 'Cover the topic fully',
},
];
const selectedDepth = depthOptions.find((option) => option.value === depth);
return (
<div className="flex flex-col gap-2">
<label
htmlFor={depthSelectId}
className="inline-block text-sm text-gray-500"
>
Choose the guide options
</label>
<Select value={depth} onValueChange={setDepth}>
<SelectTrigger id={depthSelectId}>
{selectedDepth && (
<div className="flex flex-col gap-1">
<span>{selectedDepth.label}</span>
</div>
)}
{!selectedDepth && <SelectValue placeholder="Select a depth" />}
</SelectTrigger>
<SelectContent>
{depthOptions.map((option) => (
<SelectItem key={option.value} value={option.value}>
<div className="flex flex-col gap-1">
<span>{option.label}</span>
<span className="text-xs text-gray-500">
{option.description}
</span>
</div>
</SelectItem>
))}
</SelectContent>
</Select>
</div>
);
}