Skip to content

Commit 3fd1510

Browse files
authored
Merge pull request #3102 from czwe-01/thulasizwe/en/tabed-properties-panel
Thulasizwe/en/tabed properties panel
2 parents 695c2fe + 0c2bc8b commit 3fd1510

File tree

7 files changed

+50
-16
lines changed

7 files changed

+50
-16
lines changed

shesha-reactjs/src/designer-components/_settings/components/formItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ const FormItem: FC<ISettingsFormItemProps> = (props) => {
2424
childElement,
2525
{
2626
...childElement?.props,
27-
readOnly: readOnly || hasCode,
27+
readOnly: readOnly,
2828
size: 'small',
29-
disabled: readOnly || hasCode,
29+
disabled: readOnly,
3030
onChange: handleChange(onChange),
3131
[valuePropName]: value
3232
}

shesha-reactjs/src/designer-components/_settings/settingsControl.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import { GetAvailableConstantsFunc, GetResultTypeFunc, ICodeEditorProps } from '
99
import { CodeEditorWithStandardConstants } from '../codeEditor/codeEditorWithConstants';
1010
import { useConstantsEvaluator } from '../codeEditor/hooks/useConstantsEvaluator';
1111
import { useResultTypeEvaluator } from '../codeEditor/hooks/useResultType';
12+
import { Button } from 'antd';
13+
import {
14+
CodeOutlined, CodeFilled, FormOutlined
15+
} from '@ant-design/icons';
1216

1317
export type SettingsControlChildrenType = (value: any, onChange: (val: any) => void, propertyName: string) => ReactElement;
1418

@@ -75,6 +79,11 @@ export const SettingsControl = <Value = any>(props: ISettingsControlProps<Value>
7579
}
7680
};
7781

82+
const onSwitchMode = () => {
83+
const newMode = mode === 'code' ? 'value' : 'code';
84+
onInternalChange(setting, newMode);
85+
};
86+
7887

7988
const propertyName = !!setting._code || setting._mode === 'code' ? `${props.propertyName}._value` : props.propertyName;
8089
const functionName = `get${camelcase(props.propertyName, { pascalCase: true })}`;
@@ -94,7 +103,6 @@ export const SettingsControl = <Value = any>(props: ISettingsControlProps<Value>
94103
},
95104
type: 'text',
96105
label: ' ',
97-
className: `${styles.jsSwitch}`,
98106
ghost: true,
99107
exposedVariables: defaultExposedVariables,
100108
hidden: !setting._code && props.readOnly,
@@ -107,8 +115,19 @@ export const SettingsControl = <Value = any>(props: ISettingsControlProps<Value>
107115

108116
return (
109117
<div className={mode === 'code' ? styles.contentCode : styles.contentJs}>
110-
{editor}
111-
{!code && <div className={styles.jsContent} style={{ marginLeft: 0 }}>
118+
<Button
119+
hidden={props.readOnly}
120+
className={`${styles.jsSwitch} inlineJS`}
121+
type='text'
122+
danger={mode === 'value' && !!code}
123+
ghost
124+
size='small'
125+
icon={mode === 'code' ? <FormOutlined /> : !!code ? <CodeFilled /> : <CodeOutlined />}
126+
color='lightslategrey'
127+
onClick={onSwitchMode}
128+
/>
129+
{mode === 'code' && editor}
130+
{mode === 'value' && <div className={styles.jsContent} style={{ marginLeft: 0 }}>
112131
{props.children(setting?._value, valueOnChange, propertyName)}
113132
</div>}
114133
</div>

shesha-reactjs/src/designer-components/_settings/styles/styles.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createStyles, sheshaStyles } from '@/styles';
22

3-
export const useStyles = createStyles(({ css, cx, responsive, prefixCls, token }, hasCode) => {
3+
export const useStyles = createStyles(({ css, cx, responsive, token }, hasCode) => {
44

55
const contentJs = cx(css`
66
position: relative;
@@ -51,7 +51,6 @@ export const useStyles = createStyles(({ css, cx, responsive, prefixCls, token }
5151
top: -8px;
5252
`);
5353
const jsSwitch = cx(css`
54-
&.${prefixCls}-btn {
5554
position: absolute;
5655
right: 0;
5756
top: 4px;
@@ -74,14 +73,14 @@ export const useStyles = createStyles(({ css, cx, responsive, prefixCls, token }
7473
.sidebar-container & {
7574
right: 0;
7675
left: auto;
77-
top: ${hasCode ? '-35px' : '-25px'};
76+
top: -25px;
7877
}
7978
.${sheshaStyles.verticalSettingsClass} & {
8079
right: 0;
8180
left: auto;
8281
top: ${hasCode ? '-38px' : '-25px'};
8382
}
84-
}
83+
8584
`);
8685

8786
return {

shesha-reactjs/src/designer-components/_settings/utils/border/utils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { readThemeColor } from "@/components/colorPicker";
1818

1919
export const getBorderStyle = (input: IBorderValue, jsStyle: React.CSSProperties, theme?: IConfigurableTheme): React.CSSProperties => {
2020
if (!input) return {};
21-
21+
2222
const style: React.CSSProperties = {};
2323
const border = input.border || {};
2424
const { all = {}, top = {}, right = {}, bottom = {}, left = {} } = border;
@@ -127,8 +127,8 @@ export const borderCorners = [
127127
{ value: "bottomRight", icon: "RadiusBottomrightOutlined", title: "Bottom Right" }
128128
];
129129

130-
131130
const generateCode = (type: string, isCustom: boolean, isResponsive: boolean, path: string) => {
131+
132132
const devicePath = isResponsive ? 'data[`${contexts.canvasContext?.designerDevice || "desktop"}`]' : 'data';
133133
return `return getSettingValue(${devicePath}${path ? '?.' + path : ''}?.border?.${type}) !== "${isCustom ? "custom" : "all"}";`;
134134
};

shesha-reactjs/src/designer-components/button/button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const ButtonComponent: IToolboxComponent<IButtonComponentProps> = {
9292
...(['dashed', 'default'].includes(model.buttonType) && backgroundStyles),
9393
...(['primary', 'default'].includes(model.buttonType) && shadowStyles),
9494
...stylingBoxAsCSS,
95-
...jsStyle
95+
...jsStyle,
9696
};
9797

9898
return (

shesha-reactjs/src/designer-components/codeEditor/codeEditor.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ import {
1010
Tabs,
1111
Typography
1212
} from 'antd';
13-
import classNames from 'classnames';
1413
import { CodeEditor as BaseCodeEditor } from '@/components/codeEditor/codeEditor';
15-
import { CodeFilled, CodeOutlined, ExclamationCircleFilled } from '@ant-design/icons';
14+
import { CodeOutlined, ExclamationCircleFilled } from '@ant-design/icons';
1615
import { CodeVariablesTables } from '@/components/codeVariablesTable';
1716
import { ICodeEditorProps } from './interfaces';
1817
import { Show } from '@/components';
@@ -146,8 +145,13 @@ export const CodeEditor: FC<ICodeEditorProps> = ({
146145
? (<Typography.Text disabled>No Code</Typography.Text>)
147146
: (
148147
<>
149-
<Button type={props.type ? props.type : hasValue ? 'primary' : 'default'} className={classNames(styles.button, props.className)} icon={hasValue ? <CodeFilled /> : <CodeOutlined />} onClick={openEditorDialog} size="small" style={{}}>
150-
{props.label !== " " && (readOnly ? 'View Code' : '...')}
148+
<Button
149+
className={props.className}
150+
size="small"
151+
onClick={openEditorDialog}
152+
style={hasValue ? { fontFamily: 'monospace', fontSize: '12px' } : undefined}
153+
>
154+
{hasValue ? <><CodeOutlined /> {value}</> : <><CodeOutlined /> ...</>}
151155
</Button>
152156
{showDialog && (
153157
<Modal

shesha-reactjs/src/designer-components/propertiesTabs/style.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ export const useStyles = createStyles(({ css, cx, }) => {
1616
.ant-tabs-tab {
1717
--ant-tabs-card-padding-sm: 0 8px;
1818
}
19+
20+
.sha-toolbar-btn-configurable, .ant-btn {
21+
display: flex;
22+
align-items: center;
23+
max-width: 100%;
24+
span {
25+
max-width: 100%;
26+
overflow: hidden;
27+
text-overflow: ellipsis;
28+
white-space: nowrap;
29+
}
30+
}
1931
`);
2032

2133
return {

0 commit comments

Comments
 (0)