form.stories.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import NewBooleanField from 'sentry/components/forms/booleanField';
  2. import Form from 'sentry/components/forms/form';
  3. import RadioField from 'sentry/components/forms/radioField';
  4. import RangeField from 'sentry/components/forms/rangeField';
  5. import SelectField from 'sentry/components/forms/selectField';
  6. import TextField from 'sentry/components/forms/textField';
  7. export default {
  8. title: 'Components/Forms/Form',
  9. args: {
  10. alignRight: false,
  11. required: false,
  12. visible: true,
  13. disabled: false,
  14. flexibleControlStateSize: true,
  15. inline: true,
  16. stacked: true,
  17. },
  18. };
  19. export const Default = ({...fieldProps}) => {
  20. return (
  21. <Form>
  22. <TextField
  23. name="textfieldflexiblecontrol"
  24. label="Text Field With Flexible Control State Size"
  25. placeholder="Type text and then delete it"
  26. {...fieldProps}
  27. />
  28. <NewBooleanField name="field" label="New Boolean Field" {...fieldProps} />
  29. <RadioField
  30. name="radio"
  31. label="Radio Field"
  32. choices={[
  33. ['choice_one', 'Choice One'],
  34. ['choice_two', 'Choice Two'],
  35. ['choice_three', 'Choice Three'],
  36. ]}
  37. {...fieldProps}
  38. />
  39. <SelectField
  40. name="select"
  41. label="Select Field"
  42. choices={[
  43. ['choice_one', 'Choice One'],
  44. ['choice_two', 'Choice Two'],
  45. ['choice_three', 'Choice Three'],
  46. ]}
  47. {...fieldProps}
  48. />
  49. <RangeField
  50. name="rangeField"
  51. label="Range Field"
  52. min={1}
  53. max={10}
  54. step={1}
  55. value={1}
  56. formatLabel={value => {
  57. return `${value} Toaster Strudle${value > 1 ? 's' : ''}`;
  58. }}
  59. {...fieldProps}
  60. />
  61. </Form>
  62. );
  63. };
  64. Default.storyName = 'Form';
  65. Default.parameters = {
  66. docs: {
  67. description: {
  68. story:
  69. 'Use the knobs to see how the different field props that can be used affect the form layout.',
  70. },
  71. },
  72. };