Last active
June 28, 2019 14:37
-
-
Save RecuencoJones/a715a390f801dd94f739a69e1dcaf22a to your computer and use it in GitHub Desktop.
Framer X Stencil integration
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
// Using "@stencil/core": "0.14.1" | |
exports.config = { | |
namespace: 'CustomComponents', | |
bundles: [ | |
{ | |
components: [ 'text-field' ] | |
} | |
], | |
outputTargets: [ | |
{ | |
type: 'dist' | |
}, { | |
type: 'www', | |
indexHtml: './index.html' | |
} | |
] | |
} |
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
import { Component, Prop } from '@stencil/core'; | |
@Component({ tag: 'text-field' }) | |
export class TextField { | |
@Prop() | |
public text: string; | |
public render() { | |
return ( | |
<div> | |
{ this.text } | |
</div> | |
); | |
} | |
} |
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
import * as React from "react"; | |
import { PropertyControls, ControlType } from "framer"; | |
import { defineCustomElements } from "stencil-component/dist/loader"; | |
const style: React.CSSProperties = { | |
height: "100%", | |
display: "flex", | |
alignItems: "center", | |
justifyContent: "center", | |
textAlign: "center", | |
color: "#8855FF", | |
background: "rgba(136, 85, 255, 0.1)", | |
overflow: "hidden", | |
}; | |
declare global { | |
namespace JSX { | |
interface IntrinsicElements { | |
'text-field': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & Props, HTMLElement>; | |
} | |
} | |
} | |
// Define type of property | |
interface Props { | |
text: string; | |
} | |
export class TextField extends React.Component<Props> { | |
// Set default properties | |
static defaultProps = { | |
text: "Hello World!" | |
} | |
// Items shown in property panel | |
static propertyControls: PropertyControls<Props> = { | |
text: { type: ControlType.String, title: "Text" }, | |
} | |
render() { | |
return ( | |
<div style={ style }> | |
<text-field text={ this.props.text }></text-field> | |
</div> | |
); | |
} | |
} | |
defineCustomElements(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment