feat: implement calculator app with pseudo-auth and CI/CD
Some checks failed
continuous-integration/drone/push Build is failing

- Calculator with full keyboard support and click interaction
- Pseudo-auth via localStorage (any login accepted)
- Dark theme (AntD ConfigProvider + custom styles)
- Responsive layout from 320px
- CI/CD: service.yaml + .drone.yml for deployment to test-calculator.vigdorov.ru

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alina
2026-02-17 21:03:52 +03:00
parent 56fee5cbdf
commit 37c201975c
31 changed files with 5286 additions and 0 deletions

View File

@ -0,0 +1,39 @@
import { createContext, useContext, useState, useCallback, type ReactNode } from 'react';
interface AuthContextType {
user: string | null;
login: (name: string) => void;
logout: () => void;
}
const STORAGE_KEY = 'calculator_user';
const AuthContext = createContext<AuthContextType | null>(null);
export function AuthProvider({ children }: { children: ReactNode }) {
const [user, setUser] = useState<string | null>(
() => localStorage.getItem(STORAGE_KEY),
);
const login = useCallback((name: string) => {
localStorage.setItem(STORAGE_KEY, name);
setUser(name);
}, []);
const logout = useCallback(() => {
localStorage.removeItem(STORAGE_KEY);
setUser(null);
}, []);
return (
<AuthContext.Provider value={{ user, login, logout }}>
{children}
</AuthContext.Provider>
);
}
export function useAuth() {
const ctx = useContext(AuthContext);
if (!ctx) throw new Error('useAuth must be used within AuthProvider');
return ctx;
}