Skip to content

Commit

Permalink
chore: rename componentsLookup
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jun 24, 2020
1 parent 5e779dc commit 7fdcd7d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/core/src/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export interface Document {
* since multiple components of the same name can be used
* example: ['Button']: 'c:/myapp/Button.tsx'
*/
components: {
componentsLookup: {
[name: string]: string;
};

Expand Down
2 changes: 1 addition & 1 deletion core/store/src/serialization/load-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const loadStoryStore = (
source,
component,
fileName,
components,
componentsLookup,
package: docPackage,
...otherDocProps
} = doc;
Expand Down
4 changes: 2 additions & 2 deletions core/store/src/serialization/smart-controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ export const addSmartControls = (
let componentName = getComponentName(storyComponent);
if (
!componentName ||
(!components[doc.components[componentName]] &&
(!components[doc.componentsLookup[componentName]] &&
typeof doc.component === 'string')
) {
componentName = doc.component as string;
}
if (componentName) {
const component = components[doc.components[componentName]];
const component = components[doc.componentsLookup[componentName]];

if (component?.info) {
const newControls = controlsFromProps(component.info.props);
Expand Down
2 changes: 1 addition & 1 deletion ui/blocks/src/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const Search = () => {
stories: page.stories
?.map(story => story.split('-').join(' '))
.join(' '),
component: Object.keys(page.components).join(' '),
component: Object.keys(page.componentsLookup).join(' '),
});
});
});
Expand Down
8 changes: 4 additions & 4 deletions ui/blocks/src/context/block/BlockDataContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export const BlockDataContextProvider: React.FC<BlockDataContextInoutProps> = ({

const componentName = getComponentName(storyComponent);
const component =
componentName && doc && doc.components[componentName]
? store.components[doc.components[componentName]]
componentName && doc && doc.componentsLookup[componentName]
? store.components[doc.componentsLookup[componentName]]
: undefined;
const docPackage =
doc && doc.package ? store.packages[doc.package] : undefined;
Expand All @@ -117,8 +117,8 @@ export const BlockDataContextProvider: React.FC<BlockDataContextInoutProps> = ({
const name = getComponentName(components[key]);
const component =
name &&
doc?.components[name] &&
store?.components[doc.components[name]];
doc?.componentsLookup[name] &&
store?.components[doc.componentsLookup[name]];
if (component) {
return { ...acc, [key]: component };
} else {
Expand Down
4 changes: 2 additions & 2 deletions ui/blocks/src/test/storyStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ and a [link](https://google.com)
date: new Date('2020-01-01'),
dateModified: new Date('2020-03-31'),
package: 'test-package',
components: {
componentsLookup: {
ArrowButton:
'/Users/atanasster/component-controls/core/instrument/test/fixtures/components/button-default-arrow-func.js',
Button:
Expand All @@ -324,7 +324,7 @@ and a [link](https://google.com)
},
mdxStory: {
title: 'MDX Story',
components: {},
componentsLookup: {},
author: 'atanasster',
MDXPage: () => <MDXContent components={{}} />,
stories: ['mdx-story'],
Expand Down

0 comments on commit 7fdcd7d

Please sign in to comment.