Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1df9973

Browse files
Merge pull request #799 from snowe2010/allow-pinning-code-editor-popup
Allow pinning the code editor popup
2 parents 2c9cd17 + ded0c8b commit 1df9973

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

‎client/packages/lowcoder-design/src/icons/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export { ReactComponent as ClickLinkIcon } from "./icon-clickLink.svg";
2222
export { ReactComponent as CloseEyeIcon } from "./icon-closeEye.svg";
2323
export { ReactComponent as CodeEditorCloseIcon } from "./icon-code-editor-close.svg";
2424
export { ReactComponent as CodeEditorOpenIcon } from "./icon-code-editor-open.svg";
25+
export { ReactComponent as CodeEditorPinnedIcon} from "./remix/pushpin-2-fill.svg"
26+
export { ReactComponent as CodeEditorUnPinnedIcon} from "./remix/pushpin-line.svg"
2527
export { ReactComponent as ColorHexIcon } from "./icon-colorHex.svg";
2628
export { ReactComponent as ContainerDragIcon } from "./icon-container-drag.svg";
2729
export { ReactComponent as CopyIcon } from "./icon-copy.svg";

‎client/packages/lowcoder/src/pages/editor/codeEditorPanel.tsx‎

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styled from "styled-components";
22
import { ReactNode, useContext, useMemo, useRef, useState } from "react";
33
import { Layers } from "../../constants/Layers";
4-
import { CodeEditorOpenIcon } from "lowcoder-design";
4+
import { CodeEditorOpenIcon,CodeEditorPinnedIcon,CodeEditorUnPinnedIcon } from "lowcoder-design";
55
import { CodeEditorCloseIcon } from "lowcoder-design";
66
import { DragIcon } from "lowcoder-design";
77
import Trigger from "rc-trigger";
@@ -74,6 +74,11 @@ const OpenButton = styled.div`
7474
}
7575
}
7676
`;
77+
const Buttons = styled.div`
78+
display: flex;
79+
justify-content: space-between;
80+
align-items: center;
81+
`
7782
const CloseButton = styled.div`
7883
display: flex;
7984
justify-content: space-between;
@@ -98,6 +103,30 @@ const CloseButton = styled.div`
98103
}
99104
}
100105
`;
106+
const PinButton = styled.div`
107+
width: 32px;
108+
height: 26px;
109+
border: 1px solid #d7d9e0;
110+
border-radius: 4px;
111+
color: #333333;
112+
padding: 2px ;
113+
cursor: pointer;
114+
115+
&:hover {
116+
background: #f5f5f6;
117+
118+
svg g g {
119+
stroke: #222222;
120+
}
121+
}
122+
123+
// fixes the icon when there's no text in the container
124+
svg {
125+
width: 100%;
126+
height: 100%;
127+
fill: currentColor;
128+
}
129+
`;
101130

102131
export const CodeEditorPanel = (props: {
103132
editor: ReactNode;
@@ -106,6 +135,8 @@ export const CodeEditorPanel = (props: {
106135
}) => {
107136
const draggableRef = useRef<HTMLDivElement>(null);
108137
const [unDraggable, setUnDraggable] = useState(true);
138+
const [pinned, setPinned] = useState(false);
139+
109140
const [bounds, setBounds] = useState({
110141
left: 0,
111142
top: 0,
@@ -126,7 +157,8 @@ export const CodeEditorPanel = (props: {
126157
action={["click"]}
127158
zIndex={Layers.codeEditorPanel}
128159
popupStyle={{ opacity: 1, display: visible ? "block" : "none" }}
129-
maskClosable={true}
160+
maskClosable={!pinned}
161+
mask={true}
130162
onPopupVisibleChange={(visible) => setVisible(visible)}
131163
afterPopupVisibleChange={(visible) => props.onVisibleChange(visible)}
132164
getPopupContainer={(node: any) => node.parentNode.parentNode}
@@ -169,10 +201,15 @@ export const CodeEditorPanel = (props: {
169201
<StyledDragIcon />
170202
{[compName, ...(props.breadcrumb ?? [])].filter((t) => !isEmpty(t)).join(" / ")}
171203
</TitleWrapper>
172-
<CloseButton onClick={() => setVisible(false)}>
173-
<CodeEditorCloseIcon />
174-
{trans("codeEditor.fold")}
175-
</CloseButton>
204+
<Buttons>
205+
<PinButton onClick={() => setPinned(!pinned) }>
206+
{pinned ? <CodeEditorPinnedIcon/> : <CodeEditorUnPinnedIcon/>}
207+
</PinButton>
208+
<CloseButton onClick={() => setVisible(false)}>
209+
<CodeEditorCloseIcon />
210+
{trans("codeEditor.fold")}
211+
</CloseButton>
212+
</Buttons>
176213
</HeaderWrapper>
177214

178215
<BodyWrapper>{props.editor}</BodyWrapper>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /