|
| 1 | +/*! |
| 2 | + * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved. |
| 3 | + * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.") |
| 4 | + * |
| 5 | + * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. |
| 6 | + * Unless required by applicable law or agreed to in writing, software |
| 7 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 8 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 9 | + * |
| 10 | + * See the License for the specific language governing permissions and limitations under the License. |
| 11 | + */ |
| 12 | + |
| 13 | +import React from "react"; |
| 14 | +import type { Story } from "@storybook/react"; |
| 15 | +import { NativeSelect, NativeSelectProps } from "@okta/odyssey-react"; |
| 16 | +import { NativeSelect as Source } from "../../../../odyssey-react/src"; |
| 17 | + |
| 18 | +export default { |
| 19 | + title: `Components/NativeSelect`, |
| 20 | + component: Source, |
| 21 | + args: { |
| 22 | + label: "Select", |
| 23 | + }, |
| 24 | + argTypes: { |
| 25 | + hint: { control: "text" }, |
| 26 | + error: { control: "text" }, |
| 27 | + label: { control: "text" }, |
| 28 | + required: { control: "boolean" }, |
| 29 | + disabled: { control: "boolean" }, |
| 30 | + }, |
| 31 | +}; |
| 32 | + |
| 33 | +const Template: Story<NativeSelectProps> = (args) => ( |
| 34 | + <NativeSelect {...args}> |
| 35 | + <NativeSelect.Option> |
| 36 | + This is an extremely long option for testing what happens to text when it |
| 37 | + tries to overflow |
| 38 | + </NativeSelect.Option> |
| 39 | + <NativeSelect.Option>Option 2</NativeSelect.Option> |
| 40 | + <NativeSelect.Option>Option 3</NativeSelect.Option> |
| 41 | + <NativeSelect.Option>Option 4</NativeSelect.Option> |
| 42 | + <NativeSelect.Option>Option 5</NativeSelect.Option> |
| 43 | + </NativeSelect> |
| 44 | +); |
| 45 | + |
| 46 | +export const Default = Template.bind({}); |
| 47 | + |
| 48 | +export const Multiselect = Template.bind({}); |
| 49 | +Multiselect.args = { |
| 50 | + label: "Select Multiple", |
| 51 | + multiple: true, |
| 52 | +}; |
| 53 | + |
| 54 | +export const OptionGroups = (): JSX.Element => ( |
| 55 | + <NativeSelect label="Select Option Groups"> |
| 56 | + <NativeSelect.OptionGroup label="Group 1"> |
| 57 | + <NativeSelect.Option>Option 1</NativeSelect.Option> |
| 58 | + <NativeSelect.Option>Option 2</NativeSelect.Option> |
| 59 | + </NativeSelect.OptionGroup> |
| 60 | + <NativeSelect.OptionGroup label="Group 2"> |
| 61 | + <NativeSelect.Option>Option 3</NativeSelect.Option> |
| 62 | + <NativeSelect.Option>Option 4</NativeSelect.Option> |
| 63 | + <NativeSelect.Option>Option 5</NativeSelect.Option> |
| 64 | + </NativeSelect.OptionGroup> |
| 65 | + </NativeSelect> |
| 66 | +); |
0 commit comments