react-restyle-components 0.2.5 → 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.
@@ -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,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { ColorPicker } from './color-picker.component';
3
+ declare const meta: Meta<typeof ColorPicker>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof ColorPicker>;
6
+ export declare const Primary: Story;
@@ -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: 'Arima Regular';
8
- src: url('./library/assets/fonts/arima/Arima-Regular.ttf');
7
+ font-family: "Arima Regular";
8
+ src: url("./library/assets/fonts/arima/Arima-Regular.ttf");
9
9
  }
10
10
  @font-face {
11
- font-family: 'NunitoSans Regular';
12
- src: url('./library/assets/fonts/nunito-sans/NunitoSans-Regular.ttf');
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: 'NunitoSans Bold';
16
- src: url('./library/assets/fonts/nunito-sans/NunitoSans-Bold.ttf');
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: 'DancingScript-Bold';
20
- src: url('./library/assets/fonts/dancing-script/DancingScript-Bold.ttf');
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: 'DancingScript-Regular';
24
- src: url('./library/assets/fonts/dancing-script/DancingScript-Regular.ttf');
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: 'Arima Regular';
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: '#EF4444';
71
+ background-color: "#EF4444";
72
72
  }
73
73
 
74
74
  .react-pdf__Page__canvas {