@ossy/connected-components 0.0.1-alpha → 0.0.1
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/.storybook/main.js +19 -0
- package/.storybook/preview.js +13 -0
- package/build/cjs/index.js +656 -0
- package/build/esm/index.js +638 -0
- package/package.json +50 -14
- package/rollup.config.js +35 -0
- package/src/app/App.jsx +29 -0
- package/src/app/App.stories.jsx +36 -0
- package/src/app/AppSettings.jsx +22 -0
- package/src/app/index.js +3 -0
- package/src/app/useAnalytics.jsx +18 -0
- package/src/index.js +11 -0
- package/src/layout/Layout.jsx +25 -0
- package/src/layout/Layout.stories.jsx +16 -0
- package/src/layout/index.js +1 -0
- package/src/ossybot/Ossybot.jsx +67 -0
- package/src/ossybot/Ossybot.stories.jsx +26 -0
- package/src/ossybot/index.js +1 -0
- package/src/page/Page.jsx +33 -0
- package/src/page/Page.stories.jsx +17 -0
- package/src/page/index.js +1 -0
- package/src/page-data-loader/PageDataLoader.jsx +90 -0
- package/src/page-data-loader/PageDataLoader.stories.jsx +16 -0
- package/src/page-data-loader/index.js +1 -0
- package/src/pages-module/PagesModule.jsx +8 -0
- package/src/pages-module/PagesModule.stories.jsx +17 -0
- package/src/pages-module/index.js +1 -0
- package/src/resume/Resume.jsx +13 -0
- package/src/resume/Resume.stories.jsx +23 -0
- package/src/resume/Resume.template.js +80 -0
- package/src/resume/index.js +3 -0
- package/src/resume/useResume.js +112 -0
- package/src/section/Section.jsx +93 -0
- package/src/section/Section.stories.jsx +17 -0
- package/src/section/index.js +1 -0
- package/src/stories/Button.jsx +39 -0
- package/src/stories/Button.stories.js +49 -0
- package/src/stories/Configure.mdx +364 -0
- package/src/stories/Header.jsx +56 -0
- package/src/stories/Header.stories.js +29 -0
- package/src/stories/Page.jsx +69 -0
- package/src/stories/Page.stories.js +28 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +1 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +1 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +1 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +1 -0
- package/src/stories/assets/youtube.svg +1 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +68 -0
- package/src/theme-editor/ThemeEditor.jsx +132 -0
- package/src/theme-editor/ThemeEditor.stories.jsx +16 -0
- package/src/theme-editor/index.js +1 -0
- package/src/theme-provider/ThemeProvider.jsx +9 -0
- package/src/theme-provider/ThemeProvider.stories.jsx +16 -0
- package/src/theme-provider/index.js +1 -0
- package/src/use-active-page-location/index.js +1 -0
- package/src/use-active-page-location/useActivePageLocation.js +54 -0
- package/index.cjs.js +0 -1
- package/index.esm.js +0 -1
package/package.json
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/connected-components",
|
|
3
|
-
"
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"repository": "github:ossy-se/packages",
|
|
4
5
|
"description": "Ossy's CMS Connected React component library",
|
|
5
|
-
"
|
|
6
|
-
"source": "index.js",
|
|
7
|
-
"main": "index.
|
|
8
|
-
"module": "index.
|
|
6
|
+
"type": "module",
|
|
7
|
+
"source": "src/index.js",
|
|
8
|
+
"main": "build/cjs/index.js",
|
|
9
|
+
"module": "build/esm/index.js",
|
|
9
10
|
"author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "rollup -c rollup.config.js",
|
|
13
|
+
"test": "",
|
|
14
|
+
"storybook": "storybook dev -p 6006",
|
|
15
|
+
"build-storybook": "storybook build"
|
|
16
|
+
},
|
|
10
17
|
"browserslist": {
|
|
11
18
|
"production": [
|
|
12
19
|
">0.2%",
|
|
@@ -19,17 +26,46 @@
|
|
|
19
26
|
"last 1 safari version"
|
|
20
27
|
]
|
|
21
28
|
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@babel/cli": "^7.21.5",
|
|
31
|
+
"@babel/core": "^7.14.5",
|
|
32
|
+
"@babel/eslint-parser": "^7.15.8",
|
|
33
|
+
"@babel/preset-env": "^7.21.5",
|
|
34
|
+
"@babel/preset-react": "^7.24.1",
|
|
35
|
+
"@rollup/plugin-babel": "6.0.4",
|
|
36
|
+
"@rollup/plugin-commonjs": "^25.0.5",
|
|
37
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
38
|
+
"@rollup/plugin-terser": "0.4.4",
|
|
39
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
40
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
41
|
+
"@storybook/addon-interactions": "^8.6.12",
|
|
42
|
+
"@storybook/addon-onboarding": "^8.6.12",
|
|
43
|
+
"@storybook/blocks": "^8.6.12",
|
|
44
|
+
"@storybook/react": "^8.6.12",
|
|
45
|
+
"@storybook/react-vite": "^8.6.12",
|
|
46
|
+
"@storybook/test": "^8.6.12",
|
|
47
|
+
"@types/react": "18.2.79",
|
|
48
|
+
"babel-loader": "^9.1.3",
|
|
49
|
+
"prop-types": "^15.8.1",
|
|
50
|
+
"rollup": "^4.24.3",
|
|
51
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
52
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
53
|
+
"rollup-plugin-postcss-modules": "^2.1.1",
|
|
54
|
+
"rollup-plugin-preserve-directives": "^0.4.0",
|
|
55
|
+
"storybook": "^8.6.12",
|
|
56
|
+
"tslib": "^2.6.2"
|
|
57
|
+
},
|
|
22
58
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"moment": "^2.29.4"
|
|
25
|
-
"react-ga4": "^2.1.0"
|
|
59
|
+
"@ossy/themes": "^0.0.1",
|
|
60
|
+
"moment": "^2.29.4"
|
|
26
61
|
},
|
|
27
62
|
"peerDependencies": {
|
|
28
|
-
"@ossy/design-system": "^0.0.1",
|
|
29
|
-
"react": "^
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
63
|
+
"@ossy/design-system-extras": "^0.0.1",
|
|
64
|
+
"@ossy/sdk-react": "^0.0.1",
|
|
65
|
+
"@ossy/design-system": "^0",
|
|
66
|
+
"@ossy/router": "^0.0.1",
|
|
67
|
+
"@ossy/router-react": "^0.0.1",
|
|
68
|
+
"@ossy/sdk": "^0.0.1",
|
|
69
|
+
"react": "^19"
|
|
34
70
|
}
|
|
35
71
|
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import babel from '@rollup/plugin-babel'
|
|
2
|
+
import { nodeResolve as resolveDependencies } from '@rollup/plugin-node-resolve'
|
|
3
|
+
import resolveCommonJsDependencies from '@rollup/plugin-commonjs'
|
|
4
|
+
import removeOwnPeerDependencies from 'rollup-plugin-peer-deps-external'
|
|
5
|
+
import minifyJS from '@rollup/plugin-terser'
|
|
6
|
+
// import typescript from '@rollup/plugin-typescript'
|
|
7
|
+
import preserveDirectives from "rollup-plugin-preserve-directives"
|
|
8
|
+
|
|
9
|
+
export default [
|
|
10
|
+
{
|
|
11
|
+
input: 'src/index.js',
|
|
12
|
+
output: [
|
|
13
|
+
{
|
|
14
|
+
dir: 'build/cjs',
|
|
15
|
+
format: 'cjs'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
dir: 'build/esm',
|
|
19
|
+
format: 'esm'
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
plugins: [
|
|
23
|
+
removeOwnPeerDependencies(),
|
|
24
|
+
resolveCommonJsDependencies(),
|
|
25
|
+
resolveDependencies(),
|
|
26
|
+
babel({
|
|
27
|
+
exclude: ['**/node_modules/**/*'],
|
|
28
|
+
presets: ['@babel/preset-react']
|
|
29
|
+
}),
|
|
30
|
+
preserveDirectives(),
|
|
31
|
+
// minifyJS(),
|
|
32
|
+
// typescript({ tsconfig: "./tsconfig.json" }),
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
]
|
package/src/app/App.jsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { createContext } from 'react'
|
|
2
|
+
import { SDK } from '@ossy/sdk'
|
|
3
|
+
import { WorkspaceProvider } from '@ossy/sdk-react'
|
|
4
|
+
import { Theme } from '@ossy/design-system'
|
|
5
|
+
import { ThemeEditor } from '../theme-editor/ThemeEditor.jsx'
|
|
6
|
+
import { defaultAppSettings } from './AppSettings.jsx'
|
|
7
|
+
import { Router } from '@ossy/router-react'
|
|
8
|
+
|
|
9
|
+
export const AppContext = createContext(defaultAppSettings())
|
|
10
|
+
|
|
11
|
+
export const App = (_appSettings) => {
|
|
12
|
+
const appSettings = { ...defaultAppSettings(), ..._appSettings }
|
|
13
|
+
|
|
14
|
+
const sdk = SDK.of({
|
|
15
|
+
apiUrl: appSettings.apiUrl,
|
|
16
|
+
workspaceId: appSettings.workspaceId
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<AppContext.Provider value={appSettings}>
|
|
21
|
+
<Theme theme={appSettings.theme} themes={appSettings.themes}>
|
|
22
|
+
<WorkspaceProvider sdk={sdk}>
|
|
23
|
+
<Router {..._appSettings} />
|
|
24
|
+
{ appSettings.devMode && <ThemeEditor />}
|
|
25
|
+
</WorkspaceProvider>
|
|
26
|
+
</Theme>
|
|
27
|
+
</AppContext.Provider>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { App } from './App.jsx'
|
|
3
|
+
import { Ossy } from '@ossy/themes'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'App',
|
|
7
|
+
component: App,
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Story = props => <></>
|
|
12
|
+
|
|
13
|
+
export const Default = Story.bind({})
|
|
14
|
+
Default.args = {
|
|
15
|
+
workspaceId: '',
|
|
16
|
+
theme: Ossy,
|
|
17
|
+
routes: [
|
|
18
|
+
{
|
|
19
|
+
path: '/',
|
|
20
|
+
element: (
|
|
21
|
+
<>
|
|
22
|
+
<a href="/test">Click me</a>
|
|
23
|
+
<a href="test">me me me</a>
|
|
24
|
+
<a href="localhost">No click me</a>
|
|
25
|
+
<a href="https://www.google.com" target="_blank">External with target</a>
|
|
26
|
+
<a href="http://www.google.com">External http link!</a>
|
|
27
|
+
<a href="https://www.google.com">External https link!</a>
|
|
28
|
+
</>
|
|
29
|
+
)
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
path: '/test',
|
|
33
|
+
element: <>test </>
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import { useContext } from 'react'
|
|
3
|
+
import { AppContext } from './App.jsx'
|
|
4
|
+
|
|
5
|
+
export const useAppSettings = () => useContext(AppContext)
|
|
6
|
+
|
|
7
|
+
export function defaultAppSettings() {
|
|
8
|
+
return {
|
|
9
|
+
workspaceId: undefined,
|
|
10
|
+
defaultLanguage: undefined,
|
|
11
|
+
supportedLanguages: [],
|
|
12
|
+
theme: undefined,
|
|
13
|
+
themes: undefined,
|
|
14
|
+
routes: [],
|
|
15
|
+
initialEntries: [],
|
|
16
|
+
initialIndex: 0,
|
|
17
|
+
router: 'browser',
|
|
18
|
+
gaId: undefined,
|
|
19
|
+
apiUrl: undefined,
|
|
20
|
+
devMode: false
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/app/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// import { useEffect } from 'react'
|
|
2
|
+
// import Analytics from 'react-ga4'
|
|
3
|
+
// import { useAppSettings } from './AppSettings.jsx'
|
|
4
|
+
|
|
5
|
+
// function useAnalytics(url) {
|
|
6
|
+
// const { gaId } = useAppSettings()
|
|
7
|
+
|
|
8
|
+
// useEffect(() => {
|
|
9
|
+
// if (!gaId) return
|
|
10
|
+
// Analytics.initialize(gaId)
|
|
11
|
+
// }, [gaId])
|
|
12
|
+
|
|
13
|
+
// useEffect(() => {
|
|
14
|
+
// if (!url) return
|
|
15
|
+
// Analytics.send({ hitType: 'pageview', page: url, path: url })
|
|
16
|
+
// }, [url])
|
|
17
|
+
|
|
18
|
+
// }
|
package/src/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './app/index.js'
|
|
2
|
+
export * from './layout/index.js'
|
|
3
|
+
export * from './ossybot/index.js'
|
|
4
|
+
export * from './page/index.js'
|
|
5
|
+
export * from './page-data-loader/index.js'
|
|
6
|
+
export * from './pages-module/index.js'
|
|
7
|
+
export * from './resume/index.js'
|
|
8
|
+
// export * from './section/index.js'
|
|
9
|
+
export * from './theme-editor/index.js'
|
|
10
|
+
export * from './theme-provider/index.js'
|
|
11
|
+
export * from './use-active-page-location/index.js'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useMemo, useEffect, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
useResource,
|
|
4
|
+
AsyncStatus
|
|
5
|
+
} from '@ossy/sdk-react'
|
|
6
|
+
|
|
7
|
+
export const Layout = ({
|
|
8
|
+
layoutId,
|
|
9
|
+
...props
|
|
10
|
+
}) => {
|
|
11
|
+
const { status, resource } = useResource(layoutId)
|
|
12
|
+
|
|
13
|
+
const layoutStyles = useMemo(() => !resource.data
|
|
14
|
+
? {}
|
|
15
|
+
: ({
|
|
16
|
+
display: 'grid',
|
|
17
|
+
gridTemplateRows: resource.data.rows,
|
|
18
|
+
gridTemplateColumns: resource.data.columns,
|
|
19
|
+
gridTemplateAreas: resource.data.areas
|
|
20
|
+
}), [resource])
|
|
21
|
+
|
|
22
|
+
return status === AsyncStatus.Success
|
|
23
|
+
? (<div {...props} style={layoutStyles} />)
|
|
24
|
+
: <></>
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Layout } from './Layout.jsx'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Connected components/Layout',
|
|
6
|
+
component: Layout,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'fullscreen',
|
|
9
|
+
workspaceId: '36zDqF0TKZZ5KkJdyg7NH'
|
|
10
|
+
},
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Story = props => <Layout {...props}/>
|
|
14
|
+
|
|
15
|
+
export const Default = Story.bind({})
|
|
16
|
+
Default.args = { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Layout.jsx'
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from '@ossy/design-system';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// https://twitter.com/jh3yy/status/1762979019446698310
|
|
6
|
+
// button:hover span:after {
|
|
7
|
+
// animation: flip 0.2s calc(var(--i) * 0.05s);
|
|
8
|
+
// }
|
|
9
|
+
// @keyframes flip {
|
|
10
|
+
// 20% { content: '_'; }
|
|
11
|
+
// 40% { content: var(--c1); }
|
|
12
|
+
// 60% { content: var(--c2); }
|
|
13
|
+
// }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// <button>
|
|
17
|
+
// <span style="--i: 0; --c1: 'x'; --c2: '$'; --c3: '≈';">C</span>
|
|
18
|
+
// <span style="--i: 1; --c1: 'ç'; --c2: '&'; --c3: 'π';">l</span>
|
|
19
|
+
// <!-- Other characters -->
|
|
20
|
+
// <span class="sr-only">Click Me</span>
|
|
21
|
+
// </button>
|
|
22
|
+
|
|
23
|
+
export const Ossybot = ({
|
|
24
|
+
style = {},
|
|
25
|
+
surface = "cta",
|
|
26
|
+
icon,
|
|
27
|
+
...props
|
|
28
|
+
}) => {
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<style href="@ossy/design-system/ossybot" precedence="high">
|
|
32
|
+
{`
|
|
33
|
+
@keyframes flip {
|
|
34
|
+
0% {
|
|
35
|
+
content: '_';
|
|
36
|
+
}
|
|
37
|
+
60% {
|
|
38
|
+
content: var(--c1);
|
|
39
|
+
}
|
|
40
|
+
100% {
|
|
41
|
+
content: var(--c2);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Define the animation */
|
|
46
|
+
[data-animation="flip"] {
|
|
47
|
+
animation: flip 0.2s calc(var(--i) * 0.05s) infinite;
|
|
48
|
+
}
|
|
49
|
+
`}
|
|
50
|
+
</style>
|
|
51
|
+
<Button
|
|
52
|
+
data-animation="flip"
|
|
53
|
+
prefix={{ name: icon, size: 'm'}}
|
|
54
|
+
variant={surface}
|
|
55
|
+
{...props}
|
|
56
|
+
style={{
|
|
57
|
+
'--size': '64px',
|
|
58
|
+
width: 'var(--size)',
|
|
59
|
+
height: 'var(--size)',
|
|
60
|
+
padding: 'var(--space-m)',
|
|
61
|
+
borderRadius: '999px',
|
|
62
|
+
...style,
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
</>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Ossybot } from './Ossybot.jsx'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Connected components/Ossybot',
|
|
6
|
+
component: Ossybot,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
workspaceId: '36zDqF0TKZZ5KkJdyg7NH',
|
|
10
|
+
renderInsideApp: true
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Story = props => <Ossybot {...props} />
|
|
15
|
+
|
|
16
|
+
export const Default = Story.bind({})
|
|
17
|
+
Default.args = { }
|
|
18
|
+
|
|
19
|
+
export const Add = Story.bind({})
|
|
20
|
+
Add.args = { icon: 'math-plus'}
|
|
21
|
+
|
|
22
|
+
export const Custom = Story.bind({})
|
|
23
|
+
Custom.args = { icon: 'loadbar-sound' }
|
|
24
|
+
|
|
25
|
+
export const Ascii = Story.bind({})
|
|
26
|
+
Ascii.args = { label: '(≧︿≦)' }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Ossybot.jsx'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useResources } from '@ossy/sdk-react'
|
|
2
|
+
import { useActivePageLocation } from '../use-active-page-location'
|
|
3
|
+
import { Layout } from '../layout'
|
|
4
|
+
import { Section } from '../section'
|
|
5
|
+
|
|
6
|
+
export const Page = () => {
|
|
7
|
+
const activePageLocation = useActivePageLocation()
|
|
8
|
+
const { resources: folder } = useResources(`/pages${activePageLocation}`)
|
|
9
|
+
const pageSettings = folder.find(entry => entry.name === 'Page settings')
|
|
10
|
+
const sections = folder.filter(entry => entry.name.endsWith('Section'))
|
|
11
|
+
|
|
12
|
+
const title = pageSettings?.data?.title
|
|
13
|
+
const layout = pageSettings?.data?.layout
|
|
14
|
+
|
|
15
|
+
if (!pageSettings) return
|
|
16
|
+
|
|
17
|
+
setSections(sections)
|
|
18
|
+
|
|
19
|
+
return !!pageSettings && (
|
|
20
|
+
(
|
|
21
|
+
<Layout layoutId={pageSettings.layout}>
|
|
22
|
+
{ sections.map(section => (
|
|
23
|
+
<Section
|
|
24
|
+
key={section.data.slotName}
|
|
25
|
+
slotName={section.data.slotName}
|
|
26
|
+
componentId={section.data.componentId}
|
|
27
|
+
componentProps={section.data.componentProps}
|
|
28
|
+
/>
|
|
29
|
+
))}
|
|
30
|
+
</Layout>
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Page } from './Page.jsx'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Connected components/Page',
|
|
6
|
+
component: Page,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'fullscreen',
|
|
9
|
+
workspaceId: '36zDqF0TKZZ5KkJdyg7NH',
|
|
10
|
+
renderInsideApp: true
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Story = props => <Page {...props}/>
|
|
15
|
+
|
|
16
|
+
export const Default = Story.bind({})
|
|
17
|
+
Default.args = { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Page.jsx'
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import { useResources, AsyncStatus } from '@ossy/sdk-react'
|
|
3
|
+
import { Switch, useDocumentTitle } from '@ossy/design-system'
|
|
4
|
+
import { useActivePageLocation } from '../use-active-page-location'
|
|
5
|
+
|
|
6
|
+
const getLoadingPageSettings = () => ({
|
|
7
|
+
title: 'Loading...'
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const getErrorPageSettings = () => ({
|
|
11
|
+
title: 'Error'
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const getNotFoundPageSettings = () => ({
|
|
15
|
+
title: 'Not found'
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const getDefaultPageSettings = () => ({
|
|
19
|
+
title: undefined
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const PageStatus = {
|
|
23
|
+
Loading: 'Loading',
|
|
24
|
+
Error: 'Error',
|
|
25
|
+
Success: 'Success',
|
|
26
|
+
NotFound: 'NotFound'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const PageDataLoader = ({ children }) => {
|
|
30
|
+
const activePageLocation = useActivePageLocation()
|
|
31
|
+
const { status, resources: folder } = useResources(`/pages${activePageLocation}`)
|
|
32
|
+
const [pageStatus, setPageStatus] = useState(PageStatus.Loading)
|
|
33
|
+
const [pageSettings, setPageSettings] = useState(getLoadingPageSettings())
|
|
34
|
+
|
|
35
|
+
useDocumentTitle(pageSettings.title)
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if ([AsyncStatus.NotInitialized, AsyncStatus.Loading].includes(status)) {
|
|
39
|
+
setPageSettings(getLoadingPageSettings())
|
|
40
|
+
return setPageStatus(PageStatus.Loading)
|
|
41
|
+
} else if ([AsyncStatus.Error].includes(status)) {
|
|
42
|
+
setPageSettings(getErrorPageSettings())
|
|
43
|
+
return setPageStatus(PageStatus.Error)
|
|
44
|
+
} else if ([AsyncStatus.Success].includes(status)) {
|
|
45
|
+
const pageSettings = folder.find(entry => entry.name === 'Page settings')
|
|
46
|
+
|
|
47
|
+
if (!pageSettings) {
|
|
48
|
+
setPageSettings(getNotFoundPageSettings())
|
|
49
|
+
return setPageStatus(PageStatus.NotFound)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setPageSettings({
|
|
53
|
+
title: pageSettings.data.title,
|
|
54
|
+
layout: pageSettings.data.layout,
|
|
55
|
+
slots: pageSettings.data.slots
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
setPageStatus(PageStatus.Success)
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return () => {
|
|
63
|
+
setPageSettings(getDefaultPageSettings())
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}, [status, folder])
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Switch on={pageStatus}>
|
|
70
|
+
|
|
71
|
+
<Switch.Case match={[PageStatus.NotFound]}>
|
|
72
|
+
Page not found
|
|
73
|
+
</Switch.Case>
|
|
74
|
+
|
|
75
|
+
<Switch.Case match={[PageStatus.Error]}>
|
|
76
|
+
Couldn't load the page
|
|
77
|
+
</Switch.Case>
|
|
78
|
+
|
|
79
|
+
<Switch.Case match={[PageStatus.Loading]}>
|
|
80
|
+
Page Loading
|
|
81
|
+
</Switch.Case>
|
|
82
|
+
|
|
83
|
+
<Switch.Case match={[PageStatus.Success]}>
|
|
84
|
+
{children}
|
|
85
|
+
</Switch.Case>
|
|
86
|
+
|
|
87
|
+
</Switch>
|
|
88
|
+
|
|
89
|
+
)
|
|
90
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { PageDataLoader } from './PageDataLoader.jsx'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Connected components/PageDataLoader',
|
|
6
|
+
component: PageDataLoader,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'fullscreen',
|
|
9
|
+
workspaceId: '36zDqF0TKZZ5KkJdyg7NH'
|
|
10
|
+
},
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Story = props => <PageDataLoader {...props}/>
|
|
14
|
+
|
|
15
|
+
export const Default = Story.bind({})
|
|
16
|
+
Default.args = { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PageDataLoader.jsx'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { PagesModule } from './PagesModule.jsx'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Connected components/PagesModule',
|
|
6
|
+
component: PagesModule,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'fullscreen',
|
|
9
|
+
workspaceId: '36zDqF0TKZZ5KkJdyg7NH',
|
|
10
|
+
renderInsideApp: true
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Story = props => <PagesModule {...props}/>
|
|
15
|
+
|
|
16
|
+
export const Default = Story.bind({})
|
|
17
|
+
Default.args = { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PagesModule.jsx'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Resume as _Resume } from '@ossy/design-system-extras'
|
|
3
|
+
import { useResume } from './useResume.js'
|
|
4
|
+
|
|
5
|
+
export const Resume = ({
|
|
6
|
+
resumeId,
|
|
7
|
+
...props
|
|
8
|
+
}) => {
|
|
9
|
+
const resumeProps = useResume(resumeId)
|
|
10
|
+
return resumeProps.status === 'Success'
|
|
11
|
+
? <_Resume {...resumeProps} profileCardVariant="resume" {...props}/>
|
|
12
|
+
: <></>
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { WorkspaceProvider } from '@ossy/sdk-react'
|
|
3
|
+
import { Resume } from './Resume.jsx'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Resume',
|
|
7
|
+
component: Resume,
|
|
8
|
+
args: { workspaceId: '36zDqF0TKZZ5KkJdyg7NH' },
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'fullscreen',
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Story = props => (
|
|
15
|
+
<WorkspaceProvider workspaceId={props?.workspaceId}>
|
|
16
|
+
<Resume {...props}/>
|
|
17
|
+
</WorkspaceProvider>
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
export const Default = Story.bind({})
|
|
21
|
+
Default.args = {
|
|
22
|
+
resumeId: ''
|
|
23
|
+
}
|