1- import { Component , h , Prop , State } from '@stencil/core' ;
1+ import { Component , h , Host , Prop , State } from '@stencil/core' ;
22import state from '../store' ;
33
44@Component ( {
@@ -16,6 +16,12 @@ export class MenuDropDown {
1616 this . showDropdown = ! this . showDropdown ;
1717 }
1818
19+ viewHandler ( item ) {
20+ state . page = 1 ;
21+ this . fetchData ( item ) ;
22+ this . toggleDropdown ( ) ;
23+ }
24+
1925 buttonHandler ( item ) {
2026 state . page = 1 ;
2127 this . fetchData ( item ) ;
@@ -28,36 +34,57 @@ export class MenuDropDown {
2834
2935 render ( ) {
3036 return (
31- < div class = "relative" >
32- { /* Header */ }
33- < h2 onClick = { ( ) => this . toggleDropdown ( ) } class = "font-sans text-gray-600 hover:text-indigo-800 cursor-pointer transition text-sm capitalize flex gap-1 items-center" >
34- < svg xmlns = "http://www.w3.org/2000/svg" fill = "none" viewBox = "0 0 24 24" stroke-width = "1.5" stroke = "currentColor" class = "w-6 h-6" >
35- < path
36- stroke-linecap = "round"
37- stroke-linejoin = "round"
38- d = "M12 6.75a.75.75 0 110-1.5.75.75 0 010 1.5zM12 12.75a.75.75 0 110-1.5.75.75 0 010 1.5zM12 18.75a.75.75 0 110-1.5.75.75 0 010 1.5z"
39- />
40- </ svg >
41- </ h2 >
37+ < Host class = "relative w-full py-2" >
38+ < div onClick = { ( ) => this . toggleDropdown ( ) } class = 'w-full font-semibold pl-3 flex justify-between text-indigo-700' >
39+ { this . listTitle }
40+ < div
41+ id = "dropdownDefaultButton"
42+ data-dropdown-toggle = "dropdown"
43+ >
44+ < ul id = "dropdown" class = "flex gap-5 ml-2 mr-4 pt-1" >
45+ { this . list ?. map ( item => (
46+ < li >
47+ { item === 'Edit' && < a href = "#" class = "block text-sm" >
48+ < div class = "cursor-pointer" title = { item } onClick = { ( ) => this . buttonHandler ( this . listTitle ) } >
49+ < svg xmlns = "http://www.w3.org/2000/svg" fill = "none" viewBox = "0 0 24 24" stroke-width = "1.7" stroke = "currentColor" class = "w-5 h-5" >
50+ < path stroke-linecap = "round" stroke-linejoin = "round" d = "M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10" />
51+ </ svg >
52+
53+ </ div >
54+ </ a > }
55+ { item === 'View' && < a href = "#" class = "block text-sm " >
56+ < div class = "cursor-pointer" title = { item } onClick = { ( ) => this . viewHandler ( this . listTitle ) } >
57+ < svg xmlns = "http://www.w3.org/2000/svg" fill = "none" viewBox = "0 0 24 24" stroke-width = "1.7" stroke = "currentColor" class = "w-5 h-5" >
58+ < path stroke-linecap = "round" stroke-linejoin = "round" d = "M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z" />
59+ < path stroke-linecap = "round" stroke-linejoin = "round" d = "M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
60+ </ svg >
61+
62+ </ div >
63+ </ a > }
64+ </ li >
65+ ) ) }
66+ </ ul >
67+ </ div >
68+ </ div >
4269 < backdrop-filter showBackDrop = { this . showDropdown } backDropHandler = { this . backDropHandler } > </ backdrop-filter >
4370 { /* List */ }
44- < div
71+ { /* <div
4572 id="dropdownDefaultButton"
4673 data-dropdown-toggle="dropdown"
4774 style={{ right: '0px' }}
48- class = { this . showDropdown ? 'absolute bg-white z-10 w-44 text-sm list-none mt-2 rounded divide-y right-0 divide-gray-100 shadow ' : 'hidden' }
75+ class={this.showDropdown ? 'absolute bg-gray-300 z-50 w-44 text-sm list-none mt-2 rounded-md divide-y -bottom-1 right-2 divide-gray-100 shadow ' : 'hidden'}
4976 >
50- < ul id = "dropdown" class = "py-1 bg-white " >
77+ <ul id="dropdown" class="py-1 bg-gray-300 rounded-b-md ">
5178 {this.list?.map(item => (
5279 <li>
53- < a href = "#" onClick = { ( ) => this . buttonHandler ( this . listTitle ) } class = "block py-2 px-4 text-sm text-gray-700 hover:bg-gray-100 " >
80+ <a href="#" onClick={() => this.buttonHandler(this.listTitle)} class="block py-1 px-4 text-sm text-gray-700 cursor-pointer ">
5481 {item}
5582 </a>
5683 </li>
5784 ))}
5885 </ul>
59- </ div >
60- </ div >
86+ </div> */ }
87+ </ Host >
6188 ) ;
6289 }
6390}
0 commit comments