-
Notifications
You must be signed in to change notification settings - Fork 819
/
Copy pathmy-command.js
88 lines (75 loc) · 1.88 KB
/
my-command.js
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import * as React from 'react';
import * as PropTypes from 'prop-types';
import styled from 'styled-components/primitives';
import { render } from 'react-sketchapp';
import chroma from 'chroma-js';
// take a hex and give us a nice text color to put over it
const textColor = (hex) => {
const vsWhite = chroma.contrast(hex, 'white');
if (vsWhite > 4) {
return '#FFF';
}
return chroma(hex).darken(3).hex();
};
const SwatchTile = styled.View`
height: 250px;
width: 250px;
border-radius: 4px;
margin: 4px;
background-color: ${(props) => props.hex};
justify-content: center;
align-items: center;
`;
const SwatchName = styled.Text`
color: ${(props) => textColor(props.hex)};
font-weight: bold;
`;
const Ampersand = styled.Text`
color: #f3f3f3;
font-size: 120px;
font-family: Himalaya;
line-height: 144px;
`;
const Title = styled.Text`
font-size: 24px;
font-family: 'GT America';
font-weight: bold;
padding: 4px;
`;
const Swatch = ({ name, hex }) => (
<SwatchTile name={`Swatch ${name}`} hex={hex}>
<SwatchName name="Swatch Name" hex={hex}>
{name}
</SwatchName>
<Ampersand hex={hex}>&</Ampersand>
</SwatchTile>
);
const Color = {
hex: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
};
Swatch.propTypes = Color;
const Artboard = styled.View`
flex-direction: row;
flex-wrap: wrap;
width: ${(96 + 8) * 4}px;
justify-content: center;
`;
const Document = ({ colors }) => (
<Artboard name="Swatches">
<Title>Max’s Sweaters</Title>
{Object.keys(colors).map((color) => (
<Swatch name={color} hex={colors[color]} key={color} />
))}
</Artboard>
);
Document.propTypes = {
colors: PropTypes.objectOf(PropTypes.string).isRequired,
};
export default () => {
const colorList = {
Classic: '#96324E',
Neue: '#21304E',
};
render(<Document colors={colorList} />, context.document.currentPage());
};