Skip to content
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

V3 Asset, Avatar, and Profile #218

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

35 changes: 35 additions & 0 deletions @stellar/design-system-website/docs/components/elements/asset.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
slug: /asset
description: "Asset or asset pair displayed in a circle."
---

# Asset

<ComponentDescription componentName="Asset" />

## Example

```tsx live
<PreviewBlock componentName="Asset">
<Asset
variant="single"
size="sm"
sourceOne={{
image: "https://cryptologos.cc/logos/stellar-xlm-logo.svg?v=024",
altText: "XLM",
}}
/>
</PreviewBlock>
```

## Props

<ComponentProps
componentName="Asset"
relatedType={[
"AssetBaseProps",
"SingleAssetProps",
"MultiAssetProps",
"AssetSource",
]}
/>
13 changes: 10 additions & 3 deletions @stellar/design-system-website/docs/components/elements/avatar.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: /avatar
description: "Identicon as an avatar."
description: "Avatar as an identicon, user initials, or a profile icon."
---

# Avatar
Expand All @@ -11,10 +11,17 @@ description: "Identicon as an avatar."

```tsx live
<PreviewBlock componentName="Avatar">
<Avatar publicAddress="GD4XW236EFCESNO4RKGG5PWML2WNQIJS335XECBW4GRARXKE64VIMOLZ" />
<Avatar size="sm" />
</PreviewBlock>
```

## Props

<ComponentProps componentName="Avatar" />
<ComponentProps
componentName="Avatar"
relatedType={[
"AvatarBaseProps",
"AvatarStellarAddressProps",
"AvatarUserNameProps",
]}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description: "Avatar with Stellar address."
<PreviewBlock componentName="Profile">
<Profile
publicAddress="GAVL6PM6TDJ7FBRCRL6GJ5WO2TWSH6ZRNU2HOARQ4RYMDUGSW7XWS57G"
size="md"
size="sm"
/>
</PreviewBlock>
```
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { ComponentPreview } from "@site/src/components/PreviewBlock";

const updateSourceTwo = {
prop: "sourceTwo",
value: {
altText: "USDC",
image: "https://cryptologos.cc/logos/usd-coin-usdc-logo.svg?v=024",
},
};

export const assetPreview: ComponentPreview = {
options: [
{
type: "select",
prop: "size",
options: [
{
value: "sm",
label: "SM",
},
{
value: "md",
label: "MD",
},
{
value: "lg",
label: "LG",
},
],
},
{
type: "select",
prop: "variant",
options: [
{
value: "single",
label: "Single",
updateRelated: {
prop: "sourceTwo",
value: undefined,
},
},
{
value: "swap",
label: "Swap",
updateRelated: updateSourceTwo,
},
{
value: "pair",
label: "Pair",
updateRelated: updateSourceTwo,
},
{
value: "platform",
label: "Platform",
updateRelated: updateSourceTwo,
},
],
},
],
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,60 @@
import { ComponentPreview } from "@site/src/components/PreviewBlock";

export const avatarPreview: ComponentPreview = {
options: [],
options: [
{
type: "select",
prop: "size",
options: [
{
value: "sm",
label: "SM",
},
{
value: "md",
label: "MD",
},
{
value: "lg",
label: "LG",
},
],
},
{
type: "select",
prop: "publicAddress",
options: [
{
value: "",
label: "No public address",
},
{
value: "GD4XW236EFCESNO4RKGG5PWML2WNQIJS335XECBW4GRARXKE64VIMOLZ",
label: "Public address",
updateRelated: {
prop: "userName",
value: undefined,
},
},
],
},
{
type: "select",
prop: "userName",
options: [
{
value: "",
label: "No user name",
},
{
value: "User Name",
label: "User name",
updateRelated: {
prop: "publicAddress",
value: undefined,
},
},
],
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ export const profilePreview: ComponentPreview = {
type: "select",
prop: "size",
options: [
{
value: "md",
label: "MD",
},
{
value: "sm",
label: "SM",
},
{
value: "xs",
label: "XS",
value: "md",
label: "MD",
},
{
value: "lg",
label: "LG",
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const ComponentProps = ({
}: {
componentName: string;
// To associate custom types that are used in the component. For example,
// AssetIconSource in AssetIcon.
// AssetSource in Asset.
relatedType?: string[];
}) => {
const component = SdsDocs?.children?.find(
Expand All @@ -28,6 +28,16 @@ export const ComponentProps = ({
const PropRow = ({ p }: { p: any }) => {
const defaultVal = p.comment?.blockTags?.[0]?.content?.[0];

// Don't show row that is optional and undefined
// (used in discriminated union types)
if (
p?.flags?.isOptional &&
p.type.type === "intrinsic" &&
p.type.name === "undefined"
) {
return null;
}

return (
<tr key={p.id}>
<td>
Expand All @@ -54,7 +64,7 @@ export const ComponentProps = ({
);
};

const props = component.children.map((p) => <PropRow p={p} />);
const props = component?.children?.map((p) => <PropRow p={p} />);

const relatedTypeProps = relatedTypes?.map((t) => {
const props = t.children || t?.type?.declaration?.children;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export const ElementPropType = ({ type }: { type: any }) => {
return <code>{`() => void`}</code>;
case "array":
return <code>{`${type?.elementType?.name || ""}[]`}</code>;
case "literal":
return <code>{type.value}</code>;
case "intrinsic":
case "reference":
return <code>{type.name}</code>;
Expand Down
Loading
Loading