Skip to content

Commit

Permalink
feat: Datetime component (#2810)
Browse files Browse the repository at this point in the history
* setup

* working calendar range

* added icons to eng

* small style things

* working examples

* suggestions added

* [autofix.ci] apply automated fixes

* Update internal/ui/src/components/date-time/components/suggestions.tsx

Sounds good

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update internal/ui/src/components/date-time/components/suggestions.tsx

Makes sense to add this here i think.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* [autofix.ci] apply automated fixes

* fixed for now

* more

* comment changes

* gh rabbit

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 22, 2025
1 parent ab37986 commit 2d7b9b6
Show file tree
Hide file tree
Showing 19 changed files with 719 additions and 93 deletions.
68 changes: 68 additions & 0 deletions apps/engineering/content/design/components/date-time.example.tsx
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;
};

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>
);
};
17 changes: 17 additions & 0 deletions apps/engineering/content/design/components/date-time.mdx
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/>





85 changes: 49 additions & 36 deletions apps/engineering/content/design/icons.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,38 @@ import { TypeTable } from "fumadocs-ui/components/type-table";
import { Step, Steps } from "fumadocs-ui/components/steps";

import {
BarsFilter,
Bolt,
BookBookmark,
Calendar,
CaretRight,
Check,
ChevronExpandY,
ChevronLeft,
ChevronRight,
CircleCarretRight,
Fingerprint,
Gauge,
Gear,
Grid,
InputSearch,
Layers3,
Magnifier,
Nodes,
Plus,
Refresh3,
ShieldCheck,
ShieldKey,
Sliders,
Sparkle3,
TaskChecked,
TaskUnchecked,
TimeClock,
Trash,
TriangleWarning,
Ufo,
BarsFilter,
Calendar,
CircleCarretRight,
Magnifier,
Refresh3,
Sliders,
TriangleWarning2,
Ufo,
XMark,
Grid,
CaretRight,
} from "@unkey/icons";

<TypeTable
Expand Down Expand Up @@ -80,18 +83,36 @@ import { IconName } from "@unkey/icons";
```

<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8">
<Icon name="BarsFilter">
<BarsFilter />
</Icon>
<Icon name="Bolt">
<Bolt />
</Icon>
<Icon name="BookBookmark">
<BookBookmark />
</Icon>
<Icon name="Calendar">
<Calendar />
</Icon>
<Icon name="CaretRight">
<CaretRight />
</Icon>
<Icon name="Check">
<Check />
</Icon>
<Icon name="ChevronExpandY">
<ChevronExpandY />
</Icon>
<Icon name="ChevronLeft">
<ChevronLeft />
</Icon>
<Icon name="ChevronRight">
<ChevronRight />
</Icon>
<Icon name="CircleCarretRight">
<CircleCarretRight />
</Icon>
<Icon name="Fingerprint">
<Fingerprint />
</Icon>
Expand All @@ -101,24 +122,36 @@ import { IconName } from "@unkey/icons";
<Icon name="Gear">
<Gear />
</Icon>
<Icon name="Grid">
<Grid />
</Icon>
<Icon name="InputSearch">
<InputSearch />
</Icon>
<Icon name="Layers3">
<Layers3 />
</Icon>
<Icon name="Magnifier">
<Magnifier />
</Icon>
<Icon name="Nodes">
<Nodes />
</Icon>
<Icon name="Plus">
<Plus />
</Icon>
<Icon name="Refresh3">
<Refresh3 />
</Icon>
<Icon name="ShieldCheck">
<ShieldCheck />
</Icon>
<Icon name="ShieldKey">
<ShieldKey />
</Icon>
<Icon name="Sliders">
<Sliders />
</Icon>
<Icon name="Sparkle3">
<Sparkle3 />
</Icon>
Expand All @@ -128,45 +161,25 @@ import { IconName } from "@unkey/icons";
<Icon name="TaskUnchecked">
<TaskUnchecked />
</Icon>
<Icon name="TimeClock">
<TimeClock />
</Icon>
<Icon name="Trash">
<Trash />
</Icon>
<Icon name="TriangleWarning">
<TriangleWarning />
</Icon>
<Icon name="Ufo">
<Ufo />
</Icon>
<Icon name="BarsFilter">
<BarsFilter />
</Icon>
<Icon name="Calendar">
<Calendar />
</Icon>
<Icon name="CircleCarretRight">
<CircleCarretRight />
</Icon>
<Icon name="Magnifier">
<Magnifier />
</Icon>
<Icon name="Refresh3">
<Refresh3 />
</Icon>
<Icon name="Sliders">
<Sliders />
</Icon>
<Icon name="TriangleWarning2">
<TriangleWarning2 />
</Icon>
<Icon name="Ufo">
<Ufo />
</Icon>
<Icon name="XMark">
<XMark />
</Icon>
<Icon name="Grid">
<Grid />
</Icon>
<Icon name="CaretRight">
<CaretRight />
</Icon>

</div>

## Adding new icons
Expand Down
4 changes: 2 additions & 2 deletions internal/icons/src/icons/check.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* For more details:
* https://nucleoapp.com/license
*/

import type React from "react";
// 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 Check: React.FC<IconProps> = (props) => {
return (
Expand Down
32 changes: 32 additions & 0 deletions internal/icons/src/icons/chevron-left.tsx
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>
);
};
32 changes: 32 additions & 0 deletions internal/icons/src/icons/chevron-right.tsx
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>
);
};
Loading

0 comments on commit 2d7b9b6

Please sign in to comment.