Skip to content

Commit 5d68677

Browse files
committed
Refactor ReadOnlyDisplayFormItem styles and InputField component for improved layout and alignment
1 parent ccb5cea commit 5d68677

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

shesha-reactjs/src/components/readOnlyDisplayFormItem/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const ReadOnlyDisplayFormItem: FC<IReadOnlyDisplayFormItemProps> = (props
101101
return dropdownDisplayMode === 'raw'
102102
? <InputField style={style} value={values?.join(', ')} />
103103
: (
104-
<div style={{ ...style, display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 8, justifyContent: style?.textAlign }}>
104+
<div className={styles.wrapper} style={{ ...style }}>
105105
{value?.map(({ label, color, icon, value, description }) => {
106106
return (
107107
<ReflistTag

shesha-reactjs/src/components/readOnlyDisplayFormItem/inputField.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ interface IInputFieldProps {
88
}
99

1010
function InputField({ value, style, children }: IInputFieldProps): JSX.Element {
11-
const { styles } = useStyles();
11+
const { styles } = useStyles({textAlign: style?.textAlign || 'left'});
1212

13-
const { fontSize, fontWeight, color, fontFamily, textAlign, height } = style || {};
13+
const { fontSize, fontWeight, color, fontFamily, height } = style || {};
1414

1515
return value || children ? (
16-
<div style={{ padding: '4px', ...style, height: height, display: 'flex', alignItems: 'center', justifyContent: textAlign }}>
16+
<div style={{...style}} className={styles.wrapper}>
1717
<div className={styles.inputField} style={{ fontSize, fontWeight, color, fontFamily, whiteSpace: height === 'auto' ? 'pre-wrap' : 'nowrap', flex: 'none' }}>{value || children}</div>
1818
</div>
1919
) : null;

shesha-reactjs/src/components/readOnlyDisplayFormItem/styles/styles.ts

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

33

4-
export const useStyles = createStyles(({ css, cx, prefixCls, token }) => {
4+
export const useStyles = createStyles(({ css, cx, prefixCls, token }, { textAlign }) => {
55
const readOnlyModeToggler = "read-only-mode-toggler";
66
const readOnlyDisplayFormItem = cx("read-only-display-form-item", css`
77
width: 100%;
@@ -56,9 +56,20 @@ export const useStyles = createStyles(({ css, cx, prefixCls, token }) => {
5656
// white-space: nowrap;
5757
`;
5858

59+
const wrapper = css`
60+
display: flex;
61+
flex-wrap: wrap;
62+
align-items: center;
63+
gap: 8px;
64+
padding: 4px;
65+
box-sizing: border-box;
66+
justify-content: ${textAlign === 'center' ? 'center' : textAlign === 'right' ? 'flex-end' : 'flex-start'};
67+
`;
68+
5969
return {
6070
readOnlyDisplayFormItem,
6171
readOnlyModeToggler,
6272
inputField,
73+
wrapper,
6374
};
64-
});
75+
});

0 commit comments

Comments
 (0)