Skip to content

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

chore: more fixes to typography in dark mode

Jonathan Summers-Muir3c7878fcc44e
diff --git a/www/_blog/2022-03-08-audit.mdx b/www/_blog/2022-03-08-audit.mdx
index 97d08d91aaf..6d3fd35e44e 100644
--- a/www/_blog/2022-03-08-audit.mdx
+++ b/www/_blog/2022-03-08-audit.mdx
@@ -1,7 +1,7 @@
---
title: Postgres Auditing in 150 lines of SQL
description: PostgreSQL has a robust set of features which we can leverage to create a generic auditing solution in 150 lines of SQL.
-author: oli_rice
+author: [oli_rice, kiwicopple]
author_url: https://github.com/olirice
author_image_url: https://github.com/olirice.png
authorURL: https://github.com/olirice
@@ -13,15 +13,14 @@ date: '2022-03-08'
toc_depth: 3
---
-
-Data auditing is a system that tracks changes to tables' contents over time.
+Data auditing is a system that tracks changes to tables' contents over time.
PostgreSQL has a robust set of features which we can leverage to create a generic auditing solution in 150 lines of SQL.
-Auditing is particularly useful for historical analysis. To demonstrate, imagine you have a `users` table that tracks when a user is online.
-You might add a `status` column which can have one of two values: `online` and `offline`. How would you track how long a user is online for throughout an entire month?
+Auditing is particularly useful for historical analysis. To demonstrate, imagine you have a `users` table that tracks when a user is online.
+You might add a `status` column which can have one of two values: `online` and `offline`. How would you track how long a user is online for throughout an entire month?
An auditing system would track every change with timestamps, and so you can measure the difference between each timestamp and sum them up for the entire month.
-The goals of our auditing solution are:
+The goals of our auditing solution are:
- low maintenance
- easy to use
@@ -60,11 +59,11 @@ select * from audit.record_history
```
```markdown
- id | record_id | old_record_id | op | ts | table_oid | table_schema | table_name | record | old_record
+id | record_id | old_record_id | op | ts | table_oid | table_schema | table_name | record | old_record
----+--------------------------------------+--------------------------------------+--------+-------------------------------------+-----------+--------------+------------+--------------------------+--------------------------
- 2 | 1ecd5ff0-1b6b-5bc2-ad80-1cb19769c081 | | INSERT | Mon Feb 28 18:13:52.698511 2022 PST | 16452 | public | members | {"id": 1, "name": "foo"} |
- 3 | 1ecd5ff0-1b6b-5bc2-ad80-1cb19769c081 | 1ecd5ff0-1b6b-5bc2-ad80-1cb19769c081 | UPDATE | Mon Feb 28 18:13:52.698511 2022 PST | 16452 | public | members | {"id": 1, "name": "bar"} | {"id": 1, "name": "foo"}
- 4 | | 1ecd5ff0-1b6b-5bc2-ad80-1cb19769c081 | DELETE | Mon Feb 28 18:13:52.698511 2022 PST | 16452 | public | members | | {"id": 1, "name": "bar"}
+2 | 1ecd5ff0-1b6b-5bc2-ad80-1cb19769c081 | | INSERT | Mon Feb 28 18:13:52.698511 2022 PST | 16452 | public | members | {"id": 1, "name": "foo"} |
+3 | 1ecd5ff0-1b6b-5bc2-ad80-1cb19769c081 | 1ecd5ff0-1b6b-5bc2-ad80-1cb19769c081 | UPDATE | Mon Feb 28 18:13:52.698511 2022 PST | 16452 | public | members | {"id": 1, "name": "bar"} | {"id": 1, "name": "foo"}
+4 | | 1ecd5ff0-1b6b-5bc2-ad80-1cb19769c081 | DELETE | Mon Feb 28 18:13:52.698511 2022 PST | 16452 | public | members | | {"id": 1, "name": "bar"}
(3 rows)
```
@@ -74,10 +73,9 @@ Notice that our `record_id` and `old_record_id` stayed constant as we updated th
### Namespace
-To quote a tenet from [the zen of python](https://www.python.org/dev/peps/pep-0020/):
+To quote a tenet from [the zen of python](https://www.python.org/dev/peps/pep-0020/):
> Namespaces are one honking great idea -- let's do more of those!
->
So first things first, we'll create a separate schema named `audit` to house our auditing entities.
@@ -89,12 +87,12 @@ create schema if not exists audit;
Next, we need a table to track inserts, updates and deletes.
-Classically, an audit table's schema mirrors the table being audited and appends some metadata columns like the commit's timestamp. That solution has a few maintenance challenges:
+Classically, an audit table's schema mirrors the table being audited and appends some metadata columns like the commit's timestamp. That solution has a few maintenance challenges:
- enabling auditing on a table requires a database migration
- when the source table's schema changes, the audit table's schema must also change
-So instead, we'll lean on PostgreSQL's schema-less [`JSONB` data type](https://www.postgresql.org/docs/current/datatype-json.html) to store each record's data in a single column.
+So instead, we'll lean on PostgreSQL's schema-less [`JSONB` data type](https://www.postgresql.org/docs/current/datatype-json.html) to store each record's data in a single column.
That approach has the added benefit of allowing us to store multiple tables' audit history in a single audit table.
```sql
@@ -110,23 +108,22 @@ create table audit.record_version(
table_schema name not null, -- audited table's schema name e.g. 'public'
table_name name not null, -- audited table's table name e.g. 'account'
-- record data
- record jsonb, -- contents of the new record
+ record jsonb, -- contents of the new record
old_record jsonb -- previous record contents (for UPDATE/DELETE)
);
```
<details>
-<summary>Postgres version compatibility</summary>
-<p>
-The table above uses PostgreSQL's built-in <a href="https://www.postgresql.org/docs/14/functions-uuid.html">uuid functionality</a>, which is available from version 14.
-For backwards compatibility you can use the uuid-ossp extension.
-</p>
-<p>
-<code>create extension if not exists "uuid-ossp";</code>
-</p>
+ <summary>Postgres version compatibility</summary>
+ <p>
+ The table above uses PostgreSQL's built-in{' '}
+ <a href="https://www.postgresql.org/docs/14/functions-uuid.html">uuid functionality</a>, which
+ is available from version 14. For backwards compatibility you can use the uuid-ossp extension.
+ </p>
+ <p>
+ <code>create extension if not exists "uuid-ossp";</code>
+ </p>
</details>
-
-
### Query Patterns
@@ -134,7 +131,7 @@ An audit log doesn't do us much good if its too slow to query! There are 2 query
**Changes to a Table in a Time Range**
-For time slices, we need an index on the `ts` column. Since the table is append-only and the `ts` column is populated by insertion date, our values for `ts` are naturally in ascending order.
+For time slices, we need an index on the `ts` column. Since the table is append-only and the `ts` column is populated by insertion date, our values for `ts` are naturally in ascending order.
PostgreSQL's builtin [BRIN index](https://www.postgresql.org/docs/current/brin-intro.html) can leverage that correlation between value and physical location to produce an index that, at scale, is many hundreds of times smaller than the default (BTREE index) with faster lookup times.
@@ -213,7 +210,7 @@ as $$
select
uuid_generate_v5(
'fd62bc3d-8d6e-43c2-919c-802ba3762271',
- (
+ (
jsonb_build_array(to_jsonb($1))
|| jsonb_agg($3 ->> key_)
)::text
diff --git a/www/components/Footer/index.tsx b/www/components/Footer/index.tsx
index 3612d39f684..3bb8cc544b6 100644
--- a/www/components/Footer/index.tsx
+++ b/www/components/Footer/index.tsx
@@ -125,7 +125,7 @@ const Footer = () => {
</div>
</div>
<div className="mt-32 border-t border-scale-500 dark:border-scale-600 pt-8 flex justify-between">
- <p className="mb-0 self-center text-base">&copy; Supabase Inc</p>
+ <small className="small">&copy; Supabase Inc</small>
<DarkModeToggle />
</div>
</SectionContainer>
diff --git a/www/components/Hero.tsx b/www/components/Hero.tsx
index 3f8f0d4e8b1..8b938e8b954 100644
--- a/www/components/Hero.tsx
+++ b/www/components/Hero.tsx
@@ -23,18 +23,20 @@ const Hero = () => {
<h1
className="
sm:leading-none
- text-xl lg:text-4xl xl:text-5xl"
+ text-xl lg:text-4xl xl:text-5xl
+ text-scale-1200
+ "
>
<span className="block">The Open Source</span>
<span className="text-brand-900 md:ml-0 block">Firebase Alternative</span>
</h1>
<div>
- <p className="text-base sm:mt-5 lg:text-lg ">
+ <p className="p text-base sm:mt-5 lg:text-lg ">
Create a backend in less than 2 minutes. Start your project with a
Postgres Database, Authentication, instant APIs, Realtime subscriptions
and Storage.
</p>
- <p className="text-base">Serverless functions coming soon</p>
+ <p className="p text-base">Serverless functions coming soon</p>
</div>
</div>
<div className="flex gap-2 items-center">
@@ -50,7 +52,7 @@ const Hero = () => {
</Link>
</div>
<div className="flex flex-col gap-4">
- <small className="text-xs">backed by</small>
+ <small className="small text-xs">backed by</small>
<div className="w-full sm:max-w-lg lg:ml-0">
<div className="flex flex-wrap items-center justify-start">
<img
diff --git a/www/components/Sections/ProductHeader.tsx b/www/components/Sections/ProductHeader.tsx
index e40752d52ef..b9665438ae1 100644
--- a/www/components/Sections/ProductHeader.tsx
+++ b/www/components/Sections/ProductHeader.tsx
@@ -19,7 +19,7 @@ const ProductHeader = (props: Types) => (
<div className="col-span-12 lg:col-span-5 space-y-8">
<div>
{props.icon || props.title ? (
- <div className="flex mb-4 items-center gap-2">
+ <div className="flex mb-4 items-center gap-3">
{props.icon && <ProductIcon icon={props.icon} />}
{props.title && (
<span className="text-scale-1200" key={`product-name-${props.title}`}>
diff --git a/www/pages/blog.tsx b/www/pages/blog.tsx
index 25f40998670..02d3e89fa3b 100644
--- a/www/pages/blog.tsx
+++ b/www/pages/blog.tsx
@@ -138,7 +138,7 @@ function FeaturedThumb(blog: PostTypes) {
<div key={blog.slug} className="cursor-pointer w-full">
<a href={`/blog/${blog.url}`}>
<a className="grid lg:grid-cols-2 gap-8 lg:gap-16">
- <div className="relative overflow-auto w-full h-96 border dark:border-dark rounded-lg">
+ <div className="relative overflow-auto w-full h-96 border rounded-lg">
<Image
src={`/images/blog/` + (blog.thumb ? blog.thumb : blog.image)}
layout="fill"
@@ -146,17 +146,15 @@ function FeaturedThumb(blog: PostTypes) {
/>
</div>
<div className="flex flex-col space-y-2">
- <div className="flex space-x-2 text-sm">
+ <div className="text-scale-900 flex space-x-2 text-sm">
<p>{blog.date}</p>
<p>•</p>
<p>{blog.readingTime}</p>
</div>
<div>
- <h2 className="text-4xl">{blog.title}</h2>
- <p className="m-0">
- <span className="text-xl">{blog.description}</span>
- </p>
+ <h2 className="h2">{blog.title}</h2>
+ <p className="p text-xl">{blog.description}</p>
</div>
{author && (
diff --git a/www/pages/blog/[year]/[month]/[day]/[slug].tsx b/www/pages/blog/[year]/[month]/[day]/[slug].tsx
index 5a57a9e6c3f..6345fdfc31b 100644
--- a/www/pages/blog/[year]/[month]/[day]/[slug].tsx
+++ b/www/pages/blog/[year]/[month]/[day]/[slug].tsx
@@ -102,22 +102,17 @@ function BlogPostPage(props: any) {
return (
<Link href={`/blog/${post.url}`} as={`/blog/${post.url}`}>
<div className={className}>
- <Card className="cursor-pointer" hoverable>
- <Space direction="vertical">
+ <div className="cursor-pointer border border-scale-500 p-6 transition rounded hover:bg-scale-100 dark:hover:bg-scale-300">
+ <div className="space-y-4">
<div>
- <p>{label}</p>
+ <p className="text-sm text-scale-900">{label}</p>
</div>
<div>
- <h4>{post.title}</h4>
- <p>{post.date}</p>
+ <h4 className="text-lg text-scale-1200">{post.title}</h4>
+ <p className="small">{post.date}</p>
</div>
- <div>
- {post.tags.map((tag: string) => {
- return <Badge key={`category-badge-${tag}`}>{tag}</Badge>
- })}
- </div>
- </Space>
- </Card>
+ </div>
+ </div>
</div>
</Link>
)
@@ -191,7 +186,7 @@ function BlogPostPage(props: any) {
<p>
<a
href={'/blog'}
- className="hover:text-gray-900 dark:hover:text-white cursor-pointer flex items-center"
+ className="transition text-sm text-scale-900 hover:text-scale-1200 cursor-pointer flex items-center"
>
<IconChevronLeft style={{ padding: 0 }} />
Back
@@ -203,8 +198,8 @@ function BlogPostPage(props: any) {
<div className="mb-16 space-y-8 max-w-5xl">
<div className="space-y-4">
<p className="text-brand-900">Blog post</p>
- <h1 className="text-5xl">{props.blog.title}</h1>
- <div className="flex space-x-3 text-sm">
+ <h1 className="h1">{props.blog.title}</h1>
+ <div className="text-scale-900 flex space-x-3 text-sm">
<p>{props.blog.date}</p>
<p>•</p>
<p>{generateReadingTime(props.blog.content.renderedOutput)}</p>
@@ -213,7 +208,7 @@ function BlogPostPage(props: any) {
<div className="mt-6 mb-8 lg:mb-0 w-max">
<Link href={author.author_url}>
<a className="cursor-pointer">
- <div className="flex items-center">
+ <div className="flex gap-3 items-center">
{author.author_image_url && (
<div className="w-10">
<Image
@@ -226,7 +221,7 @@ function BlogPostPage(props: any) {
</div>
)}
<div className="flex flex-col">
- <span className="text-xs mb-0">{author.author}</span>
+ <span className="text-sm text-scale-1200 mb-0">{author.author}</span>
<span className="text-xs mb-0 text-scale-900">{author.position}</span>
</div>
</div>
@@ -240,7 +235,7 @@ function BlogPostPage(props: any) {
{/* Content */}
<div className="col-span-12 lg:col-span-7 xl:col-span-7">
{props.blog.thumb && (
- <div className="relative overflow-auto w-full h-96 mb-8 border dark:border-gray-600">
+ <div className="relative overflow-auto w-full h-96 mb-8 border rounded">
<Image
src={'/images/blog/' + props.blog.thumb}
layout="fill"
@@ -313,14 +308,16 @@ function BlogPostPage(props: any) {
<div className="mb-4">
<p className="text-sm text-scale-1200">Related articles</p>
</div>
- <div className="space-y-0">
+ <div className="space-y-3">
{props.relatedPosts.map((post: any) => (
<Link href={`/blog/${post.url}`} as={`/blog/${post.url}`}>
<div>
<p className="cursor-pointer">
- <div className="flex items-center gap-2">
- <IconFile size={'small'} style={{ minWidth: '1.2rem' }} />
- <span className="text-sm hover:text-gray-900 dark:hover:text-white">
+ <div className="flex gap-2">
+ <div className="text-scale-900">
+ <IconFile size={'small'} style={{ minWidth: '1.2rem' }} />
+ </div>
+ <span className="text-sm text-scale-1100 hover:text-gray-1200">
{post.title}
</span>
</div>
@@ -329,11 +326,13 @@ function BlogPostPage(props: any) {
</div>
</Link>
))}
- <Link href={`/blog`} as={`/blog`}>
- <a className="text-sm text-scale-1100 hover:text-scale-1200 cursor-pointer">
- View all posts
- </a>
- </Link>
+ <div className="mt-2">
+ <Link href={`/blog`} passHref>
+ <a className="text-sm text-scale-1100 hover:text-scale-1200 cursor-pointer">
+ View all posts
+ </a>
+ </Link>
+ </div>
</div>
</div>
</div>