@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
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export const ResumeTemplates = [
|
|
2
|
+
{
|
|
3
|
+
name: 'Resume Experience',
|
|
4
|
+
id: 'resume-experience',
|
|
5
|
+
fields: [
|
|
6
|
+
{
|
|
7
|
+
name: 'Title',
|
|
8
|
+
type: 'text'
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: 'Sub Title',
|
|
12
|
+
type: 'text'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'Date',
|
|
16
|
+
type: 'text'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'Description',
|
|
20
|
+
type: 'textarea'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'Type of experience',
|
|
24
|
+
type: 'select',
|
|
25
|
+
options: [
|
|
26
|
+
'Work',
|
|
27
|
+
'Education',
|
|
28
|
+
'Other',
|
|
29
|
+
'Project'
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'Website',
|
|
34
|
+
type: 'text'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'Tags',
|
|
38
|
+
type: 'text'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'GitHub',
|
|
42
|
+
type: 'text'
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'Resume Summary',
|
|
48
|
+
id: 'resume-summary',
|
|
49
|
+
fields: [
|
|
50
|
+
{
|
|
51
|
+
name: 'Name',
|
|
52
|
+
type: 'text'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'Role',
|
|
56
|
+
type: 'text'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'Summary',
|
|
60
|
+
type: 'textarea'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'Mobile',
|
|
64
|
+
type: 'text'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'Email',
|
|
68
|
+
type: 'text'
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'Website',
|
|
72
|
+
type: 'text'
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'Tags',
|
|
76
|
+
type: 'textarea'
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
]
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { useResources, useResource } from '@ossy/sdk-react'
|
|
3
|
+
|
|
4
|
+
const translations = {
|
|
5
|
+
sv: {
|
|
6
|
+
tags: 'Erfarenhet med',
|
|
7
|
+
work: 'Arbete',
|
|
8
|
+
projects: 'Projekt',
|
|
9
|
+
education: 'Utbildning',
|
|
10
|
+
other: 'Övrigt',
|
|
11
|
+
download: 'Ladda ner',
|
|
12
|
+
all: 'Alla'
|
|
13
|
+
},
|
|
14
|
+
en: {
|
|
15
|
+
tags: 'Experience with',
|
|
16
|
+
work: 'Work',
|
|
17
|
+
projects: 'Projects',
|
|
18
|
+
education: 'Education',
|
|
19
|
+
other: 'Other',
|
|
20
|
+
download: 'Download',
|
|
21
|
+
all: 'All'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const getProfile = resources => {
|
|
26
|
+
const image = resources?.find(x => x.type.startsWith('image/'))
|
|
27
|
+
const { id, content } = resources?.find(x => x.type === 'resume-summary') || { content: {} }
|
|
28
|
+
|
|
29
|
+
const profile = {
|
|
30
|
+
id: id,
|
|
31
|
+
name: content.Name || content['Consultant Name'],
|
|
32
|
+
role: content.Role,
|
|
33
|
+
image: image?.content?.src,
|
|
34
|
+
summary: content.Summary,
|
|
35
|
+
tags: content?.Tags?.split(','),
|
|
36
|
+
links: [],
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
content.Mobile && profile.links.push({
|
|
40
|
+
icon: 'phone',
|
|
41
|
+
label: content.Mobile,
|
|
42
|
+
href: `tel:${content.Mobile}`,
|
|
43
|
+
target: '_blank'
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
content.Email && profile.links.push({
|
|
47
|
+
icon: 'mail',
|
|
48
|
+
label: content.Email,
|
|
49
|
+
href: `mailto:${content.Email}`
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
content.Website && profile.links.push({
|
|
53
|
+
icon: 'globe-alt',
|
|
54
|
+
label: content.Website.replace('https://', '').replace('http://', ''),
|
|
55
|
+
href: content.Website,
|
|
56
|
+
target: '_blank'
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
return profile
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const getExperiences = resources => resources
|
|
64
|
+
.filter(x => x.type === 'resume-experience')
|
|
65
|
+
.map(resource => ({
|
|
66
|
+
id: resource.id,
|
|
67
|
+
title: resource.content.Title,
|
|
68
|
+
subTitle: resource.content['Sub Title'],
|
|
69
|
+
date: resource.content.Date,
|
|
70
|
+
description: resource.content.Description,
|
|
71
|
+
website: resource.content.Website,
|
|
72
|
+
github: resource.content.GitHub,
|
|
73
|
+
tags: resource.content?.Tags?.split(',')?.map(x => x.trim()).filter(x => !!x),
|
|
74
|
+
typeOfExperience: resource.content['Type of experience']
|
|
75
|
+
}))
|
|
76
|
+
|
|
77
|
+
export const useMergeAsyncStatus = (...statuses) => {
|
|
78
|
+
return statuses.reduce((acc, status) => {
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
if (acc === 'Loading' || status === 'Loading' || status === 'NotInitialized') {
|
|
82
|
+
return 'Loading'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (acc === 'Error' || status === 'Error') {
|
|
86
|
+
return 'Error'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (acc === 'AuthenticationError' || status === 'AuthenticationError') {
|
|
90
|
+
return 'AuthenticationError'
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return 'Success'
|
|
94
|
+
|
|
95
|
+
}, 'NotInitialized')
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const location = '/@ossy/resumes/'
|
|
99
|
+
|
|
100
|
+
export const useResume = resumeId => {
|
|
101
|
+
const resumeDirectory = useResource(resumeId)
|
|
102
|
+
const resumeResources = useResources(resumeDirectory?.resource?.name ? (location + resumeDirectory?.resource?.name + '/') : undefined)
|
|
103
|
+
|
|
104
|
+
const status = useMergeAsyncStatus(resumeDirectory.status, resumeResources.status)
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
status,
|
|
108
|
+
translations: translations.en,
|
|
109
|
+
profile: getProfile(resumeResources.resources),
|
|
110
|
+
experiences: getExperiences(resumeResources.resources),
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useMemo, useEffect, useState } from 'react'
|
|
2
|
+
import { useQuery, AsyncStatus } from '@ossy/sdk-react'
|
|
3
|
+
// import { useParams } from '../use-params'
|
|
4
|
+
// import { AppHeader } from './AppHeader'
|
|
5
|
+
// import { AppFooter } from './AppFooter'
|
|
6
|
+
// import { AccentBorder } from './AccentBorder'
|
|
7
|
+
// import { ContactUsContent } from './ContactUsContent'
|
|
8
|
+
// import { ResourcesContent } from './ResourcesContent'
|
|
9
|
+
// import { ResourceContent } from './ResourceContent'
|
|
10
|
+
// import { HomeHero } from './HomeHero'
|
|
11
|
+
// import { HomeContent } from './HomeContent'
|
|
12
|
+
// import { ConsultantsContent } from './ConsultantsContent'
|
|
13
|
+
// import { CommandBar } from './CommandBar'
|
|
14
|
+
// import { ConsultantPage } from './ConsultantPage'
|
|
15
|
+
|
|
16
|
+
const components = {
|
|
17
|
+
// AppHeader: AppHeader,
|
|
18
|
+
// AppFooter: AppFooter,
|
|
19
|
+
// CommandBar: CommandBar,
|
|
20
|
+
// AccentBorder: AccentBorder,
|
|
21
|
+
// HomeHero: HomeHero,
|
|
22
|
+
// HomeContent: HomeContent,
|
|
23
|
+
// ContactUsContent: ContactUsContent,
|
|
24
|
+
// ConsultantsContent: ConsultantsContent,
|
|
25
|
+
// ResourcesContent: ResourcesContent,
|
|
26
|
+
// ResourceContent: ResourceContent,
|
|
27
|
+
// ConsultantContent: ConsultantPage
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const Section = ({
|
|
31
|
+
slotName,
|
|
32
|
+
componentId,
|
|
33
|
+
componentProps: pageSpecificProps = ''
|
|
34
|
+
}) => {
|
|
35
|
+
const params = useParams()
|
|
36
|
+
const Component = components[componentId] || (() => <>No component found</>)
|
|
37
|
+
const [componentProps, setComponentProps] = useState({})
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
status: defaultPropsStatus,
|
|
41
|
+
resources: defaultPropsQuery
|
|
42
|
+
} = useQuery({
|
|
43
|
+
location: `/design-system/${componentId}/`,
|
|
44
|
+
name: 'default',
|
|
45
|
+
type: '7Bb2zDh2EK65rV_0XHo_W'
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const {
|
|
49
|
+
status: languageSpecificPropsStatus,
|
|
50
|
+
resources: languageSpecificPropsQuery
|
|
51
|
+
} = useQuery({
|
|
52
|
+
location: `/design-system/${componentId}/`,
|
|
53
|
+
name: params.marketCode,
|
|
54
|
+
type: '7Bb2zDh2EK65rV_0XHo_W'
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const loaded = useMemo(() => (
|
|
58
|
+
[defaultPropsStatus, languageSpecificPropsStatus].every(status => status === AsyncStatus.Success)
|
|
59
|
+
), [defaultPropsStatus, languageSpecificPropsStatus])
|
|
60
|
+
|
|
61
|
+
const slotStyles = useMemo(() => ({
|
|
62
|
+
gridArea: slotName
|
|
63
|
+
}), [slotName])
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
|
|
67
|
+
let props = {}
|
|
68
|
+
|
|
69
|
+
if (!!defaultPropsQuery.length && !!defaultPropsQuery[0].data.props) {
|
|
70
|
+
const parsedProps = JSON.parse(defaultPropsQuery[0].data.props)
|
|
71
|
+
props = { ...props, ...parsedProps }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!!languageSpecificPropsQuery.length && !!languageSpecificPropsQuery[0].data.props) {
|
|
75
|
+
const parsedProps = JSON.parse(languageSpecificPropsQuery[0].data.props)
|
|
76
|
+
props = { ...props, ...parsedProps }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!!pageSpecificProps) {
|
|
80
|
+
const parsedProps = JSON.parse(pageSpecificProps)
|
|
81
|
+
props = { ...props, ...parsedProps }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
setComponentProps(props)
|
|
85
|
+
|
|
86
|
+
}, [pageSpecificProps, defaultPropsQuery, languageSpecificPropsQuery])
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<div style={slotStyles}>
|
|
90
|
+
{ loaded && <Component {...componentProps}/> }
|
|
91
|
+
</div>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Section } from './Section.jsx'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Connected components/Section',
|
|
6
|
+
component: Section,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'fullscreen',
|
|
9
|
+
workspaceId: '36zDqF0TKZZ5KkJdyg7NH',
|
|
10
|
+
renderInsideApp: true,
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Story = props => <Section {...props}/>
|
|
15
|
+
|
|
16
|
+
export const Default = Story.bind({})
|
|
17
|
+
Default.args = { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Section.jsx'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import './button.css';
|
|
6
|
+
|
|
7
|
+
/** Primary UI component for user interaction */
|
|
8
|
+
export const Button = ({
|
|
9
|
+
primary = false,
|
|
10
|
+
backgroundColor = null,
|
|
11
|
+
size = 'medium',
|
|
12
|
+
label,
|
|
13
|
+
...props
|
|
14
|
+
}) => {
|
|
15
|
+
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
16
|
+
return (
|
|
17
|
+
<button
|
|
18
|
+
type="button"
|
|
19
|
+
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
|
20
|
+
style={backgroundColor && { backgroundColor }}
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
23
|
+
{label}
|
|
24
|
+
</button>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
Button.propTypes = {
|
|
29
|
+
/** Is this the principal call to action on the page? */
|
|
30
|
+
primary: PropTypes.bool,
|
|
31
|
+
/** What background color to use */
|
|
32
|
+
backgroundColor: PropTypes.string,
|
|
33
|
+
/** How large should the button be? */
|
|
34
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
35
|
+
/** Button contents */
|
|
36
|
+
label: PropTypes.string.isRequired,
|
|
37
|
+
/** Optional click handler */
|
|
38
|
+
onClick: PropTypes.func,
|
|
39
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { fn } from '@storybook/test';
|
|
2
|
+
|
|
3
|
+
import { Button } from './Button';
|
|
4
|
+
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Example/Button',
|
|
8
|
+
component: Button,
|
|
9
|
+
parameters: {
|
|
10
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
},
|
|
13
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
|
16
|
+
argTypes: {
|
|
17
|
+
backgroundColor: { control: 'color' },
|
|
18
|
+
},
|
|
19
|
+
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
|
|
20
|
+
args: { onClick: fn() },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
24
|
+
export const Primary = {
|
|
25
|
+
args: {
|
|
26
|
+
primary: true,
|
|
27
|
+
label: 'Button',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const Secondary = {
|
|
32
|
+
args: {
|
|
33
|
+
label: 'Button',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const Large = {
|
|
38
|
+
args: {
|
|
39
|
+
size: 'large',
|
|
40
|
+
label: 'Button',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Small = {
|
|
45
|
+
args: {
|
|
46
|
+
size: 'small',
|
|
47
|
+
label: 'Button',
|
|
48
|
+
},
|
|
49
|
+
};
|