Skip to content

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

Adds a nicer scrollbar to code blocks (needs testing on windows)

Paul Copplestoneb97a375d68cf
diff --git a/web/package-lock.json b/web/package-lock.json
index 1eba0cb0f34..7d76c075e4c 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -7817,6 +7817,11 @@
"sha.js": "^2.4.8"
}
},
+ "perfect-scrollbar": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/perfect-scrollbar/-/perfect-scrollbar-1.4.0.tgz",
+ "integrity": "sha512-/2Sk/khljhdrsamjJYS5NjrH+GKEHEwh7zFSiYyxROyYKagkE4kSn2zDQDRTOMo8mpT2jikxx6yI1dG7lNP/hw=="
+ },
"performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
@@ -9391,6 +9396,15 @@
"resolved": "https://registry.npmjs.org/react-loadable-ssr-addon/-/react-loadable-ssr-addon-0.2.0.tgz",
"integrity": "sha512-gTfPaxWZa5mHKeSOE61RpoLe7hyjcJHgNa5m0ZZGV3OCkWsOKlfYgoBxXzu9ENg/ePR/kFd5H3ncF4K5eyyNTQ=="
},
+ "react-perfect-scrollbar": {
+ "version": "1.5.3",
+ "resolved": "https://registry.npmjs.org/react-perfect-scrollbar/-/react-perfect-scrollbar-1.5.3.tgz",
+ "integrity": "sha512-2fVqbDJgOb1siCCJozGbv22cAHnh6TI9HFHRpM0lBJTPPM0ajgmsU75mBnI3k0ndryo+JiwUbLKACrurx1BjBw==",
+ "requires": {
+ "perfect-scrollbar": "^1.4.0",
+ "prop-types": "^15.6.1"
+ }
+ },
"react-router": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-5.1.2.tgz",
diff --git a/web/package.json b/web/package.json
index 285fb4e332c..a896fea9cff 100755
--- a/web/package.json
+++ b/web/package.json
@@ -13,7 +13,8 @@
"classnames": "^2.2.6",
"react": "^16.8.4",
"react-dom": "^16.8.4",
- "react-inlinesvg": "^1.2.0"
+ "react-inlinesvg": "^1.2.0",
+ "react-perfect-scrollbar": "^1.5.3"
},
"browserslist": {
"production": [
diff --git a/web/src/components/CustomCodeBlock.js b/web/src/components/CustomCodeBlock.js
new file mode 100644
index 00000000000..e1d5440679d
--- /dev/null
+++ b/web/src/components/CustomCodeBlock.js
@@ -0,0 +1,15 @@
+import 'react-perfect-scrollbar/dist/css/styles.css'
+import React from 'react'
+import CodeBlock from '@theme/CodeBlock'
+import PerfectScrollbar from 'react-perfect-scrollbar'
+
+export default function CustomCodeBlock({ header, js }) {
+ return (
+ <div className={header ? 'code-with-header' : ''}>
+ {header && <div className="code-header">{header}</div>}
+ <PerfectScrollbar>
+ <CodeBlock>{js}</CodeBlock>
+ </PerfectScrollbar>
+ </div>
+ )
+}
diff --git a/web/src/css/custom.css b/web/src/css/custom.css
index 4f574a35686..194d271e5e6 100755
--- a/web/src/css/custom.css
+++ b/web/src/css/custom.css
@@ -1,14 +1,14 @@
+
+@import url('https://gitcdn.xyz/repo/kiwicopple/assets/master/public/css/metro.css');
+
+
/**
* Root variables
*
* Override the default Infima variables here. These values cascade down to
* the rest of the elements.
*/
-/* @import url('https://min.gitcdn.xyz/repo/kiwicopple/assets/master/public/css/circular.css'); */
-/* @import url('https://gitcdn.xyz/repo/kiwicopple/assets/master/public/css/gilmer.css'); */
-@import url('https://gitcdn.xyz/repo/kiwicopple/assets/master/public/css/metro.css');
-/* @import url('https://rsms.me/inter/inter.css'); */
-
+
:root,
:root[data-theme=''],
:root[data-theme='dark'] {
diff --git a/web/src/pages/index.js b/web/src/pages/index.js
index 4ee6ce5957d..4132c78fc80 100755
--- a/web/src/pages/index.js
+++ b/web/src/pages/index.js
@@ -6,6 +6,7 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext'
import useBaseUrl from '@docusaurus/useBaseUrl'
import styles from './styles.module.css'
import CodeBlock from '@theme/CodeBlock'
+import CustomCodeBlock from '../components/CustomCodeBlock'
const heroExample = `
import { createClient } from '@supabase/supabase-js'
@@ -57,7 +58,7 @@ import { createClient } from '@supabase/supabase-js'
const supabase = createClient('https://chat-room.supabase.co', '1a2b-3c4d-5e6f-7g8h')
// Create a new chat room
-const newRoom = supabase
+const newRoom = await supabase
.from('rooms')
.insert({ name: 'Supabase Fan Club', public: true })
`.trim()
@@ -68,7 +69,7 @@ import { createClient } from '@supabase/supabase-js'
const supabase = createClient('https://chat-room.supabase.co', '1a2b-3c4d-5e6f-7g8h')
// Update a user
-const updatedUser = supabase
+const updatedUser = await supabase
.from('users')
.eq('username', 'kiwicopple')
.update({ status: 'Online' })
@@ -155,9 +156,11 @@ function Home() {
</Link>
</div>
</div>
- <div className="col col--7 code-with-header">
- <div className="code-header">Get notified of all new records in your database</div>
- <CodeBlock>{heroExample}</CodeBlock>
+ <div className="col col--7">
+ <CustomCodeBlock
+ header="Get notified of all new records in your database"
+ js={heroExample}
+ />
</div>
</div>
</div>
@@ -227,30 +230,22 @@ function Home() {
</div>
<div className="col col--9 code-with-header">
{visibleCodeExample === 'SUBSCRIBE' && (
- <>
- <div className="code-header">
- Receive realtime messages in an example chat room
- </div>
- <CodeBlock>{subscribeExample}</CodeBlock>
- </>
+ <CustomCodeBlock
+ header="Receive realtime messages in an example chat room"
+ js={subscribeExample}
+ />
)}
{visibleCodeExample === 'READ' && (
- <>
- <div className="code-header">Get all public rooms and their messages</div>
- <CodeBlock>{readExample}</CodeBlock>
- </>
+ <CustomCodeBlock
+ header="Get all public rooms and their messages"
+ js={readExample}
+ />
)}
{visibleCodeExample === 'CREATE' && (
- <>
- <div className="code-header">Create a new chat room</div>
- <CodeBlock>{createExample}</CodeBlock>
- </>
+ <CustomCodeBlock header="Create a new chat room" js={createExample} />
)}
{visibleCodeExample === 'UPDATE' && (
- <>
- <div className="code-header">Update a user</div>
- <CodeBlock>{updateExample}</CodeBlock>
- </>
+ <CustomCodeBlock header="Update a user" js={updateExample} />
)}
</div>
</div>