-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@kadena/react-ui): Updated ProfileCard component
- Loading branch information
Showing
12 changed files
with
172 additions
and
167 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@kadena/react-ui': minor | ||
--- | ||
|
||
Renamed the ProfileCard component to ProfileSummary and refactored it to use a | ||
subcomponent structure |
70 changes: 0 additions & 70 deletions
70
packages/libs/react-ui/src/components/ProfileCard/ProfileCard.stories.tsx
This file was deleted.
Oops, something went wrong.
71 changes: 0 additions & 71 deletions
71
packages/libs/react-ui/src/components/ProfileCard/ProfileCard.tsx
This file was deleted.
Oops, something went wrong.
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
56 changes: 56 additions & 0 deletions
56
packages/libs/react-ui/src/components/ProfileSummary/ProfileSummary.stories.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,56 @@ | ||
import type { IProfileSummaryRootProps } from '@components/ProfileSummary'; | ||
import { ProfileSummary } from '@components/ProfileSummary'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
type StoryComponentType = IProfileSummaryRootProps & { | ||
links: Record<string, string>; | ||
}; | ||
|
||
const meta: Meta<StoryComponentType> = { | ||
title: 'Content/ProfileSummary', | ||
component: ProfileSummary.Root, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: | ||
'The ProfileSummary component renders a card with a profile picture, name, title, tags, and links. The links are rendered using the `Link` component and can be set with the `links` prop.', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<StoryComponentType>; | ||
|
||
export const Primary: Story = { | ||
name: 'ProfileSummary', | ||
args: { | ||
name: 'Tasos Bitsios', | ||
title: 'Developer Experience Developer (DED)', | ||
tags: ['Chainweb-stream', 'SSE'], | ||
imageSrc: 'https://avatars.githubusercontent.com/u/115649719?v=4', | ||
links: { | ||
'Personal website': 'https://tasosbitsios.com', | ||
Twitter: 'https://twitter.com/tasosbitsios', | ||
'Custom link': 'https://kadena.io', | ||
}, | ||
}, | ||
render: ({ name, title, tags, imageSrc, links }) => { | ||
return ( | ||
<ProfileSummary.Root | ||
name={name} | ||
title={title} | ||
tags={tags} | ||
imageSrc={imageSrc} | ||
> | ||
{Object.entries(links).map(([label, href]) => ( | ||
<ProfileSummary.Link href={href as string} key={href as string}> | ||
{label} | ||
</ProfileSummary.Link> | ||
))} | ||
</ProfileSummary.Root> | ||
); | ||
}, | ||
}; |
17 changes: 17 additions & 0 deletions
17
packages/libs/react-ui/src/components/ProfileSummary/ProfileSummaryLink.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,17 @@ | ||
import type { ILinkProps } from '@components/Link'; | ||
import { Link } from '@components/Link'; | ||
import type { FC } from 'react'; | ||
import React from 'react'; | ||
|
||
export interface IProfileSummaryLinkProps extends ILinkProps {} | ||
|
||
export const ProfileSummaryLink: FC<IProfileSummaryLinkProps> = ({ | ||
children, | ||
...restLinkProps | ||
}) => { | ||
return ( | ||
<li> | ||
<Link {...restLinkProps}>{children}</Link> | ||
</li> | ||
); | ||
}; |
56 changes: 56 additions & 0 deletions
56
packages/libs/react-ui/src/components/ProfileSummary/ProfileSummaryRoot.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,56 @@ | ||
import { | ||
boldTextClass, | ||
containerClass, | ||
imageClass, | ||
linkContainerClass, | ||
tagClass, | ||
tagContainerClass, | ||
} from './ProfileSummary.css'; | ||
import type { IProfileSummaryLinkProps } from './ProfileSummaryLink'; | ||
|
||
import { Tag } from '@components/Tag'; | ||
import type { FC, FunctionComponentElement } from 'react'; | ||
import React from 'react'; | ||
|
||
export interface IProfileSummaryRootProps { | ||
name: string; | ||
title: string; | ||
imageSrc: string; | ||
tags?: string[]; | ||
children: FunctionComponentElement<IProfileSummaryLinkProps>[]; | ||
} | ||
|
||
export const ProfileSummaryRoot: FC<IProfileSummaryRootProps> = ({ | ||
name, | ||
title, | ||
imageSrc, | ||
tags = undefined, | ||
children, | ||
}) => { | ||
return ( | ||
<div className={containerClass}> | ||
<img className={imageClass} src={imageSrc} alt={name} /> | ||
<div> | ||
<span className={boldTextClass}>{name}</span> | ||
<span>{title}</span> | ||
|
||
{tags && ( | ||
<ul className={tagContainerClass}> | ||
{tags.map((tag, i) => ( | ||
<li className={tagClass} key={i}> | ||
<Tag key={i}>{tag}</Tag> | ||
</li> | ||
))} | ||
</ul> | ||
)} | ||
|
||
{children && ( | ||
<> | ||
<span className={boldTextClass}>Links</span> | ||
<ul className={linkContainerClass}>{children}</ul> | ||
</> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; |
18 changes: 18 additions & 0 deletions
18
packages/libs/react-ui/src/components/ProfileSummary/index.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,18 @@ | ||
import type { IProfileSummaryLinkProps } from './ProfileSummaryLink'; | ||
import { ProfileSummaryLink } from './ProfileSummaryLink'; | ||
import type { IProfileSummaryRootProps } from './ProfileSummaryRoot'; | ||
import { ProfileSummaryRoot } from './ProfileSummaryRoot'; | ||
|
||
import type { FC } from 'react'; | ||
|
||
export { IProfileSummaryLinkProps, IProfileSummaryRootProps }; | ||
|
||
interface IProfileSummaryProps { | ||
Root: FC<IProfileSummaryRootProps>; | ||
Link: FC<IProfileSummaryLinkProps>; | ||
} | ||
|
||
export const ProfileSummary: IProfileSummaryProps = { | ||
Root: ProfileSummaryRoot, | ||
Link: ProfileSummaryLink, | ||
}; |
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.