Skip to content

Adding Shapes Component #854

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

Merged
merged 27 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
10d27dc
initial shape component
freddysundowner Apr 18, 2024
840678f
Merge branch 'dev' of https://github.com/lowcoder-org/lowcoder into f…
freddysundowner Apr 18, 2024
6842c4f
merged from dev
freddysundowner Apr 18, 2024
cd3d37f
initial shape component
freddysundowner Apr 18, 2024
06d6458
selecting active shape
freddysundowner Apr 19, 2024
c0325fe
selecting active shape
freddysundowner Apr 19, 2024
7e190ed
aa
freddysundowner Apr 24, 2024
cd4f98b
fixed shape width and height, added default icon selection
freddysundowner Apr 27, 2024
a78fbe1
added icons lables
freddysundowner May 6, 2024
4ac855d
added grid too shapes comp and lables to shapes lists
freddysundowner May 6, 2024
acda8fe
referencing forked coolshapes package
freddysundowner May 6, 2024
e1a49c4
added grid too shapes comp and lables to shapes lists
freddysundowner May 6, 2024
578899e
initial shape component
freddysundowner Apr 18, 2024
e9d4aa4
initial shape component
freddysundowner Apr 18, 2024
be62b7d
selecting active shape
freddysundowner Apr 19, 2024
ebc66fe
selecting active shape
freddysundowner Apr 19, 2024
b07fee5
aa
freddysundowner Apr 24, 2024
b19c9bc
fixed shape width and height, added default icon selection
freddysundowner Apr 27, 2024
e5e1e2a
added icons lables
freddysundowner May 6, 2024
9e2f907
added grid too shapes comp and lables to shapes lists
freddysundowner May 6, 2024
bcd1211
referencing forked coolshapes package
freddysundowner May 6, 2024
5665218
added grid too shapes comp and lables to shapes lists
freddysundowner May 6, 2024
9143dd5
lazy load shapes comp
raheeliftikhar5 May 9, 2024
7dab708
removed console
raheeliftikhar5 May 9, 2024
307668c
Merge branch 'feat-ShapeComp' of https://github.com/lowcoder-org/lowc…
freddysundowner May 9, 2024
84ba449
fixed drag items to shape comp
freddysundowner May 10, 2024
b156fc0
Merge branch 'dev' into feat-ShapeComp
FalkWolsky May 11, 2024
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
Prev Previous commit
Next Next commit
fixed shape width and height, added default icon selection
  • Loading branch information
freddysundowner committed Apr 27, 2024
commit cd4f98b1f939df2f787cfd557ffe5787497dc25c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const Container = styled.div<{ $style: IconStyleType | undefined }>`
display: flex;
align-items: center;
justify-content: center;
.coolshapes {
max-width: 100%;
min-height: 100%;
min-width: 100%;
}

${(props) =>
props.$style &&
Expand Down Expand Up @@ -110,7 +115,6 @@ const IconView = (props: RecordConstructorToView<typeof childrenMap>) => {
<Coolshape
type={shape.value as any}
index={shape.index}
size={48}
noise={true}
/>
</Container>
Expand Down
100 changes: 12 additions & 88 deletions client/packages/lowcoder/src/comps/controls/shapeControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ const IconPicker = (props: {
console.log(props);
let shapeDetails = props.value;
console.log("shapeDetails ", shapeDetails);



return (
<ShapeSelect
onChange={props.onChange}
Expand All @@ -98,18 +97,16 @@ const IconPicker = (props: {
<ButtonWrapper>
<ButtonIconWrapper>
<Coolshape
type={"star"}
index={0}
size={48}
type={(shapeDetails?.split("_")[1] as any) ?? "star"}
index={parseInt(shapeDetails?.split("_")[0]) ?? 0}
size={28}
noise={true}
/>
</ButtonIconWrapper>
{/* <ButtonIconWrapper>{icon.getView()}</ButtonIconWrapper>
<ButtonText title={icon.title}>{icon.title}</ButtonText> */}

<StyledDeleteInputIcon
onClick={(e) => {
props.onChange("");
props.onChange("");
e.stopPropagation();
}}
/>
Expand Down Expand Up @@ -164,63 +161,7 @@ type Range = {
to: number;
};

function IconCodeEditor(props: {
codeControl: InstanceType<typeof StringControl>;
params: ControlParams;
}) {
const [visible, setVisible] = useState(false);
const [range, setRange] = useState<Range>();
const widgetPopup = useCallback(
(v: EditorView) => (
<IconSelectBase
onChange={(value) => {
const r: Range = range ??
v.state.selection.ranges[0] ?? { from: 0, to: 0 };
const insert = '"' + value + '"';
setRange({ ...r, to: r.from + insert.length });
v.dispatch({ changes: { ...r, insert } });
}}
visible={visible}
setVisible={setVisible}
trigger="contextMenu"
// parent={document.querySelector<HTMLElement>(`${CodeEditorTooltipContainer}`)}
searchKeywords={i18nObjs.iconSearchKeywords}
/>
),
[visible, range]
);
const onClick = useCallback((e: React.MouseEvent, v: EditorView) => {
const r = onClickIcon(e, v);
if (r) {
setVisible(true);
setRange(r);
}
}, []);
const extraOnChange = useCallback((state: EditorState) => {
// popover should hide on change
setVisible(false);
setRange(undefined);
}, []);
return props.codeControl.codeEditor({
...props.params,
enableIcon: true,
widgetPopup,
onClick,
extraOnChange,
cardRichContent,
cardTips: (
<>
{trans("shapeControl.insertImage")}
<TacoButton
style={{ display: "inline" }}
onClick={() => setVisible(true)}
>
{trans("shapeControl.insertShape")}
</TacoButton>
</>
),
});
}


function isSelectValue(value: any) {
return !value || (typeof value === "string" && value.startsWith(iconPrefix));
Expand Down Expand Up @@ -278,31 +219,14 @@ export class ShapeControl extends AbstractComp<
onChange={() => this.dispatch(this.changeModeAction())}
/>
);
if (this.useCodeEditor) {
return controlItem(
{ filterText: params.label },
<Wrapper>
<SwitchWrapper
label={params.label}
tooltip={params.tooltip}
lastNode={jsContent}
/>
{this.useCodeEditor && (
<IconCodeEditor codeControl={this.codeControl} params={params} />
)}
</Wrapper>
);
}
return wrapperToControlItem(
<ControlPropertyViewWrapper {...params} lastNode={jsContent}>
{!this.useCodeEditor && (
<IconPicker
value={this.codeControl.getView()}
onChange={(x) => this.dispatchChangeValueAction(x)}
label={params.label}
IconType={params.IconType}
/>
)}
<IconPicker
value={this.codeControl.getView()}
onChange={(x) => this.dispatchChangeValueAction(x)}
label={params.label}
IconType={params.IconType}
/>
</ControlPropertyViewWrapper>
);
}
Expand Down