From aa1896ed2265bec78ed1ddb3a4bb2bed51f27442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matuzal=C3=A9m=20Teles?= Date: Fri, 4 Aug 2023 16:27:50 -0500 Subject: [PATCH] docs(clayui.com): adds compositing examples to Picker --- packages/clay-core/docs/picker.js | 217 ++++++++++++++++++++++++++++- packages/clay-core/docs/picker.mdx | 27 +++- 2 files changed, 241 insertions(+), 3 deletions(-) diff --git a/packages/clay-core/docs/picker.js b/packages/clay-core/docs/picker.js index c8a4e7bb69..875ab23f22 100644 --- a/packages/clay-core/docs/picker.js +++ b/packages/clay-core/docs/picker.js @@ -4,8 +4,13 @@ */ import Editor from '$clayui.com/src/components/Editor'; -import {Option, Picker} from '@clayui/core'; +import {Option, Picker, Text} from '@clayui/core'; +import DropDown from '@clayui/drop-down'; import Form from '@clayui/form'; +import Icon from '@clayui/icon'; +import Label from '@clayui/label'; +import Layout from '@clayui/layout'; +import {useId} from '@clayui/shared'; import React from 'react'; const exampleImports = `import {Option, Picker} from '@clayui/core'; @@ -53,4 +58,212 @@ const PickerExample = () => { return ; }; -export {PickerExample}; +const exampleTriggerImports = `import {Option, Picker} from '@clayui/core'; +import Form from '@clayui/form'; +import Icon from '@clayui/icon'; +import React from 'react';`; + +const exampleTriggerCode = `const Trigger = React.forwardRef(({children, ...otherProps}, ref) => ( +
+ + {children} +
+)); + +const CustomTrigger = () => { + const pickerId = useId(); + const labelId = useId(); + + return ( +
+ + + + {(item) => } + + +
+ ); +}; + +render()`; + +const PickerTriggerExample = () => { + const scope = {Form, Icon, Option, Picker, React, useId}; + + return ( + + ); +}; + +const exampleOptionsImports = `import {Option, Picker} from '@clayui/core'; +import Form from '@clayui/form'; +import React from 'react';`; + +const exampleOptionsCode = `const CustomOptions = () => { + const pickerId = useId(); + const labelId = useId(); + + return ( +
+ + + + {(item) => ( + + )} + + +
+ ); +}; + +render()`; + +const PickerOptionsxample = () => { + const scope = { + Form, + Icon, + Label, + Layout, + Option, + Picker, + React, + Text, + useId, + }; + + return ( + + ); +}; + +const exampleGroupImports = `import {Option, Picker} from '@clayui/core'; +import Form from '@clayui/form'; +import Icon from '@clayui/icon'; +import React from 'react';`; + +const exampleGroupCode = `const Trigger = React.forwardRef(({children, ...otherProps}, ref) => ( +
+ + {children} +
+)); + +const CustomTrigger = () => { + const pickerId = useId(); + const labelId = useId(); + + return ( +
+ + + + {(group) => ( + + {(item) => ( + + )} + + )} + + +
+ ); +}; + +render()`; + +const PickerGroupExample = () => { + const scope = {DropDown, Form, Option, Picker, React, useId}; + + return ( + + ); +}; +export { + PickerExample, + PickerGroupExample, + PickerTriggerExample, + PickerOptionsxample, +}; diff --git a/packages/clay-core/docs/picker.mdx b/packages/clay-core/docs/picker.mdx index 94d3030990..ca7350b096 100644 --- a/packages/clay-core/docs/picker.mdx +++ b/packages/clay-core/docs/picker.mdx @@ -6,7 +6,12 @@ packageStatus: 'Beta' storybookPath: 'design-system-components-picker' --- -import {PickerExample} from '$packages/clay-core/docs/picker'; +import { + PickerExample, + PickerGroupExample, + PickerTriggerExample, + PickerOptionsxample, +} from '$packages/clay-core/docs/picker';