@xyo-network/react-card 2.26.37 → 2.26.38

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/docs.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "fileName": "index.ts",
11
11
  "line": 1,
12
12
  "character": 0,
13
- "url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/eeec410/packages/card/src/index.ts#L1"
13
+ "url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/c31a96d/packages/card/src/index.ts#L1"
14
14
  }
15
15
  ]
16
16
  }
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "@mui/icons-material": "^5.8.4",
16
16
  "@mui/material": "^5.9.2",
17
17
  "@xylabs/react-flexbox": "^2.14.10",
18
- "@xyo-network/react-shared": "^2.26.37",
18
+ "@xyo-network/react-shared": "^2.26.38",
19
19
  "react": "^18.2.0",
20
20
  "react-dom": "^18.2.0",
21
21
  "react-router-dom": "^6.3.0",
@@ -77,5 +77,5 @@
77
77
  },
78
78
  "sideEffects": false,
79
79
  "types": "dist/esm/index.d.ts",
80
- "version": "2.26.37"
80
+ "version": "2.26.38"
81
81
  }
@@ -0,0 +1,20 @@
1
+ import { Card, CardProps } from '@mui/material'
2
+ import { useGradientStyles } from '@xyo-network/react-shared'
3
+
4
+ export type CardExProps = CardProps & {
5
+ gradient?: 'border' | 'background'
6
+ }
7
+
8
+ export const CardEx: React.FC<CardExProps> = ({ style, gradient, ...props }) => {
9
+ const { styles } = useGradientStyles()
10
+ const gradientStyle = gradient === 'border' ? styles.border : gradient === 'background' ? styles.background : {}
11
+ return (
12
+ <Card
13
+ style={{
14
+ ...gradientStyle,
15
+ ...style,
16
+ }}
17
+ {...props}
18
+ />
19
+ )
20
+ }
@@ -0,0 +1,37 @@
1
+ import { ComponentMeta, ComponentStory } from '@storybook/react'
2
+ import { BrowserRouter } from 'react-router-dom'
3
+
4
+ import { FullWidthCard } from './FullWidthCard'
5
+ const StorybookEntry = {
6
+ argTypes: {},
7
+ component: FullWidthCard,
8
+ parameters: {
9
+ docs: {
10
+ page: null,
11
+ },
12
+ },
13
+ title: 'shared/FullWidthCard',
14
+ } as ComponentMeta<typeof FullWidthCard>
15
+
16
+ const Template: ComponentStory<typeof FullWidthCard> = (args) => (
17
+ <BrowserRouter>
18
+ <FullWidthCard {...args}></FullWidthCard>
19
+ </BrowserRouter>
20
+ )
21
+
22
+ const Default = Template.bind({})
23
+ Default.args = {
24
+ cardIsButton: true,
25
+ desc: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat delectus nemo optio quis! Totam magni laboriosam repudiandae nam nobis at quisquam aut omnis, quis officiis similique enim id dolorem unde!',
26
+ name: 'Big Title Here',
27
+
28
+ to: '/link',
29
+ }
30
+
31
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
32
+ //@ts-ignore
33
+
34
+ export { Default }
35
+
36
+ // eslint-disable-next-line import/no-default-export
37
+ export default StorybookEntry
@@ -0,0 +1,97 @@
1
+ import ArrowForwardRoundedIcon from '@mui/icons-material/ArrowForwardRounded'
2
+ import { alpha, Card, CardActions, CardContent, CardMedia, CardProps, Grid, IconButton, Typography, useTheme, Zoom } from '@mui/material'
3
+ import { FlexGrowCol } from '@xylabs/react-flexbox'
4
+ import { useIsMobile } from '@xyo-network/react-shared'
5
+ import { ReactNode, useState } from 'react'
6
+ import { To, useNavigate } from 'react-router-dom'
7
+
8
+ export interface FullWidthCardProps extends CardProps {
9
+ name: ReactNode
10
+ desc?: ReactNode
11
+ href?: string
12
+ to?: To
13
+ linkText?: string
14
+ media?: string
15
+ small?: boolean
16
+ cardIsButton?: boolean
17
+ }
18
+
19
+ export const FullWidthCard: React.FC<FullWidthCardProps> = ({ name, small, cardIsButton, desc, href, to, media, ...props }) => {
20
+ const theme = useTheme()
21
+ const [raised, setRaised] = useState(false)
22
+ const navigate = useNavigate()
23
+ const isMobile = useIsMobile()
24
+
25
+ const localRouteChange = (to: To | undefined) => {
26
+ to ? navigate(to) : navigate('/404')
27
+ }
28
+ const externalRouteChange = (href: string | undefined) => {
29
+ href ? window.open(href) : navigate('/404')
30
+ }
31
+
32
+ return (
33
+ <Card
34
+ elevation={raised ? 3 : 0}
35
+ style={{ height: '100%', width: '100%' }}
36
+ {...props}
37
+ sx={{
38
+ '&:hover': {
39
+ cursor: 'pointer',
40
+ },
41
+ backgroundColor: alpha(theme.palette.primary.light, 0.05),
42
+ }}
43
+ onMouseEnter={() => (isMobile ? null : cardIsButton ? setRaised(true) : null)}
44
+ onMouseLeave={() => (isMobile ? null : cardIsButton ? setRaised(false) : null)}
45
+ onClick={() => (cardIsButton ? (href ? externalRouteChange(href) : to ? localRouteChange(to) : navigate('/404')) : null)}
46
+ >
47
+ {media ? <CardMedia component="img" height="100" image={media} alt="" /> : null}
48
+
49
+ <CardContent>
50
+ <Grid container alignItems="center" paddingY={2} paddingX={2}>
51
+ <Grid item xs={12} md={6}>
52
+ {typeof name === 'string' ? (
53
+ <Typography fontWeight={700} variant="h2" textAlign="left" paddingBottom={1}>
54
+ {name}
55
+ </Typography>
56
+ ) : (
57
+ name
58
+ )}
59
+ </Grid>
60
+ <Grid item xs={12} md={5}>
61
+ <Typography variant="body1" fontWeight={400} textAlign="left">
62
+ {desc}
63
+ </Typography>
64
+ </Grid>
65
+ <Grid item xs={1} display={isMobile ? 'none' : 'flex'} justifyContent="center">
66
+ <Zoom in={raised}>
67
+ <IconButton
68
+ color="primary"
69
+ size={small ? 'small' : 'medium'}
70
+ onClick={() => (href ? externalRouteChange(href) : to ? localRouteChange(to) : navigate('/404'))}
71
+ disableFocusRipple
72
+ disableRipple
73
+ disableTouchRipple
74
+ >
75
+ <ArrowForwardRoundedIcon fontSize={small ? 'small' : 'medium'} />
76
+ </IconButton>
77
+ </Zoom>
78
+ </Grid>
79
+ </Grid>
80
+ </CardContent>
81
+ <CardActions sx={{ display: { md: isMobile ? 'flex' : 'none' } }}>
82
+ <FlexGrowCol alignItems="flex-end">
83
+ <IconButton
84
+ color="primary"
85
+ size={small ? 'small' : 'medium'}
86
+ onClick={() => (href ? externalRouteChange(href) : to ? localRouteChange(to) : navigate('/404'))}
87
+ disableFocusRipple
88
+ disableRipple
89
+ disableTouchRipple
90
+ >
91
+ <ArrowForwardRoundedIcon fontSize={small ? 'small' : 'medium'} />
92
+ </IconButton>
93
+ </FlexGrowCol>
94
+ </CardActions>
95
+ </Card>
96
+ )
97
+ }
@@ -0,0 +1 @@
1
+ export * from './FullWidthCard'
@@ -0,0 +1,62 @@
1
+ /* eslint-disable import/no-internal-modules */
2
+ import { CardContent, Typography } from '@mui/material'
3
+ import { ComponentStory, Meta } from '@storybook/react'
4
+ import { useState } from 'react'
5
+
6
+ import { PageCard } from './PageCard'
7
+
8
+ const StorybookEntry: Meta = {
9
+ argTypes: {
10
+ onRefresh: {
11
+ table: {
12
+ disable: true,
13
+ },
14
+ },
15
+ },
16
+ component: PageCard,
17
+ parameters: {
18
+ docs: {
19
+ page: null,
20
+ },
21
+ },
22
+ title: 'shared/PageCard',
23
+ }
24
+
25
+ const Template: ComponentStory<typeof PageCard> = (props) => {
26
+ const [refreshedValue, setRefreshedValue] = useState<number>(Math.random)
27
+ return (
28
+ <PageCard title="Page Card" subheader="subheader" onRefresh={() => setRefreshedValue(Math.random())} {...props}>
29
+ <CardContent>
30
+ <Typography variant="body1">Page Card Content</Typography>
31
+ <Typography variant="body1">Refreshed Value: {refreshedValue?.toString()}</Typography>
32
+ </CardContent>
33
+ </PageCard>
34
+ )
35
+ }
36
+
37
+ const TemplateWithNoOnRefresh: ComponentStory<typeof PageCard> = (props) => {
38
+ return (
39
+ <PageCard title="Page Card" subheader="subheader" {...props}>
40
+ <CardContent>
41
+ <Typography variant="body1">Page Card Content</Typography>
42
+ </CardContent>
43
+ </PageCard>
44
+ )
45
+ }
46
+
47
+ const Default = Template.bind({})
48
+ Default.args = {}
49
+ Default.parameters = {
50
+ actions: { argTypesRegex: '' },
51
+ }
52
+
53
+ const WithNoOnRefresh = TemplateWithNoOnRefresh.bind({})
54
+ WithNoOnRefresh.args = {}
55
+ WithNoOnRefresh.parameters = {
56
+ actions: { argTypesRegex: '' },
57
+ }
58
+
59
+ export { Default, WithNoOnRefresh }
60
+
61
+ // eslint-disable-next-line import/no-default-export
62
+ export default StorybookEntry
@@ -0,0 +1,38 @@
1
+ import RefreshIcon from '@mui/icons-material/Refresh'
2
+ import { CardHeader, CardHeaderProps, IconButton, SvgIconProps } from '@mui/material'
3
+ import { TypographyEx } from '@xyo-network/react-shared'
4
+ import { ReactNode } from 'react'
5
+
6
+ import { CardEx, CardExProps } from './CardEx'
7
+
8
+ export interface PageCardProps extends CardExProps {
9
+ icon?: (props?: SvgIconProps) => ReactNode
10
+ onRefresh?: () => void
11
+ subheader?: CardHeaderProps['subheader']
12
+ }
13
+
14
+ export const PageCard: React.FC<PageCardProps> = ({ subheader, title, icon, onRefresh, children, style, ...props }) => {
15
+ return (
16
+ <CardEx style={{ position: 'relative', ...style }} {...props}>
17
+ {icon?.({ style: { fontSize: 512, left: '-144px', opacity: 0.05, position: 'absolute', top: '-144px' } })}
18
+ <CardHeader
19
+ title={
20
+ <TypographyEx variant="h4" gradient="text">
21
+ {title}
22
+ </TypographyEx>
23
+ }
24
+ subheader={subheader}
25
+ action={
26
+ <>
27
+ {onRefresh ? (
28
+ <IconButton onClick={() => onRefresh?.()}>
29
+ <RefreshIcon />
30
+ </IconButton>
31
+ ) : null}
32
+ </>
33
+ }
34
+ />
35
+ {children}
36
+ </CardEx>
37
+ )
38
+ }
@@ -0,0 +1,88 @@
1
+ import { Grid } from '@mui/material'
2
+ import { ComponentMeta, ComponentStory } from '@storybook/react'
3
+ import { BrowserRouter } from 'react-router-dom'
4
+
5
+ import CoinbaseWalletIcon from './coinbase-wallet.svg'
6
+ import MoneyMedia from './money.jpg'
7
+ import { SimpleCard } from './SimpleCard'
8
+ const StorybookEntry = {
9
+ argTypes: {},
10
+ component: SimpleCard,
11
+ parameters: {
12
+ docs: {
13
+ page: null,
14
+ },
15
+ },
16
+ title: 'shared/SimpleCard',
17
+ } as ComponentMeta<typeof SimpleCard>
18
+
19
+ const Template: ComponentStory<typeof SimpleCard> = (args) => (
20
+ <BrowserRouter>
21
+ <Grid container spacing={2}>
22
+ <Grid item xs={12} sm={6} md={3}>
23
+ <SimpleCard {...args}></SimpleCard>
24
+ </Grid>
25
+ <Grid item xs={12} sm={6} md={3}>
26
+ <SimpleCard {...args}></SimpleCard>
27
+ </Grid>
28
+ <Grid item xs={12} sm={6} md={3}>
29
+ <SimpleCard {...args}></SimpleCard>
30
+ </Grid>
31
+ <Grid item xs={12} sm={6} md={3}>
32
+ <SimpleCard {...args}></SimpleCard>
33
+ </Grid>
34
+ </Grid>
35
+ </BrowserRouter>
36
+ )
37
+
38
+ const Default = Template.bind({})
39
+ Default.args = {
40
+ desc: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat delectus nemo optio quis! Totam magni laboriosam repudiandae nam nobis at quisquam aut omnis, quis officiis similique enim id dolorem unde!',
41
+ headline: 'Headline Lorem Ipsum',
42
+ subtitle: 'Aug 25, 1997',
43
+ }
44
+ const DefaultWithImage = Template.bind({})
45
+ DefaultWithImage.args = {
46
+ desc: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat delectus nemo optio quis! Totam magni laboriosam repudiandae nam nobis at quisquam aut omnis, quis officiis similique enim id dolorem unde!',
47
+ headline: 'Headline Lorem Ipsum',
48
+ iconImage: CoinbaseWalletIcon,
49
+ subtitle: 'Aug 25, 1997',
50
+ }
51
+ const VariantButton = Template.bind({})
52
+ VariantButton.args = {
53
+ desc: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat delectus nemo optio quis! Totam magni laboriosam repudiandae nam nobis at quisquam aut omnis, quis officiis similique enim id dolorem unde!',
54
+ headline: 'Headline Lorem Ipsum',
55
+ interactionVariant: 'button',
56
+ subtitle: 'Aug 25, 1997',
57
+ }
58
+ const DefaultSmallCard = Template.bind({})
59
+ DefaultSmallCard.args = {
60
+ desc: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat delectus nemo optio quis!',
61
+ headline: 'Headline Lorem Ipsum',
62
+ small: true,
63
+ subtitle: 'Aug 25, 1997',
64
+ }
65
+ const DefaultMediaCard = Template.bind({})
66
+ DefaultMediaCard.args = {
67
+ desc: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat delectus nemo optio quis! Totam magni laboriosam repudiandae nam nobis at quisquam aut omnis, quis officiis similique enim id dolorem unde!',
68
+ headline: 'Headline Lorem Ipsum',
69
+ media: MoneyMedia,
70
+ subtitle: 'Aug 25, 1997',
71
+ }
72
+ const CardWithAllParameters = Template.bind({})
73
+ CardWithAllParameters.args = {
74
+ desc: 'Many people believe that a card cannot be a button. But here at XYO, we say "No way, José" and turn our cards into buttons.',
75
+ headline: 'Did you know that this card is complex?',
76
+ iconImage: CoinbaseWalletIcon,
77
+ interactionVariant: 'button',
78
+ media: MoneyMedia,
79
+ subtitle: 'Aug 25, 1997',
80
+ }
81
+
82
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
83
+ //@ts-ignore
84
+
85
+ export { CardWithAllParameters, Default, DefaultMediaCard, DefaultSmallCard, DefaultWithImage, VariantButton }
86
+
87
+ // eslint-disable-next-line import/no-default-export
88
+ export default StorybookEntry
@@ -0,0 +1,88 @@
1
+ import ArrowForwardRoundedIcon from '@mui/icons-material/ArrowForwardRounded'
2
+ import { alpha, CardActions, CardContent, CardMedia, IconButton, Typography, useTheme } from '@mui/material'
3
+ import { FlexCol, FlexGrowCol } from '@xylabs/react-flexbox'
4
+ import { useIsMobile } from '@xyo-network/react-shared'
5
+ import { ReactNode, useState } from 'react'
6
+ import { To, useNavigate } from 'react-router-dom'
7
+
8
+ import { CardEx, CardExProps } from '../CardEx'
9
+
10
+ export interface SimpleCardProps extends CardExProps {
11
+ headline?: ReactNode
12
+ desc?: ReactNode
13
+ href?: string
14
+ to?: To
15
+ media?: string
16
+ small?: boolean
17
+ iconImage?: string
18
+ interactionVariant?: 'button' | 'card'
19
+ subtitle?: string
20
+ }
21
+
22
+ export const SimpleCard: React.FC<SimpleCardProps> = ({ iconImage, subtitle, headline, small, desc, href, to, interactionVariant = 'card', media, ...props }) => {
23
+ const theme = useTheme()
24
+ const [raised, setRaised] = useState(false)
25
+ const navigate = useNavigate()
26
+ const isMobile = useIsMobile()
27
+ const localRouteChange = (to: To | undefined) => {
28
+ to ? navigate(to) : navigate('/404')
29
+ }
30
+ const externalRouteChange = (href: string | undefined) => {
31
+ href ? window.open(href) : navigate('/404')
32
+ }
33
+ return (
34
+ <CardEx
35
+ elevation={raised ? 3 : 0}
36
+ style={{ height: '100%', justifyContent: 'space-between', width: '100%' }}
37
+ sx={{
38
+ '&:hover': {
39
+ cursor: interactionVariant == 'button' ? 'pointer' : null,
40
+ },
41
+ backgroundColor: alpha(theme.palette.primary.light, 0.05),
42
+ }}
43
+ onMouseEnter={() => (isMobile ? null : interactionVariant == 'button' ? setRaised(true) : null)}
44
+ onMouseLeave={() => (isMobile ? null : interactionVariant == 'button' ? setRaised(false) : null)}
45
+ onClick={() => (interactionVariant == 'button' ? (href ? externalRouteChange(href) : to ? localRouteChange(to) : navigate('/404')) : null)}
46
+ {...props}
47
+ >
48
+ {media ? <CardMedia component="img" height="100" image={media} alt="" /> : null}
49
+
50
+ <CardContent sx={{ height: '100%' }}>
51
+ <FlexCol width="100%" alignItems="flex-start">
52
+ {iconImage ? <img src={iconImage} height="40px" style={{ paddingBottom: '8px' }} /> : null}
53
+ {typeof headline === 'string' ? (
54
+ <Typography variant={small ? 'body1' : 'h6'} textAlign="left" gutterBottom>
55
+ {headline}
56
+ </Typography>
57
+ ) : (
58
+ headline
59
+ )}
60
+ {subtitle ? (
61
+ <Typography variant="subtitle2" textAlign="left" gutterBottom>
62
+ {subtitle}
63
+ </Typography>
64
+ ) : null}
65
+ <Typography variant={small ? 'caption' : 'body1'} textAlign="left" gutterBottom>
66
+ {desc}
67
+ </Typography>
68
+ </FlexCol>
69
+ </CardContent>
70
+ {interactionVariant == 'button' ? (
71
+ <CardActions>
72
+ <FlexGrowCol alignItems="flex-end">
73
+ <IconButton
74
+ color={raised ? 'secondary' : 'primary'}
75
+ size={small ? 'small' : 'medium'}
76
+ onClick={() => (href ? externalRouteChange(href) : to ? localRouteChange(to) : navigate('/404'))}
77
+ disableFocusRipple
78
+ disableRipple
79
+ disableTouchRipple
80
+ >
81
+ <ArrowForwardRoundedIcon fontSize={small ? 'small' : 'medium'} />
82
+ </IconButton>
83
+ </FlexGrowCol>
84
+ </CardActions>
85
+ ) : null}
86
+ </CardEx>
87
+ )
88
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><style>.cls-1{fill:#005cfe;}.cls-2{fill:#fdfdfe;}</style></defs><g id="Layer_6" data-name="Layer 6"><g id="JuvZVa"><path class="cls-1" d="M0,50C0,40.77-.1,31.58.07,22.4.22,14.9,3,8.55,9.32,4.09A22.35,22.35,0,0,1,20.3.25,56.53,56.53,0,0,1,26.12,0C42.74,0,59.37,0,76,0c5.17,0,10.15.92,14.5,4A21.42,21.42,0,0,1,99.75,20.1,55.89,55.89,0,0,1,100,26c0,17.13.11,34.26-.08,51.38-.1,8.93-3.88,16-12.11,20.15A25.49,25.49,0,0,1,76.15,100Q50,100,23.83,100c-5.37,0-10.52-1.06-14.95-4.39A21.57,21.57,0,0,1,.21,79.72,59,59,0,0,1,0,73.78Q0,61.87,0,50Zm50-35a35.07,35.07,0,1,0,35,35.13A35,35,0,0,0,50,14.92Z"/><path class="cls-2" d="M50,14.92a35.07,35.07,0,1,1-35.11,35A35,35,0,0,1,50,14.92ZM38.7,50c0,2.92,0,5.83,0,8.75a2.26,2.26,0,0,0,2.52,2.53q8.74,0,17.5,0c1.73,0,2.56-.85,2.56-2.6q0-8.68,0-17.38a2.27,2.27,0,0,0-2.57-2.59q-8.7,0-17.39,0c-1.8,0-2.61.84-2.62,2.66C38.69,44.25,38.7,47.12,38.7,50Z"/><path class="cls-1" d="M38.7,50c0-2.88,0-5.75,0-8.63,0-1.82.82-2.66,2.62-2.66q8.7,0,17.39,0a2.27,2.27,0,0,1,2.57,2.59q0,8.69,0,17.38c0,1.75-.83,2.6-2.56,2.6q-8.76,0-17.5,0a2.26,2.26,0,0,1-2.52-2.53C38.68,55.83,38.7,52.92,38.7,50Z"/></g></g></svg>
@@ -0,0 +1 @@
1
+ export * from './SimpleCard'
@@ -0,0 +1,4 @@
1
+ export * from './CardEx'
2
+ export * from './FullWidthCard'
3
+ export * from './PageCard'
4
+ export * from './SimpleCard'
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './components'
@@ -0,0 +1,5 @@
1
+ declare module '*.png'
2
+ declare module '*.jpg'
3
+ declare module '*.svg'
4
+ declare module '*.gif'
5
+ declare module '*.webp'