@licklist/design 0.44.485-dev.98 → 0.44.485-dev.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { DateTime } from "luxon";
3
+ import { DateTimeButtonProps } from "./DateTimeButton";
4
+ type DateContentProps = Pick<DateTimeButtonProps, "isDisabled" | "isSelected"> & {
5
+ date: DateTime;
6
+ };
7
+ export declare const DateContent: ({ date, isDisabled, isSelected, }: DateContentProps) => JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=DateContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateContent.d.ts","sourceRoot":"","sources":["../../src/date-time-button/DateContent.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,KAAK,gBAAgB,GAAG,IAAI,CAC1B,mBAAmB,EACnB,YAAY,GAAG,YAAY,CAC5B,GAAG;IACF,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,WAAW,sCAIrB,gBAAgB,gBAyBlB,CAAC"}
@@ -0,0 +1 @@
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=e(require("react")),i=require("@licklist/core/dist/Config"),a=e(require("clsx")),o=require("@licklist/plugins/dist/utils/formatDate"),s=require("date-fns"),l=require("react-i18next/*");exports.DateContent=function(e){var n=e.date,c=e.isDisabled,d=e.isSelected,u=l.useTranslation("Design").t,f=t.__read(n.toFormat(i.DAY_NUMBER_WITH_MONTH).split(" "),2),m=f[0],D=f[1];return r.createElement("div",{className:"weekday-info"},r.createElement("div",null,s.isToday(n.toJSDate())?u("today"):s.isTomorrow(n.toJSDate())?u("tomorrow"):n.toFormat(i.DAY_OF_WEEK)),r.createElement("div",{className:a("descriptions",d&&"selected",c&&"disabled")},"".concat(o.getDayWithOrdinal(+m)," ").concat(D)))};
@@ -1,12 +1,12 @@
1
- /// <reference types="react" />
1
+ import { ReactElement } from "react";
2
2
  import { DateTime } from "luxon";
3
- export type DateTimeButtonProps = {
4
- date?: DateTime;
5
- time?: string;
3
+ export type DateTimeButtonProps<T = DateTime | string> = {
4
+ date: T;
6
5
  isSelected?: boolean;
7
6
  isDisabled?: boolean;
8
- onSelect: (date: DateTime | string) => void;
7
+ onSelect: (date: T) => void;
9
8
  isOnlyTimeContainer?: boolean;
9
+ price?: string | number | ReactElement | null;
10
10
  };
11
- export declare const DateTimeButton: ({ date, isDisabled, time, isSelected, onSelect, isOnlyTimeContainer, }: DateTimeButtonProps) => JSX.Element;
11
+ export declare const DateTimeButton: <T extends string | DateTime>({ date, isDisabled, isSelected, onSelect, isOnlyTimeContainer, price, }: DateTimeButtonProps<T>) => JSX.Element;
12
12
  //# sourceMappingURL=DateTimeButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeButton.d.ts","sourceRoot":"","sources":["../../src/date-time-button/DateTimeButton.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAKjC,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,KAAK,IAAI,CAAC;IAC5C,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,cAAc,2EAOxB,mBAAmB,gBAoDrB,CAAC"}
1
+ {"version":3,"file":"DateTimeButton.d.ts","sourceRoot":"","sources":["../../src/date-time-button/DateTimeButton.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,QAAQ,GAAG,MAAM,IAAI;IACvD,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;CAC/C,CAAC;AAEF,eAAO,MAAM,cAAc,+IA0D1B,CAAC"}
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),i=require("@licklist/core/dist/Config"),r=require("react-i18next"),n=e(require("clsx")),a=require("date-fns"),o=function(e){var o=e.date,s=e.isDisabled,l=e.isSelected,d=r.useTranslation("Design").t;return t.createElement(t.Fragment,null,a.isToday(o.toJSDate())?d("today"):a.isTomorrow(o.toJSDate())?d("tomorrow"):o.toFormat(i.DAY_OF_WEEK),t.createElement("div",{className:n("descriptions",l&&"selected",s&&"disabled")},o.toFormat(i.DAY_NUMBER_WITH_MONTH)))};exports.DateTimeButton=function(e){var i=e.date,r=e.isDisabled,a=e.time,s=e.isSelected,l=e.onSelect,d=e.isOnlyTimeContainer,c=function(){r||l(i||a)};return t.createElement("div",{role:"button",onClick:c,onKeyPress:c,className:n("date-time-button",r&&"disabled",s&&"selected",a&&"time-button",d&&"only-time-container"),tabIndex:0},i?t.createElement(o,{date:i,isDisabled:r,isSelected:s}):a)};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),n=e(require("clsx")),i=require("./DateContent.js");exports.DateTimeButton=function(e){var r=e.date,a=e.isDisabled,o=e.isSelected,s=e.onSelect,c=e.isOnlyTimeContainer,l=e.price,u="string"==typeof r;return t.createElement("button",{type:"button",onClick:function(){return s(r)},disabled:a,className:n("date-time-button",a&&"disabled",o&&"selected",u&&"time-button",c&&"only-time-container",!u&&"today")},u?r:t.createElement(i.DateContent,{date:r,isDisabled:a,isSelected:o}),l&&t.createElement("div",{className:"price"},l))};
@@ -3,27 +3,50 @@
3
3
  align-items: center;
4
4
  justify-content: center;
5
5
  flex-direction: column;
6
+ gap: 0.25rem;
6
7
  font-size: 0.82rem;
7
- line-height: 1.3rem;
8
- font-weight: 600;
9
8
  background-color: $snippet-calendar-button-background-color;
10
9
  border-radius: 0.4rem;
11
10
  text-align: center;
12
11
  border: 2px solid $snippet-calendar-button-border-color;
13
12
  color: $snippet-calendar-button-font-color;
14
- flex-grow: 1;
15
13
  transition: $color-transition;
16
14
  min-width: 6rem;
17
- max-width: 7.25rem;
18
- min-height: 3.3rem;
19
- max-height: 8.375rem;
15
+ min-height: 3rem;
16
+ max-width: max-content;
17
+ padding: 0.5rem;
18
+
19
+ .weekday-info {
20
+ div:first-child {
21
+ text-transform: uppercase;
22
+ font-weight: 600;
23
+ }
24
+
25
+ div:last-child {
26
+ color: $snippet-calendar-active-button-background-color;
27
+ }
28
+ }
29
+
30
+ .descriptions {
31
+ font-size: 0.7rem;
32
+ }
33
+
34
+ &.today:first-of-type {
35
+ min-width: 7.5rem;
36
+ }
20
37
 
21
38
  &.disabled {
22
39
  border: 2px solid $snippet-calendar-disabled-button-border-color;
23
40
  background-color: $snippet-calendar-disabled-button-background-color;
24
41
  color: $snippet-calendar-disabled-button-font-color;
25
42
 
26
- .descriptions {
43
+ .weekday-info {
44
+ div:last-child {
45
+ color: $snippet-calendar-disabled-button-font-color;
46
+ }
47
+ }
48
+
49
+ .price {
27
50
  color: $snippet-calendar-disabled-button-font-color;
28
51
  }
29
52
  }
@@ -34,7 +57,13 @@
34
57
  color: $snippet-calendar-active-button-font-color;
35
58
  transition: $color-transition;
36
59
 
37
- .descriptions {
60
+ .weekday-info {
61
+ div:last-child {
62
+ color: $snippet-calendar-active-button-font-color;
63
+ }
64
+ }
65
+
66
+ .price {
38
67
  color: $snippet-calendar-active-button-font-color;
39
68
  background-color: $snippet-calendar-active-button-background-color;
40
69
  font-weight: 600;
@@ -64,7 +93,7 @@
64
93
  font-weight: 300;
65
94
  }
66
95
 
67
- .descriptions {
96
+ .price {
68
97
  font-size: 0.7rem;
69
98
  line-height: 1.03rem;
70
99
  font-weight: 300;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.44.485-dev.98",
3
+ "version": "0.44.485-dev.99",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -0,0 +1,46 @@
1
+ import { DAY_OF_WEEK, DAY_NUMBER_WITH_MONTH } from "@licklist/core/dist/Config";
2
+ import { getDayWithOrdinal } from "@licklist/plugins/dist/utils/formatDate";
3
+ import clsx from "clsx";
4
+ import { isToday, isTomorrow } from "date-fns";
5
+ import { DateTime } from "luxon";
6
+ import React from "react";
7
+ import { useTranslation } from "react-i18next/*";
8
+ import { DateTimeButtonProps } from "./DateTimeButton";
9
+
10
+ type DateContentProps = Pick<
11
+ DateTimeButtonProps,
12
+ "isDisabled" | "isSelected"
13
+ > & {
14
+ date: DateTime;
15
+ };
16
+
17
+ export const DateContent = ({
18
+ date,
19
+ isDisabled,
20
+ isSelected,
21
+ }: DateContentProps) => {
22
+ const { t } = useTranslation("Design");
23
+
24
+ const getDate = () => {
25
+ if (isToday(date.toJSDate())) return t("today");
26
+ if (isTomorrow(date.toJSDate())) return t("tomorrow");
27
+ return date.toFormat(DAY_OF_WEEK);
28
+ };
29
+
30
+ const [day, month] = date.toFormat(DAY_NUMBER_WITH_MONTH).split(" ");
31
+
32
+ return (
33
+ <div className="weekday-info">
34
+ <div>{getDate()}</div>
35
+ <div
36
+ className={clsx(
37
+ "descriptions",
38
+ isSelected && "selected",
39
+ isDisabled && "disabled"
40
+ )}
41
+ >
42
+ {`${getDayWithOrdinal(+day)} ${month}`}
43
+ </div>
44
+ </div>
45
+ );
46
+ };
@@ -48,11 +48,10 @@ export const Time: Story<DateTimeButtonProps> = (args) => {
48
48
  };
49
49
 
50
50
  Time.args = {
51
- date,
51
+ date: "10:10",
52
52
  isSelected: false,
53
53
  isDisabled: true,
54
54
  onSelect: () => null,
55
- isTimeButton: true,
56
55
  };
57
56
 
58
57
  export const OnlyTime: Story<DateTimeButtonProps> = (args) => {
@@ -60,9 +59,22 @@ export const OnlyTime: Story<DateTimeButtonProps> = (args) => {
60
59
  };
61
60
 
62
61
  OnlyTime.args = {
63
- date,
62
+ date: "10:10",
64
63
  isSelected: false,
65
64
  isDisabled: true,
66
65
  onSelect: () => null,
67
66
  isOnlyTimeContainer: true,
68
67
  };
68
+
69
+ export const WithPrice: Story<DateTimeButtonProps> = (args) => {
70
+ return <DateTimeButton {...args} />;
71
+ };
72
+
73
+ WithPrice.args = {
74
+ date,
75
+ isSelected: false,
76
+ isDisabled: false,
77
+ onSelect: () => null,
78
+ isOnlyTimeContainer: false,
79
+ price: "from $8000",
80
+ };
@@ -1,32 +1,25 @@
1
- import React from "react";
1
+ import React, { ReactElement } from "react";
2
2
  import clsx from "clsx";
3
3
  import { DateTime } from "luxon";
4
- import { DAY_NUMBER_WITH_MONTH, DAY_OF_WEEK } from "@licklist/core/dist/Config";
5
- import { useTranslation } from "react-i18next";
6
- import { isToday, isTomorrow } from "date-fns";
4
+ import { DateContent } from "./DateContent";
7
5
 
8
- export type DateTimeButtonProps = {
9
- date?: DateTime;
10
- time?: string;
6
+ export type DateTimeButtonProps<T = DateTime | string> = {
7
+ date: T;
11
8
  isSelected?: boolean;
12
9
  isDisabled?: boolean;
13
- onSelect: (date: DateTime | string) => void;
10
+ onSelect: (date: T) => void;
14
11
  isOnlyTimeContainer?: boolean;
12
+ price?: string | number | ReactElement | null;
15
13
  };
16
14
 
17
- export const DateTimeButton = ({
15
+ export const DateTimeButton = <T extends DateTime | string>({
18
16
  date,
19
17
  isDisabled,
20
- time,
21
18
  isSelected,
22
19
  onSelect,
23
20
  isOnlyTimeContainer,
24
- }: DateTimeButtonProps) => {
25
- const onClick = () => {
26
- if (isDisabled) return;
27
- onSelect(date || time);
28
- };
29
-
21
+ price,
22
+ }: DateTimeButtonProps<T>) => {
30
23
  // const infoLogo = useMemo(() => {
31
24
  // if (info?.logo === infoLogoType.LIMIT) {
32
25
  // return <LimitedSvg />;
@@ -40,67 +33,41 @@ export const DateTimeButton = ({
40
33
  // return null;
41
34
  // }, [info]);
42
35
 
36
+ const isTimeVariant = typeof date === "string";
37
+
43
38
  return (
44
- <div
45
- role="button"
46
- onClick={onClick}
47
- onKeyPress={onClick}
39
+ <button
40
+ type="button"
41
+ onClick={() => onSelect(date)}
42
+ disabled={isDisabled}
48
43
  className={clsx(
49
44
  "date-time-button",
50
45
  isDisabled && "disabled",
51
46
  isSelected && "selected",
52
- time && "time-button",
53
- isOnlyTimeContainer && "only-time-container"
47
+ isTimeVariant && "time-button",
48
+ isOnlyTimeContainer && "only-time-container",
49
+ !isTimeVariant && "today"
54
50
  )}
55
- tabIndex={0}
56
51
  >
57
- {date ? (
52
+ {isTimeVariant ? (
53
+ date
54
+ ) : (
58
55
  <DateContent
59
56
  date={date}
60
57
  isDisabled={isDisabled}
61
58
  isSelected={isSelected}
62
59
  />
63
- ) : (
64
- time
65
60
  )}
66
61
 
67
- {/* TODO fix info props */}
62
+ {price && <div className="price">{price}</div>}
63
+
64
+ {/* TODO uncomment when adding availability */}
68
65
  {/* {info && (
69
66
  <div className="info">
70
67
  {info.logo && <Logo className="logo" logo={infoLogo} />}
71
68
  <div>{info.description}</div>
72
69
  </div>
73
70
  )} */}
74
- </div>
75
- );
76
- };
77
-
78
- const DateContent = ({
79
- date,
80
- isDisabled,
81
- isSelected,
82
- }: Pick<DateTimeButtonProps, "date" | "isDisabled" | "isSelected">) => {
83
- const { t } = useTranslation("Design");
84
-
85
- const getDate = () => {
86
- if (isToday(date.toJSDate())) return t("today");
87
- if (isTomorrow(date.toJSDate())) return t("tomorrow");
88
- return date.toFormat(DAY_OF_WEEK);
89
- };
90
-
91
- return (
92
- <>
93
- {getDate()}
94
- <div
95
- className={clsx(
96
- "descriptions",
97
- isSelected && "selected",
98
- isDisabled && "disabled"
99
- )}
100
- >
101
- {/* TODO add ordinal to date format */}
102
- {date.toFormat(DAY_NUMBER_WITH_MONTH)}
103
- </div>
104
- </>
71
+ </button>
105
72
  );
106
73
  };
@@ -3,27 +3,50 @@
3
3
  align-items: center;
4
4
  justify-content: center;
5
5
  flex-direction: column;
6
+ gap: 0.25rem;
6
7
  font-size: 0.82rem;
7
- line-height: 1.3rem;
8
- font-weight: 600;
9
8
  background-color: $snippet-calendar-button-background-color;
10
9
  border-radius: 0.4rem;
11
10
  text-align: center;
12
11
  border: 2px solid $snippet-calendar-button-border-color;
13
12
  color: $snippet-calendar-button-font-color;
14
- flex-grow: 1;
15
13
  transition: $color-transition;
16
14
  min-width: 6rem;
17
- max-width: 7.25rem;
18
- min-height: 3.3rem;
19
- max-height: 8.375rem;
15
+ min-height: 3rem;
16
+ max-width: max-content;
17
+ padding: 0.5rem;
18
+
19
+ .weekday-info {
20
+ div:first-child {
21
+ text-transform: uppercase;
22
+ font-weight: 600;
23
+ }
24
+
25
+ div:last-child {
26
+ color: $snippet-calendar-active-button-background-color;
27
+ }
28
+ }
29
+
30
+ .descriptions {
31
+ font-size: 0.7rem;
32
+ }
33
+
34
+ &.today:first-of-type {
35
+ min-width: 7.5rem;
36
+ }
20
37
 
21
38
  &.disabled {
22
39
  border: 2px solid $snippet-calendar-disabled-button-border-color;
23
40
  background-color: $snippet-calendar-disabled-button-background-color;
24
41
  color: $snippet-calendar-disabled-button-font-color;
25
42
 
26
- .descriptions {
43
+ .weekday-info {
44
+ div:last-child {
45
+ color: $snippet-calendar-disabled-button-font-color;
46
+ }
47
+ }
48
+
49
+ .price {
27
50
  color: $snippet-calendar-disabled-button-font-color;
28
51
  }
29
52
  }
@@ -34,7 +57,13 @@
34
57
  color: $snippet-calendar-active-button-font-color;
35
58
  transition: $color-transition;
36
59
 
37
- .descriptions {
60
+ .weekday-info {
61
+ div:last-child {
62
+ color: $snippet-calendar-active-button-font-color;
63
+ }
64
+ }
65
+
66
+ .price {
38
67
  color: $snippet-calendar-active-button-font-color;
39
68
  background-color: $snippet-calendar-active-button-background-color;
40
69
  font-weight: 600;
@@ -64,7 +93,7 @@
64
93
  font-weight: 300;
65
94
  }
66
95
 
67
- .descriptions {
96
+ .price {
68
97
  font-size: 0.7rem;
69
98
  line-height: 1.03rem;
70
99
  font-weight: 300;