diff --git a/apps/playground/src/helpers/mock-files.ts b/apps/playground/src/helpers/mock-files.ts index e11bc15..80ea6e3 100644 --- a/apps/playground/src/helpers/mock-files.ts +++ b/apps/playground/src/helpers/mock-files.ts @@ -161,6 +161,8 @@ import { } from "@music163/antd"; import { Space } from "@music163/antd"; import { LocalButton } from "../components"; +import { OutButton } from "../components"; + class App extends React.Component { render() { return ( @@ -181,6 +183,7 @@ class App extends React.Component {
+
@@ -290,6 +293,14 @@ registerComponentPrototype({ }); `; +const outButtonCode = ` +import React from 'react'; + +export default function OutButton(props) { + return +} +`; + const componentsInputCode = ` import React from 'react'; import { registerComponentPrototype } from '../utils'; @@ -312,6 +323,7 @@ registerComponentPrototype({ const componentsEntryCode = ` export { default as LocalButton } from './button'; export { default as LocalInput } from './input'; +export { default as OutButton } from './out-button'; `; const storeApp = ` @@ -412,6 +424,7 @@ export const sampleFiles = [ { filename: '/src/pages/list.js', code: viewHomeCode }, { filename: '/src/pages/detail.js', code: emptyPageCode }, { filename: '/src/components/button.js', code: componentsButtonCode }, + { filename: '/src/components/out-button.js', code: outButtonCode }, { filename: '/src/components/input.js', code: componentsInputCode }, { filename: '/src/components/index.js', code: componentsEntryCode }, { filename: '/src/routes.js', code: routesCode }, diff --git a/packages/designer/src/sidebar/components-panel.tsx b/packages/designer/src/sidebar/components-panel.tsx index 2ed2cf6..6110903 100644 --- a/packages/designer/src/sidebar/components-panel.tsx +++ b/packages/designer/src/sidebar/components-panel.tsx @@ -289,6 +289,10 @@ const StyledCommonGridItem = styled.div` transition: 0.15s ease-in-out; transition-property: transform; will-change: transform; + img { + width: unset; + height: 85%; + } } .info { @@ -355,6 +359,15 @@ function MaterialGrid({ data }: MaterialProps) { }; const icon = data.icon || 'icon-placeholder'; + + const iconNode = icon.startsWith('icon-') ? ( + + ) : ( + + {data.name} + + ); + if (isLine) { return ( - {icon.startsWith('icon-') ? ( - - ) : ( - {data.name} - )} + {iconNode} @@ -417,11 +426,7 @@ function MaterialGrid({ data }: MaterialProps) { onDragEnd={handleDragEnd} onClick={handleSelect} > - {icon.startsWith('icon-') ? ( - - ) : ( - {data.name} - )} + {iconNode} {data.title ?? data.name} diff --git a/packages/designer/src/simulator/selection.tsx b/packages/designer/src/simulator/selection.tsx index 0475d57..92ede72 100644 --- a/packages/designer/src/simulator/selection.tsx +++ b/packages/designer/src/simulator/selection.tsx @@ -198,7 +198,7 @@ function SelectionBox({ showActions, actions, data }: SelectionBoxProps) { } /> {!isPage && actions} - {prototype.hasChildren !== false && ( + {isFromCurrentFile && prototype?.hasChildren !== false && ( } />