@storybook/addon-actions#actions TypeScript Examples

The following examples show how to use @storybook/addon-actions#actions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PageMaker.stories.tsx    From ant-extensions with MIT License 6 votes vote down vote up
Example = () => {
  const { i18n } = useTranslation();

  const eventsFromNames = actions("onChange");

  return (
    <ConfigProvider direction={i18n.dir()}>
      <div style={{ position: "fixed", top: 0, bottom: 0, left: 0, right: 0 }}>
        <PageMaker
          config={config}
          isEditing={boolean("Edit", true)}
          widgets={widgets}
          onAdd={addNew}
          renderWidget={(widget) => <div>Widget here - {widget}</div>}
          {...eventsFromNames}
        />
      </div>
    </ConfigProvider>
  );
}
Example #2
Source File: FilterBar.stories.tsx    From ant-extensions with MIT License 4 votes vote down vote up
Example = () => {
  const { i18n } = useTranslation();

  const eventsFromNames = actions("onQueryChange", "onFilterChanged", "onSearch", "onCollapsed");

  return (
    <ConfigProvider direction={i18n.dir()}>
      <div style={{ padding: "2em", margin: "auto" }}>
        <FilterBar
          filters={[
            {
              type: "filter",
              active: true,
              field: "string",
              label: "My Label87",
              negative: true,
              operator: EnumOperator.INCLUDES,
              isTimeField: false,
              required: false,
              value: "test"
            },
            {
              type: "filter",
              active: true,
              field: "string",
              label: "My Label",
              negative: false,
              operator: EnumOperator.INCLUDES,
              isTimeField: false,
              required: false,
              value: "test"
            },
            {
              type: "filter",
              active: true,
              field: "date",
              negative: false,
              operator: EnumOperator.BETWEEN,
              isTimeField: true,
              required: true,
              value: "$week|$week"
            },
            {
              type: "compare",
              field: "string",
              operator: EnumOperator.INCLUDES,
              compare: "string2",
              negative: false,
              active: true
            }
          ]}
          emptyFields="Select schema to enable filters"
          fields={[
            {
              key: "string",
              type: EnumFieldType.STRING,
              defaultOperator: EnumOperator.IN,
              name: "String"
            },
            {
              key: "number",
              type: EnumFieldType.INT,
              defaultOperator: EnumOperator.IS,
              name: "Number"
            },
            {
              key: "date",
              type: EnumFieldType.DATE,
              defaultOperator: EnumOperator.BETWEEN,
              name: "Date"
            }
          ]}
          {...eventsFromNames}
        />
        <hr />
        <div>
          <Tag color="blue">Active Filter</Tag>
          <Tag color="red">Negative Filter</Tag>
          <Tag color="geekblue">Active Comparator</Tag>
          <Tag color="orange">Negative Comparator</Tag>
        </div>
      </div>
    </ConfigProvider>
  );
}
Example #3
Source File: SearchBar.stories.tsx    From ant-extensions with MIT License 4 votes vote down vote up
Example = () => {
  const { i18n } = useTranslation();

  const eventsFromNames = actions("onQueryChange", "onFilterChanged", "onSearch", "onCollapsed");

  return (
    <ConfigProvider direction={i18n.dir()}>
      <div style={{ padding: "2em", margin: "auto" }}>
        <SearchBar
          collapsed={false}
          filters={[
            {
              type: "filter",
              active: true,
              field: "string",
              label: "My Label87",
              negative: true,
              operator: EnumOperator.INCLUDES,
              isTimeField: false,
              required: false,
              value: "test"
            },
            {
              type: "filter",
              active: true,
              field: "string",
              label: "My Label",
              negative: false,
              operator: EnumOperator.INCLUDES,
              isTimeField: false,
              required: false,
              value: "test"
            },
            {
              type: "filter",
              active: true,
              field: "date",
              negative: false,
              operator: EnumOperator.BETWEEN,
              isTimeField: true,
              required: true,
              value: "$week|$week"
            },
            {
              type: "compare",
              field: "string",
              operator: EnumOperator.INCLUDES,
              compare: "string2",
              negative: false,
              active: true
            }
          ]}
          emptyFields="Select schema to enable filters"
          fields={[
            {
              key: "string",
              type: EnumFieldType.STRING,
              defaultOperator: EnumOperator.IN,
              name: "String"
            },
            {
              key: "number",
              type: EnumFieldType.INT,
              defaultOperator: EnumOperator.IS,
              name: "Number"
            },
            {
              key: "date",
              type: EnumFieldType.DATE,
              defaultOperator: EnumOperator.BETWEEN,
              name: "Date"
            }
          ]}
          addonPrefix={<Select />}
          addonSuffix={
            <>
              <Select />
              <Select />
            </>
          }
          actions={
            <Menu>
              <Menu.Item>Action Menu</Menu.Item>
            </Menu>
          }
          {...eventsFromNames}
        />
        <hr />
        <div>
          <Tag color="blue">Active Filter</Tag>
          <Tag color="red">Negative Filter</Tag>
          <Tag color="geekblue">Active Comparator</Tag>
          <Tag color="orange">Negative Comparator</Tag>
        </div>
      </div>
    </ConfigProvider>
  );
}