@toptal/picasso-rating 2.0.2 → 3.0.0

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.
Files changed (30) hide show
  1. package/dist-package/src/RatingIcon/RatingIcon.d.ts.map +1 -1
  2. package/dist-package/src/RatingIcon/RatingIcon.js +2 -11
  3. package/dist-package/src/RatingIcon/RatingIcon.js.map +1 -1
  4. package/dist-package/src/RatingStars/RatingStars.d.ts.map +1 -1
  5. package/dist-package/src/RatingStars/RatingStars.js +4 -12
  6. package/dist-package/src/RatingStars/RatingStars.js.map +1 -1
  7. package/dist-package/src/RatingThumbs/RatingThumbs.d.ts.map +1 -1
  8. package/dist-package/src/RatingThumbs/RatingThumbs.js +10 -16
  9. package/dist-package/src/RatingThumbs/RatingThumbs.js.map +1 -1
  10. package/dist-package/src/RatingThumbs/styles.d.ts +8 -3
  11. package/dist-package/src/RatingThumbs/styles.d.ts.map +1 -1
  12. package/dist-package/src/RatingThumbs/styles.js +12 -33
  13. package/dist-package/src/RatingThumbs/styles.js.map +1 -1
  14. package/package.json +5 -5
  15. package/src/RatingIcon/RatingIcon.tsx +5 -13
  16. package/src/RatingIcon/__snapshots__/test.tsx.snap +1 -1
  17. package/src/RatingStars/RatingStars.tsx +4 -14
  18. package/src/RatingStars/__snapshots__/test.tsx.snap +16 -16
  19. package/src/RatingThumbs/RatingThumbs.tsx +10 -19
  20. package/src/RatingThumbs/styles.ts +24 -35
  21. package/dist-package/src/RatingIcon/styles.d.ts +0 -4
  22. package/dist-package/src/RatingIcon/styles.d.ts.map +0 -1
  23. package/dist-package/src/RatingIcon/styles.js +0 -11
  24. package/dist-package/src/RatingIcon/styles.js.map +0 -1
  25. package/dist-package/src/RatingStars/styles.d.ts +0 -3
  26. package/dist-package/src/RatingStars/styles.d.ts.map +0 -1
  27. package/dist-package/src/RatingStars/styles.js +0 -13
  28. package/dist-package/src/RatingStars/styles.js.map +0 -1
  29. package/src/RatingIcon/styles.ts +0 -13
  30. package/src/RatingStars/styles.ts +0 -14
@@ -1 +1 @@
1
- {"version":3,"file":"RatingIcon.d.ts","sourceRoot":"","sources":["../../../src/RatingIcon/RatingIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAGzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAKtD,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,EAAE,OAAO,CAAA;IACpB,IAAI,EAAE,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,CAAA;CAClC;AAWD,QAAA,MAAM,UAAU,8EAuBd,CAAA;AAQF,eAAe,UAAU,CAAA"}
1
+ {"version":3,"file":"RatingIcon.d.ts","sourceRoot":"","sources":["../../../src/RatingIcon/RatingIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAItD,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,EAAE,OAAO,CAAA;IACpB,IAAI,EAAE,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,CAAA;CAClC;AAOD,QAAA,MAAM,UAAU,8EAsBd,CAAA;AAQF,eAAe,UAAU,CAAA"}
@@ -10,25 +10,16 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React, { forwardRef } from 'react';
13
- import { makeStyles } from '@material-ui/core/styles';
14
- import cx from 'classnames';
15
13
  import { Star16, StarSolid16, Star24, StarSolid24 } from '@toptal/picasso-icons';
16
- import styles from './styles';
17
- const useStyles = makeStyles(styles, {
18
- name: 'PicassoRatingIcon',
19
- });
14
+ import { twJoin } from '@toptal/picasso-tailwind-merge';
20
15
  const iconsBySize = {
21
16
  small: [Star16, StarSolid16],
22
17
  large: [Star24, StarSolid24],
23
18
  };
24
19
  const RatingIcon = forwardRef(function RatingIcon(props, ref) {
25
20
  const { active, hovered, interactive, size } = props, rest = __rest(props, ["active", "hovered", "interactive", "size"]);
26
- const classes = useStyles();
27
21
  const iconColor = 'yellow';
28
- const iconClasses = cx({
29
- [classes.clickableIcon]: interactive,
30
- [classes.hovered]: hovered,
31
- });
22
+ const iconClasses = twJoin(interactive && 'transition-all duration-350 ease-out hover:scale-150', hovered && 'scale-150');
32
23
  const [Icon, IconSolid] = iconsBySize[size] || iconsBySize.small;
33
24
  return (React.createElement("span", Object.assign({}, rest, { ref: ref }), active ? (React.createElement(IconSolid, { color: iconColor, className: iconClasses })) : (React.createElement(Icon, { color: iconColor, className: iconClasses }))));
34
25
  });
@@ -1 +1 @@
1
- {"version":3,"file":"RatingIcon.js","sourceRoot":"","sources":["../../../src/RatingIcon/RatingIcon.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEhF,OAAO,MAAM,MAAM,UAAU,CAAA;AAS7B,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,EAAE;IACnC,IAAI,EAAE,mBAAmB;CAC1B,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;IAC5B,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;CAC7B,CAAA;AAED,MAAM,UAAU,GAAG,UAAU,CAAwB,SAAS,UAAU,CACtE,KAAK,EACL,GAAG;IAEH,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAA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E,OAAO,CAAA;IACrB,mBAAmB;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,CAAA;CACnC;AAED,QAAA,MAAM,WAAW,8EAgFf,CAAA;AAUF,eAAe,WAAW,CAAA"}
@@ -10,17 +10,11 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React, { forwardRef, useCallback } from 'react';
13
- import { makeStyles } from '@material-ui/core/styles';
14
- import cx from 'classnames';
15
13
  import { Container } from '@toptal/picasso-container';
14
+ import { twJoin } from '@toptal/picasso-tailwind-merge';
16
15
  import { RatingIcon } from '../RatingIcon';
17
- import styles from './styles';
18
- const useStyles = makeStyles(styles, {
19
- name: 'PicassoRating',
20
- });
21
16
  const RatingStars = forwardRef(function RatingStars(props, ref) {
22
17
  const { name, value, onChange, renderItem = (_, icon) => icon, max, interactive = true, size = 'small' } = props, rest = __rest(props, ["name", "value", "onChange", "renderItem", "max", "interactive", "size"]);
23
- const classes = useStyles();
24
18
  const handleChange = useCallback((event) => {
25
19
  if (onChange && interactive) {
26
20
  onChange(event);
@@ -36,13 +30,11 @@ const RatingStars = forwardRef(function RatingStars(props, ref) {
36
30
  const defaultIcon = (React.createElement(RatingIcon, { active: !!value && itemValue <= value, interactive: interactive, size: size }));
37
31
  // When the user clicks again on the selected rating, reset the rating
38
32
  const shouldReset = itemValue === Number(value);
39
- return (React.createElement("label", { key: itemId, htmlFor: shouldReset ? resetInputId : itemId, className: cx(classes.label, {
40
- [classes.clickableLabel]: interactive,
41
- }) },
33
+ return (React.createElement("label", { key: itemId, htmlFor: shouldReset ? resetInputId : itemId, className: twJoin('mr-[.125rem]', interactive && 'cursor-pointer') },
42
34
  renderItem(itemValue, defaultIcon),
43
- React.createElement("input", { type: 'radio', name: name, id: itemId, value: itemValue, onChange: handleChange, readOnly: !interactive, checked: itemValue === value, className: classes.radio, "data-testid": itemId })));
35
+ React.createElement("input", { type: 'radio', name: name, id: itemId, value: itemValue, onChange: handleChange, readOnly: !interactive, checked: itemValue === value, className: 'hidden', "data-testid": itemId })));
44
36
  }),
45
- React.createElement("input", { type: 'radio', name: name, id: resetInputId, value: '', onChange: handleChange, className: classes.radio })));
37
+ React.createElement("input", { type: 'radio', name: name, id: resetInputId, value: '', onChange: handleChange, className: 'hidden' })));
46
38
  });
47
39
  RatingStars.defaultProps = {
48
40
  interactive: true,
@@ -1 +1 @@
1
- {"version":3,"file":"RatingStars.js","sourceRoot":"","sources":["../../../src/RatingStars/RatingStars.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,MAAM,MAAM,UAAU,CAAA;AAmB7B,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,EAAE;IACnC,IAAI,EAAE,eAAe;CACtB,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG,UAAU,CAAwB,SAAS,WAAW,CACxE,KAAK,EACL,GAAG;IAEH,MAAM,EACJ,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,UAAU,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAC9B,GAAG,EACH,WAAW,GAAG,IAAI,EAClB,IAAI,GAAG,OAAO,KAEZ,KAAK,EADJ,IAAI,UACL,KAAK,EATH,yEASL,CAAQ,CAAA;IAET,MAAM,OAAO,GAAG,SAAS,EAAE,CAAA;IAE3B,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,KAAoC,EAAE,EAAE;QACvC,IAAI,QAAQ,IAAI,WAAW,EAAE;YAC3B,QAAQ,CAAC,KAAK,CAAC,CAAA;S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AA;AAEF,WAAW,CAAC,YAAY,GAAG;IACzB,WAAW,EAAE,IAAI;IACjB,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,OAAO;CACd,CAAA;AAED,WAAW,CAAC,WAAW,GAAG,aAAa,CAAA;AAEvC,eAAe,WAAW,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"RatingThumbs.d.ts","sourceRoot":"","sources":["../../../src/RatingThumbs/RatingThumbs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,KAA4C,MAAM,OAAO,CAAA;AAWhE,aAAK,IAAI,GAAG,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,CAAA;AAEvC,MAAM,WAAW,KAAM,SAAQ,SAAS;IACtC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,cAAc,CAAC,KAAK,IAAI,CAAA;IAEvE;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,CAAA;IAGX,OAAO,CAAC,EAAE;QACR,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,aAAa,CAAC,EAAE,MAAM,CAAA;KACvB,CAAA;CACF;AAgBD,eAAO,MAAM,YAAY,8EAqExB,CAAA;AAID,eAAe,YAAY,CAAA"}
1
+ {"version":3,"file":"RatingThumbs.d.ts","sourceRoot":"","sources":["../../../src/RatingThumbs/RatingThumbs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,KAA4C,MAAM,OAAO,CAAA;AAWhE,aAAK,IAAI,GAAG,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,CAAA;AAEvC,MAAM,WAAW,KAAM,SAAQ,SAAS;IACtC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,cAAc,CAAC,KAAK,IAAI,CAAA;IAEvE;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,CAAA;IAGX,OAAO,CAAC,EAAE;QACR,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,aAAa,CAAC,EAAE,MAAM,CAAA;KACvB,CAAA;CACF;AAcD,eAAO,MAAM,YAAY,8EAiExB,CAAA;AAID,eAAe,YAAY,CAAA"}
@@ -1,17 +1,13 @@
1
- import { makeStyles } from '@material-ui/core/styles';
2
- import classNames from 'classnames';
3
1
  import React, { forwardRef, useCallback, useState } from 'react';
4
2
  import { ThumbsDown16, ThumbsDown24, ThumbsUp16, ThumbsUp24, } from '@toptal/picasso-icons';
5
3
  import { Container } from '@toptal/picasso-container';
6
- import styles from './styles';
7
- const useStyles = makeStyles(styles);
4
+ import { getThumbClasses, labelClasses } from './styles';
8
5
  const componentsBySize = {
9
6
  small: [ThumbsUp16, ThumbsDown16],
10
7
  large: [ThumbsUp24, ThumbsDown24],
11
8
  };
12
9
  let globalId = 0;
13
10
  export const RatingThumbs = forwardRef(function RatingThumbs({ name, interactive = true, size = 'small', value, onChange, testIds = {} }, ref) {
14
- const classes = useStyles();
15
11
  const [baseUniqueId] = useState(() => globalId++);
16
12
  const positiveInputId = `${baseUniqueId}-posititve`;
17
13
  const negativeInputId = `${baseUniqueId}-negative`;
@@ -22,18 +18,16 @@ export const RatingThumbs = forwardRef(function RatingThumbs({ name, interactive
22
18
  }
23
19
  }, [onChange, interactive]);
24
20
  return (React.createElement(Container, { ref: ref },
25
- React.createElement("label", { className: classes.label, htmlFor: positiveInputId },
26
- React.createElement(ThumbsUp, { className: classNames(classes.thumbs, {
27
- [classes.interactiveThumbs]: interactive,
28
- [classes.thumbsPositive]: value === true,
21
+ React.createElement("label", { className: labelClasses, htmlFor: positiveInputId },
22
+ React.createElement(ThumbsUp, { className: getThumbClasses({ thumbType: 'up', interactive, value }) }),
23
+ React.createElement("input", { id: positiveInputId, className: 'hidden', type: 'radio', name: name, value: "positive" /* ThumbsValue.POSITIVE */, onChange: handleChange, readOnly: !interactive, checked: value === true, "data-testid": testIds.positiveInput })),
24
+ React.createElement("label", { className: labelClasses, htmlFor: negativeInputId },
25
+ React.createElement(ThumbsDown, { className: getThumbClasses({
26
+ thumbType: 'down',
27
+ interactive,
28
+ value,
29
29
  }) }),
30
- React.createElement("input", { id: positiveInputId, className: classes.radio, type: 'radio', name: name, value: "positive" /* ThumbsValue.POSITIVE */, onChange: handleChange, readOnly: !interactive, checked: value === true, "data-testid": testIds.positiveInput })),
31
- React.createElement("label", { className: classes.label, htmlFor: negativeInputId },
32
- React.createElement(ThumbsDown, { className: classNames(classes.thumbs, {
33
- [classes.interactiveThumbs]: interactive,
34
- [classes.thumbsNegative]: value === false,
35
- }) }),
36
- React.createElement("input", { id: negativeInputId, className: classes.radio, type: 'radio', name: name, value: "negative" /* ThumbsValue.NEGATIVE */, onChange: handleChange, readOnly: !interactive, checked: value === false, "data-testid": testIds.negativeInput }))));
30
+ React.createElement("input", { id: negativeInputId, className: 'hidden', type: 'radio', name: name, value: "negative" /* ThumbsValue.NEGATIVE */, onChange: handleChange, readOnly: !interactive, checked: value === false, "data-testid": testIds.negativeInput }))));
37
31
  });
38
32
  RatingThumbs.displayName = 'RatingThumbs';
39
33
  export default RatingThumbs;
@@ -1 +1 @@
1
- {"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ui/core';
2
- declare const _default: ({ palette, transitions }: Theme) => import("@material-ui/styles").StyleRules<{}, "radio" | "label" | "thumbs" | "interactiveThumbs" | "thumbsPositive" | "thumbsNegative">;
3
- export default _default;
1
+ declare type Props = {
2
+ thumbType: 'up' | 'down';
3
+ interactive: boolean;
4
+ value?: boolean;
5
+ };
6
+ export declare const labelClasses = "[&:not(:last-child)]:mr-[1em]";
7
+ export declare const getThumbClasses: ({ thumbType, interactive, value }: Props) => string;
8
+ export {};
4
9
  //# sourceMappingURL=styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/RatingThumbs/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;mDAGJ,KAAK;AAA/C,wBAgCI"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/RatingThumbs/styles.ts"],"names":[],"mappings":"AAEA,aAAK,KAAK,GAAG;IACX,SAAS,EAAE,IAAI,GAAG,MAAM,CAAA;IACxB,WAAW,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,YAAY,kCAAkC,CAAA;AAE3D,eAAO,MAAM,eAAe,sCAAuC,KAAK,WAcvE,CAAA"}
@@ -1,34 +1,13 @@
1
- import { createStyles } from '@material-ui/core';
2
- export default ({ palette, transitions }) => createStyles({
3
- radio: {
4
- display: 'none',
5
- },
6
- label: {
7
- '&:not(:last-child)': {
8
- marginRight: '1em',
9
- },
10
- },
11
- thumbs: {
12
- color: palette.grey.light2,
13
- transition: `color ${transitions.duration.shorter}ms linear`,
14
- },
15
- interactiveThumbs: {
16
- cursor: 'pointer',
17
- '&:hover': {
18
- color: palette.text.primary,
19
- },
20
- },
21
- thumbsPositive: {
22
- color: palette.green.main,
23
- '&:hover': {
24
- color: palette.green.main,
25
- },
26
- },
27
- thumbsNegative: {
28
- color: palette.red.main,
29
- '&:hover': {
30
- color: palette.red.main,
31
- },
32
- },
33
- });
1
+ import { twJoin } from '@toptal/picasso-tailwind-merge';
2
+ export const labelClasses = '[&:not(:last-child)]:mr-[1em]';
3
+ export const getThumbClasses = ({ thumbType, interactive, value }) => {
4
+ let classByType = 'text-gray-400';
5
+ if (thumbType === 'up' && value === true) {
6
+ classByType = 'text-green-500 hover:text-green-500';
7
+ }
8
+ else if (thumbType === 'down' && value === false) {
9
+ classByType = 'text-red-500 hover:text-red-500';
10
+ }
11
+ return twJoin('transition-colors duration-200 ease-linear', interactive ? 'cursor-pointer hover:text-graphite-700' : '', classByType);
12
+ };
34
13
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/RatingThumbs/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,eAAe,CAAC,EAAE,OAAO,EAAE,WAAW,EAAS,EAAE,EAAE,CACjD,YAAY,CAAC;IACX,KAAK,EAAE;QACL,OAAO,EAAE,MAAM;KAChB;IACD,KAAK,EAAE;QACL,oBAAoB,EAAE;YACpB,WAAW,EAAE,KAAK;SACnB;KACF;IACD,MAAM,EAAE;QACN,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM;QAC1B,UAAU,EAAE,SAAS,WAAW,CAAC,QAAQ,CAAC,OAAO,WAAW;KAC7D;IACD,iBAAiB,EAAE;QACjB,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE;YACT,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO;SAC5B;KACF;IACD,cAAc,EAAE;QACd,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI;QACzB,SAAS,EAAE;YACT,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI;SAC1B;KACF;IACD,cAAc,EAAE;QACd,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI;QACvB,SAAS,EAAE;YACT,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI;SACxB;KACF;CACF,CAAC,CAAA"}
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/RatingThumbs/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAA;AAQvD,MAAM,CAAC,MAAM,YAAY,GAAG,+BAA+B,CAAA;AAE3D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAS,EAAE,EAAE;IAC1E,IAAI,WAAW,GAAG,eAAe,CAAA;IAEjC,IAAI,SAAS,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI,EAAE;QACxC,WAAW,GAAG,qCAAqC,CAAA;KACpD;SAAM,IAAI,SAAS,KAAK,MAAM,IAAI,KAAK,KAAK,KAAK,EAAE;QAClD,WAAW,GAAG,iCAAiC,CAAA;KAChD;IAED,OAAO,MAAM,CACX,4CAA4C,EAC5C,WAAW,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC,EAAE,EAC3D,WAAW,CACZ,CAAA;AACH,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/picasso-rating",
3
- "version": "2.0.2",
3
+ "version": "3.0.0",
4
4
  "description": "Toptal UI components library - Rating",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,15 +24,14 @@
24
24
  "dependencies": {
25
25
  "@toptal/picasso-container": "3.0.0",
26
26
  "@toptal/picasso-icons": "1.6.0",
27
- "@toptal/picasso-utils": "1.0.3",
28
- "classnames": "^2.5.1"
27
+ "@toptal/picasso-utils": "1.0.3"
29
28
  },
30
29
  "sideEffects": [
31
30
  "**/styles.ts",
32
31
  "**/styles.js"
33
32
  ],
34
33
  "peerDependencies": {
35
- "@material-ui/core": "4.12.4",
34
+ "@toptal/picasso-tailwind-merge": "^2.0.0",
36
35
  "@toptal/picasso-tailwind": ">=2.7",
37
36
  "react": ">=16.12.0 < 19.0.0"
38
37
  },
@@ -40,7 +39,8 @@
40
39
  ".": "./dist-package/src/index.js"
41
40
  },
42
41
  "devDependencies": {
43
- "@toptal/picasso-test-utils": "1.1.1"
42
+ "@toptal/picasso-test-utils": "1.1.1",
43
+ "@toptal/picasso-tailwind-merge": "2.0.0"
44
44
  },
45
45
  "files": [
46
46
  "dist-package/**",
@@ -1,10 +1,7 @@
1
1
  import React, { forwardRef } from 'react'
2
- import { makeStyles } from '@material-ui/core/styles'
3
- import cx from 'classnames'
4
2
  import type { SizeType } from '@toptal/picasso-shared'
5
3
  import { Star16, StarSolid16, Star24, StarSolid24 } from '@toptal/picasso-icons'
6
-
7
- import styles from './styles'
4
+ import { twJoin } from '@toptal/picasso-tailwind-merge'
8
5
 
9
6
  export interface Props {
10
7
  active: boolean
@@ -13,10 +10,6 @@ export interface Props {
13
10
  size: SizeType<'small' | 'large'>
14
11
  }
15
12
 
16
- const useStyles = makeStyles(styles, {
17
- name: 'PicassoRatingIcon',
18
- })
19
-
20
13
  const iconsBySize = {
21
14
  small: [Star16, StarSolid16],
22
15
  large: [Star24, StarSolid24],
@@ -27,13 +20,12 @@ const RatingIcon = forwardRef<HTMLDivElement, Props>(function RatingIcon(
27
20
  ref
28
21
  ) {
29
22
  const { active, hovered, interactive, size, ...rest } = props
30
- const classes = useStyles()
31
23
 
32
24
  const iconColor = 'yellow'
33
- const iconClasses = cx({
34
- [classes.clickableIcon]: interactive,
35
- [classes.hovered]: hovered,
36
- })
25
+ const iconClasses = twJoin(
26
+ interactive && 'transition-all duration-350 ease-out hover:scale-150',
27
+ hovered && 'scale-150'
28
+ )
37
29
  const [Icon, IconSolid] = iconsBySize[size] || iconsBySize.small
38
30
 
39
31
  return (
@@ -7,7 +7,7 @@ exports[`RatingIcon renders 1`] = `
7
7
  >
8
8
  <span>
9
9
  <svg
10
- class="PicassoSvgStarSolid16-root PicassoRatingIcon-clickableIcon PicassoSvgStarSolid16-yellow"
10
+ class="PicassoSvgStarSolid16-root transition-all duration-350 ease-out hover:scale-150 PicassoSvgStarSolid16-yellow"
11
11
  style="min-width: 16px; min-height: 16px;"
12
12
  viewBox="0 0 16 16"
13
13
  >
@@ -1,12 +1,10 @@
1
1
  import type { ReactNode, ChangeEvent } from 'react'
2
2
  import React, { forwardRef, useCallback } from 'react'
3
3
  import type { BaseProps, SizeType } from '@toptal/picasso-shared'
4
- import { makeStyles } from '@material-ui/core/styles'
5
- import cx from 'classnames'
6
4
  import { Container } from '@toptal/picasso-container'
5
+ import { twJoin } from '@toptal/picasso-tailwind-merge'
7
6
 
8
7
  import { RatingIcon } from '../RatingIcon'
9
- import styles from './styles'
10
8
 
11
9
  export interface Props extends BaseProps {
12
10
  /** Value of the name attribute of the rating input */
@@ -25,10 +23,6 @@ export interface Props extends BaseProps {
25
23
  size?: SizeType<'small' | 'large'>
26
24
  }
27
25
 
28
- const useStyles = makeStyles(styles, {
29
- name: 'PicassoRating',
30
- })
31
-
32
26
  const RatingStars = forwardRef<HTMLDivElement, Props>(function RatingStars(
33
27
  props,
34
28
  ref
@@ -44,8 +38,6 @@ const RatingStars = forwardRef<HTMLDivElement, Props>(function RatingStars(
44
38
  ...rest
45
39
  } = props
46
40
 
47
- const classes = useStyles()
48
-
49
41
  const handleChange = useCallback(
50
42
  (event: ChangeEvent<HTMLInputElement>) => {
51
43
  if (onChange && interactive) {
@@ -82,9 +74,7 @@ const RatingStars = forwardRef<HTMLDivElement, Props>(function RatingStars(
82
74
  <label
83
75
  key={itemId}
84
76
  htmlFor={shouldReset ? resetInputId : itemId}
85
- className={cx(classes.label, {
86
- [classes.clickableLabel]: interactive,
87
- })}
77
+ className={twJoin('mr-[.125rem]', interactive && 'cursor-pointer')}
88
78
  >
89
79
  {renderItem(itemValue, defaultIcon)}
90
80
  <input
@@ -95,7 +85,7 @@ const RatingStars = forwardRef<HTMLDivElement, Props>(function RatingStars(
95
85
  onChange={handleChange}
96
86
  readOnly={!interactive}
97
87
  checked={itemValue === value}
98
- className={classes.radio}
88
+ className='hidden'
99
89
  data-testid={itemId}
100
90
  />
101
91
  </label>
@@ -109,7 +99,7 @@ const RatingStars = forwardRef<HTMLDivElement, Props>(function RatingStars(
109
99
  id={resetInputId}
110
100
  value=''
111
101
  onChange={handleChange}
112
- className={classes.radio}
102
+ className='hidden'
113
103
  />
114
104
  </Container>
115
105
  )
@@ -9,12 +9,12 @@ exports[`Rating.Stars renders 1`] = `
9
9
  class=""
10
10
  >
11
11
  <label
12
- class="PicassoRating-label PicassoRating-clickableLabel"
12
+ class="mr-[.125rem] cursor-pointer"
13
13
  for="rating-name-1"
14
14
  >
15
15
  <span>
16
16
  <svg
17
- class="PicassoSvgStarSolid16-root PicassoRatingIcon-clickableIcon PicassoSvgStarSolid16-yellow"
17
+ class="PicassoSvgStarSolid16-root transition-all duration-350 ease-out hover:scale-150 PicassoSvgStarSolid16-yellow"
18
18
  style="min-width: 16px; min-height: 16px;"
19
19
  viewBox="0 0 16 16"
20
20
  >
@@ -24,7 +24,7 @@ exports[`Rating.Stars renders 1`] = `
24
24
  </svg>
25
25
  </span>
26
26
  <input
27
- class="PicassoRating-radio"
27
+ class="hidden"
28
28
  data-testid="rating-name-1"
29
29
  id="rating-name-1"
30
30
  name="rating-name"
@@ -33,12 +33,12 @@ exports[`Rating.Stars renders 1`] = `
33
33
  />
34
34
  </label>
35
35
  <label
36
- class="PicassoRating-label PicassoRating-clickableLabel"
36
+ class="mr-[.125rem] cursor-pointer"
37
37
  for="rating-name-2"
38
38
  >
39
39
  <span>
40
40
  <svg
41
- class="PicassoSvgStarSolid16-root PicassoRatingIcon-clickableIcon PicassoSvgStarSolid16-yellow"
41
+ class="PicassoSvgStarSolid16-root transition-all duration-350 ease-out hover:scale-150 PicassoSvgStarSolid16-yellow"
42
42
  style="min-width: 16px; min-height: 16px;"
43
43
  viewBox="0 0 16 16"
44
44
  >
@@ -48,7 +48,7 @@ exports[`Rating.Stars renders 1`] = `
48
48
  </svg>
49
49
  </span>
50
50
  <input
51
- class="PicassoRating-radio"
51
+ class="hidden"
52
52
  data-testid="rating-name-2"
53
53
  id="rating-name-2"
54
54
  name="rating-name"
@@ -57,12 +57,12 @@ exports[`Rating.Stars renders 1`] = `
57
57
  />
58
58
  </label>
59
59
  <label
60
- class="PicassoRating-label PicassoRating-clickableLabel"
60
+ class="mr-[.125rem] cursor-pointer"
61
61
  for="rating-name-reset"
62
62
  >
63
63
  <span>
64
64
  <svg
65
- class="PicassoSvgStarSolid16-root PicassoRatingIcon-clickableIcon PicassoSvgStarSolid16-yellow"
65
+ class="PicassoSvgStarSolid16-root transition-all duration-350 ease-out hover:scale-150 PicassoSvgStarSolid16-yellow"
66
66
  style="min-width: 16px; min-height: 16px;"
67
67
  viewBox="0 0 16 16"
68
68
  >
@@ -73,7 +73,7 @@ exports[`Rating.Stars renders 1`] = `
73
73
  </span>
74
74
  <input
75
75
  checked=""
76
- class="PicassoRating-radio"
76
+ class="hidden"
77
77
  data-testid="rating-name-3"
78
78
  id="rating-name-3"
79
79
  name="rating-name"
@@ -82,12 +82,12 @@ exports[`Rating.Stars renders 1`] = `
82
82
  />
83
83
  </label>
84
84
  <label
85
- class="PicassoRating-label PicassoRating-clickableLabel"
85
+ class="mr-[.125rem] cursor-pointer"
86
86
  for="rating-name-4"
87
87
  >
88
88
  <span>
89
89
  <svg
90
- class="PicassoSvgStar16-root PicassoRatingIcon-clickableIcon PicassoSvgStar16-yellow"
90
+ class="PicassoSvgStar16-root transition-all duration-350 ease-out hover:scale-150 PicassoSvgStar16-yellow"
91
91
  style="min-width: 16px; min-height: 16px;"
92
92
  viewBox="0 0 16 16"
93
93
  >
@@ -97,7 +97,7 @@ exports[`Rating.Stars renders 1`] = `
97
97
  </svg>
98
98
  </span>
99
99
  <input
100
- class="PicassoRating-radio"
100
+ class="hidden"
101
101
  data-testid="rating-name-4"
102
102
  id="rating-name-4"
103
103
  name="rating-name"
@@ -106,12 +106,12 @@ exports[`Rating.Stars renders 1`] = `
106
106
  />
107
107
  </label>
108
108
  <label
109
- class="PicassoRating-label PicassoRating-clickableLabel"
109
+ class="mr-[.125rem] cursor-pointer"
110
110
  for="rating-name-5"
111
111
  >
112
112
  <span>
113
113
  <svg
114
- class="PicassoSvgStar16-root PicassoRatingIcon-clickableIcon PicassoSvgStar16-yellow"
114
+ class="PicassoSvgStar16-root transition-all duration-350 ease-out hover:scale-150 PicassoSvgStar16-yellow"
115
115
  style="min-width: 16px; min-height: 16px;"
116
116
  viewBox="0 0 16 16"
117
117
  >
@@ -121,7 +121,7 @@ exports[`Rating.Stars renders 1`] = `
121
121
  </svg>
122
122
  </span>
123
123
  <input
124
- class="PicassoRating-radio"
124
+ class="hidden"
125
125
  data-testid="rating-name-5"
126
126
  id="rating-name-5"
127
127
  name="rating-name"
@@ -130,7 +130,7 @@ exports[`Rating.Stars renders 1`] = `
130
130
  />
131
131
  </label>
132
132
  <input
133
- class="PicassoRating-radio"
133
+ class="hidden"
134
134
  id="rating-name-reset"
135
135
  name="rating-name"
136
136
  type="radio"
@@ -1,7 +1,4 @@
1
- import type { Theme } from '@material-ui/core/styles'
2
- import { makeStyles } from '@material-ui/core/styles'
3
1
  import type { BaseProps, SizeType } from '@toptal/picasso-shared'
4
- import classNames from 'classnames'
5
2
  import type { ChangeEvent } from 'react'
6
3
  import React, { forwardRef, useCallback, useState } from 'react'
7
4
  import {
@@ -12,7 +9,7 @@ import {
12
9
  } from '@toptal/picasso-icons'
13
10
  import { Container } from '@toptal/picasso-container'
14
11
 
15
- import styles from './styles'
12
+ import { getThumbClasses, labelClasses } from './styles'
16
13
 
17
14
  type Size = SizeType<'small' | 'large'>
18
15
 
@@ -49,8 +46,6 @@ export interface Props extends BaseProps {
49
46
  }
50
47
  }
51
48
 
52
- const useStyles = makeStyles<Theme>(styles)
53
-
54
49
  const enum ThumbsValue {
55
50
  POSITIVE = 'positive',
56
51
  NEGATIVE = 'negative',
@@ -68,8 +63,6 @@ export const RatingThumbs = forwardRef<HTMLDivElement, Props>(
68
63
  { name, interactive = true, size = 'small', value, onChange, testIds = {} },
69
64
  ref
70
65
  ) {
71
- const classes = useStyles()
72
-
73
66
  const [baseUniqueId] = useState(() => globalId++)
74
67
 
75
68
  const positiveInputId = `${baseUniqueId}-posititve`
@@ -88,17 +81,14 @@ export const RatingThumbs = forwardRef<HTMLDivElement, Props>(
88
81
 
89
82
  return (
90
83
  <Container ref={ref}>
91
- <label className={classes.label} htmlFor={positiveInputId}>
84
+ <label className={labelClasses} htmlFor={positiveInputId}>
92
85
  <ThumbsUp
93
- className={classNames(classes.thumbs, {
94
- [classes.interactiveThumbs]: interactive,
95
- [classes.thumbsPositive]: value === true,
96
- })}
86
+ className={getThumbClasses({ thumbType: 'up', interactive, value })}
97
87
  />
98
88
 
99
89
  <input
100
90
  id={positiveInputId}
101
- className={classes.radio}
91
+ className='hidden'
102
92
  type='radio'
103
93
  name={name}
104
94
  value={ThumbsValue.POSITIVE}
@@ -109,17 +99,18 @@ export const RatingThumbs = forwardRef<HTMLDivElement, Props>(
109
99
  />
110
100
  </label>
111
101
 
112
- <label className={classes.label} htmlFor={negativeInputId}>
102
+ <label className={labelClasses} htmlFor={negativeInputId}>
113
103
  <ThumbsDown
114
- className={classNames(classes.thumbs, {
115
- [classes.interactiveThumbs]: interactive,
116
- [classes.thumbsNegative]: value === false,
104
+ className={getThumbClasses({
105
+ thumbType: 'down',
106
+ interactive,
107
+ value,
117
108
  })}
118
109
  />
119
110
 
120
111
  <input
121
112
  id={negativeInputId}
122
- className={classes.radio}
113
+ className='hidden'
123
114
  type='radio'
124
115
  name={name}
125
116
  value={ThumbsValue.NEGATIVE}
@@ -1,36 +1,25 @@
1
- import type { Theme } from '@material-ui/core'
2
- import { createStyles } from '@material-ui/core'
1
+ import { twJoin } from '@toptal/picasso-tailwind-merge'
3
2
 
4
- export default ({ palette, transitions }: Theme) =>
5
- createStyles({
6
- radio: {
7
- display: 'none',
8
- },
9
- label: {
10
- '&:not(:last-child)': {
11
- marginRight: '1em',
12
- },
13
- },
14
- thumbs: {
15
- color: palette.grey.light2,
16
- transition: `color ${transitions.duration.shorter}ms linear`,
17
- },
18
- interactiveThumbs: {
19
- cursor: 'pointer',
20
- '&:hover': {
21
- color: palette.text.primary,
22
- },
23
- },
24
- thumbsPositive: {
25
- color: palette.green.main,
26
- '&:hover': {
27
- color: palette.green.main,
28
- },
29
- },
30
- thumbsNegative: {
31
- color: palette.red.main,
32
- '&:hover': {
33
- color: palette.red.main,
34
- },
35
- },
36
- })
3
+ type Props = {
4
+ thumbType: 'up' | 'down'
5
+ interactive: boolean
6
+ value?: boolean
7
+ }
8
+
9
+ export const labelClasses = '[&:not(:last-child)]:mr-[1em]'
10
+
11
+ export const getThumbClasses = ({ thumbType, interactive, value }: Props) => {
12
+ let classByType = 'text-gray-400'
13
+
14
+ if (thumbType === 'up' && value === true) {
15
+ classByType = 'text-green-500 hover:text-green-500'
16
+ } else if (thumbType === 'down' && value === false) {
17
+ classByType = 'text-red-500 hover:text-red-500'
18
+ }
19
+
20
+ return twJoin(
21
+ 'transition-colors duration-200 ease-linear',
22
+ interactive ? 'cursor-pointer hover:text-graphite-700' : '',
23
+ classByType
24
+ )
25
+ }
@@ -1,4 +0,0 @@
1
- import type { Theme } from '@material-ui/core/styles';
2
- declare const _default: ({ transitions }: Theme) => import("@material-ui/styles").StyleRules<{}, "clickableIcon" | "hovered">;
3
- export default _default;
4
- //# sourceMappingURL=styles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/RatingIcon/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;0CAGpB,KAAK;AAAtC,wBASI"}
@@ -1,11 +0,0 @@
1
- import { createStyles } from '@material-ui/core/styles';
2
- export default ({ transitions }) => createStyles({
3
- clickableIcon: {
4
- transition: `all ${transitions.duration.short}ms ${transitions.easing.easeOut}`,
5
- '&:hover, &$hovered': {
6
- transform: 'scale(1.5)',
7
- },
8
- },
9
- hovered: {},
10
- });
11
- //# sourceMappingURL=styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/RatingIcon/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,eAAe,CAAC,EAAE,WAAW,EAAS,EAAE,EAAE,CACxC,YAAY,CAAC;IACX,aAAa,EAAE;QACb,UAAU,EAAE,OAAO,WAAW,CAAC,QAAQ,CAAC,KAAK,MAAM,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE;QAC/E,oBAAoB,EAAE;YACpB,SAAS,EAAE,YAAY;SACxB;KACF;IACD,OAAO,EAAE,EAAE;CACZ,CAAC,CAAA"}
@@ -1,3 +0,0 @@
1
- declare const _default: () => import("@material-ui/styles").StyleRules<{}, "radio" | "label" | "clickableLabel">;
2
- export default _default;
3
- //# sourceMappingURL=styles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/RatingStars/styles.ts"],"names":[],"mappings":";AAEA,wBAWI"}
@@ -1,13 +0,0 @@
1
- import { createStyles } from '@material-ui/core/styles';
2
- export default () => createStyles({
3
- radio: {
4
- display: 'none',
5
- },
6
- label: {
7
- marginRight: '.125rem',
8
- },
9
- clickableLabel: {
10
- cursor: 'pointer',
11
- },
12
- });
13
- //# sourceMappingURL=styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/RatingStars/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,eAAe,GAAG,EAAE,CAClB,YAAY,CAAC;IACX,KAAK,EAAE;QACL,OAAO,EAAE,MAAM;KAChB;IACD,KAAK,EAAE;QACL,WAAW,EAAE,SAAS;KACvB;IACD,cAAc,EAAE;QACd,MAAM,EAAE,SAAS;KAClB;CACF,CAAC,CAAA"}
@@ -1,13 +0,0 @@
1
- import type { Theme } from '@material-ui/core/styles'
2
- import { createStyles } from '@material-ui/core/styles'
3
-
4
- export default ({ transitions }: Theme) =>
5
- createStyles({
6
- clickableIcon: {
7
- transition: `all ${transitions.duration.short}ms ${transitions.easing.easeOut}`,
8
- '&:hover, &$hovered': {
9
- transform: 'scale(1.5)',
10
- },
11
- },
12
- hovered: {},
13
- })
@@ -1,14 +0,0 @@
1
- import { createStyles } from '@material-ui/core/styles'
2
-
3
- export default () =>
4
- createStyles({
5
- radio: {
6
- display: 'none',
7
- },
8
- label: {
9
- marginRight: '.125rem',
10
- },
11
- clickableLabel: {
12
- cursor: 'pointer',
13
- },
14
- })