Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: sort languages and frameworks alphabetically in the template filter #2502

Closed
wants to merge 16 commits into from
Closed
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 39 additions & 37 deletions apps/www/app/templates/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,43 +276,45 @@ export function TemplatesClient() {

<AccordionContent>
<Separator className="mt-4 mb-4" orientation="horizontal" />
{Object.entries(frameworks).map(([framework, occurences]) => (
<FormField
key={framework}
control={form.control}
name="frameworks"
render={({ field }) => {
return (
<FormItem
key={framework}
className="flex flex-row items-center px-2 py-1 space-x-3 h-10 space-y-0 duration-150 rounded-md bg-[rgba(255,255,255,0.05)] group hover:bg-[rgba(255,255,255,0.15)] mb-2"
>
<FormControl>
<Checkbox
aria-label={`Checkbox for ${framework}`}
checked={field.value?.includes(framework)}
onCheckedChange={(checked) => {
return checked
? field.onChange([...field.value, framework])
: field.onChange(
field.value?.filter(
(value: string) => value !== framework,
),
);
}}
/>
</FormControl>
<FormLabel className="flex items-center justify-between w-full">
<span className="text-sm font-normal">{framework}</span>
<span className="px-2 py-1 text-xs duration-150 rounded-md text-white/70 bg-white/20 group-hover:text-white/80">
{occurences}
</span>
</FormLabel>
</FormItem>
);
}}
/>
))}
{Object.entries(frameworks)
.sort((a, b) => a[0].localeCompare(b[0]))
.map(([framework, occurences]) => (
<FormField
key={framework}
control={form.control}
name="frameworks"
render={({ field }) => {
return (
<FormItem
key={framework}
className="flex flex-row items-center px-2 py-1 space-x-3 h-10 space-y-0 duration-150 rounded-md bg-[rgba(255,255,255,0.05)] group hover:bg-[rgba(255,255,255,0.15)] mb-2"
>
<FormControl>
<Checkbox
aria-label={`Checkbox for ${framework}`}
checked={field.value?.includes(framework)}
onCheckedChange={(checked) => {
return checked
? field.onChange([...field.value, framework])
: field.onChange(
field.value?.filter(
(value: string) => value !== framework,
),
);
}}
/>
</FormControl>
<FormLabel className="flex items-center justify-between w-full">
<span className="text-sm font-normal">{framework}</span>
<span className="px-2 py-1 text-xs duration-150 rounded-md text-white/70 bg-white/20 group-hover:text-white/80">
{occurences}
</span>
</FormLabel>
</FormItem>
);
}}
/>
))}
<FormMessage />
</AccordionContent>
</AccordionItem>
Expand Down