Skip to content

Commit cd4f98b

Browse files
fixed shape width and height, added default icon selection
1 parent 7e190ed commit cd4f98b

File tree

2 files changed

+17
-89
lines changed

2 files changed

+17
-89
lines changed

client/packages/lowcoder/src/comps/comps/shapeComp/shapeComp.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ const Container = styled.div<{ $style: IconStyleType | undefined }>`
3434
display: flex;
3535
align-items: center;
3636
justify-content: center;
37+
.coolshapes {
38+
max-width: 100%;
39+
min-height: 100%;
40+
min-width: 100%;
41+
}
3742
3843
${(props) =>
3944
props.$style &&
@@ -110,7 +115,6 @@ const IconView = (props: RecordConstructorToView<typeof childrenMap>) => {
110115
<Coolshape
111116
type={shape.value as any}
112117
index={shape.index}
113-
size={48}
114118
noise={true}
115119
/>
116120
</Container>

client/packages/lowcoder/src/comps/controls/shapeControl.tsx

Lines changed: 12 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ const IconPicker = (props: {
8484
console.log(props);
8585
let shapeDetails = props.value;
8686
console.log("shapeDetails ", shapeDetails);
87-
88-
87+
8988
return (
9089
<ShapeSelect
9190
onChange={props.onChange}
@@ -98,18 +97,16 @@ const IconPicker = (props: {
9897
<ButtonWrapper>
9998
<ButtonIconWrapper>
10099
<Coolshape
101-
type={"star"}
102-
index={0}
103-
size={48}
100+
type={(shapeDetails?.split("_")[1] as any) ?? "star"}
101+
index={parseInt(shapeDetails?.split("_")[0]) ?? 0}
102+
size={28}
104103
noise={true}
105104
/>
106105
</ButtonIconWrapper>
107-
{/* <ButtonIconWrapper>{icon.getView()}</ButtonIconWrapper>
108-
<ButtonText title={icon.title}>{icon.title}</ButtonText> */}
109106

110107
<StyledDeleteInputIcon
111108
onClick={(e) => {
112-
props.onChange("");
109+
props.onChange("");
113110
e.stopPropagation();
114111
}}
115112
/>
@@ -164,63 +161,7 @@ type Range = {
164161
to: number;
165162
};
166163

167-
function IconCodeEditor(props: {
168-
codeControl: InstanceType<typeof StringControl>;
169-
params: ControlParams;
170-
}) {
171-
const [visible, setVisible] = useState(false);
172-
const [range, setRange] = useState<Range>();
173-
const widgetPopup = useCallback(
174-
(v: EditorView) => (
175-
<IconSelectBase
176-
onChange={(value) => {
177-
const r: Range = range ??
178-
v.state.selection.ranges[0] ?? { from: 0, to: 0 };
179-
const insert = '"' + value + '"';
180-
setRange({ ...r, to: r.from + insert.length });
181-
v.dispatch({ changes: { ...r, insert } });
182-
}}
183-
visible={visible}
184-
setVisible={setVisible}
185-
trigger="contextMenu"
186-
// parent={document.querySelector<HTMLElement>(`${CodeEditorTooltipContainer}`)}
187-
searchKeywords={i18nObjs.iconSearchKeywords}
188-
/>
189-
),
190-
[visible, range]
191-
);
192-
const onClick = useCallback((e: React.MouseEvent, v: EditorView) => {
193-
const r = onClickIcon(e, v);
194-
if (r) {
195-
setVisible(true);
196-
setRange(r);
197-
}
198-
}, []);
199-
const extraOnChange = useCallback((state: EditorState) => {
200-
// popover should hide on change
201-
setVisible(false);
202-
setRange(undefined);
203-
}, []);
204-
return props.codeControl.codeEditor({
205-
...props.params,
206-
enableIcon: true,
207-
widgetPopup,
208-
onClick,
209-
extraOnChange,
210-
cardRichContent,
211-
cardTips: (
212-
<>
213-
{trans("shapeControl.insertImage")}
214-
<TacoButton
215-
style={{ display: "inline" }}
216-
onClick={() => setVisible(true)}
217-
>
218-
{trans("shapeControl.insertShape")}
219-
</TacoButton>
220-
</>
221-
),
222-
});
223-
}
164+
224165

225166
function isSelectValue(value: any) {
226167
return !value || (typeof value === "string" && value.startsWith(iconPrefix));
@@ -278,31 +219,14 @@ export class ShapeControl extends AbstractComp<
278219
onChange={() => this.dispatch(this.changeModeAction())}
279220
/>
280221
);
281-
if (this.useCodeEditor) {
282-
return controlItem(
283-
{ filterText: params.label },
284-
<Wrapper>
285-
<SwitchWrapper
286-
label={params.label}
287-
tooltip={params.tooltip}
288-
lastNode={jsContent}
289-
/>
290-
{this.useCodeEditor && (
291-
<IconCodeEditor codeControl={this.codeControl} params={params} />
292-
)}
293-
</Wrapper>
294-
);
295-
}
296222
return wrapperToControlItem(
297223
<ControlPropertyViewWrapper {...params} lastNode={jsContent}>
298-
{!this.useCodeEditor && (
299-
<IconPicker
300-
value={this.codeControl.getView()}
301-
onChange={(x) => this.dispatchChangeValueAction(x)}
302-
label={params.label}
303-
IconType={params.IconType}
304-
/>
305-
)}
224+
<IconPicker
225+
value={this.codeControl.getView()}
226+
onChange={(x) => this.dispatchChangeValueAction(x)}
227+
label={params.label}
228+
IconType={params.IconType}
229+
/>
306230
</ControlPropertyViewWrapper>
307231
);
308232
}

0 commit comments

Comments
 (0)