@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.
- package/dist/docs.json +1 -1
- package/package.json +1 -1
- package/src/SizeProp.ts +1 -0
- package/src/components/Ampersand.tsx +9 -0
- package/src/components/BasicHero/BasicHero.stories.tsx +58 -0
- package/src/components/BasicHero/BasicHero.tsx +162 -0
- package/src/components/BasicHero/default-desktop.svg +1 -0
- package/src/components/BasicHero/index.ts +1 -0
- package/src/components/ErrorBoundry.tsx +42 -0
- package/src/components/JsonRouteWrapper/JsonApiButton.tsx +19 -0
- package/src/components/JsonRouteWrapper/JsonFromUrl.stories.tsx +48 -0
- package/src/components/JsonRouteWrapper/JsonFromUrl.tsx +52 -0
- package/src/components/JsonRouteWrapper/JsonRouteWrapper.stories.tsx +68 -0
- package/src/components/JsonRouteWrapper/JsonRouteWrapper.tsx +78 -0
- package/src/components/JsonRouteWrapper/index.ts +3 -0
- package/src/components/ListItemButtonEx.tsx +29 -0
- package/src/components/Pipe.tsx +9 -0
- package/src/components/ScrollTableOnSm.tsx +14 -0
- package/src/components/SectionSpacingRow/SectionSpacingRow.stories.tsx +36 -0
- package/src/components/SectionSpacingRow/SectionSpacingRow.tsx +19 -0
- package/src/components/SectionSpacingRow/index.ts +1 -0
- package/src/components/StyleGuide/AppBars.example.tsx +26 -0
- package/src/components/StyleGuide/Buttons.example.tsx +41 -0
- package/src/components/StyleGuide/Papers.example.tsx +19 -0
- package/src/components/StyleGuide/StyleGuide.example.tsx +19 -0
- package/src/components/StyleGuide/StyleGuide.stories.tsx +25 -0
- package/src/components/StyleGuide/Texts.example.tsx +16 -0
- package/src/components/StyleGuide/VariantContext.example.tsx +3 -0
- package/src/components/TableCell/AddressTableCell.tsx +13 -0
- package/src/components/TableCell/EllipsisTableCell.tsx +100 -0
- package/src/components/TableCell/HashTableCell.tsx +13 -0
- package/src/components/TableCell/findParent.ts +10 -0
- package/src/components/TableCell/getRemainingRowWidth.ts +14 -0
- package/src/components/TableCell/getSmallestParentWidth.ts +13 -0
- package/src/components/TableCell/index.ts +3 -0
- package/src/components/TypographyEx.tsx +12 -0
- package/src/components/index.ts +10 -0
- package/src/contexts/Pixel/Context.ts +4 -0
- package/src/contexts/Pixel/Provider.tsx +24 -0
- package/src/contexts/Pixel/State.ts +7 -0
- package/src/contexts/Pixel/index.ts +4 -0
- package/src/contexts/Pixel/use.ts +7 -0
- package/src/contexts/contextEx/State.ts +3 -0
- package/src/contexts/contextEx/create.ts +5 -0
- package/src/contexts/contextEx/index.ts +3 -0
- package/src/contexts/contextEx/use.ts +11 -0
- package/src/contexts/index.ts +2 -0
- package/src/hooks/GradientStyles/GradientStyle.stories.tsx +68 -0
- package/src/hooks/GradientStyles/GradientStyles.tsx +60 -0
- package/src/hooks/GradientStyles/index.ts +1 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useIsMobile.ts +8 -0
- package/src/hooks/useMediaQuery.ts +7 -0
- package/src/index.ts +5 -0
- package/src/lib/assertDefinedEx.ts +4 -0
- package/src/lib/getActualPaddingX.ts +61 -0
- package/src/lib/index.ts +3 -0
- package/src/lib/networkComponents.tsx +29 -0
- package/src/types/images.d.ts +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BasicHero'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Typography } from '@mui/material'
|
|
2
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
+
import { Component, ErrorInfo, ReactNode } from 'react'
|
|
4
|
+
|
|
5
|
+
export interface ErrorBoundaryProps {
|
|
6
|
+
children: ReactNode
|
|
7
|
+
fallback?: ReactNode
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ErrorBoundaryState {
|
|
11
|
+
error?: Error
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
15
|
+
constructor(props: ErrorBoundaryProps) {
|
|
16
|
+
super(props)
|
|
17
|
+
this.state = { error: undefined }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static getDerivedStateFromError(error: Error) {
|
|
21
|
+
return { error }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
25
|
+
console.error(`${error}: ${errorInfo}`)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
render() {
|
|
29
|
+
if (this.state.error) {
|
|
30
|
+
return (
|
|
31
|
+
this.props.fallback ?? (
|
|
32
|
+
<FlexCol>
|
|
33
|
+
<Typography variant="h1">Something went wrong.</Typography>
|
|
34
|
+
<Typography variant="body1">[{this.state.error?.message}]</Typography>
|
|
35
|
+
</FlexCol>
|
|
36
|
+
)
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return this.props.children
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ButtonEx, ButtonExProps } from '@xylabs/react-button'
|
|
2
|
+
import { useSearchParams } from 'react-router-dom'
|
|
3
|
+
|
|
4
|
+
export const JsonApiButton: React.FC<ButtonExProps> = (props) => {
|
|
5
|
+
const [searchParams, setSearchParams] = useSearchParams()
|
|
6
|
+
return (
|
|
7
|
+
<ButtonEx
|
|
8
|
+
marginX={2}
|
|
9
|
+
variant="outlined"
|
|
10
|
+
onClick={() => {
|
|
11
|
+
searchParams.set('json', 'true')
|
|
12
|
+
setSearchParams(searchParams)
|
|
13
|
+
}}
|
|
14
|
+
{...props}
|
|
15
|
+
>
|
|
16
|
+
JSON
|
|
17
|
+
</ButtonEx>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* eslint-disable deprecation/deprecation */
|
|
2
|
+
/* eslint-disable import/no-deprecated */
|
|
3
|
+
import { ComponentStory, Meta } from '@storybook/react'
|
|
4
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
5
|
+
import { BrowserRouter } from 'react-router-dom'
|
|
6
|
+
|
|
7
|
+
import { DeprecateStory } from '../../../../../.storybook'
|
|
8
|
+
import { JsonFromUrl } from './JsonFromUrl'
|
|
9
|
+
|
|
10
|
+
const StorybookEntry: Meta = {
|
|
11
|
+
args: {
|
|
12
|
+
apiDomain: 'http://localhost:8081',
|
|
13
|
+
},
|
|
14
|
+
component: JsonFromUrl,
|
|
15
|
+
parameters: {
|
|
16
|
+
docs: {
|
|
17
|
+
page: null,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
title: 'shared/JsonRouteWrapper/JsonFromUrl',
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const Template: ComponentStory<typeof JsonFromUrl> = (props) => {
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<DeprecateStory />
|
|
27
|
+
<BrowserRouter>
|
|
28
|
+
<FlexCol>
|
|
29
|
+
<JsonFromUrl {...props}></JsonFromUrl>
|
|
30
|
+
</FlexCol>
|
|
31
|
+
</BrowserRouter>
|
|
32
|
+
</>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const Default = Template.bind({})
|
|
37
|
+
Default.args = { pathname: '/stats' }
|
|
38
|
+
|
|
39
|
+
const CustomTheme = Template.bind({})
|
|
40
|
+
CustomTheme.args = { pathname: '/stats', theme: 'apathy:inverted' }
|
|
41
|
+
|
|
42
|
+
const ErrorState = Template.bind({})
|
|
43
|
+
ErrorState.args = { pathname: '/foo' }
|
|
44
|
+
|
|
45
|
+
export { CustomTheme, Default, ErrorState }
|
|
46
|
+
|
|
47
|
+
// eslint-disable-next-line import/no-default-export
|
|
48
|
+
export default StorybookEntry
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ErrorDialog } from '@xylabs/react-dialogs'
|
|
2
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
+
import { useAsyncEffect } from '@xylabs/react-shared'
|
|
4
|
+
import axios, { AxiosError, AxiosResponse } from 'axios'
|
|
5
|
+
import { lazy, Suspense, useState } from 'react'
|
|
6
|
+
import { ThemeKeys, ThemeObject } from 'react-json-view'
|
|
7
|
+
import { useLocation } from 'react-router-dom'
|
|
8
|
+
|
|
9
|
+
const JsonView = lazy(() => import(/* webpackChunkName: "jsonView" */ 'react-json-view'))
|
|
10
|
+
|
|
11
|
+
const sanitizeUrlForApi = (path: string) => {
|
|
12
|
+
if (new RegExp(/json$/g).test(path)) {
|
|
13
|
+
return path.split('json')[0]
|
|
14
|
+
} else {
|
|
15
|
+
return path
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface JsonFromUrlProps {
|
|
20
|
+
apiDomain: string
|
|
21
|
+
pathname?: string
|
|
22
|
+
theme?: ThemeKeys | ThemeObject
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @deprecated - Move to JsonRouteWrapper Component */
|
|
26
|
+
export const JsonFromUrl: React.FC<JsonFromUrlProps> = ({ pathname, apiDomain, ...JsonViewProps }) => {
|
|
27
|
+
const location = useLocation()
|
|
28
|
+
const path = pathname ? pathname : location.pathname
|
|
29
|
+
const [apiResponse, setApiResponse] = useState<AxiosResponse>()
|
|
30
|
+
const [apiError, setApiError] = useState<AxiosError>()
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
useAsyncEffect(async () => {
|
|
34
|
+
const apiPath = sanitizeUrlForApi(path)
|
|
35
|
+
const url = `${apiDomain}${apiPath}`
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const response = await axios.get(url)
|
|
39
|
+
setApiResponse(response.data)
|
|
40
|
+
} catch (err) {
|
|
41
|
+
setApiError(err as AxiosError)
|
|
42
|
+
}
|
|
43
|
+
}, [apiDomain, path])
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
<p>Resource - {sanitizeUrlForApi(path)}</p>
|
|
48
|
+
<Suspense fallback={<FlexCol />}>{apiResponse && <JsonView src={apiResponse} collapseStringsAfterLength={64} {...JsonViewProps} />}</Suspense>
|
|
49
|
+
<ErrorDialog title="Error Fetching JSON" error={apiError} open={!!apiError} onAction={() => setApiError(undefined)} />
|
|
50
|
+
</>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ComponentMeta, ComponentStory, DecoratorFn } from '@storybook/react'
|
|
2
|
+
import { ButtonEx } from '@xylabs/react-button'
|
|
3
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
4
|
+
import { XyoArchivistApi } from '@xyo-network/api'
|
|
5
|
+
import { BrowserRouter, useSearchParams } from 'react-router-dom'
|
|
6
|
+
|
|
7
|
+
import { JsonRouteWrapper } from './JsonRouteWrapper'
|
|
8
|
+
|
|
9
|
+
const JsonDecorator: DecoratorFn = (Story) => (
|
|
10
|
+
<BrowserRouter>
|
|
11
|
+
<Story />
|
|
12
|
+
</BrowserRouter>
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
const StorybookEntry = {
|
|
16
|
+
argTypes: {
|
|
17
|
+
apiDomain: 'https://beta.api.archivist.xyo.network',
|
|
18
|
+
},
|
|
19
|
+
component: JsonRouteWrapper,
|
|
20
|
+
decorators: [JsonDecorator],
|
|
21
|
+
parameters: {
|
|
22
|
+
docs: {
|
|
23
|
+
page: null,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
title: 'shared/JsonRouteWrapper',
|
|
27
|
+
} as ComponentMeta<typeof JsonRouteWrapper>
|
|
28
|
+
|
|
29
|
+
const Template: ComponentStory<typeof JsonRouteWrapper> = (props) => {
|
|
30
|
+
const [searchParams, setSearchParams] = useSearchParams()
|
|
31
|
+
const activeJson = searchParams.get('json')
|
|
32
|
+
return (
|
|
33
|
+
<FlexCol>
|
|
34
|
+
<ButtonEx
|
|
35
|
+
marginY={3}
|
|
36
|
+
onClick={() => {
|
|
37
|
+
activeJson === 'true' ? searchParams.delete('json') : searchParams.set('json', 'true')
|
|
38
|
+
setSearchParams(searchParams)
|
|
39
|
+
}}
|
|
40
|
+
variant="outlined"
|
|
41
|
+
>
|
|
42
|
+
Toggle JSON Page
|
|
43
|
+
</ButtonEx>
|
|
44
|
+
<JsonRouteWrapper {...props}></JsonRouteWrapper>
|
|
45
|
+
</FlexCol>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const Default = Template.bind({})
|
|
50
|
+
Default.args = {
|
|
51
|
+
callback: () => new XyoArchivistApi({ apiDomain: 'https://beta.api.archivist.xyo.network' }).archive('temp').block.stats.get(),
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const HideBackButton = Template.bind({})
|
|
55
|
+
HideBackButton.args = {
|
|
56
|
+
callback: () =>
|
|
57
|
+
new XyoArchivistApi({
|
|
58
|
+
apiDomain: 'https://beta.api.archivist.xyo.network',
|
|
59
|
+
})
|
|
60
|
+
.archive('temp')
|
|
61
|
+
.block.stats.get(),
|
|
62
|
+
noBackButton: true,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { Default, HideBackButton }
|
|
66
|
+
|
|
67
|
+
// eslint-disable-next-line import/no-default-export
|
|
68
|
+
export default StorybookEntry
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ButtonEx } from '@xylabs/react-button'
|
|
2
|
+
import { ErrorDialog } from '@xylabs/react-dialogs'
|
|
3
|
+
import { FlexBoxProps, FlexCol, FlexRow } from '@xylabs/react-flexbox'
|
|
4
|
+
import { useAsyncEffect } from '@xylabs/react-shared'
|
|
5
|
+
import { XyoApiError } from '@xyo-network/api'
|
|
6
|
+
import { lazy, Suspense, useState } from 'react'
|
|
7
|
+
import { ReactJsonViewProps } from 'react-json-view'
|
|
8
|
+
import { useSearchParams } from 'react-router-dom'
|
|
9
|
+
|
|
10
|
+
import { JsonApiButton } from './JsonApiButton'
|
|
11
|
+
|
|
12
|
+
const JsonView = lazy(() => import(/* webpackChunkName: "jsonView" */ 'react-json-view'))
|
|
13
|
+
|
|
14
|
+
export interface JsonFromPromiseProps extends FlexBoxProps {
|
|
15
|
+
callback: () => Promise<object | undefined>
|
|
16
|
+
noBackButton?: boolean
|
|
17
|
+
noJsonButton?: boolean
|
|
18
|
+
jsonViewProps?: ReactJsonViewProps
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const JsonRouteWrapper: React.FC<JsonFromPromiseProps> = ({ callback, children, noBackButton = false, noJsonButton = false, jsonViewProps, ...props }) => {
|
|
22
|
+
const [apiResponse, setApiResponse] = useState<object>()
|
|
23
|
+
const [apiError, setApiError] = useState<XyoApiError>()
|
|
24
|
+
const [searchParams, setSearchParams] = useSearchParams()
|
|
25
|
+
const active = !!searchParams.get('json')
|
|
26
|
+
|
|
27
|
+
useAsyncEffect(
|
|
28
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
+
async (mounted) => {
|
|
30
|
+
try {
|
|
31
|
+
const response = await callback()
|
|
32
|
+
if (mounted()) {
|
|
33
|
+
setApiResponse(response)
|
|
34
|
+
}
|
|
35
|
+
} catch (ex) {
|
|
36
|
+
if (mounted()) {
|
|
37
|
+
const error = ex as XyoApiError
|
|
38
|
+
if (error.isXyoError) {
|
|
39
|
+
setApiError(error)
|
|
40
|
+
} else {
|
|
41
|
+
throw ex
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
[callback]
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<FlexCol {...props}>
|
|
51
|
+
{active ? (
|
|
52
|
+
<>
|
|
53
|
+
<Suspense fallback={null}>{apiResponse && <JsonView src={apiResponse} collapseStringsAfterLength={64} {...jsonViewProps} />}</Suspense>
|
|
54
|
+
{!noBackButton && (
|
|
55
|
+
<FlexRow marginY={3}>
|
|
56
|
+
<ButtonEx
|
|
57
|
+
flexDirection="row"
|
|
58
|
+
variant="outlined"
|
|
59
|
+
onClick={() => {
|
|
60
|
+
searchParams.delete('json')
|
|
61
|
+
setSearchParams(searchParams)
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
Back
|
|
65
|
+
</ButtonEx>
|
|
66
|
+
</FlexRow>
|
|
67
|
+
)}
|
|
68
|
+
<ErrorDialog title="Error Fetching JSON" error={apiError} open={!!apiError} onAction={() => setApiError(undefined)} />
|
|
69
|
+
</>
|
|
70
|
+
) : (
|
|
71
|
+
<>
|
|
72
|
+
{children}
|
|
73
|
+
{!noJsonButton && <JsonApiButton marginTop={2} />}
|
|
74
|
+
</>
|
|
75
|
+
)}
|
|
76
|
+
</FlexCol>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ListItemButton, ListItemButtonProps } from '@mui/material'
|
|
2
|
+
import { MouseEvent } from 'react'
|
|
3
|
+
import { NavigateOptions, To, useNavigate } from 'react-router-dom'
|
|
4
|
+
|
|
5
|
+
export interface ListItemButtonExProps extends ListItemButtonProps {
|
|
6
|
+
target?: string
|
|
7
|
+
to?: To
|
|
8
|
+
toOptions?: NavigateOptions
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const ListItemButtonExTo: React.FC<ListItemButtonExProps> = ({ to, toOptions, onClick, ...props }) => {
|
|
12
|
+
const navigate = useNavigate()
|
|
13
|
+
const localOnClick = (event: MouseEvent<HTMLDivElement>) => {
|
|
14
|
+
onClick?.(event)
|
|
15
|
+
if (to) {
|
|
16
|
+
navigate(to, toOptions)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return <ListItemButton onClick={localOnClick} {...props} />
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const ListItemButtonEx: React.FC<ListItemButtonExProps> = ({ to, ...props }) => {
|
|
24
|
+
if (to) {
|
|
25
|
+
return <ListItemButtonExTo to={to} {...props} />
|
|
26
|
+
} else {
|
|
27
|
+
return <ListItemButton {...props} />
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { styled } from '@mui/material'
|
|
2
|
+
import { WithChildren } from '@xylabs/react-shared'
|
|
3
|
+
|
|
4
|
+
const StyledScrollTableOnSm = styled('div')(({ theme }) => ({
|
|
5
|
+
[theme.breakpoints.down('md')]: {
|
|
6
|
+
overflowX: 'scroll',
|
|
7
|
+
},
|
|
8
|
+
display: 'flex',
|
|
9
|
+
flexGrow: 1,
|
|
10
|
+
}))
|
|
11
|
+
|
|
12
|
+
const ScrollTableOnSm: React.FC<WithChildren> = ({ children }) => <StyledScrollTableOnSm>{children}</StyledScrollTableOnSm>
|
|
13
|
+
|
|
14
|
+
export { ScrollTableOnSm }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Divider, Typography } from '@mui/material'
|
|
2
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react'
|
|
3
|
+
import { BrowserRouter } from 'react-router-dom'
|
|
4
|
+
|
|
5
|
+
import { SectionSpacingRow } from './SectionSpacingRow'
|
|
6
|
+
const StorybookEntry = {
|
|
7
|
+
argTypes: {},
|
|
8
|
+
component: SectionSpacingRow,
|
|
9
|
+
parameters: {
|
|
10
|
+
docs: {
|
|
11
|
+
page: null,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
title: 'shared/SectionSpacingRow',
|
|
15
|
+
} as ComponentMeta<typeof SectionSpacingRow>
|
|
16
|
+
|
|
17
|
+
const Template: ComponentStory<typeof SectionSpacingRow> = (args) => (
|
|
18
|
+
<BrowserRouter>
|
|
19
|
+
<Typography variant="subtitle2">No Spacing</Typography>
|
|
20
|
+
<Typography textAlign="center">Hello World</Typography>
|
|
21
|
+
<Divider />
|
|
22
|
+
<Typography variant="subtitle2">With Spacing</Typography>
|
|
23
|
+
<SectionSpacingRow {...args}>Hello World</SectionSpacingRow>
|
|
24
|
+
</BrowserRouter>
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const Default = Template.bind({})
|
|
28
|
+
Default.args = {}
|
|
29
|
+
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
31
|
+
//@ts-ignore
|
|
32
|
+
|
|
33
|
+
export { Default }
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line import/no-default-export
|
|
36
|
+
export default StorybookEntry
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useTheme } from '@mui/material'
|
|
2
|
+
import { FlexBoxProps, FlexGrowRow } from '@xylabs/react-flexbox'
|
|
3
|
+
|
|
4
|
+
export const SectionSpacingRow: React.FC<FlexBoxProps> = ({ children, sx, ...props }) => {
|
|
5
|
+
const theme = useTheme()
|
|
6
|
+
return (
|
|
7
|
+
<FlexGrowRow
|
|
8
|
+
sx={{
|
|
9
|
+
paddingBottom: { md: theme.spacing(5), xs: theme.spacing(5) },
|
|
10
|
+
paddingTop: { md: theme.spacing(5), xs: theme.spacing(5) },
|
|
11
|
+
...sx,
|
|
12
|
+
}}
|
|
13
|
+
width="100%"
|
|
14
|
+
{...props}
|
|
15
|
+
>
|
|
16
|
+
{children}
|
|
17
|
+
</FlexGrowRow>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SectionSpacingRow'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Menu as MenuIcon } from '@mui/icons-material'
|
|
2
|
+
import { Button, IconButton, Toolbar, Typography } from '@mui/material'
|
|
3
|
+
import { AppBarEx } from '@xylabs/react-appbar'
|
|
4
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
5
|
+
|
|
6
|
+
export const AppBarsExample = () => {
|
|
7
|
+
const contextToolbar = (
|
|
8
|
+
<Toolbar disableGutters>
|
|
9
|
+
<IconButton edge="start" color="inherit" aria-label="menu" sx={{ mr: 2 }}>
|
|
10
|
+
<MenuIcon />
|
|
11
|
+
</IconButton>
|
|
12
|
+
<Typography variant="h6" color="inherit" component="div">
|
|
13
|
+
Photos
|
|
14
|
+
</Typography>
|
|
15
|
+
</Toolbar>
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const systemToolbar = <Button variant="contained">Get Started</Button>
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<FlexCol alignItems="stretch">
|
|
22
|
+
<Typography variant="subtitle1">App Bar</Typography>
|
|
23
|
+
<AppBarEx elevation={0} contextToolbar={contextToolbar} systemToolbar={systemToolbar} />
|
|
24
|
+
</FlexCol>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Button, ButtonTypeMap, Typography } from '@mui/material'
|
|
2
|
+
import { FlexCol, FlexRow } from '@xylabs/react-flexbox'
|
|
3
|
+
|
|
4
|
+
const colors = ['primary', 'secondary'] as ButtonTypeMap['props']['color'][]
|
|
5
|
+
const variants = ['text', 'contained', 'outlined'] as ButtonTypeMap['props']['variant'][]
|
|
6
|
+
|
|
7
|
+
export const ButtonsExample: React.FC = ({ ...props }) => {
|
|
8
|
+
return (
|
|
9
|
+
<FlexCol {...props} alignItems="stretch">
|
|
10
|
+
<Typography variant="subtitle1">Buttons</Typography>
|
|
11
|
+
<Typography variant="subtitle2">Buttons</Typography>
|
|
12
|
+
<FlexRow alignItems="stretch" mb={2}>
|
|
13
|
+
{colors.map((color) => (
|
|
14
|
+
<>
|
|
15
|
+
<Button variant="contained" color={color}>
|
|
16
|
+
{color}
|
|
17
|
+
</Button>
|
|
18
|
+
|
|
19
|
+
</>
|
|
20
|
+
))}
|
|
21
|
+
</FlexRow>
|
|
22
|
+
{variants.map((variant) => (
|
|
23
|
+
<FlexCol key={`btn-${variant}`} alignItems="stretch" mb={2}>
|
|
24
|
+
<Typography variant="subtitle2">
|
|
25
|
+
<span style={{ textTransform: 'capitalize' }}>{variant}</span> Buttons
|
|
26
|
+
</Typography>
|
|
27
|
+
<FlexRow alignItems="stretch">
|
|
28
|
+
<Button variant={variant}>Button</Button>
|
|
29
|
+
<Button variant={variant} disabled>
|
|
30
|
+
Disabled
|
|
31
|
+
</Button>
|
|
32
|
+
|
|
33
|
+
<Button variant={variant} href="#href">
|
|
34
|
+
Link
|
|
35
|
+
</Button>
|
|
36
|
+
</FlexRow>
|
|
37
|
+
</FlexCol>
|
|
38
|
+
))}
|
|
39
|
+
</FlexCol>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Paper, Typography } from '@mui/material'
|
|
2
|
+
import { FlexCol, FlexRow } from '@xylabs/react-flexbox'
|
|
3
|
+
|
|
4
|
+
export const PapersExample: React.FC = ({ ...props }) => {
|
|
5
|
+
return (
|
|
6
|
+
<FlexCol {...props}>
|
|
7
|
+
<Typography variant="subtitle1">Paper</Typography>
|
|
8
|
+
<FlexRow alignItems="stretch">
|
|
9
|
+
{Array.from({ length: 5 }, () => undefined).map((_, index) => (
|
|
10
|
+
<FlexCol key={`paper-${index}`} marginRight={2}>
|
|
11
|
+
<Paper key={`paper-${index}`} elevation={index * 2} color="secondary">
|
|
12
|
+
<Typography margin={1}>Elevation-{index * 3}</Typography>
|
|
13
|
+
</Paper>
|
|
14
|
+
</FlexCol>
|
|
15
|
+
))}
|
|
16
|
+
</FlexRow>
|
|
17
|
+
</FlexCol>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Typography } from '@mui/material'
|
|
2
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
+
|
|
4
|
+
import { AppBarsExample } from './AppBars.example'
|
|
5
|
+
import { ButtonsExample } from './Buttons.example'
|
|
6
|
+
import { PapersExample } from './Papers.example'
|
|
7
|
+
import { TextsExample } from './Texts.example'
|
|
8
|
+
|
|
9
|
+
export const StyleGuideExample: React.FC = () => {
|
|
10
|
+
return (
|
|
11
|
+
<FlexCol alignItems="stretch">
|
|
12
|
+
<Typography variant="h5">XYO Network Style Guide</Typography>
|
|
13
|
+
<AppBarsExample />
|
|
14
|
+
<ButtonsExample />
|
|
15
|
+
<PapersExample />
|
|
16
|
+
<TextsExample />
|
|
17
|
+
</FlexCol>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react'
|
|
2
|
+
|
|
3
|
+
import { StyleGuideExample } from './StyleGuide.example'
|
|
4
|
+
|
|
5
|
+
const StorybookEntry = {
|
|
6
|
+
argTypes: {},
|
|
7
|
+
component: StyleGuideExample,
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
page: null,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
title: 'shared/StyleGuide',
|
|
14
|
+
} as ComponentMeta<typeof StyleGuideExample>
|
|
15
|
+
|
|
16
|
+
const Template: ComponentStory<typeof StyleGuideExample> = () => <StyleGuideExample />
|
|
17
|
+
|
|
18
|
+
const Default = Template.bind({})
|
|
19
|
+
Default.args = {}
|
|
20
|
+
Default.decorators = []
|
|
21
|
+
|
|
22
|
+
export { Default }
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line import/no-default-export
|
|
25
|
+
export default StorybookEntry
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Typography, TypographyVariant } from '@mui/material'
|
|
2
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
+
|
|
4
|
+
export const TextsExample = () => {
|
|
5
|
+
const variantList: TypographyVariant[] = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'subtitle1', 'subtitle2', 'body1', 'body2', 'button', 'caption', 'overline']
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<FlexCol>
|
|
9
|
+
{variantList.map((variant) => (
|
|
10
|
+
<Typography key={variant} variant={variant}>
|
|
11
|
+
{variant} - XYO Network
|
|
12
|
+
</Typography>
|
|
13
|
+
))}
|
|
14
|
+
</FlexCol>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EllipsisTableCell, EllipsisTableCellProps } from './EllipsisTableCell'
|
|
2
|
+
|
|
3
|
+
export interface AddressTableCellProps extends EllipsisTableCellProps {
|
|
4
|
+
archive?: string
|
|
5
|
+
exploreDomain?: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const AddressTableCell: React.FC<AddressTableCellProps> = ({ value, archive, exploreDomain, ...props }) => {
|
|
9
|
+
const href = exploreDomain && archive ? `${exploreDomain}/archive/${archive}/address/${value}` : undefined
|
|
10
|
+
const to = exploreDomain === undefined && archive ? `/archive/${archive}/address/${value}` : undefined
|
|
11
|
+
|
|
12
|
+
return <EllipsisTableCell value={value} href={href} to={to} {...props} />
|
|
13
|
+
}
|