From 4c4b0e34e0d49349fb2434dcff9666d33b8b3a5c Mon Sep 17 00:00:00 2001 From: NgocNhi123 Date: Mon, 1 Jul 2024 00:10:41 +0700 Subject: [PATCH] migrate components --- new-docs/src/components/dialog.stories.tsx | 103 ++++++++++++ new-docs/src/components/icon.stories.tsx | 110 +++++++++++++ new-docs/src/components/input.stories.tsx | 150 ++++++++++++++++++ .../src/components/pagination.stories.tsx | 69 ++++++++ new-docs/src/components/pane.stories.tsx | 50 ++++++ new-docs/src/components/popover.stories.tsx | 122 ++++++++++++++ .../components/progress-circle.stories.tsx | 70 ++++++++ new-docs/src/components/radio.stories.tsx | 86 ++++++++++ new-docs/src/components/switcher-fake.tsx | 9 -- new-docs/src/components/tag.stories.tsx | 43 +++++ new-docs/src/components/text-area.stories.tsx | 31 ++++ .../src/components/time-input.stories.tsx | 91 +++++++++++ new-docs/src/components/tooltip.stories.tsx | 67 ++++++++ new-docs/src/components/tree.stories.tsx | 64 ++++++++ new-docs/src/utils/placement.ts | 19 +++ 15 files changed, 1075 insertions(+), 9 deletions(-) create mode 100644 new-docs/src/components/dialog.stories.tsx create mode 100644 new-docs/src/components/icon.stories.tsx create mode 100644 new-docs/src/components/input.stories.tsx create mode 100644 new-docs/src/components/pagination.stories.tsx create mode 100644 new-docs/src/components/pane.stories.tsx create mode 100644 new-docs/src/components/popover.stories.tsx create mode 100644 new-docs/src/components/progress-circle.stories.tsx create mode 100644 new-docs/src/components/radio.stories.tsx delete mode 100644 new-docs/src/components/switcher-fake.tsx create mode 100644 new-docs/src/components/tag.stories.tsx create mode 100644 new-docs/src/components/text-area.stories.tsx create mode 100644 new-docs/src/components/time-input.stories.tsx create mode 100644 new-docs/src/components/tooltip.stories.tsx create mode 100644 new-docs/src/components/tree.stories.tsx create mode 100644 new-docs/src/utils/placement.ts diff --git a/new-docs/src/components/dialog.stories.tsx b/new-docs/src/components/dialog.stories.tsx new file mode 100644 index 00000000..2b306b3d --- /dev/null +++ b/new-docs/src/components/dialog.stories.tsx @@ -0,0 +1,103 @@ +import { Meta } from "@storybook/react"; +import { useState } from "react"; +import { Button, Dialog, DivGrow, Paragraph } from "../../../core/src"; +import { GalleryDialog } from "../../../gallery/src"; +import { Utils } from "../utils/utils"; + +const meta: Meta = { + title: "Components/Dialog", + component: Dialog, +} as Meta; + +Utils.page.component(meta, { + primary: "none", + shots: [], +}); + +export default meta; + +export const Primary = (): JSX.Element =>
None
; + +/** + * Dialog is a [controlled][1], [declarative][3] component: you should have a + * boolean [state][2] for whether the dialog should be visible or not, and + * conditionally render a dialog based on that state. + * + * A dialog will call its \`onEsc\` function when the user press the "Esc" key or + * click on the backdrop. It's common to set your state to \`false\` here to + * "close" the dialog. + * + * [1]: https://reactjs.org/docs/forms.html#controlled-components + * [2]: https://reactjs.org/docs/hooks-state.html + * [3]: https://reactjs.org/docs/refs-and-the-dom.html#when-to-use-refs + */ +export const Basic = (): JSX.Element => { + const [visible, setVisible] = useState(false); + return ( + <> + + + + + + + )} + + ); +}; + +/** + * The Dialog component has some utility methods as alternatives to the browser's + * built-in dialogs: + * + * - \`Dialog.alert\` for [\`window.alert\`][1] + * - \`Dialog.confirm\` for [\`window.confirm\`][2] + * - \`Dialog.prompt\` for [\`window.prompt\`][3] + * + * They accept the same parameters as their built-in counterparts, but return + * async results and thus do not block the main flow. They are implemented using + * Moai's components. + * + * [1]: https://developer.mozilla.org/en-US/docs/Web/API/Window/alert + * [2]: https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm + * [3]: https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt + */ +export const Utilities = (): JSX.Element => ( +