Skip to content

Commit

Permalink
fix: clean up code reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Feb 29, 2020
1 parent 278a178 commit daa2829
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions examples/storybook-5/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export const DocsPage = ({
<Title slot={titleSlot} />
<Subtitle slot={subtitleSlot} />
<Description slot={descriptionSlot} />
<ImportSource id="." />
<ImportSource id="." title='import component' />
<Story id="." />
<Source id="." />
<Source id="." title='source'/>
<ControlsTable id="." />
<Props slot={propsSlot} />
<DependenciesTable titleDependencies='Dependencies' titleDependents='Dependents' />
Expand Down
7 changes: 7 additions & 0 deletions ui/block-components/src/BlockContainer/BlockContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { FC } from 'react';
import styled from '@emotion/styled';
import { Heading } from 'theme-ui';
import { ActionBar, ActionItem } from '@component-controls/components';

const SpacedBlockContainer = styled.div(() => ({
Expand All @@ -14,16 +15,22 @@ const FramedBlockContainer = styled.div(() => ({
}));

export interface BlockContainerProps {
/**
* optional section title for the block
*/
title?: string;
/**
* additional actions provided to the component
*/
actions?: ActionItem[];
}
export const BlockContainer: FC<BlockContainerProps> = ({
children,
title,
actions,
}) => (
<SpacedBlockContainer>
{title && <Heading as="h3">{title}</Heading>}
<FramedBlockContainer>{children}</FramedBlockContainer>
{actions && <ActionBar actionItems={actions} />}
</SpacedBlockContainer>
Expand Down
20 changes: 10 additions & 10 deletions ui/blocks/src/ImportSource/ImportSource.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import React, { FC } from 'react';
import { Source as SourceBlock } from '@component-controls/block-components';
import {
Source as SourceBlock,
SourceProps,
} from '@component-controls/block-components';
import {
useControlsContext,
ControlsContextInputProps,
} from '../BlocksContext';
import { ThemeContext } from '../ThemeContext';

export type ImportSourceProps = ControlsContextInputProps & {
/** a title to display */
title?: string;
};
export type ImportSourceProps = ControlsContextInputProps & SourceProps;

export const ImportSource: FC<ImportSourceProps> = ({ id, name }) => {
const { component } = useControlsContext({
id,
name,
});
const source = component && component.import;
if (!source) {
return null;
}
const { dark } = React.useContext(ThemeContext);
return (
<SourceBlock dark={dark}>
{component && component.import ? component.import : ''}
</SourceBlock>
);
return <SourceBlock dark={dark}>{source}</SourceBlock>;
};

0 comments on commit daa2829

Please sign in to comment.