Last active
April 26, 2017 15:26
-
-
Save jpommerening/d4f84ac2d0cab171553574cda517d925 to your computer and use it in GitHub Desktop.
Flow types for widgets
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
{ | |
"presets": [ | |
[ "es2015", { "modules": false } ], | |
[ "flow" ] | |
], | |
"plugins": [ | |
"transform-object-rest-spread" | |
] | |
} |
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
[ignore] | |
[include] | |
[libs] | |
[options] |
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
/** | |
* Copyright 2017 aixigo AG | |
* Released under the MIT license. | |
* http://laxarjs.org/license | |
* @flow | |
*/ | |
export const injections = [ 'axFeatures' ]; | |
declare type HeadlineWidgetFeatures = { | |
headline: { htmlText: string }, | |
intro: { htmlText?: string } | |
}; | |
export function create( features: HeadlineWidgetFeatures ) { | |
return { | |
onDomAvailable( dom: HTMLElement ) { | |
[ 'headline', 'intro' ].forEach( feature => { | |
const html = features[ feature ].htmlText; | |
const element = dom.querySelector( `.${feature}-html-text` ); | |
if( !element ) { | |
return; | |
} | |
if( html ) { | |
element.innerHTML = html; | |
} | |
else { | |
element.remove(); | |
} | |
} ); | |
} | |
}; | |
} |
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
{ | |
"scripts": { | |
"flow": "flow ." | |
}, | |
"devDependencies": { | |
"babel-plugin-transform-object-rest-spread": "^6.23.0", | |
"babel-preset-es2015": "^6.24.1", | |
"babel-preset-flow": "^6.23.0", | |
"flow-bin": "^0.44.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Flow types for LaxarJS widget services: https://gist.github.com/jpommerening/634e3835d6e5ea40a23d9cfa7fc3b76a