@xyo-network/react-shared 2.26.35 → 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.
Files changed (59) hide show
  1. package/dist/docs.json +1 -1
  2. package/package.json +1 -1
  3. package/src/SizeProp.ts +1 -0
  4. package/src/components/Ampersand.tsx +9 -0
  5. package/src/components/BasicHero/BasicHero.stories.tsx +58 -0
  6. package/src/components/BasicHero/BasicHero.tsx +162 -0
  7. package/src/components/BasicHero/default-desktop.svg +1 -0
  8. package/src/components/BasicHero/index.ts +1 -0
  9. package/src/components/ErrorBoundry.tsx +42 -0
  10. package/src/components/JsonRouteWrapper/JsonApiButton.tsx +19 -0
  11. package/src/components/JsonRouteWrapper/JsonFromUrl.stories.tsx +48 -0
  12. package/src/components/JsonRouteWrapper/JsonFromUrl.tsx +52 -0
  13. package/src/components/JsonRouteWrapper/JsonRouteWrapper.stories.tsx +68 -0
  14. package/src/components/JsonRouteWrapper/JsonRouteWrapper.tsx +78 -0
  15. package/src/components/JsonRouteWrapper/index.ts +3 -0
  16. package/src/components/ListItemButtonEx.tsx +29 -0
  17. package/src/components/Pipe.tsx +9 -0
  18. package/src/components/ScrollTableOnSm.tsx +14 -0
  19. package/src/components/SectionSpacingRow/SectionSpacingRow.stories.tsx +36 -0
  20. package/src/components/SectionSpacingRow/SectionSpacingRow.tsx +19 -0
  21. package/src/components/SectionSpacingRow/index.ts +1 -0
  22. package/src/components/StyleGuide/AppBars.example.tsx +26 -0
  23. package/src/components/StyleGuide/Buttons.example.tsx +41 -0
  24. package/src/components/StyleGuide/Papers.example.tsx +19 -0
  25. package/src/components/StyleGuide/StyleGuide.example.tsx +19 -0
  26. package/src/components/StyleGuide/StyleGuide.stories.tsx +25 -0
  27. package/src/components/StyleGuide/Texts.example.tsx +16 -0
  28. package/src/components/StyleGuide/VariantContext.example.tsx +3 -0
  29. package/src/components/TableCell/AddressTableCell.tsx +13 -0
  30. package/src/components/TableCell/EllipsisTableCell.tsx +100 -0
  31. package/src/components/TableCell/HashTableCell.tsx +13 -0
  32. package/src/components/TableCell/findParent.ts +10 -0
  33. package/src/components/TableCell/getRemainingRowWidth.ts +14 -0
  34. package/src/components/TableCell/getSmallestParentWidth.ts +13 -0
  35. package/src/components/TableCell/index.ts +3 -0
  36. package/src/components/TypographyEx.tsx +12 -0
  37. package/src/components/index.ts +10 -0
  38. package/src/contexts/Pixel/Context.ts +4 -0
  39. package/src/contexts/Pixel/Provider.tsx +24 -0
  40. package/src/contexts/Pixel/State.ts +7 -0
  41. package/src/contexts/Pixel/index.ts +4 -0
  42. package/src/contexts/Pixel/use.ts +7 -0
  43. package/src/contexts/contextEx/State.ts +3 -0
  44. package/src/contexts/contextEx/create.ts +5 -0
  45. package/src/contexts/contextEx/index.ts +3 -0
  46. package/src/contexts/contextEx/use.ts +11 -0
  47. package/src/contexts/index.ts +2 -0
  48. package/src/hooks/GradientStyles/GradientStyle.stories.tsx +68 -0
  49. package/src/hooks/GradientStyles/GradientStyles.tsx +60 -0
  50. package/src/hooks/GradientStyles/index.ts +1 -0
  51. package/src/hooks/index.ts +3 -0
  52. package/src/hooks/useIsMobile.ts +8 -0
  53. package/src/hooks/useMediaQuery.ts +7 -0
  54. package/src/index.ts +5 -0
  55. package/src/lib/assertDefinedEx.ts +4 -0
  56. package/src/lib/getActualPaddingX.ts +61 -0
  57. package/src/lib/index.ts +3 -0
  58. package/src/lib/networkComponents.tsx +29 -0
  59. package/src/types/images.d.ts +5 -0
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/7efa6fa/packages/shared/src/index.ts#L1"
13
+ "url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/c31a96d/packages/shared/src/index.ts#L1"
14
14
  }
15
15
  ]
16
16
  }
package/package.json CHANGED
@@ -87,5 +87,5 @@
87
87
  },
88
88
  "sideEffects": false,
89
89
  "types": "dist/esm/index.d.ts",
90
- "version": "2.26.35"
90
+ "version": "2.26.38"
91
91
  }
@@ -0,0 +1 @@
1
+ export type SizeProp = 'small' | 'medium' | 'large'
@@ -0,0 +1,9 @@
1
+ import { Typography, TypographyProps } from '@mui/material'
2
+
3
+ export const Ampersand: React.FC<TypographyProps> = (props) => {
4
+ return (
5
+ <Typography marginX={1} component="span" {...props}>
6
+ &amp;
7
+ </Typography>
8
+ )
9
+ }
@@ -0,0 +1,58 @@
1
+ import { ComponentMeta, ComponentStory } from '@storybook/react'
2
+ import { BrowserRouter } from 'react-router-dom'
3
+
4
+ import { BasicHero } from './BasicHero'
5
+ import BackgroundImage from './default-desktop.svg'
6
+ const StorybookEntry = {
7
+ argTypes: {},
8
+ component: BasicHero,
9
+ parameters: {
10
+ docs: {
11
+ page: null,
12
+ },
13
+ },
14
+ title: 'shared/BasicHero',
15
+ } as ComponentMeta<typeof BasicHero>
16
+
17
+ const Template: ComponentStory<typeof BasicHero> = (args) => (
18
+ <BrowserRouter>
19
+ <BasicHero {...args}></BasicHero>
20
+ </BrowserRouter>
21
+ )
22
+
23
+ const Default = Template.bind({})
24
+ Default.args = {
25
+ button1Text: 'Button 1',
26
+ button1To: '',
27
+ button2Text: 'Button 2',
28
+ button2To: '',
29
+ desc: ' Ipsam illo molestiae nisi perferendis a error, eum repellendus voluptatibus, provident, voluptatum qui laborum assumenda minus!',
30
+ gradientTitle: 'dolor',
31
+ subLinkPath: 'https://medium.com/xyonetwork/xyo-2-0-has-arrived-fe160f8b2928',
32
+ subLinkText1: 'We just announced XYO 2.0',
33
+ subLinkText2: 'Read more here.',
34
+ title: 'Lorem ipsum',
35
+ }
36
+ const WithBackgroundImage = Template.bind({})
37
+ WithBackgroundImage.args = {
38
+ backgroundImage: BackgroundImage,
39
+ button1Text: 'Button 1',
40
+ button1To: '',
41
+ button2Text: 'Button 2',
42
+ button2To: '',
43
+ desc: ' Ipsam illo molestiae nisi perferendis a error, eum repellendus voluptatibus, provident, voluptatum qui laborum assumenda minus!',
44
+ gradientTitle: 'dolor',
45
+ subLinkPath: 'https://medium.com/xyonetwork/xyo-2-0-has-arrived-fe160f8b2928',
46
+ subLinkText1: 'We just announced XYO 2.0',
47
+ subLinkText2: 'Read more here.',
48
+ title: 'Lorem ipsum',
49
+ title2: 'adipisicing elit.',
50
+ }
51
+
52
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
53
+ //@ts-ignore
54
+
55
+ export { Default, WithBackgroundImage }
56
+
57
+ // eslint-disable-next-line import/no-default-export
58
+ export default StorybookEntry
@@ -0,0 +1,162 @@
1
+ import { Container, Grid, Typography } from '@mui/material'
2
+ import { ButtonEx } from '@xylabs/react-button'
3
+ import { FlexBoxProps, FlexGrowCol, FlexGrowRow } from '@xylabs/react-flexbox'
4
+ import { LinkEx } from '@xylabs/react-link'
5
+ import { ReactElement } from 'react'
6
+
7
+ import { useGradientStyles, useIsMobile } from '../../hooks'
8
+
9
+ export interface BasicHeroProps extends FlexBoxProps {
10
+ title: string
11
+ gradientTitle?: string
12
+ title2?: string
13
+ desc: string
14
+ button1Text?: string
15
+ button2Text?: string
16
+ button1To?: string
17
+ button2To?: string
18
+ button1Href?: string
19
+ button2Href?: string
20
+ subLinkText1?: string
21
+ subLinkText2?: string
22
+ heroImage?: string
23
+ subLinkPath?: string
24
+ subLinkIcon?: ReactElement
25
+ backgroundColor?: string
26
+ textColor?: string
27
+ backgroundImage?: string
28
+ sx?: Record<string, string>
29
+ }
30
+
31
+ interface SubLinkSectionProps {
32
+ subLinkText1?: string
33
+ subLinkText2?: string
34
+ subLinkPath?: string
35
+ subLinkIcon?: ReactElement
36
+ backgroundImageAlignment?: boolean
37
+ }
38
+
39
+ interface ButtonSectionProps {
40
+ href?: string
41
+ to?: string
42
+ buttonText?: string
43
+ }
44
+ const SubLinkSection: React.FC<SubLinkSectionProps> = ({ subLinkText1, subLinkText2, subLinkPath, subLinkIcon, backgroundImageAlignment }) => {
45
+ return (
46
+ <FlexGrowRow width="100%" sx={{ flexDirection: { md: 'row', xs: 'column' }, justifyContent: { md: backgroundImageAlignment ? 'flex-start' : 'center', xs: 'center' } }}>
47
+ {subLinkIcon ? <span>{subLinkIcon}&nbsp;</span> : null}
48
+ <Typography>{subLinkText1}&nbsp;</Typography>
49
+ <LinkEx href={subLinkPath} underline="always" target="_blank" color="inherit">
50
+ <Typography>{subLinkText2}</Typography>
51
+ </LinkEx>
52
+ </FlexGrowRow>
53
+ )
54
+ }
55
+
56
+ const ButtonSection: React.FC<ButtonSectionProps> = ({ href, to, buttonText }) => {
57
+ const isMobile = useIsMobile()
58
+ return (
59
+ <ButtonEx
60
+ fullWidth={true}
61
+ marginTop={1}
62
+ marginBottom={1}
63
+ marginRight={isMobile ? 2 : 1}
64
+ marginLeft={isMobile ? 2 : 0}
65
+ target={href ?? '_blank'}
66
+ to={to}
67
+ href={href}
68
+ color="primary"
69
+ variant="contained"
70
+ paddingX={3}
71
+ sx={{ display: href || to ? 'flex' : 'none' }}
72
+ >
73
+ {buttonText}
74
+ </ButtonEx>
75
+ )
76
+ }
77
+
78
+ export const BasicHero: React.FC<BasicHeroProps> = ({
79
+ backgroundImage,
80
+ title,
81
+ gradientTitle,
82
+ backgroundColor,
83
+ textColor,
84
+ desc,
85
+ heroImage,
86
+ title2,
87
+ subLinkText1,
88
+ subLinkText2,
89
+ subLinkPath,
90
+ button1Text,
91
+ button2Text,
92
+ button2To,
93
+ button1To,
94
+ button2Href,
95
+ button1Href,
96
+ subLinkIcon,
97
+ sx,
98
+ ...props
99
+ }) => {
100
+ const isMobile = useIsMobile()
101
+ const { classes } = useGradientStyles()
102
+ return (
103
+ <FlexGrowCol
104
+ sx={{
105
+ backgroundImage: `url(${backgroundImage})`,
106
+ backgroundPosition: { lg: 'bottom', md: 'center left', xs: 'top left' },
107
+ minHeight: {
108
+ md: '500px',
109
+ sm: '400px',
110
+ xs: '200px',
111
+ },
112
+ ...(sx ?? {}),
113
+ }}
114
+ style={{
115
+ backgroundColor: backgroundColor ?? '',
116
+ backgroundRepeat: 'no-repeat',
117
+ backgroundSize: 'cover',
118
+ color: textColor ?? '',
119
+ }}
120
+ {...props}
121
+ >
122
+ <Container>
123
+ <Grid
124
+ container
125
+ justifyContent="center"
126
+ alignItems="center"
127
+ sx={{
128
+ alignItems: { xs: 'center' },
129
+ justifyContent: { xs: 'center' },
130
+ }}
131
+ >
132
+ <Grid item xs={12} sm={8} md={backgroundImage ? 6 : 8} lg={backgroundImage ? 6 : 8}>
133
+ <FlexGrowCol paddingY={2} sx={{ alignItems: { xs: backgroundImage && !isMobile ? 'flex-start' : 'center' } }}>
134
+ <Typography variant="h1" component="h1" gutterBottom textAlign={backgroundImage && !isMobile ? 'left' : 'center'}>
135
+ {title ? <span>{`${title} `}</span> : null}
136
+ {gradientTitle ? <span className={classes().heading}> {` ${gradientTitle}`}</span> : null}
137
+ {title2 ? <span>{` ${title2}`}</span> : null}
138
+ </Typography>
139
+ <Typography variant="body1" component="h2" gutterBottom textAlign={backgroundImage && !isMobile ? 'left' : 'center'}>
140
+ {desc}
141
+ </Typography>
142
+ <FlexGrowRow sx={{ flexDirection: { lg: 'row', xs: 'column' } }} width="100%" marginTop={1}>
143
+ <ButtonSection href={button1Href} to={button1To} buttonText={button1Text} />
144
+ <ButtonSection href={button2Href} to={button2To} buttonText={button2Text} />
145
+ </FlexGrowRow>
146
+ <SubLinkSection
147
+ subLinkIcon={subLinkIcon}
148
+ subLinkText1={subLinkText1}
149
+ subLinkText2={subLinkText2}
150
+ subLinkPath={subLinkPath}
151
+ backgroundImageAlignment={backgroundImage ? true : false}
152
+ />
153
+ </FlexGrowCol>
154
+ </Grid>
155
+ <Grid item xs={12} md={6}>
156
+ {heroImage ? <img src={heroImage} width="100%" /> : null}
157
+ </Grid>
158
+ </Grid>
159
+ </Container>
160
+ </FlexGrowCol>
161
+ )
162
+ }