-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add React and Vue components, examples, and docs
- Loading branch information
Showing
14 changed files
with
185 additions
and
17 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div id="app"></div> | ||
|
||
<script src="https://unpkg.com/react@17/umd/react.production.min.js"></script> | ||
<script src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script> | ||
<script src="https://unpkg.com/prop-types@15/prop-types.min.js"></script> | ||
<script src="./superhero-utils/react-without-styles.js"></script> | ||
<link rel="stylesheet" href="./superhero-utils/index.css"> | ||
<script> | ||
class App extends React.Component { | ||
render() { | ||
return React.createElement('div', {}, [ | ||
React.createElement('h3', {}, ['superhero-utils example using react, script tag']), | ||
React.createElement( | ||
superheroUtils.Button, | ||
{ size: 'medium', account: 'ak_... or .chain name' }, | ||
), | ||
]); | ||
} | ||
} | ||
|
||
ReactDOM.render(React.createElement(App), document.querySelector('#app')); | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../dist |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div id="app"></div> | ||
|
||
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script> | ||
<script src="./superhero-utils/vue-without-styles.js"></script> | ||
<link rel="stylesheet" href="./superhero-utils/index.css"> | ||
<script> | ||
const App = { | ||
components: { | ||
SuperheroButton: superheroUtils.Button, | ||
}, | ||
template: ` | ||
<div> | ||
<h3>superhero-utils example using vue, script tag</h3> | ||
<SuperheroButton size="medium" account="ak_... or .chain name" /> | ||
</div> | ||
`, | ||
}; | ||
|
||
new Vue({ | ||
render: h => h(App), | ||
}).$mount('#app'); | ||
</script> |
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,5 +1,17 @@ | ||
<template> | ||
<div> | ||
Example payload | ||
<h3>superhero-utils example using vue, webpack</h3> | ||
<SuperheroButton size="medium" account="ak_... or .chain name" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import '../../superhero-utils/index.css'; | ||
import { Button } from '../../superhero-utils/vue-without-styles.js'; | ||
export default { | ||
components: { | ||
SuperheroButton: Button, | ||
}, | ||
} | ||
</script> |
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,3 +1,3 @@ | ||
import './global.scss'; | ||
export { default as createButton } from './button'; | ||
export { default as createButton, createButtonByDiv } from './button'; | ||
export { default as ensurePaid } from './paywall'; |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export * from './index'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { createButtonByDiv } from './index'; | ||
|
||
export class Button extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.button = React.createRef(); | ||
this.componentDidMount = this.componentDidUpdate = () => | ||
createButtonByDiv(this.button.current, this.props); | ||
} | ||
|
||
render() { | ||
return React.createElement('div', { ref: this.button }); | ||
} | ||
} | ||
|
||
Button.propTypes = { | ||
size: PropTypes.oneOf(['icon', 'small', 'medium', 'large']), | ||
url: PropTypes.string, | ||
account: PropTypes.string, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export * from './index'; | ||
import { createButtonByDiv } from './index'; | ||
|
||
export const Button = { | ||
props: { | ||
size: { | ||
validator: value => ['icon', 'small', 'medium', 'large'].includes(value), | ||
default: undefined, | ||
}, | ||
url: { type: String, default: undefined }, | ||
account: { type: String, default: undefined }, | ||
}, | ||
mounted() { | ||
this.$watch( | ||
({ size, url, account }) => ({ size, url, account }), | ||
(props) => createButtonByDiv(this.$refs.button, props), | ||
{ immediate: true }, | ||
); | ||
}, | ||
render(createElement) { | ||
return createElement('div', { ref: '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