@@ -57,74 +57,82 @@ defmodule LightningWeb.Components.Menu do
57
57
58
58
def projects_dropdown ( assigns ) do
59
59
~H"""
60
- < div class = "relative my-4 mx-2 px-2 " >
61
- < button
62
- type = "button "
63
- class = "relative w-full cursor-default rounded-md bg-white py-1.5 pl-3
60
+ <%= if length ( assigns [ :projects ] ) == 0 do %>
61
+ < div class = "p-2 mb-4 mt-4 text-center text-primary-300 bg-primary-800 " >
62
+ < span class = "inline-block align-middle text-sm " >
63
+ You don't have access to any projects
64
+ </ span >
65
+ </ div >
66
+ <% else %>
67
+ < div class = "relative my-4 mx-2 px-2 " >
68
+ < button
69
+ type = "button "
70
+ class = "relative w-full cursor-default rounded-md bg-white py-1.5 pl-3
64
71
pr-10 text-left text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300
65
72
focus:outline-none focus:ring-2 focus:ring-indigo-600 sm:text-sm sm:leading-6 "
66
- aria-haspopup = "listbox "
67
- aria-expanded = "true "
68
- aria-labelledby = "listbox-label "
69
- phx-click = { show_dropdown ( "project-picklist" ) }
70
- >
71
- < span class = "block truncate " >
72
- <%= if assigns [ :selected_project ] ,
73
- do: @ selected_project . name ,
74
- else: "Go to project" %>
75
- </ span >
76
- < span class = "pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2 " >
77
- < svg
78
- class = "h-5 w-5 text-gray-400 "
79
- viewBox = "0 0 20 20 "
80
- fill = "currentColor "
81
- aria-hidden = "true "
82
- >
83
- < path
84
- fill-rule = "evenodd "
85
- d = "M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z "
86
- clip-rule = "evenodd "
87
- />
88
- </ svg >
89
- </ span >
90
- </ button >
91
- < ul
92
- id = "project-picklist "
93
- class = "hidden absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm "
94
- tabindex = "-1 "
95
- role = "listbox "
96
- aria-labelledby = "listbox-label "
97
- aria-activedescendant = "listbox-option-3 "
98
- phx-click-away = { hide_dropdown ( "project-picklist" ) }
99
- >
100
- <%= for project <- @ projects do %>
101
- < . link navigate = { ~p" /projects/#{ project . id } /w" } >
102
- < li
103
- class = { [
104
- "text-gray-900 relative cursor-default select-none py-2 pl-3 pr-9 hover:bg-indigo-600 group hover:text-white"
105
- ] }
106
- role = "option "
73
+ aria-haspopup = "listbox "
74
+ aria-expanded = "true "
75
+ aria-labelledby = "listbox-label "
76
+ phx-click = { show_dropdown ( "project-picklist" ) }
77
+ >
78
+ < span class = "block truncate " >
79
+ <%= if assigns [ :selected_project ] ,
80
+ do: @ selected_project . name ,
81
+ else: "Go to project" %>
82
+ </ span >
83
+ < span class = "pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2 " >
84
+ < svg
85
+ class = "h-5 w-5 text-gray-400 "
86
+ viewBox = "0 0 20 20 "
87
+ fill = "currentColor "
88
+ aria-hidden = "true "
107
89
>
108
- < span class = { [
109
- "font-normal block truncate" ,
110
- assigns [ :project ] && @ project . id == project . id && "font-semibold"
111
- ] } >
112
- <%= project . name %>
113
- </ span >
114
- < span class = { [
115
- "absolute inset-y-0 right-0 flex items-center pr-4" ,
116
- ( ! assigns [ :project ] || @ project . id != project . id ) && "hidden"
117
- ] } >
118
- < . icon
119
- name = "hero-check "
120
- class = "group-hover:text-white text-indigo-600 "
121
- />
122
- </ span >
123
- </ li >
124
- </ . link >
125
- <% end %>
126
- </ ul >
127
- </ div >
90
+ < path
91
+ fill-rule = "evenodd "
92
+ d = "M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z "
93
+ clip-rule = "evenodd "
94
+ />
95
+ </ svg >
96
+ </ span >
97
+ </ button >
98
+ < ul
99
+ id = "project-picklist "
100
+ class = "hidden absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm "
101
+ tabindex = "-1 "
102
+ role = "listbox "
103
+ aria-labelledby = "listbox-label "
104
+ aria-activedescendant = "listbox-option-3 "
105
+ phx-click-away = { hide_dropdown ( "project-picklist" ) }
106
+ >
107
+ <%= for project <- @ projects do %>
108
+ < . link navigate = { ~p" /projects/#{ project . id } /w" } >
109
+ < li
110
+ class = { [
111
+ "text-gray-900 relative cursor-default select-none py-2 pl-3 pr-9 hover:bg-indigo-600 group hover:text-white"
112
+ ] }
113
+ role = "option "
114
+ >
115
+ < span class = { [
116
+ "font-normal block truncate" ,
117
+ assigns [ :project ] && @ project . id == project . id && "font-semibold"
118
+ ] } >
119
+ <%= project . name %>
120
+ </ span >
121
+ < span class = { [
122
+ "absolute inset-y-0 right-0 flex items-center pr-4" ,
123
+ ( ! assigns [ :project ] || @ project . id != project . id ) && "hidden"
124
+ ] } >
125
+ < . icon
126
+ name = "hero-check "
127
+ class = "group-hover:text-white text-indigo-600 "
128
+ />
129
+ </ span >
130
+ </ li >
131
+ </ . link >
132
+ <% end %>
133
+ </ ul >
134
+ </ div >
135
+ <% end %>
128
136
"""
129
137
end
130
138
0 commit comments