@purpurds/tooltip 4.6.0 → 5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpurds/tooltip",
3
- "version": "4.6.0",
3
+ "version": "5.0.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "./dist/tooltip.cjs.js",
6
6
  "types": "./dist/tooltip.d.ts",
@@ -16,11 +16,11 @@
16
16
  "dependencies": {
17
17
  "@radix-ui/react-tooltip": "~1.0.7",
18
18
  "classnames": "~2.5.0",
19
- "@purpurds/icon": "4.6.0",
20
- "@purpurds/button": "4.6.0",
21
- "@purpurds/paragraph": "4.6.0",
22
- "@purpurds/action": "4.6.0",
23
- "@purpurds/tokens": "4.6.0"
19
+ "@purpurds/button": "5.0.0",
20
+ "@purpurds/action": "5.0.0",
21
+ "@purpurds/tokens": "5.0.0",
22
+ "@purpurds/icon": "5.0.0",
23
+ "@purpurds/paragraph": "5.0.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@rushstack/eslint-patch": "~1.10.0",
@@ -6,7 +6,7 @@ import type { Meta, StoryObj } from "@storybook/react";
6
6
  import "@purpurds/button/styles";
7
7
  import "@purpurds/icon/styles";
8
8
  import "@purpurds/paragraph/styles";
9
- import { Tooltip, TOOLTIP_ALIGN, TOOLTIP_POSITION, TOOLTIP_VARIANT } from "./tooltip";
9
+ import { Tooltip, TOOLTIP_ALIGN, TOOLTIP_POSITION } from "./tooltip";
10
10
 
11
11
  const meta: Meta<typeof Tooltip> = {
12
12
  title: "Components/Tooltip",
@@ -19,14 +19,13 @@ const meta: Meta<typeof Tooltip> = {
19
19
  ),
20
20
  ],
21
21
  args: {
22
- variant: "primary",
23
- children: "Some tooltip content",
24
- triggerAriaLabel: "Tooltip button",
25
22
  align: "center",
23
+ children: "Some tooltip content",
24
+ negative: false,
26
25
  position: "top",
26
+ triggerAriaLabel: "Tooltip button",
27
27
  },
28
28
  argTypes: {
29
- variant: { options: Object.values(TOOLTIP_VARIANT), control: { type: "select" } },
30
29
  position: { options: Object.values(TOOLTIP_POSITION), control: { type: "select" } },
31
30
  align: { options: Object.values(TOOLTIP_ALIGN), control: { type: "select" } },
32
31
  },
@@ -60,7 +59,7 @@ export default meta;
60
59
  type Story = StoryObj<typeof Tooltip>;
61
60
 
62
61
  export const Showcase: Story = {
63
- name: "Primary",
62
+ name: "Default",
64
63
  args: {
65
64
  children:
66
65
  "This is a longer tooltip text to display that there is a max-width on the tooltip container.",
@@ -69,9 +68,9 @@ export const Showcase: Story = {
69
68
  };
70
69
 
71
70
  export const TooltipNegative: Story = {
72
- name: "Primary negative",
71
+ name: "Negative",
73
72
  args: {
74
- variant: "primary-negative",
73
+ negative: true,
75
74
  },
76
75
  parameters: {
77
76
  backgrounds: {
@@ -102,7 +102,7 @@ function renderTooltip({
102
102
  ["data-testid"]: dataTestId = "tooltip",
103
103
  children = "Some text content",
104
104
  className,
105
- variant,
105
+ negative,
106
106
  position,
107
107
  align,
108
108
  triggerAriaLabel,
@@ -112,7 +112,7 @@ function renderTooltip({
112
112
  render(
113
113
  <Tooltip
114
114
  className={className}
115
- variant={variant}
115
+ negative={negative}
116
116
  position={position}
117
117
  align={align}
118
118
  data-testid={dataTestId}
package/src/tooltip.tsx CHANGED
@@ -11,12 +11,6 @@ import styles from "./tooltip.module.scss";
11
11
 
12
12
  const cx = c.bind(styles);
13
13
 
14
- export const TOOLTIP_VARIANT = {
15
- PRIMARY: "primary",
16
- PRIMARY_NEGATIVE: "primary-negative",
17
- } as const;
18
- export type TooltipVariant = (typeof TOOLTIP_VARIANT)[keyof typeof TOOLTIP_VARIANT];
19
-
20
14
  export const TOOLTIP_POSITION = {
21
15
  TOP: "top",
22
16
  BOTTOM: "bottom",
@@ -36,7 +30,7 @@ export type TooltipProps = {
36
30
  align?: TooltipAlign;
37
31
  buttonSize?: Size;
38
32
  children: ReactNode;
39
- variant?: TooltipVariant;
33
+ negative?: boolean;
40
34
  position?: TooltipPosition;
41
35
  ["data-testid"]?: string;
42
36
  triggerAriaLabel?: string;
@@ -45,11 +39,6 @@ export type TooltipProps = {
45
39
  contentClassName?: string;
46
40
  };
47
41
 
48
- const ButtonVariants = {
49
- primary: BUTTON_VARIANT.TERTIARY_PURPLE,
50
- ["primary-negative"]: BUTTON_VARIANT.TERTIARY_PURPLE_NEGATVIE,
51
- };
52
-
53
42
  const rootClassName = "purpur-tooltip";
54
43
 
55
44
  export const Tooltip = forwardRef(
@@ -60,7 +49,7 @@ export const Tooltip = forwardRef(
60
49
  children,
61
50
  className,
62
51
  contentClassName,
63
- variant = TOOLTIP_VARIANT.PRIMARY,
52
+ negative = false,
64
53
  position = TOOLTIP_POSITION.TOP,
65
54
  align = TOOLTIP_ALIGN.CENTER,
66
55
  triggerAriaLabel = "",
@@ -73,15 +62,14 @@ export const Tooltip = forwardRef(
73
62
  const classes = cx([
74
63
  className,
75
64
  rootClassName,
76
- {
77
- [`${rootClassName}--${variant}`]: variant,
78
- },
65
+ `${rootClassName}--primary${negative ? "-negative" : ""}`,
79
66
  ]);
80
67
  const tooltipButton = (
81
68
  <Button
82
69
  ref={ref}
83
70
  aria-label={triggerAriaLabel}
84
- variant={ButtonVariants[variant]}
71
+ variant={BUTTON_VARIANT.TERTIARY_PURPLE}
72
+ negative={negative}
85
73
  iconOnly
86
74
  data-testid={`${dataTestId}-trigger-button`}
87
75
  size={buttonSize}
@@ -110,7 +98,7 @@ export const Tooltip = forwardRef(
110
98
  className={cx([
111
99
  contentClassName,
112
100
  styles[`${rootClassName}__content`],
113
- styles[`${rootClassName}__content--${variant}`],
101
+ styles[`${rootClassName}__content--primary${negative ? "-negative" : ""}`],
114
102
  ])}
115
103
  sideOffset={-5}
116
104
  data-testid={`${dataTestId}-content`}
@@ -119,7 +107,7 @@ export const Tooltip = forwardRef(
119
107
  <Paragraph
120
108
  className={cx([
121
109
  styles[`${rootClassName}__paragraph`],
122
- styles[`${rootClassName}__paragraph--${variant}`],
110
+ styles[`${rootClassName}__paragraph--primary${negative ? "-negative" : ""}`],
123
111
  ])}
124
112
  variant={ParagraphVariant.PARAGRAPH100}
125
113
  data-testid={`${dataTestId}-paragraph`}
@@ -132,7 +120,7 @@ export const Tooltip = forwardRef(
132
120
  <RadixTooltip.Arrow
133
121
  className={cx([
134
122
  styles[`${rootClassName}__arrow`],
135
- styles[`${rootClassName}__arrow--${variant}`],
123
+ styles[`${rootClassName}__arrow--primary${negative ? "-negative" : ""}`],
136
124
  ])}
137
125
  />
138
126
  </RadixTooltip.Content>