core-outline 1.1.0 → 1.1.2
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/.eslintignore +2 -0
- package/.eslintrc.json +23 -0
- package/.prettierignore +2 -0
- package/.prettierrc +7 -0
- package/.storybook/main.js +7 -7
- package/dist/index.es.js +3979 -15
- package/dist/index.js +3985 -15
- package/package.json +8 -2
- package/rollup.config.js +35 -35
- package/src/components/CoreOutline/CoreOutline.js +70 -45
- package/src/components/CoreOutline/RWebRecorder.js +26 -26
- package/src/components/CoreOutline/index.js +1 -1
- package/src/index.js +1 -1
- package/src/stories/Button.jsx +0 -40
- package/src/stories/Button.stories.js +0 -49
- package/src/stories/Configure.mdx +0 -364
- package/src/stories/Header.jsx +0 -60
- package/src/stories/Header.stories.js +0 -29
- package/src/stories/Page.jsx +0 -69
- package/src/stories/Page.stories.js +0 -28
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +0 -1
- 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 +0 -1
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +0 -1
- 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 +0 -1
- package/src/stories/assets/youtube.svg +0 -1
- package/src/stories/button.css +0 -30
- package/src/stories/header.css +0 -32
- package/src/stories/page.css +0 -69
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "core-outline",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "A React component for Core&Outline",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
9
|
"storybook": "storybook dev -p 6006",
|
|
10
10
|
"build-storybook": "storybook build",
|
|
11
|
-
"build-lib": "rollup -c"
|
|
11
|
+
"build-lib": "rollup -c",
|
|
12
|
+
"format": "prettier --write .",
|
|
13
|
+
"lint": "eslint . "
|
|
12
14
|
},
|
|
13
15
|
"keywords": [
|
|
14
16
|
"Core",
|
|
@@ -25,6 +27,10 @@
|
|
|
25
27
|
"@storybook/addon-links": "^6.1.16",
|
|
26
28
|
"@storybook/react": "^6.1.16",
|
|
27
29
|
"babel-loader": "^8.2.2",
|
|
30
|
+
"eslint": "^9.17.0",
|
|
31
|
+
"eslint-config-prettier": "^9.1.0",
|
|
32
|
+
"eslint-plugin-react": "^7.37.3",
|
|
33
|
+
"prettier": "^3.4.2",
|
|
28
34
|
"react": "^17.0.1",
|
|
29
35
|
"react-dom": "^17.0.1",
|
|
30
36
|
"rollup": "^2.38.4",
|
package/rollup.config.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import babel from 'rollup-plugin-babel';
|
|
2
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
-
import external from 'rollup-plugin-peer-deps-external';
|
|
4
|
-
import { terser } from 'rollup-plugin-terser';
|
|
5
|
-
import postcss from 'rollup-plugin-postcss';
|
|
6
|
-
|
|
7
|
-
export default [
|
|
8
|
-
{
|
|
9
|
-
input: './src/components/CoreOutline/CoreOutline.js',
|
|
10
|
-
output: [
|
|
11
|
-
{
|
|
12
|
-
file: 'dist/index.js',
|
|
13
|
-
format: 'cjs',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
file: 'dist/index.es.js',
|
|
17
|
-
format: 'es',
|
|
18
|
-
exports: 'named',
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
plugins: [
|
|
22
|
-
postcss({
|
|
23
|
-
plugins: [],
|
|
24
|
-
minimize: true,
|
|
25
|
-
}),
|
|
26
|
-
babel({
|
|
27
|
-
exclude: 'node_modules/**',
|
|
28
|
-
presets: ['@babel/preset-react']
|
|
29
|
-
}),
|
|
30
|
-
external(),
|
|
31
|
-
resolve(),
|
|
32
|
-
terser(),
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
];
|
|
1
|
+
import babel from 'rollup-plugin-babel';
|
|
2
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
+
import external from 'rollup-plugin-peer-deps-external';
|
|
4
|
+
import { terser } from 'rollup-plugin-terser';
|
|
5
|
+
import postcss from 'rollup-plugin-postcss';
|
|
6
|
+
|
|
7
|
+
export default [
|
|
8
|
+
{
|
|
9
|
+
input: './src/components/CoreOutline/CoreOutline.js',
|
|
10
|
+
output: [
|
|
11
|
+
{
|
|
12
|
+
file: 'dist/index.js',
|
|
13
|
+
format: 'cjs',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
file: 'dist/index.es.js',
|
|
17
|
+
format: 'es',
|
|
18
|
+
exports: 'named',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
plugins: [
|
|
22
|
+
postcss({
|
|
23
|
+
plugins: [],
|
|
24
|
+
minimize: true,
|
|
25
|
+
}),
|
|
26
|
+
babel({
|
|
27
|
+
exclude: 'node_modules/**',
|
|
28
|
+
presets: ['@babel/preset-react'],
|
|
29
|
+
}),
|
|
30
|
+
external(),
|
|
31
|
+
resolve(),
|
|
32
|
+
// terser(),
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
];
|
|
@@ -1,45 +1,70 @@
|
|
|
1
|
-
import React, { useEffect } from
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const CoreOutline = ({children}) =>{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { record } from 'rrweb';
|
|
3
|
+
|
|
4
|
+
const CoreOutline = ({ children }) => {
|
|
5
|
+
const [events, setEvents] = useState([]);
|
|
6
|
+
const recorderActive = useRef(false);
|
|
7
|
+
const [currentPage, setCurrentPage] = useState(window.location.href);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
console.log(currentPage);
|
|
11
|
+
const handleNavigation = () => {
|
|
12
|
+
setCurrentPage(window.location.href);
|
|
13
|
+
saveEvents(JSON.stringify(events));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
window.addEventListener('popstate', handleNavigation);
|
|
17
|
+
const originalPushState = window.history.pushState;
|
|
18
|
+
window.history.pushState = function (...args) {
|
|
19
|
+
originalPushState.apply(this, args);
|
|
20
|
+
handleNavigation();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return () => {
|
|
24
|
+
window.removeEventListener('popstate', handleNavigation);
|
|
25
|
+
window.history.pushState = originalPushState;
|
|
26
|
+
};
|
|
27
|
+
}, [currentPage]);
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
let stopFn;
|
|
31
|
+
if (!recorderActive.current) {
|
|
32
|
+
stopFn = record({
|
|
33
|
+
emit(event) {
|
|
34
|
+
setEvents((prevEvents) => [...prevEvents, event]);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
recorderActive.current = true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return () => {
|
|
42
|
+
if (stopFn) {
|
|
43
|
+
stopFn();
|
|
44
|
+
|
|
45
|
+
recorderActive.current = false;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
50
|
+
function saveEvents(events) {
|
|
51
|
+
const requestOptions = {
|
|
52
|
+
method: 'PUT',
|
|
53
|
+
headers: {
|
|
54
|
+
'Content-Type': 'application/json',
|
|
55
|
+
},
|
|
56
|
+
body: JSON.stringify(events),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
fetch('http://localhost:8000/generate-s3-url')
|
|
60
|
+
.then((response) => response.json())
|
|
61
|
+
.then((data) => {
|
|
62
|
+
const uploadURL = data.signed_url;
|
|
63
|
+
return fetch(uploadURL, requestOptions);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return <div>{children}</div>;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default CoreOutline;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { useEffect, useRef } from
|
|
2
|
-
import { record } from
|
|
3
|
-
|
|
4
|
-
const useRRWebRecorder = () => {
|
|
5
|
-
const eventsRef = useRef([]);
|
|
6
|
-
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
const stopRecording = record({
|
|
9
|
-
emit(event) {
|
|
10
|
-
if (event){
|
|
11
|
-
eventsRef.current.push(event);
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
return () => {
|
|
17
|
-
if (stopRecording) {
|
|
18
|
-
stopRecording();
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}, []);
|
|
22
|
-
|
|
23
|
-
return eventsRef;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default useRRWebRecorder;
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { record } from 'rrweb';
|
|
3
|
+
|
|
4
|
+
const useRRWebRecorder = () => {
|
|
5
|
+
const eventsRef = useRef([]);
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const stopRecording = record({
|
|
9
|
+
emit(event) {
|
|
10
|
+
if (event) {
|
|
11
|
+
eventsRef.current.push(event);
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return () => {
|
|
17
|
+
if (stopRecording) {
|
|
18
|
+
stopRecording();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
return eventsRef;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default useRRWebRecorder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './CoreOutline';
|
|
1
|
+
export * from './CoreOutline';
|
package/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './components/CoreOutline';
|
|
1
|
+
export * from './components/CoreOutline';
|
package/src/stories/Button.jsx
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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 = ({ primary, backgroundColor, size, label, ...props }) => {
|
|
9
|
-
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
10
|
-
return (
|
|
11
|
-
<button
|
|
12
|
-
type="button"
|
|
13
|
-
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
|
14
|
-
style={backgroundColor && { backgroundColor }}
|
|
15
|
-
{...props}
|
|
16
|
-
>
|
|
17
|
-
{label}
|
|
18
|
-
</button>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
Button.propTypes = {
|
|
23
|
-
/** Is this the principal call to action on the page? */
|
|
24
|
-
primary: PropTypes.bool,
|
|
25
|
-
/** What background color to use */
|
|
26
|
-
backgroundColor: PropTypes.string,
|
|
27
|
-
/** How large should the button be? */
|
|
28
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
29
|
-
/** Button contents */
|
|
30
|
-
label: PropTypes.string.isRequired,
|
|
31
|
-
/** Optional click handler */
|
|
32
|
-
onClick: PropTypes.func,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
Button.defaultProps = {
|
|
36
|
-
backgroundColor: null,
|
|
37
|
-
primary: false,
|
|
38
|
-
size: 'medium',
|
|
39
|
-
onClick: undefined,
|
|
40
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
};
|