From 85a549a1fc62b38def8bccee56deee20a29a99cc Mon Sep 17 00:00:00 2001 From: Tilman Frick Date: Thu, 31 May 2018 18:17:18 +0200 Subject: [PATCH] fix: rename placeholder to image (#503) * fix: rename placeholder to image * fixup! merge conflicts --- .../builtins/{placeholder.ts => image.ts} | 8 ++++---- src/model/pattern-library/builtins/index.ts | 2 +- src/model/pattern-library/pattern-library.ts | 16 +++++++--------- src/model/pattern/pattern.ts | 8 ++++---- src/model/types.ts | 8 ++++---- src/preview/preview-renderer.tsx | 4 ++-- src/preview/preview.tsx | 4 ++-- 7 files changed, 24 insertions(+), 26 deletions(-) rename src/model/pattern-library/builtins/{placeholder.ts => image.ts} (93%) diff --git a/src/model/pattern-library/builtins/placeholder.ts b/src/model/pattern-library/builtins/image.ts similarity index 93% rename from src/model/pattern-library/builtins/placeholder.ts rename to src/model/pattern-library/builtins/image.ts index 198c82c43..47472cb84 100644 --- a/src/model/pattern-library/builtins/placeholder.ts +++ b/src/model/pattern-library/builtins/image.ts @@ -3,7 +3,7 @@ import { BuiltInContext, BuiltInResult } from '../pattern-library'; import * as PatternProperty from '../../pattern-property'; import * as Types from '../../types'; -const PATTERN_CONTEXT_ID = 'synthetic:placeholder'; +const PATTERN_CONTEXT_ID = 'synthetic:image'; const SRC_CONTEXT_ID = 'src'; const WIDTH_CONTEXT_ID = 'width'; const HEIGHT_CONTEXT_ID = 'height'; @@ -12,7 +12,7 @@ const MAX_WIDTH_CONTEXT_ID = 'max-width'; const MIN_HEIGHT_CONTEXT_ID = 'min-height'; const MAX_HEIGHT_CONTEXT_ID = 'max-height'; -export const Placeholder = (context: BuiltInContext): BuiltInResult => { +export const Image = (context: BuiltInContext): BuiltInResult => { const patternId = context.options.getGlobalPatternId(PATTERN_CONTEXT_ID); const properties = [ @@ -73,11 +73,11 @@ export const Placeholder = (context: BuiltInContext): BuiltInResult => { description: 'for Design Drafts', exportName: 'default', id: patternId, - name: 'Placeholder', + name: 'Image', origin: Types.PatternOrigin.BuiltIn, propertyIds: properties.map(p => p.getId()), slots: [], - type: Types.PatternType.SyntheticPlaceholder + type: Types.PatternType.SyntheticImage }, context ); diff --git a/src/model/pattern-library/builtins/index.ts b/src/model/pattern-library/builtins/index.ts index a12651241..918477ff9 100644 --- a/src/model/pattern-library/builtins/index.ts +++ b/src/model/pattern-library/builtins/index.ts @@ -1,5 +1,5 @@ export * from './box'; export * from './link'; export * from './page'; -export * from './placeholder'; +export * from './image'; export * from './text'; diff --git a/src/model/pattern-library/pattern-library.ts b/src/model/pattern-library/pattern-library.ts index 441f712f5..5bc9818a2 100644 --- a/src/model/pattern-library/pattern-library.ts +++ b/src/model/pattern-library/pattern-library.ts @@ -1,4 +1,4 @@ -import { Box, Link, Page, Placeholder, Text } from './builtins'; +import { Box, Image, Link, Page, Text } from './builtins'; import * as Fuse from 'fuse.js'; import { isEqual } from 'lodash'; import * as Mobx from 'mobx'; @@ -87,24 +87,22 @@ export class PatternLibrary { const link = Link({ patternLibrary, options }); const page = Page({ patternLibrary, options }); - const placeholder = Placeholder({ patternLibrary, options }); + const image = Image({ patternLibrary, options }); const text = Text({ patternLibrary, options }); const box = Box({ patternLibrary, options }); syntheticFolder.addPattern(text.pattern); syntheticFolder.addPattern(box.pattern); - syntheticFolder.addPattern(placeholder.pattern); + syntheticFolder.addPattern(image.pattern); syntheticFolder.addPattern(link.pattern); - [page.pattern, text.pattern, box.pattern, placeholder.pattern, link.pattern].forEach( - pattern => { - patternLibrary.addPattern(pattern); - } - ); + [page.pattern, text.pattern, box.pattern, image.pattern, link.pattern].forEach(pattern => { + patternLibrary.addPattern(pattern); + }); [ ...page.properties, - ...placeholder.properties, + ...image.properties, ...text.properties, ...box.properties, ...link.properties diff --git a/src/model/pattern/pattern.ts b/src/model/pattern/pattern.ts index 1ace08315..56f7b2ed5 100644 --- a/src/model/pattern/pattern.ts +++ b/src/model/pattern/pattern.ts @@ -165,8 +165,8 @@ function deserializeType(input: Types.SerializedPatternType): Types.PatternType return Types.PatternType.SyntheticPage; case 'synthetic:box': return Types.PatternType.SyntheticBox; - case 'synthetic:placeholder': - return Types.PatternType.SyntheticPlaceholder; + case 'synthetic:image': + return Types.PatternType.SyntheticImage; case 'synthetic:text': return Types.PatternType.SyntheticText; case 'synthetic:link': @@ -193,8 +193,8 @@ function serializeType(input: Types.PatternType): Types.SerializedPatternType { return 'synthetic:page'; case Types.PatternType.SyntheticBox: return 'synthetic:box'; - case Types.PatternType.SyntheticPlaceholder: - return 'synthetic:placeholder'; + case Types.PatternType.SyntheticImage: + return 'synthetic:image'; case Types.PatternType.SyntheticText: return 'synthetic:text'; case Types.PatternType.SyntheticLink: diff --git a/src/model/types.ts b/src/model/types.ts index c65470bc4..539bf0f85 100644 --- a/src/model/types.ts +++ b/src/model/types.ts @@ -77,19 +77,19 @@ export interface SerializedPatternFolder { export enum PatternType { Pattern = 'pattern', SyntheticBox = 'synthetic:box', + SyntheticImage = 'synthetic:image', SyntheticLink = 'synthetic:link', SyntheticPage = 'synthetic:page', - SyntheticPlaceholder = 'synthetic:placeholder', SyntheticText = 'synthetic:text' } export type SerializedPatternType = | 'pattern' | 'synthetic:box' + | 'synthetic:image' + | 'synthetic:link' | 'synthetic:page' - | 'synthetic:placeholder' - | 'synthetic:text' - | 'synthetic:link'; + | 'synthetic:text'; export enum PatternOrigin { BuiltIn = 'built-in', diff --git a/src/preview/preview-renderer.tsx b/src/preview/preview-renderer.tsx index dcec2e72a..1f61788d1 100644 --- a/src/preview/preview-renderer.tsx +++ b/src/preview/preview-renderer.tsx @@ -101,8 +101,7 @@ const Box: React.SFC = (props: any) => { const SYNTHETICS = { box: Box, page: Page, - link: Link, - placeholder: props => + image: props => props.src ? ( ) : null, + link: Link, text: props => {props.text} }; diff --git a/src/preview/preview.tsx b/src/preview/preview.tsx index ffe5086ee..99dbf4cd2 100644 --- a/src/preview/preview.tsx +++ b/src/preview/preview.tsx @@ -448,8 +448,8 @@ function createComponentGetter(store: PreviewStore): (props: any, synthetics: an return component[pattern.exportName]; case 'synthetic:page': return synthetics.page; - case 'synthetic:placeholder': - return synthetics.placeholder; + case 'synthetic:image': + return synthetics.image; case 'synthetic:text': return synthetics.text; case 'synthetic:box':