pollination-react-io 0.0.30 → 0.0.31

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Harvey Delaney
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Harvey Delaney
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,111 +1,111 @@
1
- # Pollination React IO
2
-
3
- Plan is to create a set of hooks and higher order components (HOCs) that abstract logic originally implemented in pollination-streamlit-io to facilitate using react as a native client for the CAD plugins.
4
-
5
- ### Testing
6
-
7
- ```
8
- npm run test
9
- ```
10
-
11
- ### Building
12
-
13
- ```
14
- npm run build
15
- ```
16
-
17
- ### Storybook
18
-
19
- To run a live-reload Storybook server on your local machine:
20
-
21
- ```
22
- npm run storybook
23
- ```
24
-
25
- To export your Storybook as static files:
26
-
27
- ```
28
- npm run storybook:export
29
- ```
30
-
31
- You can then serve the files under `storybook-static` using S3, GitHub pages, Express etc. I've hosted this library at: https://www.harveydelaney.com/react-component-library
32
-
33
- ### Generating New Components
34
-
35
- I've included a handy NodeJS util file under `util` called `create-component.js`. Instead of copy pasting components to create a new component, you can instead run this command to generate all the files you need to start building out a new component. To use it:
36
-
37
- ```
38
- npm run generate YourComponentName
39
- ```
40
-
41
- This will generate:
42
-
43
- ```
44
- /src
45
- /YourComponentName
46
- YourComponentName.tsx
47
- YourComponentName.stories.tsx
48
- YourComponentName.test.tsx
49
- YourComponentName.types.ts
50
- YourComponentName.scss
51
- ```
52
-
53
- The default templates for each file can be modified under `util/templates`.
54
-
55
- Don't forget to add the component to your `index.ts` exports if you want the library to export the component!
56
-
57
- ### Installing Component Library Locally
58
-
59
- Let's say you have another project (`test-app`) on your machine that you want to try installing the component library into without having to first publish the component library. In the `test-app` directory, you can run:
60
-
61
- ```
62
- npm i --save ../react-component-library
63
- ```
64
-
65
- which will install the local component library as a dependency in `test-app`. It'll then appear as a dependency in `package.json` like:
66
-
67
- ```
68
- ...
69
- "dependencies": {
70
- ...
71
- "react-component-library": "file:../react-component-library",
72
- ...
73
- },
74
- ...
75
- ```
76
-
77
- Your components can then be imported and used in that project.
78
- ### Using Component Library SASS Variables
79
-
80
- I've found that it's helpful to export SASS variables to projects consuming the library. As such, I've added the `rollup-plugin-copy` NPM package and used it to copy the [`src/typography.scss`](src/typography.scss) and [`variables.scss`](src/variables.scss) into the `build` directory as part of the Rollup bundle process. This allows you to use these variables in your projects consuming the component library.
81
-
82
- For example, let's say you installed `harvey-component-library` into your project. To use the exported variables/mixins, in a SASS file you would do the following:
83
-
84
- ```Sass
85
- @import '~harvey-component-library/build/typography';
86
-
87
- .example-container {
88
- @include heading;
89
-
90
- color: $harvey-white;
91
- }
92
- ```
93
-
94
- ## Additional Help
95
-
96
- ### Dark Mode
97
-
98
- The example component `TestComponent` respects the user's dark mode operating system preferences and renders the component in the appropriate theme.
99
-
100
- This is achieved by using the media query: `@media (prefers-color-scheme: dark)` in combination with CSS variables. The colours that change depending on dark mode preference can be found in [`src/variables.scss`](src/variables.scss). Example usage of these variables can be found within [`src/TestComponent/TestComponent.scss`](src/TestComponent/TestComponent.scss).
101
-
102
- Read https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme for more details.
103
-
104
-
105
- [Built with react-component-library](https://blog.harveydelaney.com/creating-your-own-react-component-library/)
106
-
107
- - [Rollup](https://github.com/rollup/rollup)
108
- - [Sass](https://sass-lang.com/)
109
- - [TypeScript](https://www.typescriptlang.org/)
110
- - [Storybook](https://storybook.js.org/)
111
- - [Jest](https://jestjs.io/) and [React Testing Library](https://github.com/testing-library/react-testing-library)
1
+ # Pollination React IO
2
+
3
+ Plan is to create a set of hooks and higher order components (HOCs) that abstract logic originally implemented in pollination-streamlit-io to facilitate using react as a native client for the CAD plugins.
4
+
5
+ ### Testing
6
+
7
+ ```
8
+ npm run test
9
+ ```
10
+
11
+ ### Building
12
+
13
+ ```
14
+ npm run build
15
+ ```
16
+
17
+ ### Storybook
18
+
19
+ To run a live-reload Storybook server on your local machine:
20
+
21
+ ```
22
+ npm run storybook
23
+ ```
24
+
25
+ To export your Storybook as static files:
26
+
27
+ ```
28
+ npm run storybook:export
29
+ ```
30
+
31
+ You can then serve the files under `storybook-static` using S3, GitHub pages, Express etc. I've hosted this library at: https://www.harveydelaney.com/react-component-library
32
+
33
+ ### Generating New Components
34
+
35
+ I've included a handy NodeJS util file under `util` called `create-component.js`. Instead of copy pasting components to create a new component, you can instead run this command to generate all the files you need to start building out a new component. To use it:
36
+
37
+ ```
38
+ npm run generate YourComponentName
39
+ ```
40
+
41
+ This will generate:
42
+
43
+ ```
44
+ /src
45
+ /YourComponentName
46
+ YourComponentName.tsx
47
+ YourComponentName.stories.tsx
48
+ YourComponentName.test.tsx
49
+ YourComponentName.types.ts
50
+ YourComponentName.scss
51
+ ```
52
+
53
+ The default templates for each file can be modified under `util/templates`.
54
+
55
+ Don't forget to add the component to your `index.ts` exports if you want the library to export the component!
56
+
57
+ ### Installing Component Library Locally
58
+
59
+ Let's say you have another project (`test-app`) on your machine that you want to try installing the component library into without having to first publish the component library. In the `test-app` directory, you can run:
60
+
61
+ ```
62
+ npm i --save ../react-component-library
63
+ ```
64
+
65
+ which will install the local component library as a dependency in `test-app`. It'll then appear as a dependency in `package.json` like:
66
+
67
+ ```
68
+ ...
69
+ "dependencies": {
70
+ ...
71
+ "react-component-library": "file:../react-component-library",
72
+ ...
73
+ },
74
+ ...
75
+ ```
76
+
77
+ Your components can then be imported and used in that project.
78
+ ### Using Component Library SASS Variables
79
+
80
+ I've found that it's helpful to export SASS variables to projects consuming the library. As such, I've added the `rollup-plugin-copy` NPM package and used it to copy the [`src/typography.scss`](src/typography.scss) and [`variables.scss`](src/variables.scss) into the `build` directory as part of the Rollup bundle process. This allows you to use these variables in your projects consuming the component library.
81
+
82
+ For example, let's say you installed `harvey-component-library` into your project. To use the exported variables/mixins, in a SASS file you would do the following:
83
+
84
+ ```Sass
85
+ @import '~harvey-component-library/build/typography';
86
+
87
+ .example-container {
88
+ @include heading;
89
+
90
+ color: $harvey-white;
91
+ }
92
+ ```
93
+
94
+ ## Additional Help
95
+
96
+ ### Dark Mode
97
+
98
+ The example component `TestComponent` respects the user's dark mode operating system preferences and renders the component in the appropriate theme.
99
+
100
+ This is achieved by using the media query: `@media (prefers-color-scheme: dark)` in combination with CSS variables. The colours that change depending on dark mode preference can be found in [`src/variables.scss`](src/variables.scss). Example usage of these variables can be found within [`src/TestComponent/TestComponent.scss`](src/TestComponent/TestComponent.scss).
101
+
102
+ Read https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme for more details.
103
+
104
+
105
+ [Built with react-component-library](https://blog.harveydelaney.com/creating-your-own-react-component-library/)
106
+
107
+ - [Rollup](https://github.com/rollup/rollup)
108
+ - [Sass](https://sass-lang.com/)
109
+ - [TypeScript](https://www.typescriptlang.org/)
110
+ - [Storybook](https://storybook.js.org/)
111
+ - [Jest](https://jestjs.io/) and [React Testing Library](https://github.com/testing-library/react-testing-library)
@@ -0,0 +1,5 @@
1
+ export declare const ConditionalWrapper: ({ condition, wrapper, children }: {
2
+ condition: any;
3
+ wrapper: any;
4
+ children: any;
5
+ }) => any;
@@ -0,0 +1,26 @@
1
+ import React, { FC } from 'react';
2
+ import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
3
+ export declare type Option = {
4
+ type: 'checkbox' | 'radio' | 'button' | 'label' | 'link';
5
+ id: string;
6
+ label: string;
7
+ checked?: boolean;
8
+ disabled?: boolean;
9
+ onSelect?: (option: Option) => void;
10
+ to?: string;
11
+ };
12
+ export declare type OptionGroup = {
13
+ options: Option[];
14
+ type?: 'radio' | 'default';
15
+ value?: string;
16
+ };
17
+ interface DropdownProps {
18
+ optionGroups: OptionGroup[];
19
+ trigger: React.ReactNode;
20
+ contentProps?: DropdownMenu.DropdownMenuContentProps;
21
+ itemProps?: DropdownMenu.DropdownMenuItemProps;
22
+ arrow?: boolean;
23
+ disabled?: boolean;
24
+ }
25
+ export declare const Dropdown: FC<DropdownProps>;
26
+ export {};
@@ -0,0 +1,3 @@
1
+ export interface DropdownProps {
2
+ foo: string;
3
+ }
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ import { FileInputProps } from "./FileInput.types";
3
+ import "./FileInput.scss";
4
+ import "../../typography.scss";
5
+ declare const FileInput: React.FC<FileInputProps>;
6
+ export default FileInput;
@@ -0,0 +1,4 @@
1
+ export interface FileInputProps {
2
+ onChange?: (event: any) => void;
3
+ disabled?: boolean;
4
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function Logo(): JSX.Element;
@@ -0,0 +1,11 @@
1
+ import React, { FC, ReactNode } from 'react';
2
+ import { OptionGroup } from '../Dropdown/Dropdown';
3
+ import '../../buttons.scss';
4
+ export interface SettingsButtonProps {
5
+ onClick: () => void;
6
+ label: string | ReactNode;
7
+ options?: OptionGroup[];
8
+ disabled?: boolean;
9
+ triggerIcon?: React.ReactNode;
10
+ }
11
+ export declare const SettingsButton: FC<SettingsButtonProps>;
@@ -0,0 +1,10 @@
1
+ import React, { CSSProperties, FC } from "react";
2
+ import './Tooltip.scss';
3
+ interface TooltipProps {
4
+ content: React.ReactNode | string;
5
+ side?: "top" | "right" | "bottom" | "left";
6
+ children?: React.ReactNode;
7
+ style?: CSSProperties;
8
+ }
9
+ export declare const Tooltip: FC<TooltipProps>;
10
+ export {};
@@ -1,87 +1,87 @@
1
- @import "./variables.scss";
2
- @import "./typography.scss";
3
-
4
- .btn-group {
5
- @include font-defaults;
6
-
7
- width: fit-content;
8
- display: flex;
9
- border-radius: 4px;
10
- }
11
-
12
- .btn-group:hover {
13
- box-shadow: 0 1px 2px 0 rgba(26, 115, 232, 0.45), 0 1px 3px 1px rgba(26, 115, 232, 0.30);
14
- }
15
-
16
- .btn-group-disabled:hover {
17
- box-shadow: none;
18
- }
19
-
20
- .btn-group button {
21
- max-width: 260px;
22
- display: flex;
23
- background-color: var(--primary);
24
- border: 1px solid var(--primary);
25
- color: white;
26
- padding: 6px 10px;
27
- cursor: pointer;
28
- float: left;
29
- transition: background-color 0.125s ease-in-out;
30
- z-index: 10;
31
- align-items: center;
32
- gap: 8px;
33
- }
34
-
35
- .btn-group-disabled button {
36
- background-color: var(--grey3);
37
- color: var(--grey5);
38
- cursor: default;
39
- border-color: var(--grey5);
40
- }
41
-
42
- .btn-group button:first-child {
43
- border-top-left-radius: 4px;
44
- border-bottom-left-radius: 4px;
45
- }
46
-
47
- .btn-group button:last-child {
48
- border-top-right-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-left-color: #096dd9;
51
- }
52
-
53
- .btn-group button:last-child:disabled {
54
- border-left-color: var(--grey5);
55
- }
56
-
57
- .btn-group button:not(:last-child) {
58
- border-right: none;
59
- }
60
-
61
- .btn-group button:focus-visible {
62
- outline: none;
63
- }
64
-
65
- .btn-group button:focus {
66
- outline: none;
67
- }
68
-
69
- /* Clear floats (clearfix hack) */
70
- .btn-group:after {
71
- content: "";
72
- clear: both;
73
- display: table;
74
- }
75
-
76
- .btn-group button:hover {
77
- background-color: var(--primary2);
78
- z-index: 11;
79
- }
80
-
81
- .btn-group-disabled:hover button:hover {
82
- background-color: var(--grey3);
83
- }
84
-
85
- .options-content {
86
- font-size: calc(clamp(0.65rem, 8vw - 0.75rem, 0.85rem));
1
+ @import "./variables.scss";
2
+ @import "./typography.scss";
3
+
4
+ .btn-group {
5
+ @include font-defaults;
6
+
7
+ width: fit-content;
8
+ display: flex;
9
+ border-radius: 4px;
10
+ }
11
+
12
+ .btn-group:hover {
13
+ box-shadow: 0 1px 2px 0 rgba(26, 115, 232, 0.45), 0 1px 3px 1px rgba(26, 115, 232, 0.30);
14
+ }
15
+
16
+ .btn-group-disabled:hover {
17
+ box-shadow: none;
18
+ }
19
+
20
+ .btn-group button {
21
+ max-width: 260px;
22
+ display: flex;
23
+ background-color: var(--primary);
24
+ border: 1px solid var(--primary);
25
+ color: white;
26
+ padding: 6px 10px;
27
+ cursor: pointer;
28
+ float: left;
29
+ transition: background-color 0.125s ease-in-out;
30
+ z-index: 10;
31
+ align-items: center;
32
+ gap: 8px;
33
+ }
34
+
35
+ .btn-group-disabled button {
36
+ background-color: var(--grey3);
37
+ color: var(--grey5);
38
+ cursor: default;
39
+ border-color: var(--grey5);
40
+ }
41
+
42
+ .btn-group button:first-child {
43
+ border-top-left-radius: 4px;
44
+ border-bottom-left-radius: 4px;
45
+ }
46
+
47
+ .btn-group button:last-child {
48
+ border-top-right-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-left-color: #096dd9;
51
+ }
52
+
53
+ .btn-group button:last-child:disabled {
54
+ border-left-color: var(--grey5);
55
+ }
56
+
57
+ .btn-group button:not(:last-child) {
58
+ border-right: none;
59
+ }
60
+
61
+ .btn-group button:focus-visible {
62
+ outline: none;
63
+ }
64
+
65
+ .btn-group button:focus {
66
+ outline: none;
67
+ }
68
+
69
+ /* Clear floats (clearfix hack) */
70
+ .btn-group:after {
71
+ content: "";
72
+ clear: both;
73
+ display: table;
74
+ }
75
+
76
+ .btn-group button:hover {
77
+ background-color: var(--primary2);
78
+ z-index: 11;
79
+ }
80
+
81
+ .btn-group-disabled:hover button:hover {
82
+ background-color: var(--grey3);
83
+ }
84
+
85
+ .options-content {
86
+ font-size: calc(clamp(0.65rem, 8vw - 0.75rem, 0.85rem));
87
87
  }