hobby-by-category
Version:
A comprehensive, type-safe list of hobbies organized by categories.
161 lines (130 loc) • 4.38 kB
Markdown
A comprehensive, type-safe list of hobbies organized by categories. Perfect for forms, recommendation systems, and hobby discovery apps.
- 300+ hobbies across 10 categories
- TypeScript & JavaScript support
- Ready for dropdowns/forms
- Utility functions for easy access
- Zero dependencies
- Active maintenance
```bash
npm install hobby-by-category
yarn add hobby-by-category
```
```javascript
const hobbies = require('hobby-by-category');
// Access all creative hobbies
console.log(hobbies.creativeAndArtistic);
// Get random outdoor activity
const randomHobby = hobbies.getRandomHobby('outdoorAndAdventure');
```
```typescript
import hobbies, { getHobbiesByCategory } from 'hobby-by-category';
// Get all photography-related hobbies
const photoHobbies = getHobbiesByCategory('creativeAndArtistic')
.filter(h => h.includes('Photography'));
```
1. `creativeAndArtistic` - Painting, Drawing, Photography, etc.
2. `outdoorAndAdventure` - Hiking, Camping, Rock Climbing, etc.
3. `sportsAndFitness` - Running, Yoga, Swimming, etc.
4. `intellectualAndLearning` - Reading, Chess, Astronomy, etc.
5. `techAndGaming` - Coding, Gaming, VR, etc.
6. `musicAndPerformance` - Instruments, Singing, DJing, etc.
7. `collecting` - Coins, Vinyl, Comics, etc.
8. `foodAndDrink` - Cooking, Brewing, Mixology, etc.
9. `socialAndCommunity` - Volunteering, Board Games, etc.
10. `relaxationAndMindfulness` - Meditation, Journaling, etc.
The complete categorized hobbies object:
```typescript
{
creativeAndArtistic: string[],
outdoorAndAdventure: string[],
sportsAndFitness: string[];
intellectualAndLearning: string[];
techAndGaming: string[];
musicAndPerformance: string[];
collecting: string[];
foodAndDrink: string[];
socialAndCommunity: string[];
relaxationAndMindfulness: string[];
}
```
| Function | Description | Example |
|----------|-------------|---------|
| `getAllCategories()` | Returns all category names | `['creativeAndArtistic', ...]` |
| `getHobbiesByCategory(category)` | Returns hobbies for specific category | `getHobbiesByCategory('techAndGaming')` |
| `getRandomHobby(category?)` | Returns random hobby (optionally filtered by category) | `getRandomHobby('foodAndDrink')` |
## Example Implementations
### React Form Component
```jsx
import { useState } from 'react';
import hobbies from 'hobby-by-category';
function HobbyForm() {
const [category, setCategory] = useState('');
const [hobby, setHobby] = useState('');
return (
<form>
<label>Category:
<select value={category} onChange={e => setCategory(e.target.value)}>
<option value="">Select a category</option>
{hobbies.getAllCategories().map(cat => (
<option key={cat} value={cat}>{cat}</option>
))}
</select>
</label>
<label>Hobby:
<select
value={hobby}
onChange={e => setHobby(e.target.value)}
disabled={!category}
>
<option value="">Select a hobby</option>
{category && hobbies.getHobbiesByCategory(category).map(h => (
<option key={h} value={h}>{h}</option>
))}
</select>
</label>
</form>
);
}
```
```javascript
const hobbies = require('hobby-by-category');
app.post('/profile', (req, res) => {
const { category, hobby } = req.body;
if (!hobbies.getHobbiesByCategory(category).includes(hobby)) {
return res.status(400).send('Invalid hobby selection');
}
// Save valid hobby to profile
});
```
```bash
git clone https://github.com/therealMAO247/hobby-by-category.git
cd hobby-by-category
npm install
npm run build
```
```bash
npm test
```
Contributions are welcome! Please:
1. Fork the repository
2. Create a new branch for your feature
3. Submit a pull request
MIT © 2025, Michael Anan Onimisi <@therealMAO247>.
MIT © 2025, Ahoiza Techbologies <www.ahoizatechnologies.com>.