Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
fix: rename placeholder to image (#503)
Browse files Browse the repository at this point in the history
* fix: rename placeholder to image

* fixup! merge conflicts
  • Loading branch information
tilmx authored and Markus Ölhafen committed Jun 12, 2018
1 parent 22eacf2 commit 8d8bdbe
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 = [
Expand Down Expand Up @@ -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
);
Expand Down
2 changes: 1 addition & 1 deletion src/model/pattern-library/builtins/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './box';
export * from './link';
export * from './page';
export * from './placeholder';
export * from './image';
export * from './text';
16 changes: 7 additions & 9 deletions src/model/pattern-library/pattern-library.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/model/pattern/pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions src/model/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions src/preview/preview-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ const Box: React.SFC = (props: any) => {
const SYNTHETICS = {
box: Box,
page: Page,
link: Link,
placeholder: props =>
image: props =>
props.src ? (
<img
src={props.src}
Expand All @@ -116,6 +115,7 @@ const SYNTHETICS = {
}}
/>
) : null,
link: Link,
text: props => <span>{props.text}</span>
};

Expand Down
4 changes: 2 additions & 2 deletions src/preview/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit 8d8bdbe

Please sign in to comment.