Skip to content

Commit 0f82899

Browse files
authored
fix: use string union and add title for maxColumns (#611)
1 parent fa70526 commit 0f82899

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

apps/studio/src/components/PageEditor/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const DEFAULT_BLOCKS: Record<
6565
title: "This is an optional title of the Infocards component",
6666
subtitle: "This is an optional subtitle for the Infocards component",
6767
variant: "cardsWithImages",
68+
maxColumns: "3",
6869
cards: [
6970
{
7071
title: "This is the first card",

packages/components/src/interfaces/complex/InfoCards.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const SingleCardNoImageSchema = Type.Object({
2424
})
2525

2626
const SingleCardWithImageSchema = Type.Composite([
27+
SingleCardNoImageSchema,
2728
Type.Object({
2829
imageUrl: Type.String({
2930
title: "Upload image",
@@ -52,7 +53,6 @@ const SingleCardWithImageSchema = Type.Composite([
5253
"Add a descriptive alternative text for this image. This helps visually impaired users to understand your image.",
5354
}),
5455
}),
55-
SingleCardNoImageSchema,
5656
])
5757

5858
const InfoCardsBaseSchema = Type.Object({
@@ -70,11 +70,19 @@ const InfoCardsBaseSchema = Type.Object({
7070
}),
7171
),
7272
maxColumns: Type.Optional(
73-
Type.Union([Type.Literal(1), Type.Literal(2), Type.Literal(3)], {
74-
title: "Maximum columns variant",
75-
description:
76-
"Controls the responsive behaviour regarding the number of columns that this component will expand to in different viewports",
77-
}),
73+
Type.Union(
74+
[
75+
Type.Literal("1", { title: "1 column" }),
76+
Type.Literal("2", { title: "2 columns" }),
77+
Type.Literal("3", { title: "3 columns" }),
78+
],
79+
{
80+
title: "Maximum columns variant",
81+
description:
82+
"Controls the responsive behaviour regarding the number of columns that this component will expand to in different viewports",
83+
default: "3",
84+
},
85+
),
7886
),
7987
})
8088

packages/components/src/templates/next/components/complex/InfoCards/InfoCards.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ const createInfoCardsStyles = tv({
5555
},
5656
},
5757
maxColumns: {
58-
1: {
58+
"1": {
5959
grid: "",
6060
},
61-
2: {
61+
"2": {
6262
grid: "md:grid-cols-2",
6363
},
64-
3: {
64+
"3": {
6565
grid: "md:grid-cols-2 lg:grid-cols-3",
6666
},
6767
},
6868
},
6969
defaultVariants: {
70-
maxColumns: 3,
70+
maxColumns: "3",
7171
imageFit: "cover",
7272
},
7373
})

packages/components/src/templates/next/layouts/IndexPage/IndexPage.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export const WithSiderail: Story = {
125125
{
126126
type: "infocards",
127127
variant: "cardsWithoutImages",
128-
maxColumns: 1,
128+
maxColumns: "1",
129129
cards: [
130130
{
131131
title:
@@ -261,7 +261,7 @@ export const NoSiderail: Story = {
261261
{
262262
type: "infocards",
263263
variant: "cardsWithoutImages",
264-
maxColumns: 1,
264+
maxColumns: "1",
265265
cards: [
266266
{
267267
title:

0 commit comments

Comments
 (0)