From 8dafbbd1dbede0b4b85037a7b0530bd4616c21f8 Mon Sep 17 00:00:00 2001 From: Parsa Gholipour <12parsa@gmail.com> Date: Tue, 4 Oct 2022 11:01:37 +0330 Subject: [PATCH] Make custom driver --- src/main.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index e7109d0..12ac813 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,11 @@ +// @ts-nocheck + import './style.css' import Sharee from "./lib/Sharee"; import initVue from './vue/main'; import initReact from './react/main'; import TelegramDriver from "./lib/drivers/TelegramDriver"; +import TelegramSvg from "*?raw"; if (document.location.pathname === '/vue') { initVue() @@ -31,11 +34,31 @@ if (document.location.pathname === '/vue') { </div> </div> ` + function customDriver(lang, options) { + this.lang = lang + this.options = options + this.buttonText = 'Telegram' + this.icon = '<svg style="transform:scale(0.83)" fill="currentColor" width="512px" height="512px" viewBox="-32 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="M433.941 65.941l-51.882-51.882A48 48 0 0 0 348.118 0H176c-26.51 0-48 21.49-48 48v48H48c-26.51 0-48 21.49-48 48v320c0 26.51 21.49 48 48 48h224c26.51 0 48-21.49 48-48v-48h80c26.51 0 48-21.49 48-48V99.882a48 48 0 0 0-14.059-33.941zM266 464H54a6 6 0 0 1-6-6V150a6 6 0 0 1 6-6h74v224c0 26.51 21.49 48 48 48h96v42a6 6 0 0 1-6 6zm128-96H182a6 6 0 0 1-6-6V54a6 6 0 0 1 6-6h106v88c0 13.255 10.745 24 24 24h88v202a6 6 0 0 1-6 6zm6-256h-64V48h9.632c1.591 0 3.117.632 4.243 1.757l48.368 48.368a6 6 0 0 1 1.757 4.243V112z"/></svg>' + this.backgroundColor = '#366a81' + this.backgroundHoverColor = '#0371aa' + this.textColor = '#fff' + this.textHoverColor = '#fff' + this.getLink = () => { + return 'http://google.com' + } + this.getButtonText = () => { + // @ts-ignore + return this.lang[this.buttonText.replaceAll(' ', '_')] || this.buttonText; + } + this.rippleColor = '#ffffff75' + } + Sharee.addDriver('tel', TelegramDriver) + Sharee.addDriver('tel2', customDriver) new Sharee(document.querySelector('#sharee')!, { mode: 'dropdown', lang: 'fa', - drivers: ['tel'] + drivers: ['tel', 'tel2'] }) new Sharee(document.querySelector('#sharee-text')!, {