Skip to content
Draft
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
604 changes: 604 additions & 0 deletions apps/eclipse/content/design-system/components/datepicker.mdx

Large diffs are not rendered by default.

106 changes: 106 additions & 0 deletions apps/eclipse/src/components/date-picker-examples.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
"use client";

import { useState } from "react";
import {
DatePickerSingle,
DatePickerRange,
createDateRangePresets,
type DateRange,
} from "@prisma-docs/eclipse";

export function DatePickerSingleExample() {
const [date, setDate] = useState<Date>();

return (
<DatePickerSingle
date={date}
onDateChange={setDate}
placeholder="Select a date"
dateFormat="dd/MM/yyyy"
/>
);
}

export function DatePickerRangeExample() {
const [dateRange, setDateRange] = useState<DateRange>();

return (
<DatePickerRange
dateRange={dateRange}
onDateRangeChange={setDateRange}
placeholder="Pick a date range"
/>
);
}

export function DatePickerRangeWithPresetsExample() {
const [dateRange, setDateRange] = useState<DateRange>();
const presets = createDateRangePresets();

return (
<DatePickerRange
dateRange={dateRange}
onDateRangeChange={setDateRange}
presets={presets}
placeholder="Pick a date range with presets"
/>
);
}

export function DatePickerErrorExample() {
return (
<div className="space-y-2">
<DatePickerSingle placeholder="Error state example" isErrored={true} />
<p className="text-sm text-foreground-error">Date is required</p>
</div>
);
}

export function DatePickerDisabledExample() {
return (
<DatePickerSingle placeholder="Disabled state example" disabledBtn={true} />
);
}

export function DatePickerWithValidationExample() {
const [date, setDate] = useState<Date>();
const [submitted, setSubmitted] = useState(false);

const hasError = submitted && !date;

const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
setSubmitted(true);
if (date) {
alert(`Date selected: ${date.toLocaleDateString()}`);
}
};

return (
<form onSubmit={handleSubmit} className="space-y-4">
<div className="space-y-2">
<label className="text-sm font-medium">Event Date *</label>
<DatePickerSingle
date={date}
onDateChange={(newDate) => {
setDate(newDate);
if (newDate) setSubmitted(false);
}}
placeholder="Select event date"
isErrored={hasError}
/>
{hasError && (
<p className="text-sm text-foreground-error">
Please select an event date
</p>
)}
</div>
<button
type="submit"
className="px-4 py-2 bg-background-ppg text-foreground-ppg rounded-md hover:bg-background-ppg/90"
>
Submit
</button>
</form>
);
}
25 changes: 23 additions & 2 deletions packages/eclipse/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,28 @@ Import the global styles in your app's entry point:
import "@prisma/eclipse/styles/globals.css";
```

### 3. Configure Tailwind (Optional)
### 3. Add FontAwesome Script

Eclipse components use FontAwesome icons. Add the FontAwesome script to your app's root layout:

```tsx
import { FontAwesomeScript } from "@prisma-docs/eclipse";

export default function RootLayout({ children }) {
return (
<html>
<body>
{children}
<FontAwesomeScript />
</body>
</html>
);
}
```

This component loads the FontAwesome kit script required for icons used throughout Eclipse components.

### 4. Configure Tailwind (Optional)

To use Eclipse tokens in your Tailwind config:

Expand All @@ -62,7 +83,7 @@ const config: Config = {
export default config;
```

### 4. Use Components
### 5. Use Components

Import and use Eclipse components:

Expand Down
6 changes: 6 additions & 0 deletions packages/eclipse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"dependencies": {
"@base-ui/react": "catalog:",
"@tailwindcss/postcss": "catalog:",
"@fumadocs/base-ui": "catalog:",
"@radix-ui/react-accordion": "catalog:",
"@radix-ui/react-checkbox": "catalog:",
"@radix-ui/react-collapsible": "catalog:",
Expand All @@ -62,7 +63,12 @@
"@radix-ui/react-tabs": "catalog:",
"@radix-ui/react-tooltip": "catalog:",
"class-variance-authority": "catalog:",
"clsx": "catalog:",
"date-fns": "^4.1.0",
"fumadocs-core": "catalog:",
"fumadocs-ui": "catalog:",
"lucide-react": "catalog:",
"react-day-picker": "^9.14.0",
"recharts": "catalog:",
"tailwind-merge": "catalog:",
"tw-animate-css": "catalog:"
Expand Down
Loading
Loading