Skip to content

Commit

Permalink
Merge branch 'master' of github.com:xola/ui-kit into X2-6577
Browse files Browse the repository at this point in the history
* 'master' of github.com:xola/ui-kit:
  2.1.20
  X2-7128 fix(datepicker): enhances ux for relative date range picker (xola#268)
  2.1.19
  X2-7052: X2 account does not show start time in a listing schedule the way it does in V1 (xola#267)
  npm publish workflow (xola#269)
  • Loading branch information
rushi committed Sep 27, 2023
2 parents ac91f89 + a74ffda commit 04c7356
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 11 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: Node.js Package

on:
workflow_dispatch:
inputs:
tag:
description: "Tag version"
default: latest
required: true

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- run: npm publish --tag ${{ github.event.inputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
src/theme.js
package-lock.json
node_modules
.github
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xola/ui-kit",
"version": "2.1.18",
"version": "2.1.20",
"description": "Xola UI Kit",
"license": "MIT",
"files": [
Expand Down
10 changes: 5 additions & 5 deletions src/components/DatePicker/DatePicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
}

/* Change the dates within the date to have the full light blue to show that it's a part of the range */
.date-range-picker .DayPicker-Day--selected:not(.DayPicker-Day--start):not(.DayPicker-Day--end) {
.date-range-picker .DayPicker-Day--selected:not(.DayPicker-Day--start):not(.DayPicker-Day--end):not(.DayPicker-Day--outside) {
@apply rounded-none bg-blue-lighter text-black;
}

Expand All @@ -149,8 +149,8 @@
@apply bg-transparent text-black;
}

.date-range-picker .DayPicker-Day--selected:not(.DayPicker-Day--disabled) .date,
.date-range-picker .DayPicker-Day--selected:not(.DayPicker-Day--disabled) .date:hover {
.date-range-picker .DayPicker-Day--selected:not(.DayPicker-Day--disabled):not(.DayPicker-Day--outside) .date,
.date-range-picker .DayPicker-Day--selected:not(.DayPicker-Day--disabled):not(.DayPicker-Day--outside) .date:hover {
@apply bg-blue-lighter text-black;
}

Expand All @@ -167,7 +167,7 @@
}

/* Make the start date have a 50% light blue background towards the RIGHT side */
.date-range-picker .DayPicker-Day--start {
.date-range-picker .DayPicker-Day--start:not(.DayPicker-Day--outside) {
@apply rounded-none;
background: linear-gradient(90deg, #ffffff 40%, #d1e1ff 25%);
}
Expand All @@ -177,7 +177,7 @@
}

/* Make the end date have a 50% light blue background towards the LEFT side */
.date-range-picker .DayPicker-Day--end {
.date-range-picker .DayPicker-Day--end:not(.DayPicker-Day--outside) {
@apply rounded-none;
background: linear-gradient(90deg, #d1e1ff 40%, #ffffff 25%); /* D1E1FF Blue lighter */
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/DatePicker/DatePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export const DatePicker = ({
) : null}

<DayPicker
showOutsideDays
showOutsideDays={!isRangeVariant}
className={clsx(
"ui-date-picker rounded-lg pt-3",
useDateRangeStyle ? "date-range-picker" : null,
Expand Down
4 changes: 3 additions & 1 deletion src/components/DatePicker/DatePickerPopover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const DatePickerPopover = ({
value,
variant = "single",
dateFormat = "ddd, LL",
placeholder = "Select Date",
onChange,
children,
classNames = {},
Expand Down Expand Up @@ -66,6 +67,7 @@ export const DatePickerPopover = ({
readOnly
size="medium"
value={value ? formatDate(value, dateFormat) : ""}
placeholder={placeholder}
className={classNames?.input}
onClick={toggleVisibility}
/>
Expand Down Expand Up @@ -103,7 +105,7 @@ const DefaultInput = forwardRef(({ className, ...rest }, reference) => {
<CalendarIcon className="z-10 inline-block" />
</div>

<Input className={clsx("cursor-pointer px-8", className)} placeholder="Select Date" {...rest} />
<Input className={clsx("cursor-pointer px-8", className)} {...rest} />

<div className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
<DownArrowIcon className="inline-block" />
Expand Down
14 changes: 13 additions & 1 deletion src/components/DatePicker/MonthYearSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,28 @@ import { Select } from "../Forms/Select";

const today = dayjs();

const getDiffInMonths = (to, from) => {
return 12 * (to.getFullYear() - from.getFullYear()) + (to.getMonth() - from.getMonth());
};

export const MonthYearSelector = ({ date, onChange, currentMonth }) => {
const months = [...Array.from({ length: 12 }).keys()].map((m) => today.month(m).format("MMM"));
// 2012 as baseline + 5 years in future
const years = [...Array.from({ length: today.year() - 2012 + 5 + 1 }).keys()].map((y) =>
today.year(2012 + y).format("YYYY"),
);

/**
* For range date pickers, when we show multiple months, this indicates the index for selector component with respected to the first month selected in date-range picker (i.e. month selected on left side)
*
* @example
* If left side month is "August 2023", and we are showing this selector for "September 2023" (`date=2023-09-01T00:00:00Z`). The `selectorIndex` would be 1.
**/
const selectorIndex = getDiffInMonths(date, currentMonth);

const handleMonthChange = (event) => {
const { year, month } = event.target.form;
onChange(new Date(year.value, month.value));
onChange(new Date(year.value, Number(month.value) - selectorIndex));
};

const handleYearChange = (event) => {
Expand Down

0 comments on commit 04c7356

Please sign in to comment.