Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component/preview #112

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/styleguide/src/components/Preview/Preview.docs.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { md } from './../../utils/';
import { Preview, ComponentDocs, CodeJSX } from './../';
import { Preview, ComponentDocs, CodeJSX, Code } from './../';
import PreviewForDocs from './Preview';
import InteractForDOcs from './Interact';
import { Bar, BarItem } from './../Bar';
@@ -108,6 +108,16 @@ is used to generate JSX in code example. To overide options of this library, use
This is HTML string
</Preview>

### Preview Layout

<Preview hasLayoutPreview code={<Preview hasLayoutPreview />}>
<p>Preview a layout component behaviour by apllying special styles.</p>
<p>Lighter Styleguide supports <Code>.grid</Code> and <Code>.bar</Code>, other layout components should by styled manually in your app.</p>
<div class="grid">
<div class="grid__col" />
</div>
</Preview>

### Preview interactiveProps

`interactiveProps` are used as a pipe for sending special props to Interactive elements renderer.
31 changes: 30 additions & 1 deletion packages/styleguide/src/components/Preview/Preview.js
Original file line number Diff line number Diff line change
@@ -64,6 +64,8 @@ class Preview extends Component {
isInteractive: bool,
/** Props for interactive component */
interactiveProps: object,
/** Visual grid preview */
hasLayoutPreview: bool,
/** Enable fullscreen toggle */
enableFullscreen: bool,
};
@@ -158,13 +160,20 @@ class Preview extends Component {
isInteractive,
interactiveProps,
html,
hasLayoutPreview,
enableFullscreen,
...other
} = this.props;

const { previewBackground } = this.state;

const classes = cx(CLASS_ROOT, className);
const classes = cx(
CLASS_ROOT,
{
'layout-preview': hasLayoutPreview,
},
className
);
const wrapperClasses = cx('preview-wrapper', {
'is-fullscreen': this.state.isFullscreen,
});
@@ -366,6 +375,26 @@ const StyledPreview = styled.div`
`;

const StyledCard = styled(Card)`
&.layout-preview {
.grid,
.bar {
position: relative;
z-index: 0;
padding: 0.5em 0;
background-color: rgba(0, 0, 0, 0.08);
border: 1px solid rgba(0, 0, 0, 0.15);
}
.bar__item,
.grid__col,
*[class*='grid__col\-\-'] {
position: relative;
min-height: 1em;
line-height: 1.5;
background-color: rgba(0, 0, 0, 0.1);
background-clip: content-box;
}
}
.is-fullscreen & {
flex: 1 1 auto;
margin-bottom: 0;
1 change: 0 additions & 1 deletion packages/styleguide/src/components/Preview/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import './style';

import { ThemeConsumer } from 'styled-components';

23 changes: 0 additions & 23 deletions packages/styleguide/src/components/Preview/style.js

This file was deleted.