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

docs(Combobox): update dev docs; add mdx docs #6734

Merged
merged 11 commits into from
Sep 28, 2020
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it help to add the new sections to the TOC too or nah?

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

## Overview
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be able to use the same strategy as TJ did over in Dropdown for use-cases / component API: https://github.com/carbon-design-system/carbon/blob/master/packages/react/src/components/Dropdown/Dropdown.mdx

Some other examples could be:

  • Skeleton
  • Controlled vs uncontrolled
  • Invalid states
  • Label guidance (how to label it so that it's accessible)


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)