import { WebSocialShareRedditAttributes } from '../types/web-social-share-attributes' ; import { shareEncodedUrl } from './utils' ; export const reddit = async ( attrs ) => { let urlString = 'https://www.reddit.com/' ; if ( attrs . socialShareSubreddit ) { urlString += 'r/' + attrs . socialShareSubreddit + '/submit?url=' ; } else { urlString += 'submit?url=' ; } if ( attrs . socialSharePopupWidth < 900 ) { attrs . socialSharePopupWidth = 900 ; } if ( attrs . socialSharePopupHeight < 650 ) { attrs . socialSharePopupHeight = 650 ; } let url = urlString + shareEncodedUrl ( attrs . socialShareUrl ) ; if ( attrs . socialShareText ) { url += `&title=${ encodeURIComponent ( attrs . socialShareText ) }` ; } window . open ( url , 'Reddit' , 'toolbar=0,status=0,resizable=yes,width=' + attrs . socialSharePopupWidth + ',height=' + attrs . socialSharePopupHeight + ',top=' + ( window . innerHeight - attrs . socialSharePopupHeight ) / 2 + ',left=' + ( window . innerWidth - attrs . socialSharePopupWidth ) / 2 ) ; } ;