Skip to content

Commit

Permalink
Merge pull request #152 from pantheon-systems/ag/clean-component-defs
Browse files Browse the repository at this point in the history
Improve component definition readability
  • Loading branch information
a11rew authored Dec 26, 2023
2 parents 29818d1 + 588f8a8 commit 37205e0
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const smartComponentDefinition = {
image: {
type: "file",
required: false,
displayName: "Image",
displayName: "Image URL",
},
/**
* Size of the avatar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default meta;
export const Default: Story = {
args: {
label: "Info",
hasStatusType: true,
statusType: "info",
},
};
31 changes: 11 additions & 20 deletions packages/react-sample-library/src/components/Badge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import { type InferSmartComponentProps } from "@pantheon-systems/pcc-sdk-core";
export const reactComponent = ({
statusType,
label,
hasStatusType,
className,
}: InferSmartComponentProps<typeof smartComponentDefinition>) => {
return (
<BaseBadge
statusType={statusType}
label={label}
hasStatusType={hasStatusType}
statusType={statusType}
hasStatusType={statusType != null}
className={className}
/>
);
Expand All @@ -24,13 +23,21 @@ export const smartComponentDefinition = {
title: "Badge",
iconUrl: null,
fields: {
/**
* Text to display in the badge
*/
label: {
displayName: "Label",
type: "string",
required: true,
},
/**
* Status type for badge. Only renders if `hasStatusType` is true.
*/
statusType: {
displayName: "Status Type",
type: "enum",
required: true,
required: false,
options: [
{
label: "Status",
Expand Down Expand Up @@ -62,22 +69,6 @@ export const smartComponentDefinition = {
},
],
},
/**
* Text to display in the badge
*/
label: {
displayName: "Label",
type: "string",
required: true,
},
/**
* Should the badge be associated with a certain status type
*/
hasStatusType: {
displayName: "Has status type",
type: "boolean",
required: false,
},
className: {
displayName: "Additional CSS classes",
type: "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ export const smartComponentDefinition = {
title: "Banner Notification",
iconUrl: null,
fields: {
/**
* The message to display
*/
message: {
displayName: "Message",
type: "string",
required: true,
},
/**
* Banner style and Icon types
*/
Expand All @@ -44,14 +52,6 @@ export const smartComponentDefinition = {
},
],
},
/**
* The message to display
*/
message: {
displayName: "Message",
type: "string",
required: true,
},
className: {
displayName: "Additional CSS classes",
type: "string",
Expand Down
38 changes: 19 additions & 19 deletions packages/react-sample-library/src/components/Blockquote/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,6 @@ export const smartComponentDefinition = {
title: "Blockquote",
iconUrl: null,
fields: {
/**
* Set type to full width or inline blockquote
* @default full-width
*/
type: {
displayName: "Type",
type: "enum",
required: false,
options: [
{
label: "Full width",
value: "full-width",
},
{
label: "Inline",
value: "inline",
},
],
},
/**
* Quote text
*/
Expand All @@ -69,6 +50,25 @@ export const smartComponentDefinition = {
type: "string",
required: true,
},
/**
* Set type to full width or inline blockquote
* @default full-width
*/
type: {
displayName: "Type",
type: "enum",
required: false,
options: [
{
label: "Full width",
value: "full-width",
},
{
label: "Inline",
value: "inline",
},
],
},
className: {
displayName: "Additional CSS classes",
type: "string",
Expand Down
32 changes: 16 additions & 16 deletions packages/react-sample-library/src/components/CTALink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ export const smartComponentDefinition = {
title: "CTA Link",
iconUrl: null,
fields: {
/**
* Link text
*/
linkText: {
displayName: "Link text",
type: "string",
required: true,
},
/**
* Link location
*/
href: {
displayName: "Link URL",
type: "string",
required: true,
},
/**
* Size of the CTA Link
* @default md
Expand All @@ -42,22 +58,6 @@ export const smartComponentDefinition = {
},
],
},
/**
* Link location
*/
href: {
displayName: "Href",
type: "string",
required: true,
},
/**
* Link text
*/
linkText: {
displayName: "Link text",
type: "string",
required: true,
},
className: {
displayName: "Additional CSS classes",
type: "string",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-sample-library/src/components/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const smartComponentDefinition = {
* Url for primary link
*/
primaryLinkUrl: {
displayName: "Primary Link Url",
displayName: "Primary Link URL",
type: "string",
required: true,
},
Expand Down Expand Up @@ -152,7 +152,7 @@ export const smartComponentDefinition = {
* Url for secondary link
*/
secondaryLinkUrl: {
displayName: "Secondary Link Url",
displayName: "Secondary Link URL",
type: "string",
required: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ export const smartComponentDefinition = {
title: "Inline Banner Notification",
iconUrl: null,
fields: {
/**
* Text for the title section
*/
title: {
displayName: "Title",
type: "string",
required: true,
},
/**
* Banner style and Icon types
*/
Expand All @@ -50,19 +58,11 @@ export const smartComponentDefinition = {
},
],
},
/**
* Text for the title section
*/
title: {
displayName: "Title",
type: "string",
required: true,
},
/**
* Text for the message section
*/
text: {
displayName: "Text",
displayName: "Message Text",
type: "string",
required: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ export const smartComponentDefinition = {
title: "Section Banner Notification",
iconUrl: null,
fields: {
/**
* Message text.
*/
message: {
displayName: "Message",
type: "string",
required: true,
},
/**
* Message id.
*/
id: {
displayName: "Message ID",
type: "number",
required: true,
},
/**
* Message type.
*/
Expand Down Expand Up @@ -58,13 +74,10 @@ export const smartComponentDefinition = {
},
],
},
/**
* Message text.
*/
message: {
displayName: "Message",
title: {
displayName: "Title",
type: "string",
required: true,
required: false,
},
/**
* Includes dismiss functionality.
Expand All @@ -74,19 +87,6 @@ export const smartComponentDefinition = {
type: "boolean",
required: false,
},
/**
* Message id.
*/
id: {
displayName: "Id",
type: "number",
required: true,
},
title: {
displayName: "Title",
type: "string",
required: false,
},
className: {
displayName: "Additional CSS classes",
type: "string",
Expand Down
32 changes: 16 additions & 16 deletions packages/react-sample-library/src/components/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ export const smartComponentDefinition = {
title: "Tooltip",
iconUrl: null,
fields: {
/**
* Text to display in tooltip
*/
content: {
displayName: "Content",
type: "string",
required: true,
},
/**
* Text to use as the trigger instead of an icon. Leave blank to use the icon.
*/
triggerText: {
displayName: "Trigger text",
type: "string",
required: false,
},
/**
* Icon to trigger tooltip
* @default circleInfo
Expand All @@ -49,22 +65,6 @@ export const smartComponentDefinition = {
},
],
},
/**
* Text to display in tooltip
*/
content: {
displayName: "Content",
type: "string",
required: true,
},
/**
* Text to use as the trigger instead of an icon. Leave blank to use the icon.
*/
triggerText: {
displayName: "Trigger text",
type: "string",
required: false,
},
/**
* The accessible text for the trigger. Only necessary when the trigger is an icon.
*/
Expand Down

0 comments on commit 37205e0

Please sign in to comment.