From ed7e46b6ca0536399a046e53721d504be6d8d3a9 Mon Sep 17 00:00:00 2001 From: balibabu Date: Mon, 2 Dec 2024 19:33:20 +0800 Subject: [PATCH] Feat: Add TestingForm #3221 (#3810) ### What problem does this PR solve? Feat: Add TestingForm #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/package-lock.json | 33 ++++ web/package.json | 1 + web/src/components/ui/slider.tsx | 49 ++++++ web/src/components/ui/textarea.tsx | 22 +++ web/src/pages/dataset/testing/index.tsx | 57 +++++- .../pages/dataset/testing/testing-form.tsx | 163 ++++++++++++++++++ web/tailwind.css | 2 +- 7 files changed, 325 insertions(+), 2 deletions(-) create mode 100644 web/src/components/ui/slider.tsx create mode 100644 web/src/components/ui/textarea.tsx create mode 100644 web/src/pages/dataset/testing/testing-form.tsx diff --git a/web/package-lock.json b/web/package-lock.json index 9202ed867..f8380b436 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -23,6 +23,7 @@ "@radix-ui/react-popover": "^1.1.2", "@radix-ui/react-select": "^2.1.2", "@radix-ui/react-separator": "^1.1.0", + "@radix-ui/react-slider": "^1.2.1", "@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-switch": "^1.1.1", "@radix-ui/react-tabs": "^1.1.1", @@ -4751,6 +4752,38 @@ } } }, + "node_modules/@radix-ui/react-slider": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/@radix-ui/react-slider/-/react-slider-1.2.1.tgz", + "integrity": "sha512-bEzQoDW0XP+h/oGbutF5VMWJPAl/UU8IJjr7h02SOHDIIIxq+cep8nItVNoBV+OMmahCdqdF38FTpmXoqQUGvw==", + "dependencies": { + "@radix-ui/number": "1.1.0", + "@radix-ui/primitive": "1.1.0", + "@radix-ui/react-collection": "1.1.0", + "@radix-ui/react-compose-refs": "1.1.0", + "@radix-ui/react-context": "1.1.1", + "@radix-ui/react-direction": "1.1.0", + "@radix-ui/react-primitive": "2.0.0", + "@radix-ui/react-use-controllable-state": "1.1.0", + "@radix-ui/react-use-layout-effect": "1.1.0", + "@radix-ui/react-use-previous": "1.1.0", + "@radix-ui/react-use-size": "1.1.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-slot": { "version": "1.1.0", "resolved": "https://registry.npmmirror.com/@radix-ui/react-slot/-/react-slot-1.1.0.tgz", diff --git a/web/package.json b/web/package.json index 00882e161..63ecd6930 100644 --- a/web/package.json +++ b/web/package.json @@ -34,6 +34,7 @@ "@radix-ui/react-popover": "^1.1.2", "@radix-ui/react-select": "^2.1.2", "@radix-ui/react-separator": "^1.1.0", + "@radix-ui/react-slider": "^1.2.1", "@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-switch": "^1.1.1", "@radix-ui/react-tabs": "^1.1.1", diff --git a/web/src/components/ui/slider.tsx b/web/src/components/ui/slider.tsx new file mode 100644 index 000000000..f025182d9 --- /dev/null +++ b/web/src/components/ui/slider.tsx @@ -0,0 +1,49 @@ +'use client'; + +import * as SliderPrimitive from '@radix-ui/react-slider'; +import * as React from 'react'; + +import { cn } from '@/lib/utils'; + +const Slider = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + + + +)); +Slider.displayName = SliderPrimitive.Root.displayName; + +type SliderProps = Omit< + React.ComponentPropsWithoutRef, + 'onChange' | 'value' +> & { onChange: (value: number) => void; value: number }; + +const FormSlider = React.forwardRef< + React.ElementRef, + SliderProps +>(({ onChange, value, ...props }, ref) => ( + { + onChange(vals[0]); + }} + > +)); + +Slider.displayName = SliderPrimitive.Root.displayName; + +export { FormSlider, Slider }; diff --git a/web/src/components/ui/textarea.tsx b/web/src/components/ui/textarea.tsx new file mode 100644 index 000000000..63745407e --- /dev/null +++ b/web/src/components/ui/textarea.tsx @@ -0,0 +1,22 @@ +import * as React from 'react'; + +import { cn } from '@/lib/utils'; + +const Textarea = React.forwardRef< + HTMLTextAreaElement, + React.ComponentProps<'textarea'> +>(({ className, ...props }, ref) => { + return ( + + + + This is your public display name. + + + + )} + /> + + + + ); +} diff --git a/web/tailwind.css b/web/tailwind.css index cb16f6b70..c42f613a3 100644 --- a/web/tailwind.css +++ b/web/tailwind.css @@ -132,7 +132,7 @@ @apply border-border; } body { - @apply bg-background text-foreground; + @apply bg-colors-background-neutral-standard text-foreground; font-feature-settings: 'rlig' 1, 'calt' 1;