-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: redesign InfoCards component and update schema #414
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a27d9b7
feat: redesign InfoCards component and update schema
dcshzj 8087fdc
feat: update auto-generated index page and sort items
dcshzj 030de15
fix: change isCardWithImages to variant
dcshzj 1d3845e
chore: use switch case for exhaustive type check
dcshzj f942480
fix: add lint and format fix commands to build scripts
dcshzj dc4c8d4
chore: add eslint and prettier config as dev deps
dcshzj 07b2238
add story with white bg image
739aad8
add more details and sensible sample text to infocard stories
0e35c62
update to match design (hover states, type tokens, icon size, remove …
6cc58ce
add transition to image hover
c44b32b
optical adjustment to arrow
326e402
add better homepage stories to illustrate various card types
2e49116
chore: fix issues raised in comments
dcshzj d2a6419
chore: run format fix on tooling
dcshzj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 75 additions & 33 deletions
108
packages/components/src/interfaces/complex/InfoCards.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,103 @@ | ||
import type { Static } from "@sinclair/typebox" | ||
import { Type } from "@sinclair/typebox" | ||
|
||
export const SingleCardSchema = Type.Object({ | ||
const SingleCardNoImageSchema = Type.Object({ | ||
title: Type.String({ | ||
title: "Title", | ||
default: "This is the title of the card", | ||
}), | ||
description: Type.Optional( | ||
Type.String({ | ||
title: "Description", | ||
default: "This is an optional description for the card", | ||
}), | ||
), | ||
buttonLabel: Type.Optional( | ||
url: Type.Optional( | ||
Type.String({ | ||
title: "Link text", | ||
description: | ||
"A descriptive text. Avoid generic text such as “Click here” or “Learn more”", | ||
title: "Link destination", | ||
description: "When this is clicked, open:", | ||
}), | ||
), | ||
url: Type.String({ | ||
title: "Link destination", | ||
description: "When this is clicked, open:", | ||
}), | ||
imageUrl: Type.String({ | ||
title: "Upload image", | ||
format: "image", | ||
}), | ||
imageAlt: Type.String({ | ||
title: "Alternate text", | ||
description: | ||
"Add a descriptive alternative text for this image. This helps visually impaired users to understand your image.", | ||
}) | ||
|
||
const SingleCardWithImageSchema = Type.Composite([ | ||
SingleCardNoImageSchema, | ||
Type.Object({ | ||
imageUrl: Type.String({ | ||
title: "Upload image", | ||
format: "image", | ||
}), | ||
imageAlt: Type.String({ | ||
title: "Alternate text", | ||
description: | ||
"Add a descriptive alternative text for this image. This helps visually impaired users to understand your image.", | ||
}), | ||
}), | ||
]) | ||
|
||
const InfoCardsBaseSchema = Type.Object({ | ||
type: Type.Literal("infocards", { default: "infocards" }), | ||
title: Type.Optional( | ||
Type.String({ | ||
title: "Title", | ||
default: "This is an optional title of the Cards component", | ||
}), | ||
), | ||
subtitle: Type.Optional( | ||
Type.String({ | ||
title: "Description", | ||
default: "This is an optional description for the Cards component", | ||
}), | ||
), | ||
}) | ||
|
||
export const InfoCardsSchema = Type.Object( | ||
const InfoCardsWithImageSchema = Type.Object( | ||
{ | ||
type: Type.Literal("infocards", { default: "infocards" }), | ||
title: Type.Optional( | ||
Type.String({ | ||
title: "Title", | ||
}), | ||
), | ||
subtitle: Type.Optional( | ||
Type.String({ | ||
title: "Description", | ||
}), | ||
), | ||
cards: Type.Array(SingleCardSchema, { | ||
variant: Type.Literal("cardsWithImages", { default: "cardsWithImages" }), | ||
cards: Type.Array(SingleCardWithImageSchema, { | ||
title: "Cards", | ||
minItems: 1, | ||
default: [], | ||
}), | ||
}, | ||
{ | ||
title: "Infocards component", | ||
title: "Cards with images", | ||
}, | ||
) | ||
|
||
export type SingleCardProps = Static<typeof SingleCardSchema> | ||
const InfoCardsNoImageSchema = Type.Object( | ||
{ | ||
variant: Type.Literal("cardsWithoutImages", { | ||
default: "cardsWithoutImages", | ||
}), | ||
cards: Type.Array(SingleCardNoImageSchema, { | ||
title: "Cards", | ||
default: [], | ||
}), | ||
}, | ||
{ | ||
title: "Cards without images", | ||
}, | ||
) | ||
|
||
export const InfoCardsSchema = Type.Intersect( | ||
[ | ||
InfoCardsBaseSchema, | ||
Type.Union([InfoCardsWithImageSchema, InfoCardsNoImageSchema]), | ||
], | ||
{ | ||
title: "Cards component", | ||
}, | ||
) | ||
|
||
export type SingleCardNoImageProps = Static<typeof SingleCardNoImageSchema> & { | ||
LinkComponent?: any // Next.js link | ||
} | ||
export type SingleCardWithImageProps = Static< | ||
typeof SingleCardWithImageSchema | ||
> & { | ||
LinkComponent?: any // Next.js link | ||
} | ||
export type InfoCardsProps = Static<typeof InfoCardsSchema> & { | ||
LinkComponent?: any // Next.js link | ||
sectionIdx?: number // TODO: Remove this property, only used in classic theme | ||
} |
58 changes: 0 additions & 58 deletions
58
packages/components/src/templates/classic/components/InfoCards/InfoCards.stories.tsx
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
packages/components/src/templates/classic/components/InfoCards/InfoCards.tsx
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
packages/components/src/templates/classic/components/InfoCards/index.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's schema.const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schema.const
is a JSON Schema construct where the particular property takes in a specific literal (can be string/number/boolean). In this case, if theconst
is defined (say it'strue) then it is not meaningful to show the toggle, since the
false` case is invalid.