Vokturz commited on
Commit
a153e7f
·
1 Parent(s): ad5cd92

undo some changes

Browse files
public/workers/feature-extraction.js CHANGED
@@ -1,5 +1,5 @@
1
  /* eslint-disable no-restricted-globals */
2
- import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.0'
3
 
4
  class MyFeatureExtractionPipeline {
5
  static task = 'feature-extraction'
 
1
  /* eslint-disable no-restricted-globals */
2
+ import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.1'
3
 
4
  class MyFeatureExtractionPipeline {
5
  static task = 'feature-extraction'
public/workers/image-classification.js CHANGED
@@ -1,5 +1,5 @@
1
  /* eslint-disable no-restricted-globals */
2
- import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.0'
3
 
4
  class MyImageClassificationPipeline {
5
  static task = 'image-classification'
 
1
  /* eslint-disable no-restricted-globals */
2
+ import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.1'
3
 
4
  class MyImageClassificationPipeline {
5
  static task = 'image-classification'
public/workers/text-classification.js CHANGED
@@ -1,5 +1,5 @@
1
  /* eslint-disable no-restricted-globals */
2
- import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.0'
3
 
4
  class MyTextClassificationPipeline {
5
  static task = 'text-classification'
 
1
  /* eslint-disable no-restricted-globals */
2
+ import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.1'
3
 
4
  class MyTextClassificationPipeline {
5
  static task = 'text-classification'
public/workers/text-generation.js CHANGED
@@ -1,5 +1,5 @@
1
  /* eslint-disable no-restricted-globals */
2
- import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.0'
3
 
4
  class MyTextGenerationPipeline {
5
  static task = 'text-generation'
 
1
  /* eslint-disable no-restricted-globals */
2
+ import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.1'
3
 
4
  class MyTextGenerationPipeline {
5
  static task = 'text-generation'
public/workers/zero-shot-classification.js CHANGED
@@ -1,5 +1,5 @@
1
  /* eslint-disable no-restricted-globals */
2
- import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.0'
3
 
4
  class MyZeroShotClassificationPipeline {
5
  static task = 'zero-shot-classification'
 
1
  /* eslint-disable no-restricted-globals */
2
+ import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.1'
3
 
4
  class MyZeroShotClassificationPipeline {
5
  static task = 'zero-shot-classification'
src/components/Modal.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect } from 'react'
2
  import { X } from 'lucide-react'
3
 
4
  interface ModalProps {
@@ -26,11 +26,6 @@ const Modal: React.FC<ModalProps> = ({
26
  children,
27
  maxWidth = '4xl'
28
  }) => {
29
- // State to control if the modal is in the DOM
30
- const [isRendered, setIsRendered] = useState(isOpen)
31
- // State to control the animation classes
32
- const [isAnimating, setIsAnimating] = useState(false)
33
-
34
  useEffect(() => {
35
  const handleEscape = (e: KeyboardEvent) => {
36
  if (e.key === 'Escape') {
@@ -39,24 +34,17 @@ const Modal: React.FC<ModalProps> = ({
39
  }
40
 
41
  if (isOpen) {
42
- setIsRendered(true)
43
- document.body.style.overflow = 'hidden'
44
  document.addEventListener('keydown', handleEscape)
45
- const animationTimeout = setTimeout(() => setIsAnimating(true), 20)
46
- return () => clearTimeout(animationTimeout)
47
- } else {
48
- setIsAnimating(false)
49
- const unmountTimeout = setTimeout(() => {
50
- setIsRendered(false)
51
- document.body.style.overflow = 'unset'
52
- document.removeEventListener('keydown', handleEscape)
53
- }, 300)
54
- return () => clearTimeout(unmountTimeout)
55
  }
56
  }, [isOpen, onClose])
57
 
58
- // Unmount the component completely when not rendered
59
- if (!isRendered) return null
60
 
61
  const maxWidthClasses = {
62
  sm: 'max-w-sm',
@@ -75,30 +63,22 @@ const Modal: React.FC<ModalProps> = ({
75
  <div className="fixed inset-0 z-50 overflow-y-auto">
76
  {/* Backdrop */}
77
  <div
78
- className={`fixed inset-0 bg-black transition-opacity duration-300 ease-in-out ${
79
- isAnimating ? 'opacity-50' : 'opacity-0'
80
- }`}
81
  onClick={onClose}
82
  />
83
 
84
  {/* Modal */}
85
  <div className="flex min-h-full items-center justify-center p-4 text-center sm:p-0">
86
  <div
87
- className={`relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all duration-300 ease-in-out sm:my-8 sm:w-full ${
88
- maxWidthClasses[maxWidth]
89
- } ${
90
- isAnimating
91
- ? 'opacity-100 translate-y-0 sm:scale-100'
92
- : 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95'
93
- }`}
94
  onClick={(e) => e.stopPropagation()}
95
  >
96
  {/* Header */}
97
- <div className="flex items-center justify-between border-b border-gray-200 px-6 py-4">
98
  <h3 className="text-lg font-semibold text-gray-900">{title}</h3>
99
  <button
100
  onClick={onClose}
101
- className="rounded-md p-2 text-gray-400 hover:bg-gray-100 hover:text-gray-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
102
  >
103
  <span className="sr-only">Close</span>
104
  <X className="h-5 w-5" />
@@ -106,7 +86,7 @@ const Modal: React.FC<ModalProps> = ({
106
  </div>
107
 
108
  {/* Content */}
109
- <div className="max-h-[calc(100vh-200px)] overflow-y-auto px-6 py-4">
110
  {children}
111
  </div>
112
  </div>
 
1
+ import React, { useEffect } from 'react'
2
  import { X } from 'lucide-react'
3
 
4
  interface ModalProps {
 
26
  children,
27
  maxWidth = '4xl'
28
  }) => {
 
 
 
 
 
29
  useEffect(() => {
30
  const handleEscape = (e: KeyboardEvent) => {
31
  if (e.key === 'Escape') {
 
34
  }
35
 
36
  if (isOpen) {
 
 
37
  document.addEventListener('keydown', handleEscape)
38
+ document.body.style.overflow = 'hidden'
39
+ }
40
+
41
+ return () => {
42
+ document.removeEventListener('keydown', handleEscape)
43
+ document.body.style.overflow = 'unset'
 
 
 
 
44
  }
45
  }, [isOpen, onClose])
46
 
47
+ if (!isOpen) return null
 
48
 
49
  const maxWidthClasses = {
50
  sm: 'max-w-sm',
 
63
  <div className="fixed inset-0 z-50 overflow-y-auto">
64
  {/* Backdrop */}
65
  <div
66
+ className="fixed inset-0 bg-black opacity-50 transition-opacity"
 
 
67
  onClick={onClose}
68
  />
69
 
70
  {/* Modal */}
71
  <div className="flex min-h-full items-center justify-center p-4 text-center sm:p-0">
72
  <div
73
+ className={`relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full ${maxWidthClasses[maxWidth]}`}
 
 
 
 
 
 
74
  onClick={(e) => e.stopPropagation()}
75
  >
76
  {/* Header */}
77
+ <div className="flex items-center justify-between px-6 py-4 border-b border-gray-200">
78
  <h3 className="text-lg font-semibold text-gray-900">{title}</h3>
79
  <button
80
  onClick={onClose}
81
+ className="rounded-md p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 focus:outline-hidden focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
82
  >
83
  <span className="sr-only">Close</span>
84
  <X className="h-5 w-5" />
 
86
  </div>
87
 
88
  {/* Content */}
89
+ <div className="px-6 py-4 max-h-[calc(100vh-200px)] overflow-y-auto">
90
  {children}
91
  </div>
92
  </div>