@@ -3,19 +3,35 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
3
import map from 'ramda/src/map.js' ;
4
4
import selfoss from './selfoss-base' ;
5
5
import * as icons from './icons' ;
6
+ import { Configuration } from './model/Configuration' ;
6
7
7
- function materializeSharerIcon ( sharer ) {
8
+ type Sharer = {
9
+ label : string ,
10
+ icon : string | JSX . Element ,
11
+ action : ( params : { url : string , title : string } ) => void ,
12
+ available ?: boolean ,
13
+ } ;
14
+
15
+ function materializeSharerIcon ( sharer : Sharer ) : Sharer {
8
16
const { icon } = sharer ;
9
17
return {
10
18
...sharer ,
19
+ // We want to allow people to use <svg> or <img> in user.js
11
20
icon : typeof icon === 'string' && icon . includes ( '<' ) ? < span dangerouslySetInnerHTML = { { __html : icon } } /> : icon ,
12
21
} ;
13
22
}
14
23
15
- export function useSharers ( { configuration, _ } ) {
24
+ export function useSharers (
25
+ args : {
26
+ configuration : Configuration ,
27
+ _ : ( identifier : string , params ?: { [ index : string ] : string } ) => string ,
28
+ } ,
29
+ ) : Array < Sharer > {
30
+ const { configuration, _ } = args ;
31
+
16
32
return useMemo (
17
- ( ) => {
18
- const availableSharers = {
33
+ ( ) : Array < Sharer > => {
34
+ const availableSharers : { [ key : string ] : Sharer } = {
19
35
'a' : {
20
36
label : _ ( 'share_native_label' ) ,
21
37
icon : < FontAwesomeIcon icon = { icons . share } /> ,
0 commit comments