-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
324 additions
and
180 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
import { Component, Prop } from '@stencil/core'; | ||
import { getURL } from '../utils/index'; | ||
|
||
import { LiskButton } from '../lisk-button/lisk-button'; | ||
import { getURL } from '../utils/index'; | ||
|
||
@Component({ | ||
tag: 'lisk-button-send', | ||
styleUrl: '../lisk-button/lisk-button.scss', | ||
shadow: true | ||
}) | ||
export class LiskButtonSend extends LiskButton { | ||
constructor() { | ||
super(); | ||
this.open = this.open.bind(this); | ||
} | ||
|
||
@Prop() amount: number; | ||
@Prop() recipient: string; | ||
@Prop() buttonTitle: string | ||
@Prop() buttonTitle: string; | ||
@Prop() classNames = 'lisk-btn-send-wrapper'; | ||
|
||
open() { | ||
private open = (): void => { | ||
const { amount, recipient } = this; | ||
const url = getURL({ amount, recipient, kind: 'send' }); | ||
this.openUrl(url); | ||
} | ||
|
||
private getTitle = () => | ||
this.buttonTitle || `Send ${this.amount} LSK to ${this.recipient}` | ||
|
||
hostData() { | ||
return super.hostData(this.classNames); | ||
} | ||
|
||
render() { | ||
return <button class={`btn btn-primary ${this.loading ? 'loading' : ''} ${this.showTooltip ? 'tooltip' : ''}`} | ||
onClick={this.open} | ||
data-tooltip={this.getTooltipText()}>{this.buttonTitle || `Send ${this.amount} LSK to ${this.recipient}`}</button> | ||
return <button onClick={this.open}>{this.getTitle()}</button>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,48 @@ | ||
import { Component, Prop } from '@stencil/core'; | ||
import { getURL } from '../utils/index'; | ||
|
||
import { LiskButton } from '../lisk-button/lisk-button'; | ||
import { getURL } from '../utils/index'; | ||
|
||
@Component({ | ||
tag: 'lisk-button-sign', | ||
styleUrl: '../lisk-button/lisk-button.scss', | ||
shadow: true | ||
}) | ||
export class LiskButtonSign extends LiskButton { | ||
constructor() { | ||
super(); | ||
this.open = this.open.bind(this); | ||
} | ||
|
||
@Prop() type: string; | ||
@Prop() message: string; | ||
@Prop() buttonTitle: string; | ||
@Prop() sourceId: string = ""; | ||
@Prop() sourceId = ''; | ||
@Prop() classNames = 'lisk-btn-sign-wrapper'; | ||
|
||
getValue(): string { | ||
private getValue(): string { | ||
const input: HTMLInputElement = document.querySelector(`#${this.sourceId}`); | ||
return input.value; | ||
} | ||
|
||
open(): void { | ||
private open = (): void => { | ||
const { type, message } = this; | ||
const data = !!this.sourceId ? this.getValue() : message; | ||
const data = this.sourceId ? this.getValue() : message; | ||
const url = getURL({ | ||
message: data, | ||
kind: (type === 'nano' ? 'sign-nano' : 'sign-hub') | ||
kind: type === 'nano' ? 'sign-nano' : 'sign-hub', | ||
}); | ||
this.openUrl(url); | ||
} | ||
|
||
private getTitle = () => { | ||
const wallet = this.type === 'nano' ? 'Lisk Nano' : 'Lisk Hub'; | ||
return this.buttonTitle || `Use ${wallet} to sign the message`; | ||
} | ||
|
||
hostData() { | ||
return super.hostData(this.classNames); | ||
} | ||
|
||
render() { | ||
//NB: Lisk-nano doesn't support message pre-fill... it will just open sign message page | ||
const wallet = this.type === 'nano' ? 'Lisk Nano' : "Lisk Hub"; | ||
return <button class={`btn btn-primary ${this.loading ? 'loading' : ''} ${this.showTooltip ? 'tooltip' : ''}`} | ||
onClick={this.open} | ||
data-tooltip={this.getTooltipText()}>{this.buttonTitle || `Use ${wallet} to sign the message`}</button> | ||
// NB: Lisk-nano doesn't support message pre-fill... it will just open sign message page | ||
return <button onClick={this.open}>{this.getTitle()}</button>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,48 @@ | ||
import { Component, Prop } from '@stencil/core'; | ||
import { getURL } from '../utils/index'; | ||
|
||
import { LiskButton } from '../lisk-button/lisk-button'; | ||
import { getURL } from '../utils/index'; | ||
|
||
@Component({ | ||
tag: 'lisk-button-vote', | ||
styleUrl: '../lisk-button/lisk-button.scss', | ||
shadow: true | ||
}) | ||
export class LiskButtonVote extends LiskButton { | ||
constructor() { | ||
super(); | ||
this.open = this.open.bind(this); | ||
this.getDefaultTitle = this.getDefaultTitle.bind(this); | ||
} | ||
|
||
@Prop() unvotes: string; | ||
@Prop() votes: string; | ||
@Prop() buttonTitle: string; | ||
@Prop() classNames = 'lisk-btn-vote-wrapper'; | ||
|
||
open() { | ||
private open = (): void => { | ||
const { votes, unvotes } = this; | ||
const url = getURL({ votes, unvotes, kind: 'vote' }); | ||
this.openUrl(url); | ||
} | ||
|
||
getDefaultTitle() { | ||
private getTitel = () => this.buttonTitle || this.getDefaultTitle(); | ||
|
||
private getDefaultTitle = () => { | ||
if (this.votes) { | ||
const [first, ...others] = this.votes.split(','); | ||
return `Vote for ${first}${others.length ? ` and ${others.length} others...` : ''}`; | ||
return `Vote for ${first}${ | ||
others.length ? ` and ${others.length} others...` : '' | ||
}`; | ||
} else if (this.unvotes) { | ||
const [first, ...others] = this.unvotes.split(','); | ||
return `Unvote ${first}${others.length ? ` and ${others.length} others...` : ''}`; | ||
return `Unvote ${first}${ | ||
others.length ? ` and ${others.length} others...` : '' | ||
}`; | ||
} | ||
} | ||
|
||
hostData() { | ||
return super.hostData(this.classNames); | ||
} | ||
|
||
render() { | ||
return <button class={`btn btn-success ${this.loading ? 'loading' : ''} ${this.showTooltip ? 'tooltip' : ''}`} | ||
onClick={this.open} | ||
data-tooltip={this.getTooltipText()}>{this.buttonTitle || this.getDefaultTitle()}</button> | ||
return <button onClick={this.open}>{this.getTitel()}</button>; | ||
} | ||
} |
Oops, something went wrong.