Skip to content

Commit

Permalink
Merge pull request #7 from jepser/fix-new-confab-url
Browse files Browse the repository at this point in the history
Update new confab url
  • Loading branch information
jepser authored Jul 13, 2019
2 parents 148209b + 5a59f8f commit e417a7b
Show file tree
Hide file tree
Showing 8 changed files with 9,227 additions and 203 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"react-dom": "^16.0.0"
},
"devDependencies": {
"@commitlint/cli": "^7.0.0",
"@commitlint/config-conventional": "^7.0.1",
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
"babel-core": "^6.26.3",
"babel-jest": "^23.0.1",
"babel-preset-env": "^1.7.0",
Expand All @@ -31,7 +31,7 @@
"semantic-release": "^15.5.1"
},
"scripts": {
"test": "jest",
"test": "jest ./src",
"precommit": "lint-staged",
"commitmsg": "commitlint -E GIT_PARAMS",
"format": "prettier-standard 'src/**/*.js'",
Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const EMBED_URL = 'https://public-assets.typeform.com/confab/embed.js'
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './ReactCui'
export { default } from './ReactCui'
export { default } from './react-cui'
17 changes: 2 additions & 15 deletions src/ReactCui.js → src/react-cui.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { Component, Fragment, createRef } from 'react'
import PropTypes from 'prop-types'

export const EMBED_URL = 'https://labs-assets.typeform.com/cui/cui-embed.js'
import { scriptTagExists } from './utils'
import { EMBED_URL } from './constants'

class Cui extends Component {
constructor () {
Expand Down Expand Up @@ -49,17 +50,3 @@ Cui.propTypes = {
}

export default Cui

const getScriptTags = ({ document }) => {
const scriptTags = document.getElementsByTagName('head')[0].childNodes
const cuiEmbedScriptTags = [].filter.call(scriptTags, script => {
return script.src === EMBED_URL
})
return cuiEmbedScriptTags
}

const scriptTagExists = ({ document }) => {
const scriptTags = getScriptTags({ document })

return !!scriptTags.length
}
5 changes: 4 additions & 1 deletion src/ReactCui.test.js → src/react-cui.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from 'react'
import { shallow, mount, configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import Cui, { EMBED_URL } from './ReactCui'
import Cui from './react-cui'
import { EMBED_URL } from './constants'

console.log(EMBED_URL)

configure({ adapter: new Adapter() })

Expand Down
15 changes: 15 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { EMBED_URL } from './constants'

export const getScriptTags = ({ document }) => {
const scriptTags = document.getElementsByTagName('head')[0].childNodes
const cuiEmbedScriptTags = [].filter.call(scriptTags, script => {
return script.src === EMBED_URL
})
return cuiEmbedScriptTags
}

export const scriptTagExists = ({ document }) => {
const scriptTags = getScriptTags({ document })

return !!scriptTags.length
}
Loading

0 comments on commit e417a7b

Please sign in to comment.