Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ pids

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
.sprint-plan.md
46 changes: 46 additions & 0 deletions apps/web/components/TagMultiSelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use client';

interface TagMultiSelectProps {
options: readonly string[];
selected: string[];
onChange: (selected: string[]) => void;
max?: number;
label: string;
}

export function TagMultiSelect({ options, selected, onChange, max, label }: TagMultiSelectProps) {
function toggle(tag: string) {
if (selected.includes(tag)) {
onChange(selected.filter((t) => t !== tag));
} else {
if (max && selected.length >= max) return;
onChange([...selected, tag]);
}
}

return (
<div>
<p>{label}</p>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem' }}>
{options.map((tag) => {
const isSelected = selected.includes(tag);
const isDisabled = !isSelected && max !== undefined && selected.length >= max;

return (
<button
key={tag}
type="button"
onClick={() => toggle(tag)}
disabled={isDisabled}
aria-pressed={isSelected}
style={{ opacity: isDisabled ? 0.4 : 1, cursor: isDisabled ? 'not-allowed' : 'pointer' }}
>
{tag}
</button>
Comment on lines +30 to +39

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TagMultiSelect buttons are missing aria-pressed={isSelected} — screen readers can't tell users which tags are currently active.

);
})}
</div>
{max && <p>{selected.length} of {max} selected</p>}
</div>
);
}
2 changes: 2 additions & 0 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export * from './types/auth.js';
export * from './validation/auth.js';
export * from './types/tags.js';
export * from './validation/tags.js';
41 changes: 41 additions & 0 deletions packages/shared/src/types/tags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export const CUISINE_TAGS = [
'american',
'barbecue',
'breakfast',
'burgers',
'caribbean',
'chinese',
'desserts',
'fast-food',
'french',
'greek',
'indian',
'italian',
'japanese',
'korean',
'lebanese',
'mediterranean',
'mexican',
'pizza',
'seafood',
'sushi',
'thai',
'turkish',
'vegan-friendly',
'vietnamese',
] as const;

export type CuisineTag = (typeof CUISINE_TAGS)[number];

export const DIETARY_TAGS = [
'vegetarian',
'vegan',
'gluten-free',
'halal',
'kosher',
'dairy-free',
'nut-free',
'low-carb',
] as const;

export type DietaryTag = (typeof DIETARY_TAGS)[number];
5 changes: 5 additions & 0 deletions packages/shared/src/validation/tags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { z } from 'zod';
import { CUISINE_TAGS, DIETARY_TAGS } from '../types/tags.js';

export const cuisineTagSchema = z.enum(CUISINE_TAGS);
export const dietaryTagSchema = z.enum(DIETARY_TAGS);
Loading