-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_button.tsx
64 lines (56 loc) · 1.92 KB
/
simple_button.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import * as React from "react";
import { Override, Data, PropertyControls, ControlType } from "framer";
import styled, { injectGlobal } from 'styled-components';
injectGlobal`
@font-face {
font-family: "Montserrat";
font-weight: 400;
src: url(/code/fonts/Montserrat.woff) format("woff");
}
`;
const Button = styled<Props, any>("div")`
font-family: ${props => props.fontFamily};
font-size: ${props => props.fontSize};
width: ${props => props.width};
height: ${props => props.height};
background-color: ${props => props.backgroundColor};
text-align: ${props => props.textAlign};
`;
// Define type of property
interface Props {
text: string;
fontSize: string;
fontFamily: string;
width: string;
height: string;
backgroundColor: string;
color: string;
textAlign: string;
}
export class SimpleButton extends React.Component<Props> {
// Set default properties
static defaultProps = {
text: "Hello World!",
fontSize: "1rem",
fontFamily: "Montserrat",
width: "4rem",
height: "1rem",
backgroundColor: "yellow",
numberOfButtons: 3,
textAlign: "left",
}
// Items shown in property panel
static propertyControls: PropertyControls = {
fontFamily: { type: ControlType.String, title: "Font Family" },
width: { type: ControlType.String, title: "Button Width" },
height: { type: ControlType.String, title: "Button Height" },
backgroundColor: { type: ControlType.Color, title: "Button Color" },
textAlign: { type: ControlType.String, title: "Text Align"},
}
render() {
return <Button color={this.props.color}
fontSize={this.props.fontSize} fontFamily={this.props.fontFamily}
width={this.props.width} height={this.props.height} backgroundColor={this.props.backgroundColor}
textAlign={this.props.textAlign}>{this.props.text}</Button>
}
}