-
Notifications
You must be signed in to change notification settings - Fork 610
feat: Datetime component #2810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: Datetime component #2810
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ddf7bac
setup
c16cf9c
working calendar range
355faa1
added icons to eng
b38cf79
small style things
32bf4e0
working examples
3eccd3e
suggestions added
fa45c05
Merge branch 'main' into eng-1608-calendar-component
MichaelUnkey e1b2a03
[autofix.ci] apply automated fixes
autofix-ci[bot] 707aad9
Update internal/ui/src/components/date-time/components/suggestions.tsx
MichaelUnkey 4f05676
Update internal/ui/src/components/date-time/components/suggestions.tsx
MichaelUnkey 7fde8c8
[autofix.ci] apply automated fixes
autofix-ci[bot] ca198a3
fixed for now
9cdd9e2
more
d8754c9
Merge branch 'main' of https://github.com/unkeyed/unkey into eng-1608…
59d78c4
Merge branch 'eng-1608-calendar-component' of https://github.com/unke…
18ca7a3
comment changes
fc73335
gh rabbit
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
apps/engineering/content/design/components/date-time.example.tsx
This file contains hidden or 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,68 @@ | ||
| "use client"; | ||
| import { RenderComponentWithSnippet } from "@/app/components/render"; | ||
| import { Row } from "@/app/components/row"; | ||
| import { Button, DateTime, type Range } from "@unkey/ui"; | ||
| import { useState } from "react"; | ||
|
|
||
| type TimeUnit = { | ||
| HH: string; | ||
| mm: string; | ||
| ss: string; | ||
| }; | ||
|
|
||
| export const DateTimeExample: React.FC = () => { | ||
| const [date, setDate] = useState<Range>(); | ||
| const [startTime, setStartTime] = useState<TimeUnit>(); | ||
| const [endTime, setEndTime] = useState<TimeUnit>(); | ||
|
|
||
| const handleApply = (newDate?: Range, newStartTime?: TimeUnit, newEndTime?: TimeUnit) => { | ||
| newDate ? setDate(newDate) : null; | ||
| newStartTime ? setStartTime(newStartTime) : null; | ||
| newEndTime ? setEndTime(newEndTime) : null; | ||
| }; | ||
| const handleChange = (newDate?: Range, newStartTime?: TimeUnit, newEndTime?: TimeUnit) => { | ||
| newDate ? setDate(newDate) : null; | ||
| newStartTime ? setStartTime(newStartTime) : null; | ||
| newEndTime ? setEndTime(newEndTime) : null; | ||
| }; | ||
MichaelUnkey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return ( | ||
| <RenderComponentWithSnippet> | ||
| <Row> | ||
| <div className="flex flex-col w-full"> | ||
| <div className="w-full p-4 border border-1-gray-12 h-32"> | ||
| <div className="w-full "> | ||
| <p className="m-0 p-0"> | ||
| Date Range: <span>{date?.from?.toLocaleDateString() ?? "no date"}</span> -{" "} | ||
| <span>{date?.to?.toLocaleDateString() ?? "no date"}</span> | ||
| </p> | ||
| <p className="m-0 p-0"> | ||
| Time Span: <span>{`${startTime?.HH}:${startTime?.mm}:${startTime?.ss}`}</span> -{" "} | ||
| <span>{`${endTime?.HH}:${endTime?.mm}:${endTime?.ss}`}</span> | ||
| </p> | ||
| </div> | ||
| </div> | ||
| <div className="flex flex-col w-full pt-12 justify-center items-center"> | ||
| <DateTime | ||
| onChange={(date?: Range, startTime?: TimeUnit, endTime?: TimeUnit) => | ||
| handleChange(date, startTime, endTime) | ||
| } | ||
| > | ||
| <DateTime.Calendar mode="range" /> | ||
| <DateTime.TimeInput type="range" /> | ||
| <DateTime.Actions> | ||
| <Button | ||
| className="w-full" | ||
| onClick={() => handleApply(date, startTime, endTime)} | ||
| variant={"primary"} | ||
| > | ||
| Apply Filter | ||
| </Button> | ||
| </DateTime.Actions> | ||
| </DateTime> | ||
| </div> | ||
| </div> | ||
| </Row> | ||
| </RenderComponentWithSnippet> | ||
| ); | ||
| }; | ||
This file contains hidden or 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,17 @@ | ||
| --- | ||
| title: DateTime | ||
| --- | ||
| import { Button } from "@unkey/ui" | ||
| import { RenderComponentWithSnippet } from "@/app/components/render" | ||
| import { Row } from "@/app/components/row" | ||
| import { DateTimeExample } from "./date-time.example" | ||
|
|
||
|
|
||
| ## Example | ||
|
|
||
| <DateTimeExample/> | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
This file contains hidden or 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 hidden or 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 hidden or 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,32 @@ | ||
| /** | ||
| * Copyright © Nucleo | ||
| * Version 1.3, January 3, 2024 | ||
| * Nucleo Icons | ||
| * https://nucleoapp.com/ | ||
| * - Redistribution of icons is prohibited. | ||
| * - Icons are restricted for use only within the product they are bundled with. | ||
| * | ||
| * For more details: | ||
| * https://nucleoapp.com/license | ||
| */ | ||
|
|
||
| // biome-ignore lint: React in this context is used throughout, so biome will change to types because no APIs are used even though React is needed. | ||
| import React from "react"; | ||
| import type { IconProps } from "../props"; | ||
|
|
||
| export const ChevronLeft: React.FC<IconProps> = (props: IconProps) => { | ||
| return ( | ||
| <svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> | ||
| <g fill="currentColor"> | ||
| <path | ||
| d="M11.5 15.25L5.25 9L11.5 2.75" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| strokeWidth="1.5" | ||
| /> | ||
| </g> | ||
| </svg> | ||
| ); | ||
| }; |
This file contains hidden or 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,32 @@ | ||
| /** | ||
| * Copyright © Nucleo | ||
| * Version 1.3, January 3, 2024 | ||
| * Nucleo Icons | ||
| * https://nucleoapp.com/ | ||
| * - Redistribution of icons is prohibited. | ||
| * - Icons are restricted for use only within the product they are bundled with. | ||
| * | ||
| * For more details: | ||
| * https://nucleoapp.com/license | ||
| */ | ||
|
|
||
| // biome-ignore lint: React in this context is used throughout, so biome will change to types because no APIs are used even though React is needed. | ||
| import React from "react"; | ||
| import type { IconProps } from "../props"; | ||
|
|
||
| export const ChevronRight: React.FC<IconProps> = (props: IconProps) => { | ||
| return ( | ||
| <svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> | ||
| <g fill="currentColor"> | ||
| <path | ||
| d="M6.5 2.75L12.75 9L6.5 15.25" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| strokeWidth="1.5" | ||
| /> | ||
| </g> | ||
| </svg> | ||
| ); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.