@@ -2,115 +2,89 @@ import ForesightButtonVisibility from "./test-buttons/ForesightButtonVisibility"
22import ForesightButtonResizeable from "./test-buttons/ForesightButtonResizeable"
33import ForesightButtonRemoveable from "./test-buttons/ForesightButtonRemoveable"
44import ForesightButtonNoName from "./test-buttons/ForesightButtonNoName"
5- import { useResetKey } from "../stores/ButtonStateStore"
6- import { ForesightManager } from "js.foresight"
7- import { useEffect } from "react"
5+ import {
6+ useButtonActions ,
7+ useIsRemoved ,
8+ useIsResized ,
9+ useIsVisible ,
10+ useResetKey ,
11+ } from "../stores/ButtonStateStore"
812import ForesightButtonError from "./test-buttons/ForesightButtonError"
913import { Navigation } from "./Navigation"
10- import ForesightReactiveButton from "./test-buttons/ForesightReactiveButton"
1114
12- export const Main = ( ) => {
13- const resetKey = useResetKey ( )
15+ type SectionProps = {
16+ title : string
17+ toggleLabel ?: string
18+ toggleOn ?: boolean
19+ onToggle ?: ( ) => void
20+ children : React . ReactNode
21+ }
1422
15- useEffect ( ( ) => {
16- const handleCallbackFired = ( ) => { }
23+ function Section ( { title, toggleLabel, toggleOn, onToggle, children } : SectionProps ) {
24+ return (
25+ < section className = "border-t border-gray-300 pb-8" >
26+ < div className = "sticky top-12 z-[5] -mx-6 px-6 py-4 bg-stone-50/95 backdrop-blur flex items-center justify-between mb-6" >
27+ < h3 className = "text-lg font-semibold text-gray-900" > { title } </ h3 >
28+ { toggleLabel && onToggle && (
29+ < button
30+ onClick = { onToggle }
31+ className = "px-2 py-1 text-xs border border-gray-400 text-gray-800 hover:bg-gray-100"
32+ >
33+ { toggleLabel } : { toggleOn ? "on" : "off" }
34+ </ button >
35+ ) }
36+ </ div >
37+ { children }
38+ </ section >
39+ )
40+ }
1741
18- ForesightManager . instance . addEventListener ( "callbackCompleted" , handleCallbackFired )
42+ export const Main = ( ) => {
43+ const resetKey = useResetKey ( )
44+ const actions = useButtonActions ( )
45+ const isVisible = useIsVisible ( )
46+ const isRemoved = useIsRemoved ( )
47+ const isResized = useIsResized ( )
1948
20- return ( ) => {
21- ForesightManager . instance . removeEventListener ( "callbackCompleted" , handleCallbackFired )
22- }
23- } , [ ] )
2449 return (
25- < div
26- key = { resetKey }
27- className = "min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 font-sans"
28- >
50+ < div key = { resetKey } className = "min-h-screen bg-stone-50 text-gray-900" >
2951 < Navigation />
3052
31- { /* Test Buttons Section */ }
32- < div className = "max-w-full mx-auto px-6 py-12" >
33- < div className = "text-center mb-12" >
34- < h2 className = "text-3xl font-bold text-gray-900 mb-4" > Interactive Test Buttons </ h2 >
35- < p className = "text-lg text-gray-600 max-w-2xl mx-auto" >
36- Each button demonstrates different ForesightJS behaviors and configurations. Hover over
37- them to trigger predictive callbacks and observe the interactions.
38- </ p >
39- </ div >
53+ < main className = "max-w-6xl mx-auto px-6 pb-16" >
54+ < Section
55+ title = "Resizable elements"
56+ toggleLabel = "Resize"
57+ toggleOn = { isResized }
58+ onToggle = { actions . toggleResized }
59+ >
60+ < ForesightButtonResizeable name = "resizeable" / >
61+ </ Section >
4062
41- < div className = "space-y-12" >
42- { /* Dynamic Behavior Group */ }
43- < div className = "bg-white/70 backdrop-blur-sm rounded-2xl p-8 border border-gray-200/50 shadow-lg" >
44- < div className = "flex items-center gap-3 mb-6" >
45- < div className = "w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center" >
46- < svg
47- className = "w-5 h-5 text-blue-600"
48- fill = "none"
49- stroke = "currentColor"
50- viewBox = "0 0 24 24"
51- >
52- < path
53- strokeLinecap = "round"
54- strokeLinejoin = "round"
55- strokeWidth = { 2 }
56- d = "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
57- />
58- </ svg >
59- </ div >
60- < h3 className = "text-2xl font-semibold text-gray-900" > Dynamic Behavior</ h3 >
61- </ div >
62- < p className = "text-gray-600 mb-8" >
63- Test elements with dynamic properties like resizing, removal, and visibility
64- </ p >
65- < div className = "mb-8" >
66- < h4 className = "text-lg font-medium text-gray-800 mb-4" > Resizable Elements</ h4 >
67- < ForesightButtonResizeable name = "resizeable" />
68- </ div >
69- < div className = "mb-8" >
70- < h4 className = "text-lg font-medium text-gray-800 mb-4" > Removable Elements</ h4 >
71- < div className = "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8" >
72- < ForesightButtonRemoveable name = "removeable" />
73- < ForesightButtonRemoveable name = "removeable2" />
74- < ForesightButtonRemoveable name = "removeable3" />
75- </ div >
76- </ div >
77- < div >
78- < h4 className = "text-lg font-medium text-gray-800 mb-4" > Visibility Elements</ h4 >
79- < div className = "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8" >
80- < ForesightButtonVisibility name = "visibility" />
81- </ div >
82- </ div >
83- </ div >
63+ < Section
64+ title = "Removable elements"
65+ toggleLabel = "Remove"
66+ toggleOn = { isRemoved }
67+ onToggle = { actions . toggleRemoved }
68+ >
69+ < ForesightButtonRemoveable name = "removeable" />
70+ </ Section >
71+
72+ < Section
73+ title = "Visibility elements"
74+ toggleLabel = "Visible"
75+ toggleOn = { isVisible }
76+ onToggle = { actions . toggleVisibility }
77+ >
78+ < ForesightButtonVisibility name = "visibility" />
79+ </ Section >
8480
85- { /* Edge Cases Group */ }
86- < div className = "bg-white/70 backdrop-blur-sm rounded-2xl p-8 border border-gray-200/50 shadow-lg" >
87- < div className = "flex items-center gap-3 mb-6" >
88- < div className = "w-10 h-10 bg-red-100 rounded-lg flex items-center justify-center" >
89- < svg
90- className = "w-5 h-5 text-red-600"
91- fill = "none"
92- stroke = "currentColor"
93- viewBox = "0 0 24 24"
94- >
95- < path
96- strokeLinecap = "round"
97- strokeLinejoin = "round"
98- strokeWidth = { 2 }
99- d = "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.863-.833-2.632 0L4.232 15.5c-.77.833.192 2.5 1.732 2.5z"
100- />
101- </ svg >
102- </ div >
103- < h3 className = "text-2xl font-semibold text-gray-900" > Edge Cases</ h3 >
104- </ div >
105- < p className = "text-gray-600 mb-8" > Test error handling and unusual configurations</ p >
106- < div className = "grid grid-cols-2 md:grid-cols-2 gap-8" >
107- < ForesightButtonError name = "callback error" />
108- < ForesightButtonNoName />
109- < ForesightReactiveButton name = "reactive 3s" />
110- </ div >
81+ < Section title = "Edge cases" >
82+ < div className = "flex flex-wrap gap-x-6 gap-y-8" >
83+ < ForesightButtonError name = "callback error" />
84+ < ForesightButtonNoName />
11185 </ div >
112- </ div >
113- </ div >
86+ </ Section >
87+ </ main >
11488 </ div >
11589 )
11690}
0 commit comments