The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: add select option component
Muhammad Rivki50c9baf14315
diff --git a/supabase-ui/src/components/Select/Select.css b/supabase-ui/src/components/Select/Select.cssnew file mode 100644index 00000000000..f13770d017c--- /dev/null+++ b/supabase-ui/src/components/Select/Select.css@@ -0,0 +1,7 @@+.form-select:disabled {+ @apply bg-gray-100 cursor-not-allowed;+}++.form-select--error {+ @apply border-red-500;+}diff --git a/supabase-ui/src/components/Select/Select.js b/supabase-ui/src/components/Select/Select.jsnew file mode 100644index 00000000000..ecfef32736e--- /dev/null+++ b/supabase-ui/src/components/Select/Select.js@@ -0,0 +1,32 @@+import React from 'react'+import PropTypes from 'prop-types'+import './Select.css'++const Textarea = ({+ className = '',+ isError = false,+ children,+ ...props+}) => {+ const classes = []++ if (isError) {+ classes.push('form-select--error')+ }++ return (+ <select+ className={`form-select border-solid ${classes.join(' ')} ${className}`}+ {...props}+ >+ {children}+ </select>+ )+}++Textarea.propTypes = {+ isError: PropTypes.bool,+ className: PropTypes.string,+}++export default Textareadiff --git a/supabase-ui/src/components/Select/Select.stories.js b/supabase-ui/src/components/Select/Select.stories.jsnew file mode 100644index 00000000000..e1766cdf2a1--- /dev/null+++ b/supabase-ui/src/components/Select/Select.stories.js@@ -0,0 +1,18 @@+import React from 'react'++import { Select } from '.'++export default {+ title: 'Form/Select',+ component: Select,+}++export const Default = (args) => (<Select {...args}>+ <option>JavaScript</option>+ <option>TypeScript</option>+ <option>React</option>+</Select>)++Default.args = {+ disabled: false+}diff --git a/supabase-ui/src/components/Select/Select.test.js b/supabase-ui/src/components/Select/Select.test.jsnew file mode 100644index 00000000000..35e2b81fbad--- /dev/null+++ b/supabase-ui/src/components/Select/Select.test.js@@ -0,0 +1,25 @@+import React from 'react'+import { render, screen } from '@testing-library/react'+import Select from './Select'++describe('#Select', () => {+ it('should render select correctly', async () => {+ render(+ <Select data-testid="form-select">+ <option>1</option>+ <option>2</option>+ </Select>+ )+ expect(screen.queryByTestId('form-select')).toBeInTheDocument()+ })++ it('should have "form-select--error" class', () => {+ render(+ <Select isError data-testid="form-select">+ <option>1</option>+ <option>2</option>+ </Select>+ )+ expect(screen.queryByTestId('form-select')).toHaveClass('form-select border-solid form-select--error')+ })+})\ No newline at end of filediff --git a/supabase-ui/src/components/Select/index.js b/supabase-ui/src/components/Select/index.jsnew file mode 100644index 00000000000..b9b41e1b348--- /dev/null+++ b/supabase-ui/src/components/Select/index.js@@ -0,0 +1 @@+export { default as Select } from './Select'