Skip to content

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

Move the Admonition component to the ui package.

Ivan Vasilov28e36d0ddb3d
diff --git a/apps/docs/components/AppleSecretGenerator.tsx b/apps/docs/components/AppleSecretGenerator.tsx
index 7bfeed67dcc..4029b1d8770 100644
--- a/apps/docs/components/AppleSecretGenerator.tsx
+++ b/apps/docs/components/AppleSecretGenerator.tsx
@@ -1,6 +1,5 @@
import { useState } from 'react'
-import { Input, Button } from 'ui'
-import Admonition from '~/components/Admonition'
+import { Admonition, Button, Input } from 'ui'
function base64URL(value: string) {
return globalThis.btoa(value).replace(/[=]/g, '').replace(/[+]/g, '-').replace(/[\/]/g, '_')
diff --git a/apps/docs/components/index.tsx b/apps/docs/components/index.tsx
index 5a50214c12e..d5538b8ee1c 100644
--- a/apps/docs/components/index.tsx
+++ b/apps/docs/components/index.tsx
@@ -2,7 +2,6 @@ import Link from 'next/link'
import { Alert, Button, CodeBlock, GlassPanel, markdownComponents, Tabs } from 'ui'
import StepHikeCompact from '~/components/StepHikeCompact'
// Common components
-import Admonition from './Admonition'
import ButtonCard from './ButtonCard'
import JwtGenerator from './JwtGenerator'
@@ -31,6 +30,7 @@ import CliGlobalFlagsHandler from '~/components/reference/enrichments/cli/CliGlo
import Options from '~/components/Options'
import Param from '~/components/Params'
+import { Admonition } from 'ui'
import {
IconMenuJavascript,
IconMenuHome,
diff --git a/apps/docs/components/reference/OldVersionAlert.tsx b/apps/docs/components/reference/OldVersionAlert.tsx
index 55b94576d75..a9c04d535d8 100644
--- a/apps/docs/components/reference/OldVersionAlert.tsx
+++ b/apps/docs/components/reference/OldVersionAlert.tsx
@@ -1,7 +1,7 @@
import Link from 'next/link'
import { useRouter } from 'next/router'
+import { Admonition } from 'ui'
import { useMenuActiveRefId } from '~/hooks/useMenuState'
-import Admonition from '../Admonition'
import { ICommonSection } from './Reference.types'
export interface OldVersionAlertProps {
diff --git a/apps/docs/lib/mdx/plugins/remarkAdmonition.ts b/apps/docs/lib/mdx/plugins/remarkAdmonition.ts
index 343c58ad419..a9a212d2825 100644
--- a/apps/docs/lib/mdx/plugins/remarkAdmonition.ts
+++ b/apps/docs/lib/mdx/plugins/remarkAdmonition.ts
@@ -1,8 +1,8 @@
import { Content, Paragraph, Parent } from 'mdast'
import { MdxJsxFlowElement } from 'mdast-util-mdx'
+import { AdmonitionProps } from 'ui'
import { Node } from 'unist'
import { visit } from 'unist-util-visit'
-import { AdmonitionProps } from '~/components/Admonition'
/**
* Transforms an `mkdocs-material` Admonition to a Supabase Admonition.
diff --git a/apps/docs/pages/guides/platform/backups.mdx b/apps/docs/pages/guides/platform/backups.mdx
index 3385c859537..65f60334402 100644
--- a/apps/docs/pages/guides/platform/backups.mdx
+++ b/apps/docs/pages/guides/platform/backups.mdx
@@ -1,5 +1,5 @@
import Layout from '~/layouts/DefaultGuideLayout'
-import Admonition from '~/components/Admonition'
+import { Admonition } from 'ui'
export const meta = {
title: 'Database Backups',
diff --git a/apps/www/components/Admonition.tsx b/apps/www/components/Admonition.tsx
deleted file mode 100644
index 8a85475d929..00000000000
--- a/apps/www/components/Admonition.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { PropsWithChildren } from 'react'
-import { IconAlertTriangle, IconHelpCircle, IconInfo } from 'ui'
-
-export interface AdmonitionProps {
- type: 'note' | 'tip' | 'info' | 'caution' | 'danger'
- label?: string
-}
-
-const Admonition = ({ type = 'note', label, children }: PropsWithChildren<AdmonitionProps>) => {
- return (
- <div
- className={[
- 'shadow p-4 rounded border-l-[5px] space-y-2 my-4',
- `${
- type === 'note'
- ? 'bg-scale-400 border-scale-800'
- : type === 'info'
- ? 'bg-scale-500 border-scale-800'
- : type === 'tip'
- ? 'bg-brand-300 border-brand-800'
- : type === 'caution'
- ? 'bg-yellow-400 border-yellow-800'
- : type === 'danger'
- ? 'bg-red-500 border-red-800'
- : 'bg-scale-500 border-scale-800'
- }`,
- ].join(' ')}
- >
- <div className="flex items-center space-x-2">
- {type === 'note' ? (
- <IconInfo className="text-scale-1200" size={18} strokeWidth={1.5} />
- ) : type === 'info' ? (
- <IconInfo className="text-scale-1200" size={18} strokeWidth={1.5} />
- ) : type === 'tip' ? (
- <IconHelpCircle className="text-scale-1200" size={18} strokeWidth={1.5} />
- ) : type === 'caution' ? (
- <IconAlertTriangle className="text-scale-1200" size={18} strokeWidth={1.5} />
- ) : type === 'danger' ? (
- <IconAlertTriangle className="text-scale-1200" size={18} strokeWidth={1.5} />
- ) : (
- <IconInfo className="text-scale-1200" size={18} strokeWidth={1.5} />
- )}
- <p className="text-sm text-scale-1200 uppercase my-0 font-bold">{label || type}</p>
- </div>
- <div className="admonition-content text-scale-1200 text-base space-y-1">{children}</div>
- </div>
- )
-}
-
-export default Admonition
diff --git a/apps/www/pages/partners/integrations/[slug].tsx b/apps/www/pages/partners/integrations/[slug].tsx
index 211e952cb1b..492c8bb87db 100644
--- a/apps/www/pages/partners/integrations/[slug].tsx
+++ b/apps/www/pages/partners/integrations/[slug].tsx
@@ -8,8 +8,7 @@ import Link from 'next/link'
import { Dispatch, SetStateAction, useState } from 'react'
import { Swiper, SwiperSlide } from 'swiper/react'
import 'swiper/swiper.min.css'
-import { CodeBlock, IconChevronLeft, IconExternalLink } from 'ui'
-import Admonition from '~/components/Admonition'
+import { Admonition, CodeBlock, IconChevronLeft, IconExternalLink } from 'ui'
import ImageModal from '~/components/ImageModal'
import InlineCodeTag from '~/components/InlineCode'
import DefaultLayout from '~/components/Layouts/Default'
diff --git a/packages/ui/index.tsx b/packages/ui/index.tsx
index f1c481e4a50..ae5581d03ea 100644
--- a/packages/ui/index.tsx
+++ b/packages/ui/index.tsx
@@ -10,6 +10,7 @@ export * from './src/lib/Markdown'
// // GENERAL
+export * from './src/components/Admonition'
export * from './src/components/Button'
export * from './src/components/Icon'
export * from './src/components/Icon/IconContext'
diff --git a/apps/docs/components/Admonition.tsx b/packages/ui/src/components/Admonition/index.tsx
similarity index 93%
rename from apps/docs/components/Admonition.tsx
rename to packages/ui/src/components/Admonition/index.tsx
index 8a85475d929..d4b2bec0686 100644
--- a/apps/docs/components/Admonition.tsx
+++ b/packages/ui/src/components/Admonition/index.tsx
@@ -6,7 +6,11 @@ export interface AdmonitionProps {
label?: string
}
-const Admonition = ({ type = 'note', label, children }: PropsWithChildren<AdmonitionProps>) => {
+export const Admonition = ({
+ type = 'note',
+ label,
+ children,
+}: PropsWithChildren<AdmonitionProps>) => {
return (
<div
className={[
@@ -46,5 +50,3 @@ const Admonition = ({ type = 'note', label, children }: PropsWithChildren<Admoni
</div>
)
}
-
-export default Admonition