diff --git a/src/App.css b/src/App.css new file mode 100644 index 0000000..f40c522 --- /dev/null +++ b/src/App.css @@ -0,0 +1,33 @@ +/* Accessibility Focus Styles */ +button:focus-visible, +textarea:focus-visible, +input:focus-visible { + outline: 3px solid #ffa500; + outline-offset: 2px; +} + +/* Button hover and active states */ +button:hover { + background-color: #006a8e !important; + transform: translateY(-1px); +} + +button:active { + transform: translateY(0); +} + +/* High contrast mode support */ +@media (prefers-contrast: high) { + button, + textarea { + border-width: 3px; + } +} + +/* Reduced motion support */ +@media (prefers-reduced-motion: reduce) { + button, + * { + transition: none !important; + } +} diff --git a/src/App.tsx b/src/App.tsx index 851cc82..faba58a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,46 +1,129 @@ import { useState } from 'react'; +import { add } from './stringCalculator'; +import './App.css'; const App = () => { const [input, setInput] = useState(''); - const [result] = useState(null); + const [result, setResult] = useState(null); + const [error, setError] = useState(''); - const handleCalculate = () => {}; + const handleCalculate = () => { + try { + setError(''); + const sum = add(input); + setResult(sum); + } catch (err) { + setError(err instanceof Error ? err.message : 'An error occurred'); + setResult(null); + } + }; + + const handleInputChange = (e: React.ChangeEvent) => { + setInput(e.target.value); + setError(''); + setResult(null); + }; return ( -
+
Calculator with colorful number buttons and mathematical symbols -

String Calculator

+

String Calculator

-

Enter numbers

+

+ Enter numbers below to calculate their sum +

+