@imposium-hub/components 1.22.3 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/assets/AssetField.tsx +2 -1
- package/components/assets/AssetsTableNameCell.tsx +1 -0
- package/components/assets/FontAssetPreview.tsx +20 -15
- package/components/button-menu/ButtonMenu.tsx +11 -8
- package/components/color-field/ColorField.tsx +11 -8
- package/components/compositions/CompositionRendererLayer.tsx +4 -16
- package/components/compositions/StaticCompositionConfig.tsx +17 -40
- package/components/compositions/StaticCompositionRenderer.tsx +3 -3
- package/components/compositions/TextLayer.tsx +22 -29
- package/components/compositions/TextLayerOptions.tsx +109 -39
- package/components/number-field/NumberField.tsx +6 -6
- package/components/portal/Portal.tsx +3 -1
- package/components/story-previewer/StoryPreviewer.tsx +3 -2
- package/constants/compositions.ts +30 -69
- package/dist/components.js +2 -2
- package/dist/components.js.map +1 -1
- package/package.json +13 -11
- package/services/API.ts +8 -4
- package/components/compositions/ImageLayerOptions.tsx +0 -123
- package/components/compositions/StaticCompositionLayerConfig.tsx +0 -149
|
@@ -73,9 +73,10 @@ class AssetField extends React.PureComponent<IAssetFieldProps, IAssetFieldState>
|
|
|
73
73
|
this.props.updateFilters({type: (accepts) ? accepts : '', page: 1});
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
private onFileDrop = (i : any, monitor :
|
|
76
|
+
private onFileDrop = (i : any, monitor : any) : void => {
|
|
77
77
|
const {accepts, storyId, api} = this.props;
|
|
78
78
|
if (monitor) {
|
|
79
|
+
|
|
79
80
|
const {files} = monitor.getItem();
|
|
80
81
|
|
|
81
82
|
if (mimetypeConformsToOverlay(accepts, files[0])) {
|
|
@@ -20,6 +20,7 @@ const AssetsTableNameCell : React.FC<IAssetsTableNameCell> = (props : IAssetsTab
|
|
|
20
20
|
const {cell: {row, row: {original: {name, id}}}} = props;
|
|
21
21
|
|
|
22
22
|
const [_, drag] = useDrag({
|
|
23
|
+
type: ASSET_DND_TYPES.ASSET_NAME,
|
|
23
24
|
item: {
|
|
24
25
|
name: DRAGGER_NAME,
|
|
25
26
|
assetData: row.original,
|
|
@@ -30,7 +30,7 @@ class FontAssetPreview extends React.PureComponent<IFontAssetPreviewProps, undef
|
|
|
30
30
|
|
|
31
31
|
public render() {
|
|
32
32
|
|
|
33
|
-
const {active, asset: {name, url, id}} = this.props;
|
|
33
|
+
const {active, asset: {name, url, id}, width, height} = this.props;
|
|
34
34
|
const wrapperStyle = this.getWrapperStyle();
|
|
35
35
|
|
|
36
36
|
if (active !== false) {
|
|
@@ -38,24 +38,29 @@ class FontAssetPreview extends React.PureComponent<IFontAssetPreviewProps, undef
|
|
|
38
38
|
<div className = 'media-player'>
|
|
39
39
|
<div className = 'inner-viewer' style = {wrapperStyle}>
|
|
40
40
|
<TextLayer
|
|
41
|
-
width = {wrapperStyle.width}
|
|
42
|
-
height = {wrapperStyle.height}
|
|
43
41
|
options = {{
|
|
42
|
+
width,
|
|
43
|
+
height,
|
|
44
|
+
x: 0,
|
|
45
|
+
y: 0,
|
|
46
|
+
rotation: 0,
|
|
47
|
+
id: 'xxx',
|
|
48
|
+
name: 'xxx',
|
|
44
49
|
content: `ABCDEFGHIJKLM\nNOPQRSTUVWXYZ\nabcdefghijklm\nnopqrstuvwxyz\n1234567890`,
|
|
45
50
|
color: '#000000',
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
background_color: '#ffffff',
|
|
52
|
+
font_size: 80,
|
|
53
|
+
font_type: 'custom',
|
|
49
54
|
font: name,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
custom_font_url: url,
|
|
56
|
+
custom_font_id: id,
|
|
57
|
+
letter_spacing: null,
|
|
58
|
+
word_spacing: null,
|
|
59
|
+
line_height: null,
|
|
60
|
+
horizontal_alignment: 'center',
|
|
61
|
+
vertical_alignment: 'center',
|
|
62
|
+
text_wrap: true,
|
|
63
|
+
text_fit: true
|
|
59
64
|
}}/>
|
|
60
65
|
</div>
|
|
61
66
|
</div>
|
|
@@ -24,11 +24,11 @@ class ButtonMenu extends React.PureComponent<IButtonMenuProps, IButtonMenuState>
|
|
|
24
24
|
|
|
25
25
|
this.evtHandlers = {
|
|
26
26
|
toggleMenu: (e) => this.toggleMenu(e),
|
|
27
|
-
clickOutside: (e) => this.handleClickOutside()
|
|
27
|
+
clickOutside: (e) => this.handleClickOutside(e)
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
private handleClickOutside() {
|
|
31
|
+
private handleClickOutside(e) {
|
|
32
32
|
|
|
33
33
|
document.removeEventListener('click', this.evtHandlers.clickOutside);
|
|
34
34
|
|
|
@@ -44,16 +44,19 @@ class ButtonMenu extends React.PureComponent<IButtonMenuProps, IButtonMenuState>
|
|
|
44
44
|
|
|
45
45
|
public toggleMenu(e) {
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
e.stopPropagation();
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
document.addEventListener('click', this.evtHandlers.clickOutside);
|
|
51
|
-
} else {
|
|
52
|
-
document.removeEventListener('click', this.evtHandlers.clickOutside);
|
|
53
|
-
}
|
|
50
|
+
const newState = !this.state.open;
|
|
54
51
|
|
|
55
52
|
this.setState({
|
|
56
53
|
open : newState
|
|
54
|
+
}, () => {
|
|
55
|
+
if (this.state.open) {
|
|
56
|
+
document.addEventListener('click', this.evtHandlers.clickOutside);
|
|
57
|
+
} else {
|
|
58
|
+
document.removeEventListener('click', this.evtHandlers.clickOutside);
|
|
59
|
+
}
|
|
57
60
|
});
|
|
58
61
|
}
|
|
59
62
|
|
|
@@ -42,18 +42,21 @@ class ColorField extends React.PureComponent<IColorFieldProps, IColorFieldState>
|
|
|
42
42
|
this.clickOutsideHandler = (e) => this.handleClickOutside(e);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
private togglePicker() {
|
|
45
|
+
private togglePicker(e) {
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
e.stopPropagation();
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
document.addEventListener('click', this.clickOutsideHandler);
|
|
51
|
-
} else {
|
|
52
|
-
document.removeEventListener('click', this.clickOutsideHandler);
|
|
53
|
-
}
|
|
50
|
+
const newState = !this.state.pickerOpen;
|
|
54
51
|
|
|
55
52
|
this.setState({
|
|
56
53
|
pickerOpen: newState
|
|
54
|
+
}, () => {
|
|
55
|
+
if (this.state.pickerOpen) {
|
|
56
|
+
document.addEventListener('click', this.clickOutsideHandler);
|
|
57
|
+
} else {
|
|
58
|
+
document.removeEventListener('click', this.clickOutsideHandler);
|
|
59
|
+
}
|
|
57
60
|
});
|
|
58
61
|
}
|
|
59
62
|
|
|
@@ -118,7 +121,7 @@ class ColorField extends React.PureComponent<IColorFieldProps, IColorFieldState>
|
|
|
118
121
|
info = {info}
|
|
119
122
|
labelPosition = {labelPosition}
|
|
120
123
|
width = {width}>
|
|
121
|
-
<div className = 'swatch' style = {swatchStyle} onClick = {() => this.togglePicker()}/>
|
|
124
|
+
<div className = 'swatch' style = {swatchStyle} onClick = {(e) => this.togglePicker(e)}/>
|
|
122
125
|
<div className = {`picker picker-${pickerPos}`} ref = {this.picker}>
|
|
123
126
|
{picker}
|
|
124
127
|
</div>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import Moveable from 'react-moveable';
|
|
3
3
|
import TextLayer from './TextLayer';
|
|
4
|
-
import { COMPOSITION_LAYER_TYPES} from '../../constants/compositions';
|
|
5
4
|
|
|
6
5
|
interface ICompositionRendererLayerProps {
|
|
7
6
|
layer : any;
|
|
@@ -87,21 +86,10 @@ class CompositionRendererLayer extends React.PureComponent<ICompositionRendererL
|
|
|
87
86
|
|
|
88
87
|
const {layer, inventory} = this.props;
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return <TextLayer
|
|
95
|
-
width = {layer.width}
|
|
96
|
-
height = {layer.height}
|
|
97
|
-
onReady = {this.props.onReady}
|
|
98
|
-
inventory = {inventory}
|
|
99
|
-
options = {layer.options}/>;
|
|
100
|
-
|
|
101
|
-
case COMPOSITION_LAYER_TYPES.IMAGE:
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return null;
|
|
89
|
+
return <TextLayer
|
|
90
|
+
onReady = {this.props.onReady}
|
|
91
|
+
inventory = {inventory}
|
|
92
|
+
options = {layer}/>;
|
|
105
93
|
}
|
|
106
94
|
|
|
107
95
|
public render() {
|
|
@@ -8,9 +8,9 @@ import FieldWrapper from '../field-wrapper/FieldWrapper';
|
|
|
8
8
|
import ButtonMenu from '../button-menu/ButtonMenu';
|
|
9
9
|
import Button from '../button/Button';
|
|
10
10
|
import ButtonMenuItem from '../button-menu/ButtonMenuItem';
|
|
11
|
-
import {
|
|
11
|
+
import { getNewCompositionLayer } from '../../constants/compositions';
|
|
12
12
|
import { ICON_PLUS, ICON_IMAGE, ICON_FONT } from '../../constants/icons';
|
|
13
|
-
import
|
|
13
|
+
import TextLayerOptions from './TextLayerOptions';
|
|
14
14
|
|
|
15
15
|
interface IStaticCompositionConfigProps {
|
|
16
16
|
storyId : string;
|
|
@@ -40,41 +40,18 @@ class StaticCompositionConfig extends React.PureComponent<IStaticCompositionConf
|
|
|
40
40
|
selectLayer: (l) => this.props.onSelectLayer(l)
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
this.addLayerMenu = <
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<ButtonMenuItem
|
|
51
|
-
key = {COMPOSITION_LAYER_TYPES.IMAGE}
|
|
52
|
-
label = {<span>{ this.getLayerIcon(COMPOSITION_LAYER_TYPES.IMAGE) } {copy.layerImage}</span>}
|
|
53
|
-
onClick = {() => this.addLayer(COMPOSITION_LAYER_TYPES.IMAGE)}/>
|
|
54
|
-
]}
|
|
55
|
-
button = {<Button
|
|
56
|
-
style = 'subtle'
|
|
57
|
-
size = 'small'
|
|
58
|
-
color = 'primary'>
|
|
59
|
-
{ICON_PLUS}
|
|
60
|
-
</Button>}/>;
|
|
43
|
+
this.addLayerMenu = <Button
|
|
44
|
+
onClick = {() => this.addLayer()}
|
|
45
|
+
style = 'subtle'
|
|
46
|
+
size = 'small'
|
|
47
|
+
color = 'primary'>
|
|
48
|
+
{ICON_PLUS}
|
|
49
|
+
</Button>;
|
|
61
50
|
}
|
|
62
51
|
|
|
63
|
-
private
|
|
52
|
+
private addLayer() {
|
|
64
53
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
case COMPOSITION_LAYER_TYPES.TEXT:
|
|
68
|
-
return ICON_FONT;
|
|
69
|
-
case COMPOSITION_LAYER_TYPES.IMAGE:
|
|
70
|
-
return ICON_IMAGE;
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
private addLayer(type) {
|
|
76
|
-
|
|
77
|
-
const layerConfig = getNewCompositionLayer(type);
|
|
54
|
+
const layerConfig = getNewCompositionLayer();
|
|
78
55
|
const comp = {...this.props.composition};
|
|
79
56
|
const layers = [...comp.layers];
|
|
80
57
|
layers.push(layerConfig);
|
|
@@ -104,17 +81,17 @@ class StaticCompositionConfig extends React.PureComponent<IStaticCompositionConf
|
|
|
104
81
|
private bgChanged(color) {
|
|
105
82
|
|
|
106
83
|
if (color.hex === 'transparent') {
|
|
107
|
-
this.compValueChanged('
|
|
84
|
+
this.compValueChanged('background_color', null);
|
|
108
85
|
} else {
|
|
109
86
|
const values = color.rgb;
|
|
110
|
-
this.compValueChanged('
|
|
87
|
+
this.compValueChanged('background_color', `rgba(${values.r},${values.g},${values.b},${values.a})`);
|
|
111
88
|
}
|
|
112
89
|
}
|
|
113
90
|
|
|
114
91
|
public render() {
|
|
115
92
|
|
|
116
93
|
const {composition, selectedLayer, storyId, api} = this.props;
|
|
117
|
-
const bg = (composition.
|
|
94
|
+
const bg = (composition.background_color) ? composition.background_color : 'transparent';
|
|
118
95
|
const layerLabel = <span>{copy.layers} {this.addLayerMenu}</span>;
|
|
119
96
|
|
|
120
97
|
return (
|
|
@@ -137,7 +114,7 @@ class StaticCompositionConfig extends React.PureComponent<IStaticCompositionConf
|
|
|
137
114
|
label = {copy.backgroundColor}
|
|
138
115
|
tooltip = {copy.tooltipBackgroundColor}
|
|
139
116
|
enableAlpha = {true}
|
|
140
|
-
value = {composition['
|
|
117
|
+
value = {composition['background_color']}
|
|
141
118
|
width = '40%'
|
|
142
119
|
labelPosition = 'top'
|
|
143
120
|
pickerPosition = 'right'
|
|
@@ -148,14 +125,14 @@ class StaticCompositionConfig extends React.PureComponent<IStaticCompositionConf
|
|
|
148
125
|
labelPosition = 'top'>
|
|
149
126
|
{composition.layers.map((layer, i) => {
|
|
150
127
|
const selected = (layer.id === selectedLayer);
|
|
151
|
-
return <
|
|
128
|
+
return <TextLayerOptions
|
|
152
129
|
storyId = {storyId}
|
|
153
130
|
api = {api}
|
|
154
131
|
key = {layer.id}
|
|
155
132
|
selected = {selected}
|
|
156
133
|
onSelectLayer = {this.eventHandlers.selectLayer}
|
|
157
134
|
onUpdate = {(c) => this.updateLayer(i, c)}
|
|
158
|
-
|
|
135
|
+
options = {layer}/>;
|
|
159
136
|
})}
|
|
160
137
|
</FieldWrapper>
|
|
161
138
|
</>
|
|
@@ -99,15 +99,15 @@ class StaticCompositionRenderer extends React.PureComponent<IStaticCompositionRe
|
|
|
99
99
|
|
|
100
100
|
public render() {
|
|
101
101
|
|
|
102
|
-
const {composition: {width, height,
|
|
102
|
+
const {composition: {width, height, background_color}} = this.props;
|
|
103
103
|
|
|
104
104
|
const style : any = {
|
|
105
105
|
width: `${width}px`,
|
|
106
106
|
height: `${height}px`
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
if (
|
|
110
|
-
style.backgroundColor =
|
|
109
|
+
if (background_color) {
|
|
110
|
+
style.backgroundColor = background_color;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
return (
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ASSET_DISTRO, ASSET_ORIGIN } from '../../constants/assets';
|
|
4
|
-
import {
|
|
4
|
+
import { ITextLayer, FONT_TYPES} from '../../constants/compositions';
|
|
5
5
|
import { s3Url } from '../../Util';
|
|
6
6
|
|
|
7
7
|
interface ITextLayerProps {
|
|
8
8
|
inventory? : any;
|
|
9
9
|
onReady?() : void;
|
|
10
|
-
|
|
11
|
-
height : number;
|
|
12
|
-
options : ITextLayerOptions;
|
|
10
|
+
options : ITextLayer;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
interface ITextLayerState {
|
|
@@ -39,10 +37,10 @@ export default class TextLayer extends React.PureComponent<ITextLayerProps, ITex
|
|
|
39
37
|
public componentDidUpdate(prevProps) {
|
|
40
38
|
|
|
41
39
|
const {fontLoaded} = this.state;
|
|
42
|
-
const {options: {font,
|
|
40
|
+
const {options: {font, custom_font_id, content}} = this.props;
|
|
43
41
|
|
|
44
42
|
if (prevProps.options.font !== font ||
|
|
45
|
-
prevProps.options.
|
|
43
|
+
prevProps.options.custom_font_id !== custom_font_id) {
|
|
46
44
|
this.loadFont();
|
|
47
45
|
}
|
|
48
46
|
|
|
@@ -55,11 +53,6 @@ export default class TextLayer extends React.PureComponent<ITextLayerProps, ITex
|
|
|
55
53
|
|
|
56
54
|
const computedStyle = window.getComputedStyle(element, null);
|
|
57
55
|
|
|
58
|
-
// element.style.fontSize = '';
|
|
59
|
-
// element.style.letterSpacing = '';
|
|
60
|
-
// element.style.wordSpacing = '';
|
|
61
|
-
// element.style.lineHeight = '';
|
|
62
|
-
|
|
63
56
|
let fSize = parseFloat(computedStyle.getPropertyValue('font-size'));
|
|
64
57
|
let lSpace = parseFloat(computedStyle.getPropertyValue('letter-spacing'));
|
|
65
58
|
let lHeight = parseFloat(computedStyle.getPropertyValue('line-height'));
|
|
@@ -91,14 +84,14 @@ export default class TextLayer extends React.PureComponent<ITextLayerProps, ITex
|
|
|
91
84
|
|
|
92
85
|
private loadFont() {
|
|
93
86
|
|
|
94
|
-
const {options: {font,
|
|
87
|
+
const {options: {font, font_size, font_type, custom_font_url}} = this.props;
|
|
95
88
|
|
|
96
|
-
if (
|
|
89
|
+
if (font_type === FONT_TYPES.CUSTOM && font_size && custom_font_url) {
|
|
97
90
|
|
|
98
|
-
const fontOrigin = s3Url(
|
|
91
|
+
const fontOrigin = s3Url(custom_font_url, ASSET_DISTRO, ASSET_ORIGIN);
|
|
99
92
|
|
|
100
93
|
// Not sure why you need to pass the size in here, but .check() throws an error without it.
|
|
101
|
-
const loaded = document.fonts.check(`${
|
|
94
|
+
const loaded = document.fonts.check(`${font_size}px ${font}`);
|
|
102
95
|
|
|
103
96
|
if (!loaded) {
|
|
104
97
|
this.setState({
|
|
@@ -117,7 +110,7 @@ export default class TextLayer extends React.PureComponent<ITextLayerProps, ITex
|
|
|
117
110
|
this.fontReady();
|
|
118
111
|
}
|
|
119
112
|
|
|
120
|
-
} else if (
|
|
113
|
+
} else if (font_type === FONT_TYPES.STANDARD) {
|
|
121
114
|
|
|
122
115
|
// TODO: check this?
|
|
123
116
|
this.fontReady();
|
|
@@ -156,10 +149,10 @@ export default class TextLayer extends React.PureComponent<ITextLayerProps, ITex
|
|
|
156
149
|
|
|
157
150
|
private fitText() {
|
|
158
151
|
|
|
159
|
-
if (this.props.options.
|
|
152
|
+
if (this.props.options.text_fit) {
|
|
160
153
|
const text = this.innerTextRef.current;
|
|
161
154
|
if (text) {
|
|
162
|
-
this.fitElement(text, this.props.width, this.props.height);
|
|
155
|
+
this.fitElement(text, this.props.options.width, this.props.options.height);
|
|
163
156
|
}
|
|
164
157
|
}
|
|
165
158
|
}
|
|
@@ -191,14 +184,14 @@ export default class TextLayer extends React.PureComponent<ITextLayerProps, ITex
|
|
|
191
184
|
|
|
192
185
|
public render() {
|
|
193
186
|
|
|
194
|
-
const {options: {color,
|
|
195
|
-
|
|
187
|
+
const {options: {color, background_color, line_height, word_spacing,
|
|
188
|
+
letter_spacing, font_size, font, horizontal_alignment, vertical_alignment, text_wrap}} = this.props;
|
|
196
189
|
|
|
197
|
-
const whiteSpace = (
|
|
198
|
-
const lS = (
|
|
199
|
-
const wS = (
|
|
200
|
-
const lH = (
|
|
201
|
-
const fS = (
|
|
190
|
+
const whiteSpace = (text_wrap) ? 'normal' : 'nowrap';
|
|
191
|
+
const lS = (letter_spacing) ? `${letter_spacing}px` : 'normal';
|
|
192
|
+
const wS = (word_spacing) ? `${word_spacing}px` : 'normal';
|
|
193
|
+
const lH = (line_height) ? `${line_height}px` : 'normal';
|
|
194
|
+
const fS = (font_size) ? `${font_size}px` : '0px';
|
|
202
195
|
|
|
203
196
|
const innerTextStyle = {
|
|
204
197
|
color,
|
|
@@ -212,10 +205,10 @@ export default class TextLayer extends React.PureComponent<ITextLayerProps, ITex
|
|
|
212
205
|
|
|
213
206
|
const wrapperStyle = {
|
|
214
207
|
display: 'flex',
|
|
215
|
-
textAlign:
|
|
216
|
-
justifyContent: this.getFlexStart(
|
|
217
|
-
alignItems:
|
|
218
|
-
backgroundColor:
|
|
208
|
+
textAlign: horizontal_alignment as any,
|
|
209
|
+
justifyContent: this.getFlexStart(horizontal_alignment),
|
|
210
|
+
alignItems: vertical_alignment,
|
|
211
|
+
backgroundColor: background_color as any
|
|
219
212
|
};
|
|
220
213
|
|
|
221
214
|
return <div className = 'composition-text-layer' style = {wrapperStyle}>
|