Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update angular and vue sdks #192

Merged
merged 1 commit into from
Feb 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,35 @@
"@microlink/vanilla": "^5.0.12"
},
"devDependencies": {
"@angular-devkit/build-angular": "latest",
"@angular-devkit/build-ng-packagr": "latest",
"@angular/cli": "latest",
"@angular/common": "latest",
"@angular/compiler": "latest",
"@angular/compiler-cli": "latest",
"@angular/core": "latest",
"@angular/forms": "latest",
"@angular/language-service": "latest",
"@angular/platform-browser": "latest",
"@angular/platform-browser-dynamic": "latest",
"@babel/core": "latest",
"@angular-devkit/build-angular": "~0.803.23",
"@angular-devkit/build-ng-packagr": "~0.803.23",
"@angular/cli": "~8.3.23",
"@angular/common": "~8.2.14",
"@angular/compiler": "~8.2.14",
"@angular/compiler-cli": "~8.2.14",
"@angular/core": "~8.2.14",
"@angular/forms": "^8.2.14",
"@angular/language-service": "~8.2.14",
"@angular/platform-browser": "^8.2.14",
"@angular/platform-browser-dynamic": "^8.2.14",
"@babel/core": "^7.8.4",
"@microlink/demo-links": "latest",
"@storybook/angular": "latest",
"@types/node": "latest",
"babel-loader": "latest",
"codelyzer": "latest",
"ng-packagr": "latest",
"babel-loader": "^8.0.6",
"codelyzer": "^5.0.0",
"ng-packagr": "^5.4.0",
"prettier-standard": "latest",
"protractor": "latest",
"protractor": "~5.4.0",
"react": "latest",
"react-dom": "latest",
"rxjs": "latest",
"rxjs": "^6.4.0",
"styled-components": "latest",
"ts-node": "latest",
"tsickle": "latest",
"tslint": "latest",
"typescript": "3.7.5",
"zone.js": "latest"
"ts-node": "~7.0.0",
"tsickle": "^0.37.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3",
"zone.js": "^0.9.1"
},
"peerDependencies": {
"@angular/core": "^8",
Expand Down
13 changes: 11 additions & 2 deletions packages/angular/src/microlink/microlink.component.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
import {
AfterViewInit,
Component,
ElementRef,
Input,
OnChanges,
SimpleChanges,
ViewChild
} from '@angular/core'
import ReactDOM from 'react-dom'
import microlink from '@microlink/vanilla'

@Component({
selector: 'microlink',
template: '<div #cardSpace class="microlink_angular_dom"></div>'
})
export class MicrolinkComponent {
export class MicrolinkComponent implements AfterViewInit, OnChanges {
@Input() url: string
@Input() options: object

@ViewChild('cardSpace', { static: false }) cardSpace: ElementRef

renderCard () {
const { nativeElement } = this.cardSpace

if (nativeElement && nativeElement.childNodes.length > 0) {
ReactDOM.unmountComponentAtNode(nativeElement)
}

const anchor = document.createElement('a')
anchor.href = this.url
anchor.innerHTML = this.url

microlink(anchor, this.options, this.cardSpace.nativeElement)
microlink(anchor, this.options, nativeElement)
}

ngAfterViewInit () {
Expand Down
6 changes: 6 additions & 0 deletions packages/vue/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Vue from 'vue'
import ReactDOM from 'react-dom'
import microlink from '@microlink/vanilla'

const camelCase = string => string.replace(/-([a-z])/g, g => g[1].toUpperCase())
Expand All @@ -18,6 +19,11 @@ export const Microlink = Vue.component('Microlink', {
methods: {
renderCard () {
const { cardSpace } = this.$refs

if (cardSpace && cardSpace.childNodes.length > 0) {
ReactDOM.unmountComponentAtNode(cardSpace)
}

const anchor = document.createElement('a')
anchor.href = this.url
anchor.innerHTML = this.url
Expand Down