@@ -47,68 +47,97 @@ defmodule AlgoraWeb.Forms.BountyForm do
4747
4848 def bounty_form ( assigns ) do
4949 ~H"""
50- < . form id = "main-bounty-form " for = { @ form } phx-submit = "create_bounty_main " >
51- < div class = "space-y-4 " >
52- < div class = "grid grid-cols-2 gap-4 " phx-update = "ignore " id = "main-bounty-form-tabs " >
53- <%= for { label , value } <- type_options ( ) do %>
54- < label class = { [
55- "group relative flex cursor-pointer rounded-lg px-3 py-2 shadow-sm focus:outline-none" ,
56- "border-2 bg-background transition-all duration-200 hover:border-primary hover:bg-primary/10" ,
57- "border-border has-[:checked]:border-primary has-[:checked]:bg-primary/10"
58- ] } >
59- < . input
60- id = { "main-bounty-form-type-#{ value } " }
61- type = "radio "
62- field = { @ form [ :type ] }
63- checked = { @ form [ :type ] . value == value }
64- value = { value }
65- class = "sr-only "
66- phx-click = {
67- % JS { }
68- |> JS . hide ( to: "#main-bounty-form [data-tab]:not([data-tab=#{ value } ])" )
69- |> JS . show ( to: "#main-bounty-form [data-tab=#{ value } ]" )
70- }
71- />
72- < span class = "flex flex-1 items-center justify-between " >
73- < span class = "text-sm font-medium " > { label } </ span >
74- < . icon
75- name = "tabler-check "
76- class = "invisible size-5 text-primary group-has-[:checked]:visible "
50+ < . bounty_form_wrapper has_fresh_token? = { @ has_fresh_token? } >
51+ < . form id = "main-bounty-form " for = { @ form } phx-submit = "create_bounty_main " >
52+ < div class = "space-y-4 " >
53+ < div class = "grid grid-cols-2 gap-4 " phx-update = "ignore " id = "main-bounty-form-tabs " >
54+ <%= for { label , value } <- type_options ( ) do %>
55+ < label class = { [
56+ "group relative flex cursor-pointer rounded-lg px-3 py-2 shadow-sm focus:outline-none" ,
57+ "border-2 bg-background transition-all duration-200 hover:border-primary hover:bg-primary/10" ,
58+ "border-border has-[:checked]:border-primary has-[:checked]:bg-primary/10"
59+ ] } >
60+ < . input
61+ id = { "main-bounty-form-type-#{ value } " }
62+ type = "radio "
63+ field = { @ form [ :type ] }
64+ checked = { @ form [ :type ] . value == value }
65+ value = { value }
66+ class = "sr-only "
67+ phx-click = {
68+ % JS { }
69+ |> JS . hide ( to: "#main-bounty-form [data-tab]:not([data-tab=#{ value } ])" )
70+ |> JS . show ( to: "#main-bounty-form [data-tab=#{ value } ]" )
71+ }
7772 />
78- </ span >
79- </ label >
80- <% end %>
81- </ div >
73+ < span class = "flex flex-1 items-center justify-between " >
74+ < span class = "text-sm font-medium " > { label } </ span >
75+ < . icon
76+ name = "tabler-check "
77+ class = "invisible size-5 text-primary group-has-[:checked]:visible "
78+ />
79+ </ span >
80+ </ label >
81+ <% end %>
82+ </ div >
8283
83- < div data-tab = "github " >
84- < . input
85- label = "URL "
86- field = { @ form [ :url ] }
87- placeholder = "https://github.com/owner/repo/issues/123 "
88- />
89- </ div >
84+ < div data-tab = "github " >
85+ < . input
86+ label = "URL "
87+ field = { @ form [ :url ] }
88+ placeholder = "https://github.com/owner/repo/issues/123 "
89+ />
90+ </ div >
91+
92+ < div data-tab = "custom " class = "hidden space-y-4 " >
93+ < . input label = "Title " field = { @ form [ :title ] } placeholder = "Brief description of the bounty " />
94+ < . input
95+ label = "Description (optional) "
96+ field = { @ form [ :description ] }
97+ type = "textarea "
98+ placeholder = "Requirements and acceptance criteria "
99+ />
100+ </ div >
90101
91- < div data-tab = "custom " class = "hidden space-y-4 " >
92- < . input label = "Title " field = { @ form [ :title ] } placeholder = "Brief description of the bounty " />
93- < . input
94- label = "Description (optional) "
95- field = { @ form [ :description ] }
96- type = "textarea "
97- placeholder = "Requirements and acceptance criteria "
98- />
102+ < . input label = "Amount " icon = "tabler-currency-dollar " field = { @ form [ :amount ] } />
99103 </ div >
104+ < div class = "pt-4 ml-auto flex gap-4 " >
105+ < . button variant = "secondary " phx-click = "close_share_drawer " type = "button " >
106+ Cancel
107+ </ . button >
108+ < . button type = "submit " >
109+ Share Bounty < . icon name = "tabler-arrow-right " class = "-mr-1 ml-2 h-4 w-4 " />
110+ </ . button >
111+ </ div >
112+ </ . form >
113+ </ . bounty_form_wrapper >
114+ """
115+ end
100116
101- < . input label = "Amount " icon = "tabler-currency-dollar " field = { @ form [ :amount ] } />
102- </ div >
103- < div class = "pt-4 ml-auto flex gap-4 " >
104- < . button variant = "secondary " phx-click = "close_share_drawer " type = "button " >
105- Cancel
106- </ . button >
107- < . button type = "submit " >
108- Share Bounty < . icon name = "tabler-arrow-right " class = "-mr-1 ml-2 h-4 w-4 " />
109- </ . button >
117+ def bounty_form_wrapper ( assigns ) do
118+ ~H"""
119+ <%= if @ has_fresh_token? do %>
120+ { render_slot ( @ inner_block ) }
121+ <% else %>
122+ < div class = "relative " >
123+ < div class = "absolute inset-0 z-10 bg-background/50 " />
124+ < div class = "pointer-events-none saturate-0 " >
125+ { render_slot ( @ inner_block ) }
126+ </ div >
127+ < . alert
128+ variant = "default "
129+ class = "absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-20 w-auto flex flex-col items-center justify-center gap-2 text-center "
130+ >
131+ < . alert_title > Let's get you started</ . alert_title >
132+ < . alert_description >
133+ Connect your GitHub account to create a bounty
134+ </ . alert_description >
135+ < . button type = "submit " href = { Algora.Github . authorize_url ( ) } >
136+ Connect GitHub < . icon name = "tabler-arrow-right " class = "-mr-1 ml-2 h-4 w-4 " />
137+ </ . button >
138+ </ . alert >
110139 </ div >
111- </ . form >
140+ <% end % >
112141 """
113142 end
114143end
0 commit comments