Skip to content

Commit c742284

Browse files
authored
fix: add content colSizes option to background card (#1247)
1 parent af2471a commit c742284

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

memory-bank/usage/backgroundCard.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ graph TD
4646
- `analyticsEvents`: Analytics events to track
4747
- `controlPosition`: Position of controls (links and buttons) - 'content' or 'footer'
4848
- `list`: Array of content list items
49+
- `colSizes`: Grid column sizes configuration (default: `{all: 12, sm: 12}`)
4950

5051
## Usage Patterns
5152

@@ -114,7 +115,7 @@ The BackgroundCard component is composed of several key parts:
114115
links={links}
115116
buttons={buttons}
116117
list={list}
117-
colSizes={{all: 12, md: 12}}
118+
colSizes={colSizes}
118119
controlPosition={areControlsInFooter ? 'bottom' : 'default'}
119120
/>
120121
</CardBase.Content>
@@ -222,6 +223,25 @@ The BackgroundCard component integrates with the page-constructor theme system:
222223
- Use `content` position for standard layout
223224
- Use `footer` position for cards where controls should be aligned at the bottom
224225

226+
## Column Sizing
227+
228+
The BackgroundCard component supports responsive column sizing through the `colSizes` prop:
229+
230+
```tsx
231+
// Default column sizing
232+
colSizes = {all: 12, md: 12};
233+
```
234+
235+
This prop allows you to control how much of the available grid space the card's content should occupy at different breakpoints:
236+
237+
- `all`: Base size for all viewport widths
238+
- `sm`: Size for small viewports
239+
- `md`: Size for medium viewports
240+
- `lg`: Size for large viewports
241+
- `xl`: Size for extra large viewports
242+
243+
Each value is a number between 1-12, representing the number of columns in a 12-column grid system.
244+
225245
## Example Usage
226246

227247
### Basic BackgroundCard

src/models/constructor-items/sub-blocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export interface BackgroundCardProps
141141
extends CardBaseProps,
142142
AnalyticsEventsBase,
143143
CardLayoutProps,
144-
Omit<ContentBlockProps, 'colSizes' | 'centered' | 'controlPosition'> {
144+
Omit<ContentBlockProps, 'centered' | 'controlPosition'> {
145145
url?: string;
146146
urlTitle?: string;
147147
background?: ThemeSupporting<ImageObjectProps>;

src/sub-blocks/BackgroundCard/BackgroundCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const BackgroundCard = (props: BackgroundCardProps) => {
2525
buttons,
2626
analyticsEvents,
2727
urlTitle,
28+
colSizes = {all: 12, md: 12},
2829
controlPosition = 'content',
2930
list,
3031
size = 's',
@@ -62,7 +63,7 @@ const BackgroundCard = (props: BackgroundCardProps) => {
6263
links={links}
6364
buttons={buttons}
6465
list={list}
65-
colSizes={{all: 12, md: 12}}
66+
colSizes={colSizes}
6667
controlPosition={areControlsInFooter ? 'bottom' : 'default'}
6768
/>
6869
</CardBase.Content>

src/sub-blocks/BackgroundCard/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@
1515
`links?: Link[]` — An array with link objects (see [Content blocks](?path=/docs/documentation-types--docs))
1616

1717
`buttons?: Button[]` — An array with button objects (see [Content blocks](?path=/docs/documentation-types--docs))
18+
19+
`colSizes?: Object` — more info [Content blocks](?path=/docs/documentation-types--docs#colsizes).

src/sub-blocks/BackgroundCard/schema.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import omit from 'lodash/omit';
22

33
import {ImageObjectProps} from '../../components/Image/schema';
4-
import {BaseProps, CardBase, CardLayoutProps, withTheme} from '../../schema/validators/common';
4+
import {
5+
BaseProps,
6+
CardBase,
7+
CardLayoutProps,
8+
containerSizesObject,
9+
withTheme,
10+
} from '../../schema/validators/common';
511
import {AnalyticsEventSchema} from '../../schema/validators/event';
612
import {ContentBase} from '../Content/schema';
713

@@ -47,6 +53,7 @@ export const BackgroundCard = {
4753
type: 'string',
4854
enum: ['content', 'footer'],
4955
},
56+
colSizes: containerSizesObject,
5057
},
5158
},
5259
};

0 commit comments

Comments
 (0)