The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: add icon component
Muhammad Rivki70b2e41aa85e
diff --git a/supabase-ui/src/components/Icon/Icon.css b/supabase-ui/src/components/Icon/Icon.cssnew file mode 100644index 00000000000..e69de29bb2ddiff --git a/supabase-ui/src/components/Icon/Icon.js b/supabase-ui/src/components/Icon/Icon.jsnew file mode 100644index 00000000000..783dae0da46--- /dev/null+++ b/supabase-ui/src/components/Icon/Icon.js@@ -0,0 +1,31 @@+import React from 'react'+import * as Icons from 'react-feather'+import PropTypes from 'prop-types'++const Icon = ({+ className,+ size = 24,+ type = 'Activity',+ strokeWidth = 2,+ ...props+}) => {+ const FeatherIcon = Icons[type]++ return (+ <FeatherIcon+ className={`${className}`}+ strokeWidth={strokeWidth}+ size={size}+ {...props}+ />+ )+}++Icon.propTypes = {+ size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),+ strokeWidth: PropTypes.number,+ type: PropTypes.string,+ className: PropTypes.string,+}++export default Icondiff --git a/supabase-ui/src/components/Icon/Icon.stories.js b/supabase-ui/src/components/Icon/Icon.stories.jsnew file mode 100644index 00000000000..baa943ef249--- /dev/null+++ b/supabase-ui/src/components/Icon/Icon.stories.js@@ -0,0 +1,45 @@+import React from 'react'+import * as Icons from 'react-feather'++import { Icon } from '.'++const LIST_ICONS = Object.keys(Icons)++export default {+ title: 'Basic/Icon',+ component: Icon,+}++export const Default = (args) => (+ <div className="block font-sans">+ <div>+ <Icon {...args} />+ </div>+ </div>+)+Default.argTypes = {+ type: {+ control: {+ type: 'select',+ options: LIST_ICONS,+ },+ },+}++export const ListIcons = () => (+ <>+ <div className="font-sans text-xl bg-blue-100 p-5 mb-3 rounded-md">+ This icons uses react-feather from Feather Icons. For detail you can check+ it <a href="https://github.com/feathericons/react-feather">here</a> and{' '}+ <a href="https://feathericons.com/">here</a>+ </div>+ <div className="flex flex-wrap font-sans">+ {LIST_ICONS.map((icon) => (+ <div className="m-2 shadow-lg rounded-lg w-36 h-36 flex flex-col justify-center items-center">+ <Icon type={icon} key={icon} />+ <span className="mt-2">{icon}</span>+ </div>+ ))}+ </div>+ </>+)diff --git a/supabase-ui/src/components/Icon/Icon.test.js b/supabase-ui/src/components/Icon/Icon.test.jsnew file mode 100644index 00000000000..865c70baa4b--- /dev/null+++ b/supabase-ui/src/components/Icon/Icon.test.js@@ -0,0 +1,26 @@+import React from 'react'+import { render, screen } from '@testing-library/react'+import Icon from './Icon'++describe('#Icon', () => {+ it('should render Icon correctly', () => {+ render(<Icon data-testid="icon" />)+ const $elIcon = screen.queryByTestId('icon')+ expect($elIcon).toBeInTheDocument()+ })++ it('should change svg size', () => {+ render(<Icon data-testid="icon" size={40} />)++ const $elIcon = screen.queryByTestId('icon')+ expect($elIcon.getAttribute('width')).toEqual('40')+ expect($elIcon.getAttribute('height')).toEqual('40')+ })++ it('should change strokeWidth value', () => {+ render(<Icon data-testid="icon" strokeWidth={1} />)++ const $elIcon = screen.queryByTestId('icon')+ expect($elIcon.getAttribute('stroke-width')).toEqual('1')+ })+})diff --git a/supabase-ui/src/components/Icon/index.js b/supabase-ui/src/components/Icon/index.jsnew file mode 100644index 00000000000..e4375f59b8d--- /dev/null+++ b/supabase-ui/src/components/Icon/index.js@@ -0,0 +1 @@+export { default as Icon } from './Icon'diff --git a/supabase-ui/src/index.js b/supabase-ui/src/index.jsindex a47a8dab06a..9d805074824 100644--- a/supabase-ui/src/index.js+++ b/supabase-ui/src/index.js@@ -1,5 +1,6 @@export * from './components/Button/index'export * from './components/Toggle/index'+export * from './components/Icon/index'// FORMexport * from './components/Checkbox/index'