Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฑ Magic 8-Ball

Magic 8-Ball hero

A mystical Magic 8-Ball web app โ€” think your question, shake your phone (or tap the button), and receive your answer from the universe.

๐Ÿ”ฎ Live app โ†’ zhannam85.github.io/magic-ball


Features

  • Shake detection โ€” uses the DeviceMotionEvent API on mobile; iOS 13+ asks for permission once, and gracefully falls back to button-only mode if denied
  • Shake button โ€” always visible, works on desktop and any device regardless of motion permission
  • 20 classic answers โ€” 10 positive, 5 neutral, 5 negative, colour-coded green / yellow / red
  • English & Russian โ€” auto-detects nothing (Russian is the default); toggle with the EN / RU switcher in the top-right corner, choice is saved across visits
  • Smooth animations โ€” wobble shake, triangle window fade-in, answer text fade-up
  • Mobile-first โ€” optimised for phones, works in all modern browsers
  • Capacitor-ready โ€” structured for a future App Store / Google Play release with minimal changes

Tech stack

Framework React 18 + TypeScript (strict)
Build tool Vite 5
i18n react-i18next + i18next-browser-languagedetector
Styling CSS Modules (no UI library)
Hosting GitHub Pages via GitHub Actions
Future mobile Capacitor (stub committed, ready to add)

Getting started

# Install dependencies
npm install

# Start dev server
npm run dev

# Production build
npm run build

# Preview production build locally
npm run preview

Project structure

src/
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ MagicBall.tsx        # The ball visual + shake button
โ”‚   โ””โ”€โ”€ LanguageSwitcher.tsx # EN / RU toggle
โ”œโ”€โ”€ hooks/
โ”‚   โ””โ”€โ”€ useDeviceMotion.ts   # Shake detection (Capacitor swap-point)
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ answers.ts           # 20 classic answers ร— 2 languages
โ”œโ”€โ”€ i18n/
โ”‚   โ”œโ”€โ”€ index.ts             # i18next initialisation
โ”‚   โ””โ”€โ”€ locales/
โ”‚       โ”œโ”€โ”€ en.ts            # English UI strings
โ”‚       โ””โ”€โ”€ ru.ts            # Russian UI strings
โ”œโ”€โ”€ styles/                  # CSS Modules
โ”œโ”€โ”€ types/index.ts           # Shared TypeScript types
โ””โ”€โ”€ App.tsx                  # State machine & orchestration

Deployment

Every push to main automatically builds and deploys to GitHub Pages via GitHub Actions (.github/workflows/deploy.yml). No manual steps needed.


Adding Capacitor (future mobile)

A capacitor.config.ts stub is already committed. When ready:

npm install @capacitor/core @capacitor/cli @capacitor/ios @capacitor/android
npx cap add ios
npx cap add android

# Build for native (overrides the GitHub Pages base path)
npx vite build --base /
npx cap sync
npx cap open ios

To use native shake detection, replace the DeviceMotionEvent listener in src/hooks/useDeviceMotion.ts with @capacitor/motion.

About

๐ŸŽฑ Magic 8-Ball โ€” shake your phone (or tap) to get a mystical answer. Built with React + TypeScript, supports English & Russian.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages