Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: createIcon props #2629

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function createAction(content: ReactNode | ComponentType<any> | IPublicTypeActio
});
}}
>
{icon && createIcon(icon)}
{icon && createIcon(icon, { key, node })}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 node 得用 node.internalToShellNode()

另外,还需要补充一下相关的示例

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

示例:

// demo.tsx
import React from 'react';
import { Node } from '@alilc/lowcode-designer';
import { Dropdown, Icon } from '@alifd/next';
import store from 'store';

const model = [
  {
      value: 'option1',
      label: '选项1',
    },
    {
      value: ' option2',
      label: '选项2',
    },
]

import './index.less';

function SettetSwitch(props: any) {
 // 该 node 为 createIcon 传入
  const { node } = props;

  return (
    <Dropdown
      trigger={<Icon type="switch" size="small" />}
      onVisibleChange={() => store.set('setterValue', null)}
      triggerType={['hover']}
    >
      <div>
        {model.map((item) => (
          <div
            className="component-select-item"
            onClick={() => {
              // 设置物料属性
              node?.setPropValue('setter.componentName', item.value);
              node?.document?.selection.remove(node.id);
            }}
          >
            {item.label}
          </div>
        ))}
      </div>
    </Dropdown>
  );
}

export default {
  name: 'settetSwitch',
  content: {
    icon: <SettetSwitch />,
    title: 'Setter切换',
  },
  condition: (node: Node) => {
    return node.componentMeta?.componentName === 'Setters';
  },
  important: true,
};


// plugin.tsx
export default async function registerPlugins() {
  // 在设计器辅助层增加一个扩展 action
  material.addBuiltinComponentAction(setterSelect);
}

<Tip>{title}</Tip>
</div>
);
Expand Down