Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .cursor/rules/studio/forms/RULE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: "Studio: form patterns (page layouts + side panels) and react-hook-form conventions"
description: 'Studio: form patterns (page layouts + side panels) and react-hook-form conventions'
globs:
- apps/studio/**/*.{ts,tsx}
alwaysApply: false
Expand Down Expand Up @@ -29,7 +29,6 @@ Use the Design System UI pattern docs as the source of truth:

## Actions and state

- Handle dirty state (`form.formState.isDirty`) to show Cancel and to disable Save.
- Handle dirty state by destructuring `isDirty` from `formState` (`const { isDirty } = form.formState`) then use it to show Cancel and to disable Save.
- Show loading on submit buttons via `loading`.
- When submit button is outside the `<form>`, set a stable `formId` and use the button’s `form` prop.

2 changes: 1 addition & 1 deletion apps/design-system/content/docs/ui-patterns/forms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Use the shared [Key/Value Field Array](../fragments/key-value-field-array) fragm

4. **Use Cards for grouping**: Wrap form sections in `Card` components with `CardContent` and `CardFooter` for actions.

5. **Handle dirty state**: Show cancel buttons and disable save buttons based on `form.formState.isDirty`.
5. **Handle dirty state**: Show cancel buttons and disable save buttons based on `form.formState.isDirty`. Make sure you destructure `isDirty` from `form.formState` (see https://react-hook-form.com/docs/useform/formstate)

6. **Error handling**: Always use mutations with `onSuccess` and `onError` callbacks that show toast notifications.

Expand Down
7 changes: 6 additions & 1 deletion apps/design-system/content/docs/ui-patterns/modality.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ Studio implementation (preferred in Studio code):
import { DiscardChangesConfirmationDialog } from 'components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'
import { useConfirmOnClose } from 'hooks/ui/useConfirmOnClose'

const form = useForm(...)
// Always destructure formState values otherwise they won't be updated
// See https://react-hook-form.com/docs/useform/formstate
const { isDirty } = form.formState

const { confirmOnClose, handleOpenChange, modalProps } = useConfirmOnClose({
checkIsDirty: () => form.formState.isDirty,
checkIsDirty: () => isDirty,
onClose,
})

Expand Down
2 changes: 1 addition & 1 deletion apps/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dev": "next dev --turbopack --port 3003",
"dev:full": "concurrently \"pnpm dev\" \"pnpm content:dev\"",
"build": "pnpm run content:build && pnpm run build:registry && next build --turbopack",
"build:registry": "tsx --tsconfig ./tsconfig.scripts.json ./scripts/build-registry.mts && prettier --log-level silent --write \"registry/**/*.{ts,tsx,mdx}\" --cache",
"build:registry": "tsx ./scripts/build-registry.mts && prettier --log-level silent --write \"registry/**/*.{ts,tsx,mdx}\" --cache",
"start": "next start",
"lint": "eslint .",
"content:dev": "contentlayer2 dev",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ErrorDisplay } from 'ui-patterns/ErrorDisplay'
import { ErrorDisplay } from 'ui-patterns/ErrorDisplay/ErrorDisplay'

export default function ErrorDisplayDemo() {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ErrorDisplay } from 'ui-patterns/ErrorDisplay'
import { ErrorDisplay } from 'ui-patterns/ErrorDisplay/ErrorDisplay'

export default function ErrorDisplayWithChildren() {
return (
Expand Down
20 changes: 0 additions & 20 deletions apps/design-system/tsconfig.base.json

This file was deleted.

25 changes: 4 additions & 21 deletions apps/design-system/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,23 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "tsconfig/base.json",
"extends": "tsconfig/nextjs.json",
"compilerOptions": {
"target": "es5",
"allowJs": false,
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"paths": {
"@/*": ["./*"],
"@ui/*": ["./../../packages/ui/src/*"], // handle ui package paths
"contentlayer/generated": ["./.contentlayer/generated"],
"icons/*": ["./../../packages/icons/*"]
},
"plugins": [
{
"name": "next"
}
]
"plugins": [{ "name": "next" }]
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".contentlayer/generated",
"./../../packages/ui/src/**/*.d.ts"
".contentlayer/generated"
],
"exclude": ["node_modules", "./scripts/build-registry.mts"]
}
13 changes: 0 additions & 13 deletions apps/design-system/tsconfig.scripts.json

This file was deleted.

4 changes: 4 additions & 0 deletions apps/design-system/types/assets.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.scss' {
export const styles: Record<string, string>
export default styles
}
1 change: 1 addition & 0 deletions apps/docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public/llms.txt
public/llms/
# Generated guide markdown files
public/docs/
public/docs.tar.gz

# Copied examples folder
/examples/
Expand Down
9 changes: 4 additions & 5 deletions apps/docs/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import '@code-hike/mdx/styles'
import '@code-hike/mdx/styles.css'
import 'config/code-hike.scss'
import 'ui-patterns/ShimmeringLoader/index.css'
import '../styles/main.scss'
import '../styles/new-docs.scss'
import '../styles/prism-okaidia.scss'

import { TelemetryTagManager } from 'common'

import { genFaviconData } from 'common/MetaFavicons/app-router'
import type { Metadata, Viewport } from 'next'
import { GlobalProviders } from '~/features/app.providers'
import { TopNavSkeleton } from '~/layouts/MainSkeleton'
import { BASE_PATH, IS_PRODUCTION } from '~/lib/constants'
import { getCustomContent } from '~/lib/custom-content/getCustomContent'
import { TelemetryTagManager } from 'common'
import { genFaviconData } from 'common/MetaFavicons/app-router'
import type { Metadata, Viewport } from 'next'

const { metadataApplicationName, metadataTitle } = getCustomContent([
'metadata:application_name',
Expand Down
Loading
Loading