Skip to content

Commit

Permalink
docs(@clayui/core): adds flexible width documentation for Picker
Browse files Browse the repository at this point in the history
  • Loading branch information
matuzalemsteles committed Apr 24, 2024
1 parent fa59afc commit 460c337
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
47 changes: 47 additions & 0 deletions packages/clay-core/docs/picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,52 @@ import Layout from '@clayui/layout';
import {useId} from '@clayui/shared';
import React from 'react';

const PickerWidthExample = () => {
const imports = `import {Option, Picker} from '@clayui/core';
import Form from '@clayui/form';
import React from 'react';`;

const code = `const CustomWidth = () => {
return (
<div style={{width: '240px'}}>
<Form.Group>
<label htmlFor="picker" id="picker-label">
Choose a fruit
</label>
<Picker
width="flexible"
aria-labelledby="picker-label"
id="picker"
items={[
'Apple',
'Banana',
'Mangos',
'Blueberry',
'Boysenberry',
'Cherry',
'Cranberry',
'Eggplant',
'Fig',
'Grape',
'Guava',
'Huckleberry',
]}
placeholder="Select a fruit"
>
{(item) => <Option key={item}>{item}</Option>}
</Picker>
</Form.Group>
</div>
);
};
render(<CustomWidth />)`;

return (
<Editor code={code} imports={imports} scope={{Form, Option, Picker}} />
);
};

const exampleImports = `import {Option, Picker} from '@clayui/core';
import Form from '@clayui/form';
import React from 'react';`;
Expand Down Expand Up @@ -262,6 +308,7 @@ const PickerGroupExample = () => {
);
};
export {
PickerWidthExample,
PickerExample,
PickerGroupExample,
PickerTriggerExample,
Expand Down
6 changes: 6 additions & 0 deletions packages/clay-core/docs/picker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ storybookPath: 'design-system-components-picker'
---

import {
PickerWidthExample,
PickerExample,
PickerGroupExample,
PickerTriggerExample,
Expand All @@ -26,6 +27,7 @@ import {
- [Custom Trigger](#custom-trigger)
- [Custom Options](#custom-options)
- [Group](#group)
- [Flexibe width](#flexibe-width)
- [Hybrid component](#hybrid-component)

</div>
Expand Down Expand Up @@ -153,6 +155,10 @@ The composition allows you to customize the component or add new features. See s

<PickerGroupExample />

## Flexibe width

<PickerWidthExample />

## Hybrid component

Native select for mobile devices offers a better experience compared to Picker in some cases. The Picker offers the possibility to render using the native selector of the browser of the device when it is detected that it is on a mobile device, by default this property is disabled but it can be enabled by setting the `native` property to `true`.
Expand Down

0 comments on commit 460c337

Please sign in to comment.