Home / File/ calendar-presets.tsx — ui Source File

calendar-presets.tsx — ui Source File

Architecture documentation for calendar-presets.tsx, a tsx file in the ui codebase. 5 imports, 0 dependents.

File tsx DocumentationAtlas Changelog 5 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  1b76bd85_9b96_ffe6_674e_d7f0eace0d25["calendar-presets.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  1b76bd85_9b96_ffe6_674e_d7f0eace0d25 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  4b1d2128_46d9_46f0_b915_b6e1925b7876["button"]
  1b76bd85_9b96_ffe6_674e_d7f0eace0d25 --> 4b1d2128_46d9_46f0_b915_b6e1925b7876
  4bae96d1_8974_035f_9042_62ec299030b9["calendar"]
  1b76bd85_9b96_ffe6_674e_d7f0eace0d25 --> 4bae96d1_8974_035f_9042_62ec299030b9
  a3f5dc6c_2f22_a06c_c4d4_d84a4ed2818e["card"]
  1b76bd85_9b96_ffe6_674e_d7f0eace0d25 --> a3f5dc6c_2f22_a06c_c4d4_d84a4ed2818e
  f9e8c1ea_9de4_3e04_ca27_b15cada2e81e["date-fns"]
  1b76bd85_9b96_ffe6_674e_d7f0eace0d25 --> f9e8c1ea_9de4_3e04_ca27_b15cada2e81e
  style 1b76bd85_9b96_ffe6_674e_d7f0eace0d25 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"
import { Button } from "@/examples/radix/ui/button"
import { Calendar } from "@/examples/radix/ui/calendar"
import { Card, CardContent, CardFooter } from "@/examples/radix/ui/card"
import { addDays } from "date-fns"

export function CalendarWithPresets() {
  const [date, setDate] = React.useState<Date | undefined>(
    new Date(new Date().getFullYear(), 1, 12)
  )
  const [currentMonth, setCurrentMonth] = React.useState<Date>(
    new Date(new Date().getFullYear(), new Date().getMonth(), 1)
  )

  return (
    <Card className="mx-auto w-fit max-w-[300px]" size="sm">
      <CardContent>
        <Calendar
          mode="single"
          selected={date}
          onSelect={setDate}
          month={currentMonth}
          onMonthChange={setCurrentMonth}
          fixedWeeks
          className="p-0 [--cell-size:--spacing(9.5)]"
        />
      </CardContent>
      <CardFooter className="flex flex-wrap gap-2 border-t">
        {[
          { label: "Today", value: 0 },
          { label: "Tomorrow", value: 1 },
          { label: "In 3 days", value: 3 },
          { label: "In a week", value: 7 },
          { label: "In 2 weeks", value: 14 },
        ].map((preset) => (
          <Button
            key={preset.value}
            variant="outline"
            size="sm"
            className="flex-1"
            onClick={() => {
              const newDate = addDays(new Date(), preset.value)
              setDate(newDate)
              setCurrentMonth(
                new Date(newDate.getFullYear(), newDate.getMonth(), 1)
              )
            }}
          >
            {preset.label}
          </Button>
        ))}
      </CardFooter>
    </Card>
  )
}

Subdomains

Dependencies

  • button
  • calendar
  • card
  • date-fns
  • react

Frequently Asked Questions

What does calendar-presets.tsx do?
calendar-presets.tsx is a source file in the ui codebase, written in tsx. It belongs to the DocumentationAtlas domain, Changelog subdomain.
What functions are defined in calendar-presets.tsx?
calendar-presets.tsx defines 1 function(s): CalendarWithPresets.
What does calendar-presets.tsx depend on?
calendar-presets.tsx imports 5 module(s): button, calendar, card, date-fns, react.
Where is calendar-presets.tsx in the architecture?
calendar-presets.tsx is located at apps/v4/examples/radix/calendar-presets.tsx (domain: DocumentationAtlas, subdomain: Changelog, directory: apps/v4/examples/radix).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free