Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
6 changes: 4 additions & 2 deletions shesha-reactjs/src/components/panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface ICollapsiblePanelProps extends CollapseProps, Omit<IStyleType,
headerStyles?: IStyleType;
bodyStyle?: React.CSSProperties;
headerStyle?: React.CSSProperties;
accentStyle?: boolean;
}

/**
Expand Down Expand Up @@ -60,12 +61,13 @@ export const CollapsiblePanel: FC<Omit<ICollapsiblePanelProps, 'radiusLeft' | 'r
panelHeadType,
noContentPadding,
hideWhenEmpty,
hideCollapseContent
hideCollapseContent,
accentStyle
}) => {
// Prevent the CollapsiblePanel from collapsing every time you click anywhere on the extra and header
const onContainerClick = (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => event?.stopPropagation();

const { styles } = useStyles({ bodyStyle, headerStyle, panelHeadType, ghost, isSimpleDesign, noContentPadding, hideWhenEmpty, hideCollapseContent });
const { styles } = useStyles({ bodyStyle, headerStyle, panelHeadType, ghost, isSimpleDesign, noContentPadding, hideWhenEmpty, hideCollapseContent, accentStyle });
const shaCollapsiblePanelStyle = isSimpleDesign ? styles.shaSimpleDesign : styles.shaCollapsiblePanel;

return (
Expand Down
27 changes: 14 additions & 13 deletions shesha-reactjs/src/components/panel/styles/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const useStyles = createStyles(({ css, cx, token, prefixCls }, {
bodyStyle = {} as CSSProperties,
hideCollapseContent,
isSimpleDesign,
ghost
ghost,
accentStyle
}) => {
const noContentPadding = "no-content-padding";
const hideWhenEmpty = "hide-empty";
Expand Down Expand Up @@ -71,7 +72,7 @@ export const useStyles = createStyles(({ css, cx, token, prefixCls }, {
borderWidth: headerBorderWidth,
borderStyle: headerBorderStyle,
borderColor: headerBorderColor,
borderTopWidth: headerBorderTopWidth = panelHeadType === 'parent' ? '3px' : '',
borderTopWidth: headerBorderTopWidth,
borderTopStyle: headerBorderTopStyle,
borderTopColor: headerBorderTopColor,
borderBottomWidth: headerBorderBottomWidth,
Expand All @@ -80,9 +81,9 @@ export const useStyles = createStyles(({ css, cx, token, prefixCls }, {
borderRightWidth: headerBorderRightWidth,
borderRightStyle: headerBorderRightStyle,
borderRightColor: headerBorderRightColor,
borderLeftWidth: headerBorderLeftWidth = panelHeadType === 'child' ? '3px' : '',
borderLeftWidth: headerBorderLeftWidth,
borderLeftStyle: headerBorderLeftStyle,
borderLeftColor: headerBorderLeftColor = panelHeadType === 'child' ? token.colorPrimary : '',
borderLeftColor: headerBorderLeftColor,
borderRadius: headerBorderRadius,
paddingBottom: headerPaddingBottom = '8px',
paddingTop: headerPaddingTop = '8px',
Expand Down Expand Up @@ -159,9 +160,11 @@ export const useStyles = createStyles(({ css, cx, token, prefixCls }, {
height: ${headerHeight};
min-height: ${headerMinHeight};
max-height: ${headerMaxHeight};
border-top: ${headerBorderWidth || headerBorderTopWidth} ${headerBorderTopStyle || headerBorderStyle} ${headerBorderTopColor || headerBorderColor};
border-top: ${accentStyle && (panelHeadType === 'default' || panelHeadType === 'parent') ?
`3px` : headerBorderTopWidth || headerBorderWidth} ${headerBorderTopStyle || headerBorderStyle} ${accentStyle && (panelHeadType === 'default' || panelHeadType === 'parent') ?
'var(--primary-color)' : headerBorderTopColor || headerBorderColor};
border-right: ${headerBorderRightWidth || headerBorderWidth} ${headerBorderRightStyle || headerBorderStyle} ${headerBorderRightColor || headerBorderColor};
border-left: ${headerBorderLeftWidth || headerBorderWidth} ${headerBorderLeftStyle || headerBorderStyle} ${headerBorderLeftColor || headerBorderColor};
border-left: ${accentStyle && panelHeadType === 'child' ? `3px` : headerBorderLeftWidth || headerBorderWidth} ${headerBorderLeftStyle || headerBorderStyle} ${accentStyle && panelHeadType === 'child' ? 'var(--primary-color)' : headerBorderLeftColor || headerBorderColor};
border-bottom: ${headerBorderBottomWidth || headerBorderWidth} ${headerBorderBottomStyle || headerBorderStyle} ${headerBorderBottomColor || headerBorderColor};
padding-top: ${headerPaddingTop} !important;
padding-right: ${headerPaddingRight} !important;
Expand Down Expand Up @@ -194,9 +197,9 @@ export const useStyles = createStyles(({ css, cx, token, prefixCls }, {
--ant-collapse-header-padding: 5px 0px !important;
border-bottom-left-radius: unset;
border-bottom-right-radius: unset;
border-bottom: 2px solid ${token.colorPrimary};
border-top: ${panelHeadType === 'parent' || panelHeadType === 'default' ? `3px solid var(--primary-color)` : 'none'};
border-left: ${panelHeadType === 'child' ? `3px solid var(--primary-color)` : 'none'};
${accentStyle && `border-bottom: 2px solid ${token.colorPrimary};`}
${accentStyle && (panelHeadType === 'default' || panelHeadType === 'parent') && `border-top: 3px solid var(--primary-color);`}
${accentStyle && panelHeadType === 'child' && `border-left: 3px solid var(--primary-color);`}
font-weight: ${fontWeight || '500'};
}
> .ant-collapse-content {
Expand Down Expand Up @@ -224,8 +227,6 @@ export const useStyles = createStyles(({ css, cx, token, prefixCls }, {
> .ant-collapse-header {
--ant-collapse-header-padding: ${headerStyle?.padding || '12px 16px'} !important;
padding: 12px 16px !important;
border-top: ${panelHeadType === 'parent' ? `3px solid var(--primary-color)` : 'none'};
border-left: ${panelHeadType === 'child' ? `3px solid var(--primary-color)` : 'none'};
font-size: ${panelHeadType === 'parent' ? '13px' : '16px'};
}
}
Expand All @@ -248,8 +249,8 @@ export const useStyles = createStyles(({ css, cx, token, prefixCls }, {

> .ant-collapse-item > .ant-collapse-header {
visibility: ${hideCollapseContent ? 'hidden' : 'visible'};
border-top: ${panelHeadType === 'parent' ? `3px solid var(--primary-color)` : 'none'};
border-left: ${panelHeadType === 'child' ? `3px solid var(--primary-color)` : 'none'};
${accentStyle && (panelHeadType === 'default' || panelHeadType === 'parent') && `border-top: 3px solid var(--primary-color);`}
${accentStyle && panelHeadType === 'child' && `border-left: 3px solid var(--primary-color);`}
font-size: ${panelHeadType === 'parent' ? '13px' : '16px'};
height: ${headerHeight};
min-height: ${headerMinHeight};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const useStyles = createStyles(({ token, css, cx, prefixCls }, { style, m
display: flex !important;
justify-content: center !important;
}

.ant-image .anticon {
border-radius: ${borderRadius ?? '8px'} !important;
display: block !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const CollapsiblePanelComponent: IToolboxComponent<ICollapsiblePanelComponentPro
panelHeadType={headType}
hideCollapseContent={hideCollapseContent}
hideWhenEmpty={hideWhenEmpty}
accentStyle={model?.accentStyle}
>
<ComponentsContainer
containerId={content.id}
Expand Down Expand Up @@ -228,12 +229,13 @@ const CollapsiblePanelComponent: IToolboxComponent<ICollapsiblePanelComponentPro
}))
.add<ICollapsiblePanelComponentProps>(8, (prev) => {
const newModel = migratePrevStyles(prev, defaultStyles(prev));
const defaultHeaderStyle = defaultHeaderStyles(prev);
const defaultHeaderStyle = { ...defaultHeaderStyles(prev) };
const accentStyle = prev.accentStyle || !!prev?.headerStyles;

return {
...newModel, desktop: { ...newModel.desktop, overflow: prev.overflow ?? 'auto', headerStyles: defaultHeaderStyle },
tablet: { ...newModel.tablet, overflow: prev.overflow ?? 'auto', headerStyles: defaultHeaderStyle },
mobile: { ...newModel.mobile, overflow: prev.overflow ?? 'auto', headerStyles: defaultHeaderStyle }
...newModel, accentStyle, desktop: { ...newModel.desktop, overflow: prev.overflow ?? 'auto', headerStyles: defaultHeaderStyle, accentStyle },
tablet: { ...newModel.tablet, overflow: prev.overflow ?? 'auto', headerStyles: defaultHeaderStyle, accentStyle },
mobile: { ...newModel.mobile, overflow: prev.overflow ?? 'auto', headerStyles: defaultHeaderStyle, accentStyle }
};
}),
customContainerNames: ['header', 'content', 'customHeader'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ICollapsiblePanelComponentProps extends IConfigurableFormCompon
content?: ICollapsiblePanelContent;
collapsible?: CollapsibleType;
ghost?: boolean;
accentStyle?: boolean;
hideWhenEmpty?: boolean;
className?: string;
marginBottom?: string;
Expand All @@ -29,9 +30,9 @@ export interface ICollapsiblePanelComponentProps extends IConfigurableFormCompon
customHeader?: ICollapsiblePanelContent;
panelHeadType?: headerType;
headerStyles?: IStyleType;
desktop?: IStyleType;
mobile?: IStyleType;
tablet?: IStyleType;
desktop?: any;
mobile?: any;
tablet?: any;
};

export interface ICollapsiblePanelComponentPropsV0 extends IConfigurableFormComponent {
Expand Down
Loading
Loading