Skip to content

Commit

Permalink
Make custom driver
Browse files Browse the repository at this point in the history
  • Loading branch information
parsagholipour committed Oct 4, 2022
1 parent 5089743 commit 8dafbbd
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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')!, {
Expand Down

0 comments on commit 8dafbbd

Please sign in to comment.