55from ._base import InputActionBase , WidthLocM
66
77
8- # TODO: Use mixin for dowloadlink and download button
9- class DownloadLink (InputActionBase ):
8+ class _DownloadMixin (WidthLocM , InputActionBase ):
9+ """Mixin for download controls."""
10+
11+ def __init__ (self , page : Page , id : str , * , loc_suffix : str ) -> None :
12+ super ().__init__ (
13+ page ,
14+ id = id ,
15+ loc = f"#{ id } .shiny-download-link{ loc_suffix } " ,
16+ )
17+
18+
19+ class DownloadLink (_DownloadMixin ):
1020 """
1121 Controller for :func:`shiny.ui.download_link`.
1222 """
@@ -22,17 +32,10 @@ def __init__(self, page: Page, id: str) -> None:
2232 id
2333 The ID of the download link.
2434 """
25- super ().__init__ (
26- page ,
27- id = id ,
28- loc = f"#{ id } .shiny-download-link:not(.btn)" ,
29- )
35+ super ().__init__ (page , id = id , loc_suffix = ":not(.btn)" )
3036
3137
32- class DownloadButton (
33- WidthLocM ,
34- InputActionBase ,
35- ):
38+ class DownloadButton (_DownloadMixin ):
3639 """
3740 Controller for :func:`shiny.ui.download_button`
3841 """
@@ -48,8 +51,4 @@ def __init__(self, page: Page, id: str) -> None:
4851 id
4952 The ID of the download button.
5053 """
51- super ().__init__ (
52- page ,
53- id = id ,
54- loc = f"#{ id } .btn.shiny-download-link" ,
55- )
54+ super ().__init__ (page , id = id , loc_suffix = ".btn" )
0 commit comments