react-restyle-components 0.2.4 → 0.2.6
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/lib/package.json +9 -15
- package/lib/src/App.css +1 -1
- package/lib/src/App.js +4 -547
- package/lib/src/core-components/index.d.ts +1 -0
- package/lib/src/core-components/index.js +1 -0
- package/lib/src/core-components/molecules/color-picker/color-picker.component.d.ts +6 -0
- package/lib/src/core-components/molecules/color-picker/color-picker.component.js +14 -0
- package/lib/src/core-components/molecules/color-picker/color-picker.css +22 -0
- package/lib/src/core-components/molecules/color-picker/color-picker.spec.d.ts +1 -0
- package/lib/src/core-components/molecules/color-picker/color-picker.spec.js +9 -0
- package/lib/src/core-components/molecules/color-picker/color-picker.stories.d.ts +6 -0
- package/lib/src/core-components/molecules/color-picker/color-picker.stories.js +18 -0
- package/lib/src/hooks/index.d.ts +1 -0
- package/lib/src/hooks/index.js +1 -0
- package/lib/src/hooks/outside.hook.d.ts +1 -0
- package/lib/src/hooks/outside.hook.js +28 -0
- package/lib/src/index.css +12 -12
- package/lib/src/tc.css +944 -1
- package/package.json +9 -15
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.picker {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.swatch {
|
|
6
|
+
width: 28px;
|
|
7
|
+
height: 28px;
|
|
8
|
+
border-radius: 8px;
|
|
9
|
+
border: 3px solid #fff;
|
|
10
|
+
box-shadow:
|
|
11
|
+
0 0 0 1px rgba(0, 0, 0, 0.1),
|
|
12
|
+
inset 0 0 0 1px rgba(0, 0, 0, 0.1);
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.popover {
|
|
17
|
+
position: absolute;
|
|
18
|
+
top: calc(100% + 2px);
|
|
19
|
+
left: 0;
|
|
20
|
+
border-radius: 9px;
|
|
21
|
+
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { ColorPicker } from './color-picker.component';
|
|
5
|
+
test('Render Autocomplete', () => {
|
|
6
|
+
render(React.createElement(ColorPicker, { color: "#000000", onChange: () => { } }));
|
|
7
|
+
expect(screen.getByRole('input')).toBeInTheDocument();
|
|
8
|
+
expect(screen.getByRole('list')).toBeInTheDocument();
|
|
9
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ColorPicker } from './color-picker.component';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Design System/Molecules/ColorPicker',
|
|
4
|
+
component: ColorPicker,
|
|
5
|
+
tags: ['autodocs'],
|
|
6
|
+
parameters: {
|
|
7
|
+
componentSubtitle: `import { ColorPicker } from 'react-restyle-components'`,
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
export const Primary = {
|
|
12
|
+
args: {
|
|
13
|
+
color: '#000000',
|
|
14
|
+
onChange: (color) => {
|
|
15
|
+
console.log({ color });
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './outside.hook';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './outside.hook';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useClickOutside: (ref: any, handler: any) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
export const useClickOutside = (ref, handler) => {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
let startedInside = false;
|
|
5
|
+
let startedWhenMounted = false;
|
|
6
|
+
const listener = (event) => {
|
|
7
|
+
// Do nothing if `mousedown` or `touchstart` started inside ref element
|
|
8
|
+
if (startedInside || !startedWhenMounted)
|
|
9
|
+
return;
|
|
10
|
+
// Do nothing if clicking ref's element or descendent elements
|
|
11
|
+
if (!ref.current || ref.current.contains(event.target))
|
|
12
|
+
return;
|
|
13
|
+
handler(event);
|
|
14
|
+
};
|
|
15
|
+
const validateEventStart = (event) => {
|
|
16
|
+
startedWhenMounted = ref.current;
|
|
17
|
+
startedInside = ref.current && ref.current.contains(event.target);
|
|
18
|
+
};
|
|
19
|
+
document.addEventListener('mousedown', validateEventStart);
|
|
20
|
+
document.addEventListener('touchstart', validateEventStart);
|
|
21
|
+
document.addEventListener('click', listener);
|
|
22
|
+
return () => {
|
|
23
|
+
document.removeEventListener('mousedown', validateEventStart);
|
|
24
|
+
document.removeEventListener('touchstart', validateEventStart);
|
|
25
|
+
document.removeEventListener('click', listener);
|
|
26
|
+
};
|
|
27
|
+
}, [ref, handler]);
|
|
28
|
+
};
|
package/lib/src/index.css
CHANGED
|
@@ -4,24 +4,24 @@
|
|
|
4
4
|
|
|
5
5
|
@layer base {
|
|
6
6
|
@font-face {
|
|
7
|
-
font-family:
|
|
8
|
-
src: url(
|
|
7
|
+
font-family: "Arima Regular";
|
|
8
|
+
src: url("./library/assets/fonts/arima/Arima-Regular.ttf");
|
|
9
9
|
}
|
|
10
10
|
@font-face {
|
|
11
|
-
font-family:
|
|
12
|
-
src: url(
|
|
11
|
+
font-family: "NunitoSans Regular";
|
|
12
|
+
src: url("./library/assets/fonts/nunito-sans/NunitoSans-Regular.ttf");
|
|
13
13
|
}
|
|
14
14
|
@font-face {
|
|
15
|
-
font-family:
|
|
16
|
-
src: url(
|
|
15
|
+
font-family: "NunitoSans Bold";
|
|
16
|
+
src: url("./library/assets/fonts/nunito-sans/NunitoSans-Bold.ttf");
|
|
17
17
|
}
|
|
18
18
|
@font-face {
|
|
19
|
-
font-family:
|
|
20
|
-
src: url(
|
|
19
|
+
font-family: "DancingScript-Bold";
|
|
20
|
+
src: url("./library/assets/fonts/dancing-script/DancingScript-Bold.ttf");
|
|
21
21
|
}
|
|
22
22
|
@font-face {
|
|
23
|
-
font-family:
|
|
24
|
-
src: url(
|
|
23
|
+
font-family: "DancingScript-Regular";
|
|
24
|
+
src: url("./library/assets/fonts/dancing-script/DancingScript-Regular.ttf");
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
|
|
50
50
|
body {
|
|
51
51
|
font-size: 14px;
|
|
52
|
-
font-family:
|
|
52
|
+
font-family: "Arima Regular";
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.ps__rail-y {
|
|
@@ -68,7 +68,7 @@ body {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
.bg-orange1 {
|
|
71
|
-
background-color:
|
|
71
|
+
background-color: "#EF4444";
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
.react-pdf__Page__canvas {
|