@@ -3,19 +3,35 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
33import map from 'ramda/src/map.js' ;
44import selfoss from './selfoss-base' ;
55import * as icons from './icons' ;
6+ import { Configuration } from './model/Configuration' ;
67
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 {
816 const { icon } = sharer ;
917 return {
1018 ...sharer ,
19+ // We want to allow people to use <svg> or <img> in user.js
1120 icon : typeof icon === 'string' && icon . includes ( '<' ) ? < span dangerouslySetInnerHTML = { { __html : icon } } /> : icon ,
1221 } ;
1322}
1423
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+
1632 return useMemo (
17- ( ) => {
18- const availableSharers = {
33+ ( ) : Array < Sharer > => {
34+ const availableSharers : { [ key : string ] : Sharer } = {
1935 'a' : {
2036 label : _ ( 'share_native_label' ) ,
2137 icon : < FontAwesomeIcon icon = { icons . share } /> ,
0 commit comments