Skip to content

Commit b59a797

Browse files
authored
Merge pull request #3628 from czwe-01/thulasizwe/en/button-group
Thulasizwe/en/button group
2 parents 5ac455b + 6ecd46c commit b59a797

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export const ButtonGroupInner: FC<IButtonGroupProps> = (props) => {
222222

223223
if (isInline) {
224224
return (
225-
<Button.Group size={size} style={{ ...props.styles, ...getOverflowStyle(true, false) }}>
225+
<Button.Group size={size} style={{ ...props.styles, ...getOverflowStyle(true, false) }} className={styles.shaHideEmpty}>
226226
<Space size={gap}>
227227
{filteredItems?.map((item) =>
228228
(<InlineItem styles={item?.styles} item={item} uuid={item.id} size={item.size ?? size} getIsVisible={getIsVisible} appContext={allData} key={item.id} form={form} />)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ import { getSettings } from './settingsForm';
1414
import { migratePrevStyles, migrateStyles } from '@/designer-components/_common-migrations/migrateStyles';
1515
import { defaultContainerStyles, defaultStyles } from './utils';
1616
import { ConfigurableFormItem } from '@/components';
17+
import { useStyles } from './styles/styles';
1718

1819
const ButtonGroupComponent: IToolboxComponent<IButtonGroupComponentProps> = {
1920
type: 'buttonGroup',
2021
isInput: false,
2122
name: 'Button Group',
2223
icon: <GroupOutlined />,
2324
Factory: ({ model, form }) => {
25+
const { styles } = useStyles();
2426
return model.hidden ? null :
25-
<ConfigurableFormItem model={{ ...model, hideLabel: true }}>
27+
<ConfigurableFormItem model={{ ...model, hideLabel: true }} className={styles.shaHideEmpty}>
2628
<ButtonGroup {...model} styles={model.allStyles.fullStyle} form={form} />
2729
</ConfigurableFormItem>;
2830
},

shesha-reactjs/src/designer-components/button/buttonGroup/styles/styles.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const useStyles = createStyles(({ css, cx, prefixCls, token }) => {
3636
*/
3737

3838
const shaResponsiveButtonGroupContainer = cx("sha-responsive-button-group-container", css`
39+
3940
.${shaResponsiveButtonGroup} {
4041
line-height: unset;
4142
min-height: 30px;
@@ -98,11 +99,45 @@ export const useStyles = createStyles(({ css, cx, prefixCls, token }) => {
9899
}
99100
}
100101
}
102+
103+
> ul {
104+
&:empty {
105+
display: none;
106+
}
107+
}
108+
`);
109+
110+
const shaHideEmpty = cx("sha-hide-empty", css`
111+
&:empty {
112+
display: none;
113+
}
114+
115+
/* Hide when containing empty ul elements */
116+
&:has(ul:empty) {
117+
display: none;
118+
}
119+
120+
/* Hide when containing ul with no li children */
121+
&:has(ul:not(:has(li))) {
122+
display: none;
123+
}
124+
125+
/* Hide when containing empty ant-btn-group */
126+
&:has(.ant-btn-group:empty) {
127+
display: none;
128+
}
129+
130+
/* Hide when containing ant-btn-group with no button children */
131+
&:has(.ant-btn-group:not(:has(button))) {
132+
display: none;
133+
}
101134
`);
135+
102136
return {
103137
shaResponsiveButtonGroupContainer,
104138
shaResponsiveButtonGroup,
105139
shaResponsiveButtonGroupInlineContainer,
106140
a,
141+
shaHideEmpty
107142
};
108143
});

0 commit comments

Comments
 (0)