Skip to content

Commit

Permalink
support case where xnsName is passed but should be ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesmac committed Sep 17, 2024
1 parent d528285 commit a5a780d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
22 changes: 17 additions & 5 deletions packages/sdk/packages/share/src/out/CopyLinkStack.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,38 @@ const WithShareUrl = Template.bind({})
WithShareUrl.args = { shareUrl: 'https://google.com' }

const WithXnsName = Template.bind({})
WithXnsName.args = { shareUrl: 'https://beta.node.xyo.network.com/view/arietrouw.xyo/profile', xnsName: 'arietrouw.xyo' }
WithXnsName.args = {
shareUrl: 'https://beta.node.xyo.network.com/view/arietrouw.xyo/profile', xnsName: 'arietrouw.xyo', addToXnsName: true,
}

const WithNoAddToXnsName = Template.bind({})
WithNoAddToXnsName.args = {
shareUrl: 'https://beta.node.xyo.network.com/view/somehash1234567/profile', xnsName: 'arietrouw.xyo', addToXnsName: false,
}

const WithXnsNameShortened = Template.bind({})
WithXnsNameShortened.args = {
shareUrl: 'https://beta.node.xyo.network.com/view/arietrouw.xyo/profile', xnsName: 'arietrouw.xyo', sx: { maxWidth: '200px' },
shareUrl: 'https://beta.node.xyo.network.com/view/arietrouw.xyo/profile', xnsName: 'arietrouw.xyo', addToXnsName: true, sx: { maxWidth: '200px' },
}

const WithXnsNameInSubdomain = Template.bind({})
WithXnsNameInSubdomain.args = { shareUrl: 'https://arietrouw.xyo.network', xnsName: 'arietrouw.xyo' }
WithXnsNameInSubdomain.args = {
shareUrl: 'https://arietrouw.xyo.network', xnsName: 'arietrouw.xyo', addToXnsName: true,
}

const WithXnsNameCustomColors = Template.bind({})
WithXnsNameCustomColors.args = {
shareUrl: 'https://arietrouw.xyo.network', xnsName: 'arietrouw.xyo', xnsStartColor: 'blue', xnsEndColor: 'red',
shareUrl: 'https://arietrouw.xyo.network', xnsName: 'arietrouw.xyo', xnsStartColor: 'blue', xnsEndColor: 'red', addToXnsName: true,
}

const WithError = Template.bind({})
WithError.args = { shareUrl: 'https://google.com', xnsName: 'foo.xyo' }
WithError.args = {
shareUrl: 'https://google.com', xnsName: 'foo.xyo', addToXnsName: true,
}

export {
Default, WithError,
WithNoAddToXnsName,
WithShareUrl, WithXnsName, WithXnsNameCustomColors,
WithXnsNameInSubdomain, WithXnsNameShortened,
}
7 changes: 4 additions & 3 deletions packages/sdk/packages/share/src/out/CopyLinkStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import {
} from './lib/index.ts'

export interface CopyLinkStackProps extends ShareLinkProps, StackProps {
addToXnsName?: boolean
xnsEndColor?: string
xnsStartColor?: string
}

export const CopyLinkStack: React.FC<CopyLinkStackProps> = ({
shareLinkName, shareUrl, xnsName: xnsNameProp, xnsEndColor, xnsStartColor, ...props
addToXnsName, shareLinkName, shareUrl, xnsName: xnsNameProp, xnsEndColor, xnsStartColor, ...props
}) => {
const [error, setError] = useState<Error>()

Expand All @@ -29,7 +30,7 @@ export const CopyLinkStack: React.FC<CopyLinkStackProps> = ({
}, [])

const parsedXnsName = useMemo(() => {
if (shareUrl && xnsNameProp) {
if (shareUrl && xnsNameProp && addToXnsName) {
try {
const parts = splitAroundSubstring(shareUrl, xnsNameProp)
return parts
Expand All @@ -43,7 +44,7 @@ export const CopyLinkStack: React.FC<CopyLinkStackProps> = ({

return (
<Stack direction="row" alignItems="center" gap={0.25} {...props}>
{xnsName
{xnsName && addToXnsName
? (
<Stack direction="row" maxWidth="100%" sx={{ overflowX: 'auto' }}>
<Typography sx={{ display: 'inline-flex' }}>{part1}</Typography>
Expand Down

0 comments on commit a5a780d

Please sign in to comment.