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

hotfix/1.2 #160

Merged
merged 5 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 13 additions & 0 deletions apps/playground/src/helpers/mock-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -181,6 +183,7 @@ class App extends React.Component {
<Section tid="section2">
<Space tid="space1">
<LocalButton />
<OutButton />
<Button tid="button1">button</Button>
</Space>
</Section>
Expand Down Expand Up @@ -290,6 +293,14 @@ registerComponentPrototype({
});
`;

const outButtonCode = `
import React from 'react';

export default function OutButton(props) {
return <button {...props}>Out button (from other file)</button>
}
`;

const componentsInputCode = `
import React from 'react';
import { registerComponentPrototype } from '../utils';
Expand All @@ -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 = `
Expand Down Expand Up @@ -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 },
Expand Down
25 changes: 15 additions & 10 deletions packages/designer/src/sidebar/components-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -355,6 +359,15 @@ function MaterialGrid({ data }: MaterialProps) {
};

const icon = data.icon || 'icon-placeholder';

const iconNode = icon.startsWith('icon-') ? (
<IconFont className="material-icon" type={data.icon || 'icon-placeholder'} />
) : (
<Box className="material-icon">
<img src={icon} alt={data.name} />
</Box>
);

if (isLine) {
return (
<Box
Expand All @@ -380,11 +393,7 @@ function MaterialGrid({ data }: MaterialProps) {
alignItems="center"
justifyContent="center"
>
{icon.startsWith('icon-') ? (
<IconFont className="material-icon" type={data.icon || 'icon-placeholder'} />
) : (
<img className="material-icon" src={icon} alt={data.name} />
)}
{iconNode}
</Box>
<Box flex={1}>
<Box fontWeight="500" display="flex" justifyContent="space-between">
Expand Down Expand Up @@ -417,11 +426,7 @@ function MaterialGrid({ data }: MaterialProps) {
onDragEnd={handleDragEnd}
onClick={handleSelect}
>
{icon.startsWith('icon-') ? (
<IconFont className="material-icon" type={data.icon || 'icon-placeholder'} />
) : (
<img className="material-icon" src={icon} alt={data.name} />
)}
{iconNode}
<Text fontSize="12px" marginTop="4px">
{data.title ?? data.name}
</Text>
Expand Down
2 changes: 1 addition & 1 deletion packages/designer/src/simulator/selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function SelectionBox({ showActions, actions, data }: SelectionBoxProps) {
}
/>
<SelectionToolSet>{!isPage && actions}</SelectionToolSet>
{prototype.hasChildren !== false && (
{isFromCurrentFile && prototype?.hasChildren !== false && (
<ComponentsPopover>
<Tooltip title="快捷添加子元素">
<SelectionHelper icon={<PlusOutlined />} />
Expand Down
Loading