Skip to content

Commit

Permalink
fix: use react hooks to separate UI and logic (#100)
Browse files Browse the repository at this point in the history
* use hooks to separate-UI-and-logic

* fix: use correct icon file

* fix: refine style
  • Loading branch information
yanggggjie authored Feb 27, 2024
1 parent 674ac76 commit b29aa5f
Show file tree
Hide file tree
Showing 22 changed files with 616 additions and 892 deletions.
52 changes: 0 additions & 52 deletions app/components/editor/editors/CustomFunctionEditor.tsx

This file was deleted.

49 changes: 0 additions & 49 deletions app/components/editor/editors/ModalEditor.tsx

This file was deleted.

49 changes: 0 additions & 49 deletions app/components/editor/editors/PolicyEditor.tsx

This file was deleted.

49 changes: 0 additions & 49 deletions app/components/editor/editors/RequestEditor.tsx

This file was deleted.

52 changes: 0 additions & 52 deletions app/components/editor/editors/RequestResultEditor.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import React from 'react';

interface CopyProps {
content: string;
cb: () => void;
}

const Copy = (props: CopyProps) => {
function copy(data: string): void {
export default function useCopy() {
function copy(cb: any, data: string): void {
const listener = (e: ClipboardEvent) => {
if (!e.clipboardData) {
throw new Error('Clipboard API unavailable.');
Expand All @@ -31,21 +24,10 @@ const Copy = (props: CopyProps) => {
};
document.addEventListener('copy', listener);
document.execCommand('copy');
props.cb();
// props.cb();
cb();
}

return (
<button
style={{ marginRight: 8 }}
onClick={() => {
return copy(
`${window.location.origin + window.location.pathname}#${props.content}`,
);
}}
>
COPY
</button>
);
};

export default Copy;
return {
copy,
};
}
Loading

0 comments on commit b29aa5f

Please sign in to comment.