there's a frood who really knows where his towel is
→ Huge thanks to Douglas Adams for making this possible, and everything else
→ Dive into the code and experience the galactic adventure that awaits with each mood at Galactic Hitchhiker
→ Always remember: DON'T PANIC 🚀
Galactic Hitchhiker is a Single-Page Application (SPA) that guides users through an interactive mood-based journey and offers different experiences using The Hitchhiker Guide to the Galaxy unvaluable knowledge
Mood Selector
- Users begin their journey by selecting a mood from a set of buttons within the
MoodSelectorComponent
- The
MoodSelectorComponent
is responsible for displaying mood options to the user - When a mood is selected, it sets the
selectedMood
state and emits an event to inform parent components of the change
Mood Button
- Each button in the
MoodButtonComponent
correlates to a specific mood and triggers a unique action when selected, generating a random selection of a quote included in the chosen mood - The
MoodButtonComponent
receives amood
as input and displays it as a button - It also tracks whether it is the currently active mood
- On click, it emits the
mood
value to theMoodSelectorComponent
, signaling a user's choice
Marvin
- In response to the user’s selection
MarvinComponent
starts playing at the same time that the quote appears
Hitchhiker Quotes
HitchhikerQuotesComponent
displays quotes inspired by the user's mood selection- Each quote is intended to resonate with the current mood, enhancing the user’s immersion in the experience
- All quotes are stored in
assets/data
; check the filegalaxy-hitchhiker-quotes.json
to access all the quotes and labels - The
HitchhikerQuotesComponent
listens for changes in mood from theMoodSelectorComponent
- Upon receiving a new mood, it consults the
DataService
to fetch a relevant quote - This component uses Angular's
OnChanges
lifecycle hook to detect when the inputselectedMood
changes - When a change is detected, and if the new mood is not null, it calls
getQuotesByMood()
from theDataService
to retrieve a quote associated with the new mood - The retrieved quote is then stored in the
selectedQuote
property, ready to be displayed to the user
- User selection is managed through
DataService
, which acts as a single source of truth for the selected state - This service centralizes the logic to pick the right quote
DataService
DataService
serves as the central hub for managing and accessing quotes related to the user's selected moodgetQuotes()
retrieves the complete list of quotes from the local JSON data storegetQuotesByMood(mood: string)
filters and returns a random quote that aligns with the specified mood category
Upon invoking getQuotesByMood
, it:
- Filters
quotesData
to find all quotes with a category matching the given mood - Selects a random quote from the filtered list to provide variety in user experience
- Returns the selected quote to be displayed by the
HitchhikerQuotesComponent
The service implements efficient data retrieval methods ensuring minimal overhead and quick response times for an optimized user experience.
AppComponent
serves as the orchestrator for the entire SPA, initializing components and managing their interactions.- Utilizes Angular's
OnInit
lifecycle hook to kickstart the application's logic by fetching initial data usingDataService
. - Relies on
ViewChild
to reference theMarvinComponent
, allowing it to control video playback in response to user interactions. - The
onMoodChosen
method is pivotal in reacting to mood selections. It sets the current mood and triggers Marvin's video playback, linking user choice to an immediate visual response. - In a delightful alignment with the universe's sense of humor, the logic in
AppComponent
culminates in exactly 42 lines — the answer to life, the universe, and everything!
- The app adjusts to a variety of devices, maintaining consistency and functionality through responsive design
- The SPA is designed to be intuitive and easy to navigate, emphasizing simplicity and clarity
- Friendly interactions and engaging visual styles are used to enhance the user experience
- Galactic Hitchhiker aims to provide an engaging and thoughtful experience that adapts to the user, while maintaining a clean interface and efficient code
Feel free to open an issue if you have any suggestion
Interested in contributing or customizing? Fork the project
Thoughts? Write to [email protected]
[ build, don't talk ]