@xyo-network/react-share 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/button/ShareButton.d.ts +8 -0
- package/dist/browser/button/ShareButton.d.ts.map +1 -0
- package/dist/browser/button/index.d.ts +2 -0
- package/dist/browser/button/index.d.ts.map +1 -0
- package/dist/browser/icons/index.d.ts +2 -0
- package/dist/browser/icons/index.d.ts.map +1 -0
- package/dist/browser/icons/social/Facebook.d.ts +4 -0
- package/dist/browser/icons/social/Facebook.d.ts.map +1 -0
- package/dist/browser/icons/social/XTwitter.d.ts +4 -0
- package/dist/browser/icons/social/XTwitter.d.ts.map +1 -0
- package/dist/browser/icons/social/index.d.ts +3 -0
- package/dist/browser/icons/social/index.d.ts.map +1 -0
- package/dist/browser/index.d.ts +5 -68
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.mjs +197 -46
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/meta-server/dynamic-share/DynamicShareImage.d.ts +6 -0
- package/dist/browser/meta-server/dynamic-share/DynamicShareImage.d.ts.map +1 -0
- package/dist/browser/meta-server/dynamic-share/index.d.ts +2 -0
- package/dist/browser/meta-server/dynamic-share/index.d.ts.map +1 -0
- package/dist/browser/meta-server/index.d.ts +3 -0
- package/dist/browser/meta-server/index.d.ts.map +1 -0
- package/dist/browser/meta-server/live-share/HideParentsFlexbox.d.ts +5 -0
- package/dist/browser/meta-server/live-share/HideParentsFlexbox.d.ts.map +1 -0
- package/dist/browser/meta-server/live-share/index.d.ts +2 -0
- package/dist/browser/meta-server/live-share/index.d.ts.map +1 -0
- package/dist/browser/out/CopyIconButton.d.ts +8 -0
- package/dist/browser/out/CopyIconButton.d.ts.map +1 -0
- package/dist/browser/out/CopyLinkTextField.d.ts +8 -0
- package/dist/browser/out/CopyLinkTextField.d.ts.map +1 -0
- package/dist/browser/out/CopyLinkTypography.d.ts +7 -0
- package/dist/browser/out/CopyLinkTypography.d.ts.map +1 -0
- package/dist/browser/out/Dialog.d.ts +14 -0
- package/dist/browser/out/Dialog.d.ts.map +1 -0
- package/dist/browser/out/Explanation.d.ts +6 -0
- package/dist/browser/out/Explanation.d.ts.map +1 -0
- package/dist/browser/out/GenerateShareLinkButton.d.ts +7 -0
- package/dist/browser/out/GenerateShareLinkButton.d.ts.map +1 -0
- package/dist/browser/out/HeadingFlexbox.d.ts +8 -0
- package/dist/browser/out/HeadingFlexbox.d.ts.map +1 -0
- package/dist/browser/out/SocialButtonsFlexbox.d.ts +7 -0
- package/dist/browser/out/SocialButtonsFlexbox.d.ts.map +1 -0
- package/dist/browser/out/index.d.ts +8 -0
- package/dist/browser/out/index.d.ts.map +1 -0
- package/dist/browser/out/lib/AnimatedGradientTypography.d.ts +4 -0
- package/dist/browser/out/lib/AnimatedGradientTypography.d.ts.map +1 -0
- package/dist/browser/out/lib/ShareLinkProps.d.ts +6 -0
- package/dist/browser/out/lib/ShareLinkProps.d.ts.map +1 -0
- package/dist/browser/out/lib/index.d.ts +4 -0
- package/dist/browser/out/lib/index.d.ts.map +1 -0
- package/dist/browser/out/lib/splitAroundSubstring.d.ts +2 -0
- package/dist/browser/out/lib/splitAroundSubstring.d.ts.map +1 -0
- package/package.json +52 -47
- package/src/button/ShareButton.stories.tsx +4 -4
- package/src/button/ShareButton.tsx +6 -2
- package/src/icons/social/Facebook.tsx +1 -0
- package/src/icons/social/XTwitter.tsx +3 -1
- package/src/out/CopyIconButton.tsx +46 -0
- package/src/out/CopyLinkTextField.stories.tsx +2 -6
- package/src/out/CopyLinkTextField.tsx +11 -21
- package/src/out/CopyLinkTypography.stories.tsx +30 -0
- package/src/out/CopyLinkTypography.tsx +56 -0
- package/src/out/Dialog.stories.tsx +15 -6
- package/src/out/Dialog.tsx +6 -2
- package/src/out/Explanation.tsx +4 -1
- package/src/out/GenerateShareLinkButton.stories.tsx +2 -6
- package/src/out/GenerateShareLinkButton.tsx +6 -2
- package/src/out/HeadingFlexbox.tsx +3 -1
- package/src/out/SocialButtonsFlexbox.stories.tsx +2 -6
- package/src/out/SocialButtonsFlexbox.tsx +4 -1
- package/src/out/index.ts +1 -0
- package/src/out/lib/AnimatedGradientTypography.tsx +50 -0
- package/src/out/lib/ShareLinkProps.ts +5 -0
- package/src/out/lib/index.ts +3 -0
- package/src/out/lib/splitAroundSubstring.ts +19 -0
- package/xy.config.ts +1 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CopyAllRounded } from '@mui/icons-material'
|
|
2
|
+
import {
|
|
3
|
+
type ButtonProps, IconButton, Tooltip,
|
|
4
|
+
} from '@mui/material'
|
|
5
|
+
import { forget } from '@xylabs/forget'
|
|
6
|
+
import React, { useState } from 'react'
|
|
7
|
+
|
|
8
|
+
import type { ShareLinkProps } from './lib/index.ts'
|
|
9
|
+
|
|
10
|
+
export interface CopyIconButtonProps extends ButtonProps, ShareLinkProps {
|
|
11
|
+
onCopyToClipboard?: (error?: Error) => void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const CopyLink = 'Copy Link'
|
|
15
|
+
const Copied = 'Copied!'
|
|
16
|
+
|
|
17
|
+
export const CopyIconButton: React.FC<CopyIconButtonProps> = ({
|
|
18
|
+
onCopyToClipboard, shareLinkName, shareUrl, ...props
|
|
19
|
+
}) => {
|
|
20
|
+
const [copyTooltipTitle, setCopyToolTipTitle] = useState(CopyLink)
|
|
21
|
+
|
|
22
|
+
const copyToClipboard = async (link?: string) => {
|
|
23
|
+
if (link) {
|
|
24
|
+
try {
|
|
25
|
+
await navigator.clipboard.writeText(link)
|
|
26
|
+
onCopyToClipboard?.()
|
|
27
|
+
setCopyToolTipTitle(Copied)
|
|
28
|
+
setTimeout(() => setCopyToolTipTitle(CopyLink), 2000)
|
|
29
|
+
} catch (e) {
|
|
30
|
+
const message = 'Error copying shareUrl to clipboard'
|
|
31
|
+
console.error(message, e, link)
|
|
32
|
+
onCopyToClipboard?.(new Error(message))
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
console.warn('tried to copy shareUrl before it was generated')
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Tooltip title={copyTooltipTitle}>
|
|
41
|
+
<IconButton aria-label={`copy ${shareLinkName} link`} onClick={() => forget(copyToClipboard(shareUrl))} edge="end" {...props}>
|
|
42
|
+
<CopyAllRounded />
|
|
43
|
+
</IconButton>
|
|
44
|
+
</Tooltip>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
@@ -3,9 +3,7 @@ import React from 'react'
|
|
|
3
3
|
|
|
4
4
|
import { CopyLinkTextField } from './CopyLinkTextField.tsx'
|
|
5
5
|
|
|
6
|
-
export default {
|
|
7
|
-
title: 'modules/ShareOut/CopyLinkTextField',
|
|
8
|
-
} as Meta<typeof CopyLinkTextField>
|
|
6
|
+
export default { title: 'modules/ShareOut/CopyLinkTextField' } as Meta<typeof CopyLinkTextField>
|
|
9
7
|
|
|
10
8
|
const Template: StoryFn<typeof CopyLinkTextField> = (props) => {
|
|
11
9
|
return <CopyLinkTextField {...props} />
|
|
@@ -15,8 +13,6 @@ const Default = Template.bind({})
|
|
|
15
13
|
Default.args = {}
|
|
16
14
|
|
|
17
15
|
const WithShareUrl = Template.bind({})
|
|
18
|
-
WithShareUrl.args = {
|
|
19
|
-
shareUrl: 'https://google.com',
|
|
20
|
-
}
|
|
16
|
+
WithShareUrl.args = { shareUrl: 'https://google.com' }
|
|
21
17
|
|
|
22
18
|
export { Default, WithShareUrl }
|
|
@@ -1,30 +1,22 @@
|
|
|
1
|
-
import { CopyAllRounded } from '@mui/icons-material'
|
|
2
1
|
import type { StandardTextFieldProps } from '@mui/material'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { InputAdornment, TextField } from '@mui/material'
|
|
3
|
+
import React, { useCallback, useState } from 'react'
|
|
4
|
+
|
|
5
|
+
import { CopyIconButton } from './CopyIconButton.tsx'
|
|
6
6
|
|
|
7
7
|
export interface CopyLinkTextFieldProps extends StandardTextFieldProps {
|
|
8
8
|
shareLinkName?: string
|
|
9
9
|
shareUrl?: string
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const CopyLinkTextField: React.FC<CopyLinkTextFieldProps> = ({
|
|
12
|
+
export const CopyLinkTextField: React.FC<CopyLinkTextFieldProps> = ({
|
|
13
|
+
shareLinkName, shareUrl, ...props
|
|
14
|
+
}) => {
|
|
13
15
|
const [error, setError] = useState<Error>()
|
|
14
16
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
await navigator.clipboard.writeText(link)
|
|
19
|
-
} catch (e) {
|
|
20
|
-
const message = 'Error copying shareUrl to clipboard'
|
|
21
|
-
console.error(message, e, link)
|
|
22
|
-
setError(new Error(message))
|
|
23
|
-
}
|
|
24
|
-
} else {
|
|
25
|
-
console.warn('tried to copy shareUrl before it was generated')
|
|
26
|
-
}
|
|
27
|
-
}
|
|
17
|
+
const onCopyToClipboard = useCallback((error?: Error) => {
|
|
18
|
+
setError(error)
|
|
19
|
+
}, [])
|
|
28
20
|
|
|
29
21
|
return (
|
|
30
22
|
<TextField
|
|
@@ -36,9 +28,7 @@ export const CopyLinkTextField: React.FC<CopyLinkTextFieldProps> = ({ shareLinkN
|
|
|
36
28
|
InputProps={{
|
|
37
29
|
endAdornment: (
|
|
38
30
|
<InputAdornment position="end">
|
|
39
|
-
<
|
|
40
|
-
<CopyAllRounded />
|
|
41
|
-
</IconButton>
|
|
31
|
+
<CopyIconButton shareLinkName={shareLinkName} shareUrl={shareUrl} onCopyToClipboard={onCopyToClipboard} />
|
|
42
32
|
</InputAdornment>
|
|
43
33
|
),
|
|
44
34
|
}}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Meta, StoryFn } from '@storybook/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { CopyLinkTypography } from './CopyLinkTypography.tsx'
|
|
5
|
+
|
|
6
|
+
export default { title: 'modules/ShareOut/CopyLinkTypography' } as Meta<typeof CopyLinkTypography>
|
|
7
|
+
|
|
8
|
+
const Template: StoryFn<typeof CopyLinkTypography> = (props) => {
|
|
9
|
+
return <CopyLinkTypography {...props} />
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Default = Template.bind({})
|
|
13
|
+
Default.args = {}
|
|
14
|
+
|
|
15
|
+
const WithShareUrl = Template.bind({})
|
|
16
|
+
WithShareUrl.args = { shareUrl: 'https://google.com' }
|
|
17
|
+
|
|
18
|
+
const WithXnsName = Template.bind({})
|
|
19
|
+
WithXnsName.args = { shareUrl: 'https://beta.node.xyo.network.com/view/arietrouw.xyo/profile', xnsName: 'arietrouw.xyo' }
|
|
20
|
+
|
|
21
|
+
const WithXnsNameInSubdomain = Template.bind({})
|
|
22
|
+
WithXnsNameInSubdomain.args = { shareUrl: 'https://arietrouw.xyo.network', xnsName: 'arietrouw.xyo' }
|
|
23
|
+
|
|
24
|
+
const WithError = Template.bind({})
|
|
25
|
+
WithError.args = { shareUrl: 'https://google.com', xnsName: 'foo.xyo' }
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
Default, WithError,
|
|
29
|
+
WithShareUrl, WithXnsName, WithXnsNameInSubdomain,
|
|
30
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Cancel } from '@mui/icons-material'
|
|
2
|
+
import type { TypographyProps } from '@mui/material'
|
|
3
|
+
import {
|
|
4
|
+
Stack,
|
|
5
|
+
Tooltip,
|
|
6
|
+
Typography,
|
|
7
|
+
} from '@mui/material'
|
|
8
|
+
import React, {
|
|
9
|
+
useCallback, useMemo, useState,
|
|
10
|
+
} from 'react'
|
|
11
|
+
|
|
12
|
+
import { CopyIconButton } from './CopyIconButton.tsx'
|
|
13
|
+
import {
|
|
14
|
+
AnimatedGradientTypography, type ShareLinkProps, splitAroundSubstring,
|
|
15
|
+
} from './lib/index.ts'
|
|
16
|
+
|
|
17
|
+
export interface CopyLinkTypographyProps extends ShareLinkProps, TypographyProps {}
|
|
18
|
+
|
|
19
|
+
export const CopyLinkTypography: React.FC<CopyLinkTypographyProps> = ({
|
|
20
|
+
shareLinkName, shareUrl, xnsName: xnsNameProp, ...props
|
|
21
|
+
}) => {
|
|
22
|
+
const [error, setError] = useState<Error>()
|
|
23
|
+
|
|
24
|
+
const onCopyToClipboard = useCallback((error?: Error) => {
|
|
25
|
+
setError(error)
|
|
26
|
+
}, [])
|
|
27
|
+
|
|
28
|
+
const parsedXnsName = useMemo(() => {
|
|
29
|
+
if (shareUrl && xnsNameProp) {
|
|
30
|
+
try {
|
|
31
|
+
const parts = splitAroundSubstring(shareUrl, xnsNameProp)
|
|
32
|
+
return parts
|
|
33
|
+
} catch (e) {
|
|
34
|
+
setError(e as Error)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}, [])
|
|
38
|
+
|
|
39
|
+
const [part1, xnsName, part3] = parsedXnsName || []
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Stack direction="row" alignItems="center" gap={0.25}>
|
|
43
|
+
{xnsName
|
|
44
|
+
? (
|
|
45
|
+
<Stack direction="row">
|
|
46
|
+
<Typography sx={{ display: 'inline-flex' }} {...props}>{part1}</Typography>
|
|
47
|
+
<AnimatedGradientTypography sx={{ display: 'inline-flex' }} {...props}>{xnsName}</AnimatedGradientTypography>
|
|
48
|
+
<Typography sx={{ display: 'inline-flex' }} {...props}>{part3}</Typography>
|
|
49
|
+
</Stack>
|
|
50
|
+
)
|
|
51
|
+
: <Typography sx={{ display: 'inline-flex' }} {...props}>{shareUrl}</Typography>}
|
|
52
|
+
<CopyIconButton onCopyToClipboard={onCopyToClipboard} shareLinkName={shareLinkName} shareUrl={shareUrl} sx={{ display: 'inline-flex' }} />
|
|
53
|
+
{error ? <Tooltip title={error.message}><Cancel color="error" sx={{ display: 'inline-flex' }} /></Tooltip> : null}
|
|
54
|
+
</Stack>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
@@ -10,9 +10,7 @@ import { GenerateShareLinkButton } from './GenerateShareLinkButton.tsx'
|
|
|
10
10
|
import { ShareOutHeadingFlexbox } from './HeadingFlexbox.tsx'
|
|
11
11
|
import { SocialButtonsFlexbox } from './SocialButtonsFlexbox.tsx'
|
|
12
12
|
|
|
13
|
-
export default {
|
|
14
|
-
title: 'modules/ShareOut/Dialog',
|
|
15
|
-
} as Meta<typeof ShareOutDialog>
|
|
13
|
+
export default { title: 'modules/ShareOut/Dialog' } as Meta<typeof ShareOutDialog>
|
|
16
14
|
|
|
17
15
|
const Template: StoryFn<typeof ShareOutDialog> = (props) => {
|
|
18
16
|
return <ShareOutDialog {...props} />
|
|
@@ -24,8 +22,10 @@ const TemplateWithContent: StoryFn<typeof ShareOutDialog> = (props) => {
|
|
|
24
22
|
const [shareUrl, setShareUrl] = useState('')
|
|
25
23
|
const [loading, setLoading] = useState(false)
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
27
|
+
open: unused, ...restProps
|
|
28
|
+
} = props
|
|
29
29
|
|
|
30
30
|
const cardImg = <img src="https://picsum.photos/100/100" height="100px" width="100px" />
|
|
31
31
|
const shareLinkName = 'My Share Link'
|
|
@@ -59,7 +59,16 @@ const TemplateWithContent: StoryFn<typeof ShareOutDialog> = (props) => {
|
|
|
59
59
|
return (
|
|
60
60
|
<>
|
|
61
61
|
<Button onClick={() => setOpen(true)} variant="contained">Open</Button>
|
|
62
|
-
<ShareOutDialog
|
|
62
|
+
<ShareOutDialog
|
|
63
|
+
cardImg={cardImg}
|
|
64
|
+
onClose={onClose}
|
|
65
|
+
ShareOutDialogActions={shareOutDialogActions}
|
|
66
|
+
shareOutDialogContent={shareOutDialogContent}
|
|
67
|
+
open={open}
|
|
68
|
+
title="Share Out Dialog"
|
|
69
|
+
subtitle="With a subtitle"
|
|
70
|
+
{...restProps}
|
|
71
|
+
/>
|
|
63
72
|
</>
|
|
64
73
|
)
|
|
65
74
|
}
|
package/src/out/Dialog.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { DialogProps } from '@mui/material'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Dialog, DialogActions, DialogContent, DialogTitle, Stack, Typography,
|
|
4
|
+
} from '@mui/material'
|
|
3
5
|
import { FlexCol, FlexGrowCol } from '@xylabs/react-flexbox'
|
|
4
6
|
import type { ComponentType, ReactNode } from 'react'
|
|
5
7
|
import React from 'react'
|
|
@@ -12,7 +14,9 @@ export interface ShareOutDialogProps extends DialogProps {
|
|
|
12
14
|
title?: string
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
export const ShareOutDialog: React.FC<ShareOutDialogProps> = ({
|
|
17
|
+
export const ShareOutDialog: React.FC<ShareOutDialogProps> = ({
|
|
18
|
+
ShareOutDialogActions, cardImg, open, onClose, shareOutDialogContent, subtitle, title, ...props
|
|
19
|
+
}) => {
|
|
16
20
|
const handleClose = () => {
|
|
17
21
|
onClose?.('', 'backdropClick')
|
|
18
22
|
}
|
package/src/out/Explanation.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { InfoOutlined } from '@mui/icons-material'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Tooltip, Typography, useTheme,
|
|
4
|
+
} from '@mui/material'
|
|
3
5
|
import { FlexGrowRow } from '@xylabs/react-flexbox'
|
|
4
6
|
import React from 'react'
|
|
5
7
|
|
|
@@ -9,6 +11,7 @@ export interface ShareOutExplanationProps {
|
|
|
9
11
|
|
|
10
12
|
export const ShareOutExplanation: React.FC<ShareOutExplanationProps> = ({ toolTipTitle }) => {
|
|
11
13
|
const theme = useTheme()
|
|
14
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
12
15
|
const title = toolTipTitle ?? 'In order for your data to be publicly viewable, it needs to be saved to the XYO Network Public Archivist. Public data can be seen by your friends, and XYO can generate preview images for easier sharing on social media.'
|
|
13
16
|
return (
|
|
14
17
|
<>
|
|
@@ -3,9 +3,7 @@ import React from 'react'
|
|
|
3
3
|
|
|
4
4
|
import { GenerateShareLinkButton } from './GenerateShareLinkButton.tsx'
|
|
5
5
|
|
|
6
|
-
export default {
|
|
7
|
-
title: 'modules/ShareOut/GenerateShareLinkButton',
|
|
8
|
-
} as Meta<typeof GenerateShareLinkButton>
|
|
6
|
+
export default { title: 'modules/ShareOut/GenerateShareLinkButton' } as Meta<typeof GenerateShareLinkButton>
|
|
9
7
|
|
|
10
8
|
const Template: StoryFn<typeof GenerateShareLinkButton> = (props) => {
|
|
11
9
|
return <GenerateShareLinkButton {...props} />
|
|
@@ -15,8 +13,6 @@ const Default = Template.bind({})
|
|
|
15
13
|
Default.args = {}
|
|
16
14
|
|
|
17
15
|
const WithLoading = Template.bind({})
|
|
18
|
-
WithLoading.args = {
|
|
19
|
-
loading: true,
|
|
20
|
-
}
|
|
16
|
+
WithLoading.args = { loading: true }
|
|
21
17
|
|
|
22
18
|
export { Default, WithLoading }
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { ButtonProps } from '@mui/material'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Button, CircularProgress, styled,
|
|
4
|
+
} from '@mui/material'
|
|
3
5
|
import React from 'react'
|
|
4
6
|
|
|
5
7
|
export interface GenerateShareLinkButtonProps extends ButtonProps {
|
|
6
8
|
loading?: boolean
|
|
7
9
|
}
|
|
8
10
|
|
|
9
|
-
export const GenerateShareLinkButton: React.FC<GenerateShareLinkButtonProps> = ({
|
|
11
|
+
export const GenerateShareLinkButton: React.FC<GenerateShareLinkButtonProps> = ({
|
|
12
|
+
children = 'Generate My Share Link', loading, ...props
|
|
13
|
+
}) => {
|
|
10
14
|
return (
|
|
11
15
|
<Button
|
|
12
16
|
variant="contained"
|
|
@@ -8,7 +8,9 @@ export interface ShareOutHeadingFlexboxProps extends FlexBoxProps {
|
|
|
8
8
|
shareUrl?: string
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const ShareOutHeadingFlexbox: React.FC<ShareOutHeadingFlexboxProps> = ({
|
|
11
|
+
export const ShareOutHeadingFlexbox: React.FC<ShareOutHeadingFlexboxProps> = ({
|
|
12
|
+
children, shareLinkName, shareUrl, ...props
|
|
13
|
+
}) => {
|
|
12
14
|
const GenerateShareLinkExplanation = "When you generate your share link, we'll make a small amount of your data public so friends can check it out!"
|
|
13
15
|
|
|
14
16
|
return (
|
|
@@ -3,9 +3,7 @@ import React from 'react'
|
|
|
3
3
|
|
|
4
4
|
import { SocialButtonsFlexbox } from './SocialButtonsFlexbox.tsx'
|
|
5
5
|
|
|
6
|
-
export default {
|
|
7
|
-
title: 'modules/ShareOut/SocialButtonsFlexbox',
|
|
8
|
-
} as Meta<typeof SocialButtonsFlexbox>
|
|
6
|
+
export default { title: 'modules/ShareOut/SocialButtonsFlexbox' } as Meta<typeof SocialButtonsFlexbox>
|
|
9
7
|
|
|
10
8
|
const Template: StoryFn<typeof SocialButtonsFlexbox> = (props) => {
|
|
11
9
|
return <SocialButtonsFlexbox {...props} />
|
|
@@ -15,8 +13,6 @@ const Default = Template.bind({})
|
|
|
15
13
|
Default.args = {}
|
|
16
14
|
|
|
17
15
|
const WithShareUrl = Template.bind({})
|
|
18
|
-
WithShareUrl.args = {
|
|
19
|
-
shareUrl: 'https://google.com',
|
|
20
|
-
}
|
|
16
|
+
WithShareUrl.args = { shareUrl: 'https://google.com' }
|
|
21
17
|
|
|
22
18
|
export { Default, WithShareUrl }
|
|
@@ -16,7 +16,10 @@ export const SocialButtonsFlexbox: React.FC<SocialButtonsFlexboxProps> = ({ shar
|
|
|
16
16
|
<Typography variant="body1" gutterBottom>
|
|
17
17
|
<strong>Share on Social Media</strong>
|
|
18
18
|
</Typography>
|
|
19
|
-
<FlexRow
|
|
19
|
+
<FlexRow
|
|
20
|
+
gap={0.5}
|
|
21
|
+
sx={{ flexDirection: { md: 'row', xs: 'column' } }}
|
|
22
|
+
>
|
|
20
23
|
{shareUrl
|
|
21
24
|
? (
|
|
22
25
|
<>
|
package/src/out/index.ts
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
keyframes, styled, Typography,
|
|
3
|
+
} from '@mui/material'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Start the animation at 100% to give the gradient a left to right effect
|
|
7
|
+
*/
|
|
8
|
+
const moveBg = keyframes(`
|
|
9
|
+
0% {
|
|
10
|
+
background-position: 100% 0%;
|
|
11
|
+
}
|
|
12
|
+
100% {
|
|
13
|
+
background-position: 0% 0%;
|
|
14
|
+
}
|
|
15
|
+
`)
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Adapted from - https://codepen.io/web-dot-dev/pen/vYrGPNE
|
|
19
|
+
*/
|
|
20
|
+
export const AnimatedGradientTypography = styled(Typography, { name: 'AnimatedGradientTypography' })(({ theme }) => ({
|
|
21
|
+
// Set the color variables for the gradient
|
|
22
|
+
'--color-one': theme.palette.secondary.dark,
|
|
23
|
+
'--color-two': theme.palette.primary.light,
|
|
24
|
+
// set the gradient so it has the same start and end color for looping effect
|
|
25
|
+
'background': `linear-gradient(
|
|
26
|
+
.25turn,
|
|
27
|
+
var(--color-one),
|
|
28
|
+
var(--color-two),
|
|
29
|
+
var(--color-one)
|
|
30
|
+
)`,
|
|
31
|
+
// Set the text color to transparent so the gradient shows through
|
|
32
|
+
'color': 'transparent',
|
|
33
|
+
// Clip the background to the text shape
|
|
34
|
+
'backgroundClip': 'text',
|
|
35
|
+
// Set the background size to 800% so we don't see the third color initially creating the looping effect
|
|
36
|
+
'backgroundSize': '800%',
|
|
37
|
+
// Set the text to bold so the gradient is more visible
|
|
38
|
+
'fontWeight': 'bold',
|
|
39
|
+
// Set the animation
|
|
40
|
+
'@media (prefers-reduced-motion: no-preference)': {
|
|
41
|
+
animationName: moveBg,
|
|
42
|
+
animationDuration: '2s',
|
|
43
|
+
animationIterationCount: 'infinite',
|
|
44
|
+
},
|
|
45
|
+
// reset for users that prefer reduced motion
|
|
46
|
+
'@media (prefers-reduced-motion)': {
|
|
47
|
+
background: 'none',
|
|
48
|
+
color: theme.palette.text.primary,
|
|
49
|
+
},
|
|
50
|
+
}))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const splitAroundSubstring = (path: string, substring: string): [string, string, string] => {
|
|
2
|
+
// Find the index of the substring
|
|
3
|
+
const index = path.indexOf(substring)
|
|
4
|
+
|
|
5
|
+
if (index === -1) {
|
|
6
|
+
throw new Error(`XNS name "${substring}" not found in path.`)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Extract the part before the substring
|
|
10
|
+
const part1 = path.slice(0, index)
|
|
11
|
+
|
|
12
|
+
// The substring itself is part2
|
|
13
|
+
const part2 = substring
|
|
14
|
+
|
|
15
|
+
// Extract the part after the substring
|
|
16
|
+
const part3 = path.slice(index + substring.length)
|
|
17
|
+
|
|
18
|
+
return [part1, part2, part3]
|
|
19
|
+
}
|