-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: mo.ui.datetime, mo.ui.date_range (#2174)
* feat: mo.ui.datetime, mo.ui.date_range * lock * keyword fix
- Loading branch information
Showing
24 changed files
with
1,677 additions
and
324 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Dates | ||
|
||
## Single date | ||
|
||
```{eval-rst} | ||
.. marimo-embed:: | ||
@app.cell | ||
def __(): | ||
date = mo.ui.date(label="Start Date") | ||
return | ||
@app.cell | ||
def __(): | ||
mo.hstack([date, mo.md(f"Has value: {date.value}")]) | ||
return | ||
``` | ||
|
||
```{eval-rst} | ||
.. autoclass:: marimo.ui.date | ||
:members: | ||
.. autoclasstoc:: marimo._plugins.ui._impl.input.date | ||
``` | ||
|
||
## Date and time | ||
|
||
```{eval-rst} | ||
.. marimo-embed:: | ||
@app.cell | ||
def __(): | ||
datetime = mo.ui.datetime(label="Start Date") | ||
return | ||
@app.cell | ||
def __(): | ||
mo.hstack([datetime, mo.md(f"Has value: {datetime.value}")]) | ||
return | ||
``` | ||
|
||
## Date range | ||
|
||
````{eval-rst} | ||
```{eval-rst} | ||
.. marimo-embed:: | ||
@app.cell | ||
def __(): | ||
date_range = mo.ui.date_range(label="Start Date") | ||
return | ||
@app.cell | ||
def __(): | ||
mo.hstack([date_range, mo.md(f"Has value: {date_range.value}")]) | ||
return | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* Copyright 2024 Marimo. All rights reserved. */ | ||
import { cn } from "@/utils/cn"; | ||
import { | ||
Dialog as AriaDialog, | ||
type DialogProps as AriaDialogProps, | ||
DialogTrigger as AriaDialogTrigger, | ||
Popover as AriaPopover, | ||
type PopoverProps as AriaPopoverProps, | ||
composeRenderProps, | ||
} from "react-aria-components"; | ||
|
||
const PopoverTrigger = AriaDialogTrigger; | ||
|
||
const Popover = ({ className, offset = 4, ...props }: AriaPopoverProps) => ( | ||
<AriaPopover | ||
offset={offset} | ||
className={composeRenderProps(className, (className) => | ||
cn( | ||
"z-50 rounded-md border bg-popover text-popover-foreground shadow-md outline-none", | ||
/* Entering */ | ||
"data-[entering]:animate-in data-[entering]:fade-in-0 data-[entering]:zoom-in-95", | ||
/* Exiting */ | ||
"data-[exiting]:animate-out data-[exiting]:fade-out-0 data-[exiting]:zoom-out-95", | ||
/* Placement */ | ||
"data-[placement=bottom]:slide-in-from-top-2 data-[placement=left]:slide-in-from-right-2 data-[placement=right]:slide-in-from-left-2 data-[placement=top]:slide-in-from-bottom-2", | ||
className, | ||
), | ||
)} | ||
{...props} | ||
/> | ||
); | ||
|
||
const PopoverDialog = ({ className, ...props }: AriaDialogProps) => { | ||
return ( | ||
<AriaDialog className={cn("p-4 outline outline-0", className)} {...props} /> | ||
); | ||
}; | ||
|
||
export { Popover, PopoverTrigger, PopoverDialog }; |
Oops, something went wrong.