-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fleet UI: Software headers more responsive (#25212)
- Loading branch information
1 parent
464d99d
commit 5873cb9
Showing
11 changed files
with
161 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 50 additions & 31 deletions
81
frontend/components/forms/fields/DropdownWrapper/DropdownWrapper.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,81 @@ | ||
// stories/DropdownWrapper.stories.tsx | ||
|
||
import React from "react"; | ||
import { Meta, Story } from "@storybook/react"; | ||
import DropdownWrapper, { | ||
IDropdownWrapper, | ||
CustomOptionType, | ||
} from "./DropdownWrapper"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import DropdownWrapper, { CustomOptionType } from "./DropdownWrapper"; | ||
|
||
// Define metadata for the story | ||
export default { | ||
const meta: Meta<typeof DropdownWrapper> = { | ||
title: "Components/DropdownWrapper", | ||
component: DropdownWrapper, | ||
argTypes: { | ||
onChange: { action: "changed" }, | ||
}, | ||
} as Meta; | ||
// Padding added to view tooltips | ||
decorators: [ | ||
(Story) => ( | ||
<div style={{ overflow: "visible", padding: "150px" }}> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
}; | ||
|
||
export default meta; | ||
|
||
// Define a template for the stories | ||
const Template: Story<IDropdownWrapper> = (args) => ( | ||
<DropdownWrapper {...args} /> | ||
); | ||
type Story = StoryObj<typeof DropdownWrapper>; | ||
|
||
// Sample options to be used in the dropdown | ||
const sampleOptions: CustomOptionType[] = [ | ||
{ label: "Option 1", value: "option1", helpText: "Help text for option 1" }, | ||
{ | ||
label: "Option 2", | ||
label: "Option 1 - just help text", | ||
value: "option1", | ||
helpText: "Help text for option 1", | ||
}, | ||
{ | ||
label: "Option 2 - just tooltip", | ||
value: "option2", | ||
tooltipContent: "Tooltip for option 2", | ||
}, | ||
{ label: "Option 3", value: "option3", isDisabled: true }, | ||
{ label: "Option 3 - just disabled", value: "option3", isDisabled: true }, | ||
{ | ||
label: "Option 4 - help text, disabled, and tooltip", | ||
value: "option4", | ||
helpText: "Help text for option 4", | ||
isDisabled: true, | ||
tooltipContent: "Tooltip for option 4", | ||
}, | ||
]; | ||
|
||
// Default story | ||
export const Default = Template.bind({}); | ||
Default.args = { | ||
options: sampleOptions, | ||
name: "dropdown-example", | ||
label: "Select an option", | ||
export const Default: Story = { | ||
args: { | ||
options: sampleOptions, | ||
name: "dropdown-example", | ||
label: "Select an option", | ||
}, | ||
}; | ||
|
||
// Disabled story | ||
export const Disabled = Template.bind({}); | ||
Disabled.args = { | ||
...Default.args, | ||
isDisabled: true, | ||
export const Disabled: Story = { | ||
args: { | ||
...Default.args, | ||
isDisabled: true, | ||
}, | ||
}; | ||
|
||
// With Help Text story | ||
export const WithHelpText = Template.bind({}); | ||
WithHelpText.args = { | ||
...Default.args, | ||
helpText: "This is some help text for the dropdown", | ||
export const WithHelpText: Story = { | ||
args: { | ||
...Default.args, | ||
helpText: "This is some help text for the dropdown", | ||
}, | ||
}; | ||
|
||
// With Error story | ||
export const WithError = Template.bind({}); | ||
WithError.args = { | ||
...Default.args, | ||
error: "This is an error message", | ||
export const WithError: Story = { | ||
args: { | ||
...Default.args, | ||
error: "This is an error message", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.