Package Exports
- @lelbakna/tarl
- @lelbakna/tarl/styles
Readme
TARL - Language Learning Component Library
A comprehensive React component library for building language learning interfaces with Redux Toolkit Query integration.
Features
- 🎨 Built with Tailwind CSS for styling
- ⚛️ React components with TypeScript
- 🔄 Redux Toolkit Query integration
- 🎭 Framer Motion animations
- 📦 Ready for NPM publishing
- 🚀 Framework agnostic (works with React, Next.js, etc.)
- 📝 Full TypeScript support
Installation
npm install tarlPeer Dependencies
Make sure to install the required peer dependencies:
npm install react react-dom @reduxjs/toolkit react-redux framer-motionQuick Start
1. Set up Redux Store
import { Provider } from 'react-redux';
import { createTarlStore } from 'tarl';
const store = createTarlStore();
function App() {
return (
<Provider store={store}>
{/* Your app */}
</Provider>
);
}2. Import Styles
import 'tarl/styles'; // or 'tarl/dist/styles.css'3. Use Components
import { LanguageLearningInterface } from 'tarl';
function MyApp() {
return (
<LanguageLearningInterface
activityId={3}
source="interactive"
userName="John Doe"
sessionNumber={3}
/>
);
}Core Components
LanguageLearningInterface
The main component for displaying language learning activities.
import { LanguageLearningInterface } from 'tarl';
<LanguageLearningInterface
activityId={3} // Activity ID from API
source="interactive" // 'interactive' or 'slides'
userName="John Doe" // User name
sessionNumber={3} // Session number
onBack={() => console.log('back')}
onContinue={() => console.log('continue')}
onReplay={() => console.log('replay')}
/>SplashScreen
Display a splash screen before starting the activity.
import { SplashScreen } from 'tarl';
<SplashScreen
activityId={3}
onStart={() => setShowSplash(false)}
/>Header
Header component with session info and progress.
import { Header } from 'tarl';
<Header
sessionNumber={3}
sessionType="Ecriture"
currentStep={1}
etapes={etapes}
userName="John Doe"
mode="interactive"
onBack={() => {}}
/>API Integration
Using RTK Query Hooks
import { useGetActivityPropositionsQuery } from 'tarl';
function MyComponent() {
const { data, isLoading, error } = useGetActivityPropositionsQuery({
activityId: 3,
source: 'interactive'
});
if (isLoading) return <div>Loading...</div>;
if (error) return <div>Error: {error.toString()}</div>;
return <div>{/* Use data */}</div>;
}Using Component Wrapper
import { LanguageLearningInterfaceWithQuery } from 'tarl';
<LanguageLearningInterfaceWithQuery
activityId={3}
sessionNumber={3}
userName="John Doe"
/>Environment Variables
Set up your API endpoints:
NEXT_PUBLIC_API_BASE_URL=http://localhost:8003
NEXT_PUBLIC_PRONUNCIATION_API_BASE_URL=http://localhost:8002Complete Example
import { Provider } from 'react-redux';
import { createTarlStore, LanguageLearningInterface } from 'tarl';
import 'tarl/styles';
const store = createTarlStore();
function App() {
return (
<Provider store={store}>
<LanguageLearningInterface
activityId={3}
source="interactive"
userName="John Doe"
sessionNumber={3}
onBack={() => console.log('Back clicked')}
onContinue={() => console.log('Continue clicked')}
onReplay={() => console.log('Replay clicked')}
/>
</Provider>
);
}Available Components
LanguageLearningInterface- Main learning interfaceSplashScreen- Splash screen componentHeader- Header with session infoButton- Custom button componentCard- Card containerLetterBlock- Letter block displayLetterInputs- Letter input componentActionButtons- Action buttonsMicrophoneButton- Microphone buttonSpeakerButton- Speaker buttonVoiceRecorder- Voice recorderWordIllustration- Word illustrationBookCharacter- Book character animationProgressTag- Progress tagTimerBar- Timer bar- And more...
Available Hooks
useWordLearningData- Get word learning datauseAudioPlayback- Audio playback hookuseTimer- Timer hookuseLetterInput- Letter input hookuseCelebration- Celebration animationsuseLocalStoragePersistence- Local storage persistence
Building the Library
To build the library for distribution:
npm run build:libThis creates the dist/ folder with:
index.js- CommonJS buildindex.esm.js- ES Module buildindex.d.ts- TypeScript declarationsstyles.css- Compiled Tailwind CSS
Development
To run the development server:
npm run devPublishing
- Update
package.jsonversion - Build:
npm run build:lib - Publish:
npm publish(ornpm publish --access publicfor scoped packages)
Project Structure
TARL/
├── src/
│ ├── components/ # React components
│ ├── hooks/ # Custom hooks
│ ├── api/ # RTK Query API
│ ├── store/ # Redux store
│ ├── styles/ # Tailwind CSS styles
│ ├── types/ # TypeScript types
│ └── index.ts # Main export file
├── app/ # Next.js app (for development)
├── dist/ # Built library (generated)
└── package.jsonImage Assets
The library uses images from /images/ path. Make sure to:
- Copy the
public/images/folder to your consuming project's public directory - Or configure your build tool to handle image paths correctly
License
MIT