Skip to content

Commit

Permalink
docs(Combobox): add mdx docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dakahn committed Aug 26, 2020
1 parent 92992ef commit aae5638
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 17 deletions.
42 changes: 25 additions & 17 deletions packages/react/src/components/ComboBox/ComboBox-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

import React from 'react';
import { action } from '@storybook/addon-actions';
import { withKnobs, boolean, select, text } from '@storybook/addon-knobs';
import { boolean, select, text } from '@storybook/addon-knobs';
import ComboBox from '../ComboBox';
import mdx from './ComboBox.mdx';

const items = [
{
Expand Down Expand Up @@ -50,6 +51,28 @@ const directions = {
'Top ': 'top',
};

export default {
title: 'ComboBox',
component: ComboBox,
parameters: {
docs: {
page: mdx,
},
},
};

export const combobox = () => (
<div style={{ width: 300 }}>
<ComboBox
items={items}
itemToString={(item) => (item ? item.text : '')}
placeholder="Filter..."
titleText="ComboBox title"
helperText="Combobox helper text"
/>
</div>
);

const props = () => ({
id: text('Combobox ID (id)', 'carbon-combobox-example'),
placeholder: text('Placeholder text (placeholder)', 'Filter...'),
Expand All @@ -64,16 +87,7 @@ const props = () => ({
onChange: action('onChange'),
});

export default {
title: 'ComboBox',
decorators: [withKnobs],

parameters: {
component: ComboBox,
},
};

export const Default = () => (
export const Playground = () => (
<div style={{ width: 300 }}>
<ComboBox
items={items}
Expand All @@ -82,9 +96,3 @@ export const Default = () => (
/>
</div>
);

Default.parameters = {
info: {
text: 'ComboBox',
},
};
30 changes: 30 additions & 0 deletions packages/react/src/components/ComboBox/ComboBox.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Story, Props, Source, Preview } from '@storybook/addon-docs/blocks';
import { withKnobs, boolean, select, text } from '@storybook/addon-knobs';
import * as stories from './ComboBox-story.js';
import ComboBox from '../ComboBox';

# ComboBox

## Table of Contents

- [Overview](#overview)
- [Component API](#component-api)
- [Feedback](#feedback)

## Overview

A combobox allows the user to make a selection from a predefined list of options
and is typically used when there are a large amount of options to choose from.

<Preview>
<Story id="combobox--combobox" />
</Preview>

## Component API

<Props sort="asc" />

## Feedback

Help us improve these docs by
[editing this file on GitHub](https://github.com/carbon-design-system/carbon/edit/master/packages/react/src/components/ComboBox/ComboBox.stories.mdx)

0 comments on commit aae5638

Please sign in to comment.