Last active
January 6, 2019 10:57
-
-
Save tonilaukka/443a4fa1148f48daf0718a7b4be1ccc9 to your computer and use it in GitHub Desktop.
React Components in Framer X
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 styled from 'styled-components'; | |
const CourseContainer = styled.div` | |
background-color: ${props => props.color}; | |
background-image: url(${props => props.image}); | |
background-position: center; | |
background-size: cover; | |
height: 100%; | |
color: white; | |
padding: 20px; | |
font-size: 18px; | |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | |
font-weight: bold; | |
border-radius: 10px; | |
transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); | |
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25); | |
&:hover { | |
background: #1199EE; | |
transform: scale(1.1, 1.1) translateY(-5px); | |
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25); | |
} | |
` | |
// Define type of property | |
interface Props { | |
color: string; | |
image: string; | |
text: string; | |
} | |
export class Course extends React.Component<Props> { | |
// Set default properties | |
static defaultProps = { | |
color: "black", | |
text: "Hello World!" | |
} | |
// Items shown in property panel | |
static propertyControls: PropertyControls = { | |
color: { type: ControlType.Color, title: "Background Color" }, | |
image: { type: ControlType.Image, title: "Image"}, | |
text: { type: ControlType.String, title: "Text" }, | |
} | |
render() { | |
return <CourseContainer color={this.props.color} image={this.props.image}>{this.props.text}</CourseContainer>; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment