avada-feature-request
Version:
Feature Request component library for React applications
376 lines (287 loc) β’ 8.04 kB
Markdown
# avada-feature-request
A comprehensive React component library for feature request management, providing a complete solution for collecting, displaying, and managing user feature requests.
## β¨ Key Features
- π¨ **Beautiful UI** - Responsive and modern UI components
- π§ **TypeScript** - Full TypeScript support with type safety
- ποΈ **Flexible Customization** - Easy styling customization with SCSS and Polaris
- π **Simple Integration** - Quick setup in just a few steps
- π± **Mobile-friendly** - Optimized for all devices
- π **Anonymous Submission** - Support for submissions without login
- π **Voting System** - Like/dislike with real-time updates
- π¬ **Multi-level Comments** - Comment system with replies
- π·οΈ **Categorization** - Bug report, improvement, new feature
- π **Trending** - Display hottest feature requests
- π₯ **Firebase Integration** - Real-time data with Firestore
- π― **Status Management** - Doing, Considering, Completed
## π¦ Installation
```bash
npm install avada-feature-request
```
or
```bash
yarn add avada-feature-request
```
## π Quick Start
### 1. Setup Provider
Wrap your application with `FeatureRequestProvider`:
```tsx
import React from 'react';
import {
FeatureRequestProvider,
FeatureReqHome
} from 'avada-feature-request';
const shopInfo = {
id: "shop123",
shopId: "shop123",
shopOwner: "John Doe",
email: "admin@example.com",
domain: "example.com",
avatar: "https://example.com/avatar.jpg"
};
function App() {
return (
<FeatureRequestProvider
shopInfo={shopInfo}
appDomain="https://your-app.com"
fetchAuthenticatedApi={fetchAPI}
firebaseConfig={{
apiKey: "your-api-key",
authDomain: "your-project.firebaseapp.com",
projectId: "your-project-id",
// ... other config
}}
>
<div className="container">
<h1>Feature Requests</h1>
<FeatureReqHome />
</div>
</FeatureRequestProvider>
);
}
```
### 2. Display Feature Request List
```tsx
import { FeatureReqHome } from 'avada-feature-request';
function FeatureRequestPage() {
return (
<div className="feature-requests">
<FeatureReqHome />
</div>
);
}
```
### 3. Create New Feature Request
```tsx
import { CreateFeatureReq } from 'avada-feature-request';
function CreatePage() {
return (
<div className="create-feature">
<CreateFeatureReq />
</div>
);
}
```
## π§© Main Components
### FeatureRequestProvider
The main provider component that manages global state and API configuration.
**Props:**
- `shopInfo: Shop` - Shop/user information
- `appDomain: string` - Application domain
- `fetchAuthenticatedApi: Function` - Authenticated API call function
- `firebaseConfig?: FirebaseConfig` - Firebase configuration
- `typeRequest?: string[]` - Allowed request types
- `isEmbeddedAppEnv?: boolean` - Embedded app environment
- `onShopInfoUpdate?: Function` - Callback when shop info changes
### FeatureReqHome
Home page component displaying feature requests list with filter and search functionality.
**Features:**
- π Search by title
- π― Filter by status (Doing, Considering, Completed)
- π Filter by type (new-feature, bug-report, improvement)
- π Sort by trending, newest, most votes
- βΎοΈ Infinite scroll loading
- π± Responsive design
### CreateFeatureReq
Form component for creating new feature requests with validation.
**Features:**
- π Rich text editor for description
- π·οΈ Feature request type selection
- π Anonymous submission option
- β
Complete form validation
- π¨ User-friendly UI/UX
### FeatureReqDetails
Component for displaying detailed view of a feature request.
**Features:**
- π Full content display with HTML
- π Vote/unvote functionality
- π¬ Multi-level comment system
- π Social sharing links
- π·οΈ Dynamic status badges
### FeatureReqTrending
Component displaying trending feature requests.
**Features:**
- π₯ Smart trending algorithm
- β° Real-time updates
- π¨ Special card design
- π Metrics display
## πͺ Hooks
### useFeatureRequest
Hook to access feature request context.
```tsx
import { useFeatureRequest } from 'avada-feature-request';
function MyComponent() {
const {
shopInfo,
fetchAuthenticatedApi,
isEmbeddedAppEnv
} = useFeatureRequest();
// Use context values...
}
```
## π¨ Custom Components
### CustomBadge
Flexible badge component with multiple styles.
```tsx
import { CustomBadge } from 'avada-feature-request';
<CustomBadge
tone="success"
size="medium"
progress="complete"
>
Completed
</CustomBadge>
```
**Props:**
- `tone: 'success' | 'critical' | 'warning' | 'info'`
- `size: 'small' | 'medium' | 'large'`
- `progress: 'incomplete' | 'partiallyComplete' | 'complete'`
### UserComment
Component for displaying comments with avatar and metadata.
### ActionFeatureReq
Component containing action buttons (vote, comment, share).
## π Types & Interfaces
```tsx
// Main Feature Request
interface FeatureRequest {
id: string;
title: string;
description: string;
status: "Doing" | "Considering" | "Completed";
featureType: "new-feature" | "bug-report" | "improvement";
commentCount: number;
voteCount: number;
createdAt: string | Date;
createdBy: {
id: string;
name: string;
email: string;
avatar?: string;
};
shopId: string;
shopOwner: string;
isAnonymous?: boolean;
}
// Comment
interface FeatureRequestComment {
id: string;
content: string;
createdAt: string | Date;
likedUserIds: string[];
parentId?: string;
replies?: boolean;
repliesCount?: number;
shopId: string;
shopOwner: string;
isTeamAvada?: boolean;
voteCount: number;
}
// Shop Info
interface Shop {
id: string;
shopId: string;
shopOwner: string;
email: string;
domain: string;
avatar?: string;
}
```
## π οΈ Development
### Building the Project
```bash
# Build library
npm run build
# Build types
npm run build:types
# Watch mode for development
npm run watch
```
### Testing
```bash
# Run tests
npm test
# Lint code
npm run lint
```
## π¨ Styling
The project uses SCSS and Shopify Polaris for styling. You can override CSS variables:
```scss
// Custom variables
:root {
--avada-primary-color: #007ace;
--avada-success-color: #008060;
--avada-critical-color: #d72c0d;
--avada-warning-color: #ffc453;
}
```
## π Deployment
### Build for Production
```bash
npm run build
```
### Publish to NPM
```bash
npm run prepublishOnly
npm publish
```
## π§ Firebase Configuration
To use real-time features, you need to configure Firebase:
1. Create a new Firebase project
2. Enable Firestore Database
3. Setup security rules
4. Provide config in `FeatureRequestProvider`
```javascript
// firestore.rules example
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /feature-requests/{document} {
allow read, write: if true; // Customize based on your needs
}
}
}
```
## π Changelog
### v1.0.0
- β
Basic features: create, view, vote feature requests
- β
Multi-level comment system
- β
Real-time updates with Firebase
- β
Responsive design
- β
TypeScript support
## π€ Contributing
We welcome all contributions! Please:
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Merge Request
## π License
MIT License - see the [LICENSE](LICENSE) file for more details.
## π₯ Author
**Nguyen Truong** - [GitLab](https://gitlab.com/TruongNN62)
## π Support
If you encounter issues or have questions:
- π§ Email: support@avada.io
- π Issues: [GitLab Issues](https://gitlab.com/TruongNN62/avada-feature-request/-/issues)
- π Documentation: [Docs](https://docs.avada.io/feature-request)
---
Made with β€οΈ by Avada Team