Skip to content

Drawer Close Button Left or Right #716

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 2 commits into from
Feb 26, 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
75 changes: 44 additions & 31 deletions client/packages/lowcoder/src/comps/hooks/drawerComp.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { CloseOutlined } from "@ant-design/icons";
import { CloseOutlined, PropertySafetyFilled } from "@ant-design/icons";
import { default as Button } from "antd/es/button";
import { ContainerCompBuilder } from "comps/comps/containerBase/containerCompBuilder";
import { gridItemCompToGridItems, InnerGrid } from "comps/comps/containerComp/containerView";
import { AutoHeightControl } from "comps/controls/autoHeightControl";
import { BoolControl } from "comps/controls/boolControl";
import { StringControl } from "comps/controls/codeControl";
import { booleanExposingStateControl } from "comps/controls/codeStateControl";
import { PositionControl } from "comps/controls/dropdownControl";
import { PositionControl, LeftRightControl } from "comps/controls/dropdownControl";
import { closeEvent, eventHandlerControl } from "comps/controls/eventHandlerControl";
import { styleControl } from "comps/controls/styleControl";
import { DrawerStyle } from "comps/controls/styleControlConstants";
Expand Down Expand Up @@ -35,40 +35,22 @@ const DrawerWrapper = styled.div`
pointer-events: auto;
`;

const ButtonStyle = styled(Button)`
position: absolute;
left: 0;
top: 0;
z-index: 10;
font-weight: 700;
box-shadow: none;
color: rgba(0, 0, 0, 0.45);
height: 54px;
width: 54px;
svg {
width: 16px;
height: 16px;
}
&,
:hover,
:focus {
background-color: transparent;
border: none;
}
:hover,
:focus {
color: rgba(0, 0, 0, 0.75);
}
`;

// If it is a number, use the px unit by default
function transToPxSize(size: string | number) {
return isNumeric(size) ? size + "px" : (size as string);
}

const ClosePlacementOptions = [
{
label: trans("drawer.left"),
value: "left",
},
{
label: trans("drawer.right"),
value: "right",
},
] as const;

const PlacementOptions = [
{
label: trans("drawer.top"),
Expand All @@ -88,6 +70,7 @@ const PlacementOptions = [
},
] as const;


let TmpDrawerComp = (function () {
return new ContainerCompBuilder(
{
Expand All @@ -98,6 +81,7 @@ let TmpDrawerComp = (function () {
autoHeight: AutoHeightControl,
style: styleControl(DrawerStyle),
placement: PositionControl,
closePosition: withDefault(LeftRightControl, "left"),
maskClosable: withDefault(BoolControl, true),
showMask: withDefault(BoolControl, true),
},
Expand All @@ -119,6 +103,34 @@ let TmpDrawerComp = (function () {
},
[dispatch, isTopBom]
);
const ButtonStyle = styled(Button)`
position: absolute;
${props.closePosition === "right" ? "right: 0;" : "left: 0;"}
top: 0;
z-index: 10;
font-weight: 700;
box-shadow: none;
color: rgba(0, 0, 0, 0.45);
height: 54px;
width: 54px;
svg {
width: 16px;
height: 16px;
}
&,
:hover,
:focus {
background-color: transparent;
border: none;
}
:hover,
:focus {
color: rgba(0, 0, 0, 0.75);
}
`;
return (
<BackgroundColorContext.Provider value={props.style.background}>
<DrawerWrapper>
Expand Down Expand Up @@ -181,6 +193,7 @@ let TmpDrawerComp = (function () {
.setPropertyViewFn((children) => (
<>
<Section name={sectionNames.basic}>
{children.closePosition.propertyView({ label: trans("drawer.closePosition"), radioButton: true })}
{children.placement.propertyView({ label: trans("drawer.placement"), radioButton: true })}
{["top", "bottom"].includes(children.placement.getView())
? children.autoHeight.getPropertyView()
Expand Down
1 change: 1 addition & 0 deletions client/packages/lowcoder/src/i18n/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,7 @@ export const de = {
"title": "Angezeigter Container-Titel"
},
"drawer": {
"closePosition": "Platzierung der Verschlusses",
"placement": "Platzierung der Schubladen",
"size": "Größe",
"top": "Top",
Expand Down
1 change: 1 addition & 0 deletions client/packages/lowcoder/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,7 @@ export const en = {
"title": "Displayed Container Title"
},
"drawer": {
"closePosition": "Close Button Placement",
"placement": "Drawer Placement",
"size": "Size",
"top": "Top",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,7 @@
"title": "Angezeigter Container-Titel"
},
"drawer": {
"closePosition": "Platzierung der Verschlusses",
"placement": "Platzierung der Schubladen",
"size": "Größe",
"top": "Top",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,7 @@
"title": "Displayed Container Title"
},
"drawer": {
"closePosition": "Close Button Placement",
"placement": "Drawer Placement",
"size": "Size",
"top": "Top",
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/packages/lowcoder/src/i18n/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,7 @@ container: {
title: "容器标题",
},
drawer: {
closePosition: "关闭位置",
placement: "抽屉位置",
size: "大小",
top: "顶部",
Expand Down