-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
packages/react-sample-library/src/components/cards/LinksCard/LinksCard.stories.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { reactComponent as Card } from "./index"; | ||
|
||
const meta = { | ||
title: "Components/Cards/Links Card", | ||
component: Card, | ||
} satisfies Meta<typeof Card>; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export default meta; | ||
|
||
export const Default: Story = { | ||
args: { | ||
headingText: "Links Card", | ||
links: [ | ||
{ | ||
linkText: "Link 1", | ||
href: "https://pantheon.com", | ||
}, | ||
{ | ||
linkText: "Link 2", | ||
href: "https://pantheon.com", | ||
}, | ||
{ | ||
linkText: "Link 3", | ||
href: "https://pantheon.com", | ||
}, | ||
], | ||
}, | ||
}; |
83 changes: 83 additions & 0 deletions
83
packages/react-sample-library/src/components/cards/LinksCard/index.tsx
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { LinksCard as BaseCard } from "@pantheon-systems/pds-toolkit-react"; | ||
import { | ||
InferSmartComponentProps, | ||
SmartComponentMap, | ||
} from "@pantheon-systems/pcc-sdk-core"; | ||
|
||
/** | ||
* Links Card UI component | ||
*/ | ||
export const reactComponent = ({ | ||
headingText, | ||
links, | ||
headingLevel = "h2", | ||
className, | ||
}: InferSmartComponentProps<typeof smartComponentDefinition>) => { | ||
const linkItems = links.map((link) => ( | ||
<a href={link.href}>{link.linkText}</a> | ||
)); | ||
return ( | ||
<BaseCard | ||
headingText={headingText} | ||
linkItems={linkItems} | ||
headingLevel={headingLevel} | ||
className={className} | ||
/> | ||
); | ||
}; | ||
|
||
export const smartComponentDefinition = { | ||
title: "Links Card", | ||
iconUrl: null, | ||
fields: { | ||
/** | ||
* Link Card heading. | ||
*/ | ||
headingText: { | ||
displayName: "Heading text", | ||
type: "string", | ||
required: true, | ||
}, | ||
/** | ||
* Link items | ||
*/ | ||
links: { | ||
displayName: "Links", | ||
type: "object", | ||
multiple: true, | ||
required: true, | ||
fields: { | ||
/** | ||
* Link text | ||
*/ | ||
linkText: { | ||
displayName: "Link text", | ||
type: "string", | ||
required: true, | ||
}, | ||
/** | ||
* Link location | ||
*/ | ||
href: { | ||
displayName: "Link URL", | ||
type: "string", | ||
required: true, | ||
}, | ||
}, | ||
}, | ||
/** | ||
* Heading level | ||
*/ | ||
headingLevel: { | ||
displayName: "Heading level", | ||
type: "enum", | ||
required: false, | ||
options: ["h2", "h3", "h4"], | ||
}, | ||
className: { | ||
displayName: "Additional CSS classes", | ||
type: "string", | ||
required: false, | ||
}, | ||
}, | ||
} as const satisfies SmartComponentMap[string]; |
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