Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: add textarea input

Muhammad Rivki8a4b6ab51fd0
diff --git a/supabase-ui/src/components/Input/Input.css b/supabase-ui/src/components/Input/Input.css
index 58bca693e25..da67b809b72 100644
--- a/supabase-ui/src/components/Input/Input.css
+++ b/supabase-ui/src/components/Input/Input.css
@@ -1,5 +1,5 @@
.form-input:disabled {
- @apply bg-gray-100;
+ @apply bg-gray-100 cursor-not-allowed;
}
.form-input--small {
diff --git a/supabase-ui/src/components/Input/Input.test.js b/supabase-ui/src/components/Input/Input.test.js
index 050eea2925e..98fb06abcf9 100644
--- a/supabase-ui/src/components/Input/Input.test.js
+++ b/supabase-ui/src/components/Input/Input.test.js
@@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/react'
import Input, { SIZES } from './Input'
describe('#Input', () => {
- it('should render button correctly', async () => {
+ it('should render input correctly', async () => {
render(<Input data-testid="form-input" />)
expect(screen.queryByTestId('form-input')).toBeInTheDocument()
})
diff --git a/supabase-ui/src/components/Textarea/Textarea.css b/supabase-ui/src/components/Textarea/Textarea.css
new file mode 100644
index 00000000000..cb34744c4b3
--- /dev/null
+++ b/supabase-ui/src/components/Textarea/Textarea.css
@@ -0,0 +1,7 @@
+.form-textarea:disabled {
+ @apply bg-gray-100 cursor-not-allowed;
+}
+
+.form-textarea--error {
+ @apply border-red-500;
+}
diff --git a/supabase-ui/src/components/Textarea/Textarea.js b/supabase-ui/src/components/Textarea/Textarea.js
new file mode 100644
index 00000000000..5946a84ef06
--- /dev/null
+++ b/supabase-ui/src/components/Textarea/Textarea.js
@@ -0,0 +1,32 @@
+import React from 'react'
+import PropTypes from 'prop-types'
+import './Textarea.css'
+
+const Textarea = ({
+ className = '',
+ isError = false,
+ rows = 3,
+ children,
+ ...props
+}) => {
+ const classes = []
+
+ if (isError) {
+ classes.push('form-textarea--error')
+ }
+
+ return (
+ <textarea
+ className={`form-textarea border-solid ${classes.join(' ')} ${className}`}
+ rows={rows}
+ {...props}
+ />
+ )
+}
+
+Textarea.propTypes = {
+ isError: PropTypes.bool,
+ className: PropTypes.string,
+}
+
+export default Textarea
diff --git a/supabase-ui/src/components/Textarea/Textarea.spec.js b/supabase-ui/src/components/Textarea/Textarea.spec.js
new file mode 100644
index 00000000000..47730087d8a
--- /dev/null
+++ b/supabase-ui/src/components/Textarea/Textarea.spec.js
@@ -0,0 +1,15 @@
+import React from 'react'
+import { render, screen } from '@testing-library/react'
+import Textarea from './Textarea'
+
+describe('#Textarea', () => {
+ it('should render textarea correctly', async () => {
+ render(<Textarea data-testid="form-textarea" />)
+ expect(screen.queryByTestId('form-textarea')).toBeInTheDocument()
+ })
+
+ it('should have "form-textarea--error" class', () => {
+ render(<Textarea isError data-testid="form-textarea" />)
+ expect(screen.queryByTestId('form-textarea')).toHaveClass('form-textarea border-solid form-textarea--error')
+ })
+})
\ No newline at end of file
diff --git a/supabase-ui/src/components/Textarea/Textarea.stories.js b/supabase-ui/src/components/Textarea/Textarea.stories.js
new file mode 100644
index 00000000000..55920862ae9
--- /dev/null
+++ b/supabase-ui/src/components/Textarea/Textarea.stories.js
@@ -0,0 +1,14 @@
+import React from 'react'
+
+import { Textarea } from '.'
+
+export default {
+ title: 'Basic/Textarea',
+ component: Textarea,
+}
+
+export const Default = (args) => <Textarea {...args} />
+Default.args = {
+ placeholder: 'Type text here ...',
+ disabled: false
+}
diff --git a/supabase-ui/src/components/Textarea/index.js b/supabase-ui/src/components/Textarea/index.js
new file mode 100644
index 00000000000..57766a9ef20
--- /dev/null
+++ b/supabase-ui/src/components/Textarea/index.js
@@ -0,0 +1 @@
+export { default as Textarea } from './Textarea'