Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jgmullor committed Apr 7, 2020
0 parents commit 1357262
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
env: {
browser: true,
node: true,
es6: true
},
extends: [
'eslint:recommended',
'plugin:vue/vue3-recommended'
],
rules: {
}
}
119 changes: 119 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package-lock.json

# Created by .ignore support plugin (hsz.mobi)
### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env


### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

.idea
*.iws
*.iml

cmake-build-debug/


## Plugin-specific files:

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.nuxt/
coverage/
dist/
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"semi": false,
"singleQuote": true
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
nuxt-typeform

Copyright (C) 2020, jgmullor

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# nuxt-typeform
A NuxtJS wrapper for [Typeform Embed SDK](https://developer.typeform.com/embed/).

## Installation

```bash
$ npm install --save nuxt-typeform # or yarn add
```

## Setup
- Install with
```
npm install --save nuxt-typeform
// or
yarn add nuxt-typeform
```
- Add `nuxt-typeform` to `modules` section of `nuxt.config.js`
```js
modules: [
'nuxt-typeform',
]
```

## Usage
```js
<Typeform
url="https://test.typeform.com/to/test"
:hide-headers="true"
:hide-footer="true"
:button-text="Send"
:opacity="0"
:on-submit="onSubmit"
/>
```

```js
export default {
methods: {
...
onSubmit () {
console.log('Typeform successfully submitted')
}
}
}
```

## Component Options

#### `url` (required)
typeform's URL (like: https://admin.typeform.com/to/PlBzgL)

#### `hide-headers` (optional)
Hide typeform header, that appears when you have a Question group, or a long question that you need to scroll through to answer, like a Multiple Choice block.

#### `hide-footer` (optional)
Hide typeform footer, that appears showing the progress bar and the navigation buttons.

#### `opacity` (optional)
You can make your typeform's background totally transparent, or opaque. (For example, to have a video as a background)

#### `button-text` (optional)
The button text that appears on mobile in order to open the typeform.

#### `on-submit` (optional)
**PRO+ accounts only** Callback function that will be executed right after the typeform is successfully submitted.

## Development

```bash
$ git clone https://github.com/jgmullor/nuxt-typeform.git
$ cd nuxt-typeform
$ npm
```

## License
Code released under the [MIT license](LICENSE.txt).
14 changes: 14 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { resolve } = require('path')

module.exports = function () {
this.addPlugin({
fileName: 'nuxt-typeform.js',
src: resolve(__dirname, 'plugin.js'),
options: {},
template: {
ssr: false
}
});
}

module.exports.meta = require('./package.json')
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "nuxt-typeform",
"version": "0.0.1",
"description": "Embed Typeform surveys in your NuxtJS application",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jgmullor/nuxt-typeform.git"
},
"keywords": [
"nuxtJS",
"vue",
"typeform",
"vuejs"
],
"author": "Jose Gilberto Mullor <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/jgmullor/nuxt-typeform/issues"
},
"homepage": "https://github.com/jgmullor/nuxt-typeform",
"dependencies": {
"@typeform/embed": "^0.16"
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint-plugin-vue": "^7.0.0-alpha.0"
}
}
45 changes: 45 additions & 0 deletions plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Vue from 'vue';
import * as typeformEmbed from '@typeform/embed';

Vue.component('Typeform', {
props: {
url: {
type: String,
required: true
},
hideHeaders: {
type: Boolean,
default: true
},
hideFooter: {
type: Boolean,
default: true
},
opacity: {
type: Number,
default: 100
},
buttonText: {
type: String,
default: undefined
},
onSubmit: {
type: Function,
default: undefined
}
},
mounted () {
const options = {
hideHeaders: this.hideHeaders,
hideFooter: this.hideFooter,
opacity: this.opacity,
buttonText: this.buttonText,
onSubmit: this.onSubmit
}

typeformEmbed.makeWidget(this.$el, this.url, options)
},
render(createElement) {
return createElement('div');
}
});

0 comments on commit 1357262

Please sign in to comment.