-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add supabase example showcasing list component (#2851)
- Loading branch information
1 parent
dd8d147
commit a6a1c4f
Showing
10 changed files
with
325 additions
and
8 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Supabase | ||
|
||
<p class="description">A Toolpad app that fetches data from Supabase and shows it in a list component.</p> | ||
|
||
<a target="_blank"> | ||
<img src="https://mui.com//static/toolpad/marketing/supabase.png" alt="Supabase integration" style="aspect-ratio: 1.8" width="100%"> | ||
</a> | ||
|
||
## How to run | ||
|
||
Download the example [or clone the repo](https://github.com/mui/mui-toolpad): | ||
|
||
<!-- #default-branch-switch --> | ||
|
||
```bash | ||
curl https://codeload.github.com/mui/mui-toolpad/tar.gz/master | tar -xz --strip=2 mui-toolpad-master/examples/supabase | ||
cd supabase | ||
``` | ||
|
||
Install it and run: | ||
|
||
```bash | ||
npm install | ||
npm run dev | ||
``` | ||
|
||
## What's inside | ||
|
||
This app demonstrates the following capabilities of Toolpad: | ||
|
||
1. Connecting to Supabase database using custom functions. | ||
2. Using the list component to create a basic product catalogue manager. | ||
|
||
[Check out the source code](https://github.com/mui/mui-toolpad/tree/master/examples/supabase) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "supabase", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "toolpad dev", | ||
"build": "toolpad build", | ||
"start": "toolpad start" | ||
}, | ||
"dependencies": { | ||
"@mui/toolpad": "0.1.34", | ||
"@supabase/supabase-js": "2.38.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
apiVersion: v1 | ||
kind: page | ||
spec: | ||
id: BKAYeeK | ||
title: Default page | ||
queries: | ||
- name: query | ||
query: | ||
function: supabase.ts#default | ||
kind: local | ||
content: | ||
- component: List | ||
name: list | ||
props: | ||
renderItem: | ||
$$template: | ||
- component: PageRow | ||
name: pageRow | ||
props: | ||
justifyContent: start | ||
children: | ||
- component: PageColumn | ||
name: pageColumn | ||
layout: | ||
columnSize: 1.2040938643407977 | ||
children: | ||
- component: Text | ||
name: text | ||
props: | ||
mode: markdown | ||
value: | ||
$$jsExpression: | | ||
`### ${query.data[i].name}` | ||
layout: | ||
columnSize: 1.400990099009901 | ||
verticalAlign: end | ||
- component: Text | ||
name: text2 | ||
props: | ||
mode: markdown | ||
value: | ||
$$jsExpression: | | ||
`** ${query.data[i].description} **` | ||
layout: | ||
verticalAlign: start | ||
- component: Text | ||
name: text4 | ||
props: | ||
mode: markdown | ||
value: | ||
$$jsExpression: | | ||
`Date added: ${query.data[i].date_added}` | ||
layout: | ||
columnSize: 1 | ||
verticalAlign: center | ||
- component: PageRow | ||
name: pageRow1 | ||
props: | ||
justifyContent: start | ||
children: | ||
- component: PageColumn | ||
name: pageColumn1 | ||
layout: | ||
columnSize: 1 | ||
children: | ||
- component: PageRow | ||
name: pageRow3 | ||
props: | ||
justifyContent: start | ||
children: | ||
- component: Text | ||
name: text1 | ||
layout: | ||
columnSize: 1 | ||
verticalAlign: center | ||
props: | ||
mode: markdown | ||
value: | ||
$$jsExpression: > | ||
`Quantity left: | ||
${query.data[i].quantity}` | ||
- component: Text | ||
name: text3 | ||
layout: | ||
verticalAlign: center | ||
props: | ||
value: | ||
$$jsExpression: | | ||
`Price: $${query.data[i].price}` | ||
mode: text | ||
- component: PageRow | ||
name: pageRow2 | ||
props: | ||
justifyContent: start | ||
children: | ||
- component: Text | ||
name: text5 | ||
layout: | ||
columnSize: 1 | ||
verticalAlign: center | ||
props: | ||
mode: markdown | ||
value: | ||
$$jsExpression: > | ||
`Average rating: ${query.data[i].rating}` | ||
- component: Checkbox | ||
name: checkbox | ||
props: | ||
label: Offer discount? | ||
- component: Image | ||
name: image | ||
props: | ||
src: | ||
$$jsExpression: | | ||
query.data[i].image | ||
width: 200 | ||
height: 200 | ||
layout: | ||
columnSize: 0.7959061356592024 | ||
horizontalAlign: center | ||
itemCount: 10 | ||
display: standalone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { createClient } from '@supabase/supabase-js'; | ||
|
||
const supabaseUrl = 'https://qlhkchzecwkyfcvxmwmb.supabase.co'; | ||
const supabaseKey = process.env.SUPABASE_KEY; | ||
const supabase = createClient(supabaseUrl, supabaseKey ?? ''); | ||
|
||
export default async function handler() { | ||
const { data } = await supabase.from('product_data').select('*'); | ||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters