@usefui/components 1.6.0 → 1.7.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 (69) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.d.mts +380 -52
  3. package/dist/index.d.ts +380 -52
  4. package/dist/index.js +2534 -511
  5. package/dist/index.mjs +2520 -508
  6. package/package.json +3 -3
  7. package/src/__tests__/Avatar.test.tsx +55 -55
  8. package/src/accordion/Accordion.stories.tsx +6 -4
  9. package/src/accordion/index.tsx +1 -2
  10. package/src/avatar/Avatar.stories.tsx +37 -7
  11. package/src/avatar/index.tsx +90 -19
  12. package/src/avatar/styles/index.ts +58 -12
  13. package/src/badge/Badge.stories.tsx +27 -5
  14. package/src/badge/index.tsx +21 -13
  15. package/src/badge/styles/index.ts +69 -40
  16. package/src/button/Button.stories.tsx +40 -27
  17. package/src/button/index.tsx +13 -9
  18. package/src/button/styles/index.ts +308 -47
  19. package/src/card/index.tsx +2 -4
  20. package/src/checkbox/Checkbox.stories.tsx +72 -33
  21. package/src/checkbox/index.tsx +8 -6
  22. package/src/checkbox/styles/index.ts +239 -19
  23. package/src/collapsible/Collapsible.stories.tsx +6 -4
  24. package/src/dialog/Dialog.stories.tsx +173 -31
  25. package/src/dialog/styles/index.ts +15 -8
  26. package/src/dropdown/Dropdown.stories.tsx +61 -23
  27. package/src/dropdown/index.tsx +42 -31
  28. package/src/dropdown/styles/index.ts +30 -19
  29. package/src/field/Field.stories.tsx +183 -24
  30. package/src/field/index.tsx +930 -13
  31. package/src/field/styles/index.ts +246 -14
  32. package/src/field/types/index.ts +31 -0
  33. package/src/field/utils/index.ts +201 -0
  34. package/src/index.ts +2 -1
  35. package/src/message-bubble/MessageBubble.stories.tsx +59 -12
  36. package/src/message-bubble/index.tsx +22 -4
  37. package/src/message-bubble/styles/index.ts +4 -7
  38. package/src/otp-field/OTPField.stories.tsx +22 -24
  39. package/src/otp-field/index.tsx +9 -0
  40. package/src/otp-field/styles/index.ts +114 -16
  41. package/src/otp-field/types/index.ts +9 -1
  42. package/src/overlay/styles/index.ts +1 -0
  43. package/src/ruler/Ruler.stories.tsx +43 -0
  44. package/src/ruler/constants/index.ts +3 -0
  45. package/src/ruler/hooks/index.tsx +53 -0
  46. package/src/ruler/index.tsx +239 -0
  47. package/src/ruler/styles/index.tsx +154 -0
  48. package/src/ruler/types/index.ts +17 -0
  49. package/src/select/Select.stories.tsx +91 -0
  50. package/src/select/hooks/index.tsx +71 -0
  51. package/src/select/index.tsx +331 -0
  52. package/src/select/styles/index.tsx +156 -0
  53. package/src/shimmer/Shimmer.stories.tsx +6 -4
  54. package/src/skeleton/index.tsx +7 -6
  55. package/src/spinner/Spinner.stories.tsx +29 -4
  56. package/src/spinner/index.tsx +16 -6
  57. package/src/spinner/styles/index.ts +41 -22
  58. package/src/switch/Switch.stories.tsx +46 -17
  59. package/src/switch/index.tsx +5 -8
  60. package/src/switch/styles/index.ts +45 -45
  61. package/src/tabs/Tabs.stories.tsx +43 -15
  62. package/src/text-area/Textarea.stories.tsx +45 -8
  63. package/src/text-area/index.tsx +9 -6
  64. package/src/text-area/styles/index.ts +1 -1
  65. package/src/toggle/Toggle.stories.tsx +6 -4
  66. package/src/tree/Tree.stories.tsx +6 -4
  67. package/src/privacy-field/PrivacyField.stories.tsx +0 -29
  68. package/src/privacy-field/index.tsx +0 -56
  69. package/src/privacy-field/styles/index.ts +0 -17
@@ -1,91 +1,98 @@
1
1
  import styled, { css } from "styled-components";
2
2
 
3
3
  const BadgeBaseStyles = css`
4
- display: inline-flex;
4
+ display: flex;
5
5
  align-items: center;
6
6
  justify-content: center;
7
7
  gap: var(--measurement-medium-10);
8
+
8
9
  min-width: var(--measurement-medium-60);
9
10
  min-height: var(--measurement-medium-60);
10
11
  width: fit-content;
11
12
 
12
13
  border: var(--measurement-small-10) solid transparent;
14
+ padding: 0 var(--measurement-medium-30);
13
15
 
14
16
  font-size: var(--fontsize-small-60);
15
- padding: var(--measurement-medium-10) var(--measurement-medium-30);
16
17
  font-weight: 500;
18
+ letter-spacing: calc(
19
+ var(--fontsize-small-10) - ((var(--fontsize-small-10) * 1.066))
20
+ );
21
+ line-height: 0;
22
+
17
23
  transition: all ease-in-out 0.2s;
18
24
  `;
19
-
20
25
  const BadgeVariantStyles = css`
21
26
  border: var(--measurement-small-10) solid transparent;
22
27
 
23
28
  &[data-variant="primary"] {
24
- background-color: var(--font-color);
25
- color: var(--body-color);
29
+ background-color: var(--font-color-alpha-10);
30
+ color: var(--font-color-alpha-80);
26
31
 
27
- &:hover,
28
- &:focus {
29
- border-color: var(--font-color-alpha-10);
32
+ * {
33
+ color: currentColor !important;
30
34
  }
31
35
  }
32
36
  &[data-variant="secondary"] {
33
- background-color: var(--font-color-alpha-10);
34
- color: var(--font-color-alpha-60);
37
+ background-color: var(--contrast-color);
38
+ color: var(--font-color-alpha-80);
35
39
 
36
- &:hover,
37
- &:focus {
38
- color: var(--font-color);
40
+ * {
41
+ color: currentColor !important;
39
42
  }
40
43
  }
41
44
  &[data-variant="border"] {
42
45
  background-color: transparent;
43
46
  border-color: var(--font-color-alpha-10);
44
- color: var(--font-color-alpha-60);
47
+ color: var(--font-color-alpha-80);
45
48
 
46
- &:hover,
47
- &:focus {
48
- color: var(--font-color);
49
+ * {
50
+ color: currentColor !important;
49
51
  }
50
52
  }
51
- &[data-variant="error"] {
53
+ &[data-variant="danger"] {
52
54
  background-color: var(--alpha-red-10);
53
- color: var(--alpha-red-80);
55
+ border-color: var(--alpha-red-10);
56
+ color: var(--shade-red-20);
54
57
 
55
- &:hover,
56
- &:focus {
57
- background-color: var(--alpha-red-10);
58
- color: var(--color-red);
58
+ * {
59
+ color: currentColor !important;
59
60
  }
60
61
  }
61
62
  &[data-variant="warning"] {
62
63
  background-color: var(--alpha-orange-10);
63
- color: var(--alpha-orange-80);
64
+ border-color: var(--alpha-orange-10);
65
+ color: var(--shade-orange-20);
64
66
 
65
- &:hover,
66
- &:focus {
67
- background-color: var(--alpha-orange-10);
68
- color: var(--color-orange);
67
+ * {
68
+ color: currentColor !important;
69
69
  }
70
70
  }
71
71
  &[data-variant="success"] {
72
72
  background-color: var(--alpha-green-10);
73
- color: var(--alpha-green-80);
73
+ border-color: var(--alpha-green-10);
74
+ color: var(--shade-lime-20);
74
75
 
75
- &:hover,
76
- &:focus {
77
- background-color: var(--alpha-green-10);
78
- color: var(--color-green);
76
+ * {
77
+ color: currentColor !important;
79
78
  }
80
79
  }
81
80
  &[data-variant="meta"] {
82
- background-color: var(--alpha-blue-10);
83
- color: var(--alpha-blue-80);
81
+ background-color: var(--alpha-indigo-10);
82
+ border-color: var(--alpha-indigo-10);
83
+ color: var(--shade-indigo-20);
84
+
85
+ * {
86
+ color: currentColor !important;
87
+ }
88
+ }
89
+ &[data-variant="hint"] {
90
+ background-color: var(--alpha-purple-10);
91
+ border-color: var(--alpha-purple-10);
92
+ color: var(--shade-purple-20);
84
93
 
85
- &:hover,
86
- &:focus {
87
- background-color: var(--alpha-blue-10);
88
- color: var(--color-blue);
94
+ * {
95
+ color: currentColor !important;
89
96
  }
90
97
  }
91
98
  `;
@@ -97,13 +104,35 @@ const BadgeShapeStyles = css`
97
104
  border-radius: var(--measurement-medium-20);
98
105
  }
99
106
  &[data-shape="round"] {
100
- border-radius: var(--measurement-large-90);
107
+ border-radius: var(--measurement-medium-60);
101
108
  }
102
109
  `;
110
+ const BadgeSizeStyles = css`
111
+ &[data-size="small"] {
112
+ padding: 0 var(--measurement-medium-30);
113
+
114
+ min-width: var(--measurement-medium-70);
115
+ min-height: var(--measurement-medium-70);
116
+ }
117
+ &[data-size="medium"] {
118
+ padding: 0 var(--measurement-medium-40);
119
+
120
+ min-width: var(--fontsize-medium-60);
121
+ min-height: var(--fontsize-medium-60);
122
+ }
123
+ &[data-size="large"] {
124
+ padding: 0 var(--measurement-medium-40);
125
+
126
+ min-width: var(--fontsize-medium-70);
127
+ min-height: var(--fontsize-medium-70);
128
+ }
129
+ `;
130
+
103
131
  export const BadgeWrapper = styled.div<any>`
104
132
  &[data-raw="false"] {
105
133
  ${BadgeBaseStyles}
106
134
  ${BadgeVariantStyles}
107
135
  ${BadgeShapeStyles}
136
+ ${BadgeSizeStyles}
108
137
  }
109
138
  `;
@@ -8,9 +8,11 @@ const meta = {
8
8
  tags: ["autodocs"],
9
9
  decorators: [
10
10
  (Story) => (
11
- <div className="m-medium-30">
12
- <Story />
13
- </div>
11
+ <Page>
12
+ <Page.Content className="p-medium-30">
13
+ <Story />
14
+ </Page.Content>
15
+ </Page>
14
16
  ),
15
17
  ],
16
18
  } satisfies Meta<typeof Button>;
@@ -46,15 +48,28 @@ export const Variants: Story = {
46
48
  render: ({ ...args }) => {
47
49
  return (
48
50
  <Page>
49
- <Page.Content className="flex align-center justify-center">
51
+ <Page.Content className="flex flex-column g-medium-30 align-center justify-center">
52
+ <div className="flex align-center justify-center g-medium-30 flex-wrap">
53
+ <Button variant="accent">
54
+ <span className="color-mono-white">Accent</span>
55
+ </Button>
56
+ </div>
50
57
  <div className="flex align-center justify-center g-medium-30 flex-wrap">
51
58
  <Button variant="primary">Primary</Button>
52
59
  <Button variant="secondary">Secondary</Button>
53
60
  <Button variant="tertiary">Tertiary</Button>
54
- <Button variant="danger">Danger</Button>
55
- <Button variant="warning">Warning</Button>
56
61
  <Button variant="mono">Mono</Button>
57
62
  <Button variant="border">Border</Button>
63
+ </div>
64
+ <div className="flex align-center justify-center g-medium-30 flex-wrap">
65
+ <Button variant="hint">Hint</Button>
66
+ <Button variant="meta">Meta</Button>
67
+ <Button variant="success">Success</Button>
68
+ <Button variant="danger">Danger</Button>
69
+ <Button variant="warning">Warning</Button>
70
+ </div>
71
+ <div className="flex align-center justify-center g-medium-30 flex-wrap">
72
+ <Button variant="link">Link</Button>
58
73
  <Button variant="ghost">Ghost</Button>
59
74
  </div>
60
75
  </Page.Content>
@@ -67,6 +82,11 @@ export const Animations: Story = {
67
82
  return (
68
83
  <Page>
69
84
  <Page.Content className="flex flex-column g-medium-30 align-center justify-center">
85
+ <div className="flex align-center justify-center g-medium-30 flex-wrap">
86
+ <Button animation="reflective" variant="accent">
87
+ <span className="color-mono-white">Accent</span>
88
+ </Button>
89
+ </div>
70
90
  <div className="flex align-center justify-center g-medium-30 flex-wrap">
71
91
  <Button animation="reflective" variant="primary">
72
92
  Primary
@@ -77,12 +97,6 @@ export const Animations: Story = {
77
97
  <Button animation="reflective" variant="tertiary">
78
98
  Tertiary
79
99
  </Button>
80
- <Button animation="reflective" variant="danger">
81
- Danger
82
- </Button>
83
- <Button animation="reflective" variant="warning">
84
- Warning
85
- </Button>
86
100
  <Button animation="reflective" variant="mono">
87
101
  Mono
88
102
  </Button>
@@ -91,27 +105,26 @@ export const Animations: Story = {
91
105
  </Button>
92
106
  </div>
93
107
  <div className="flex align-center justify-center g-medium-30 flex-wrap">
94
- <Button animation="reflective" variant="border" sizing="small">
95
- Small
108
+ <Button animation="reflective" variant="hint">
109
+ Hint
96
110
  </Button>
97
- <Button animation="reflective" variant="border" sizing="medium">
98
- Medium
111
+ <Button animation="reflective" variant="meta">
112
+ Meta
99
113
  </Button>
100
- <Button animation="reflective" variant="border" sizing="large">
101
- Large
114
+ <Button animation="reflective" variant="success">
115
+ Success
102
116
  </Button>
103
- </div>
104
- <div className="flex align-center justify-center g-medium-30 flex-wrap">
105
- <Button animation="reflective" variant="border" shape="square">
106
- Square
107
- </Button>
108
- <Button animation="reflective" variant="border" shape="smooth">
109
- Smooth
117
+ <Button animation="reflective" variant="danger">
118
+ Danger
110
119
  </Button>
111
- <Button animation="reflective" variant="border" shape="round">
112
- Round
120
+ <Button animation="reflective" variant="warning">
121
+ Warning
113
122
  </Button>
114
123
  </div>
124
+ <div className="flex align-center justify-center g-medium-30 flex-wrap">
125
+ <Button variant="link">Link</Button>
126
+ <Button variant="ghost">Ghost</Button>
127
+ </div>
115
128
  </Page.Content>
116
129
  </Page>
117
130
  );
@@ -9,16 +9,20 @@ import {
9
9
  IComponentSize,
10
10
  ComponentVariantEnum,
11
11
  TComponentVariant,
12
- TComponentShape,
12
+ ComponentShapeEnum,
13
+ IComponentShape,
14
+ TComponentVariantExtended,
13
15
  } from "../../../../types";
14
16
 
15
17
  export interface IButtonProperties
16
- extends IComponentStyling,
18
+ extends
19
+ IComponentStyling,
20
+ IComponentShape,
17
21
  IComponentSize,
18
22
  React.ComponentPropsWithRef<"button"> {
19
23
  rawicon?: boolean;
20
- variant?: TComponentVariant | "danger" | "warning";
21
- shape?: TComponentShape;
24
+ variant?: TComponentVariant | TComponentVariantExtended | "link" | "accent";
25
+
22
26
  animation?: "reflective";
23
27
  }
24
28
 
@@ -46,7 +50,7 @@ export const Button = React.forwardRef<HTMLButtonElement, IButtonProperties>(
46
50
  name,
47
51
  variant = ComponentVariantEnum.Primary,
48
52
  sizing = ComponentSizeEnum.Medium,
49
- shape = "smooth",
53
+ shape = ComponentShapeEnum.Smooth,
50
54
  animation,
51
55
  raw,
52
56
  rawicon,
@@ -82,7 +86,7 @@ export const Button = React.forwardRef<HTMLButtonElement, IButtonProperties>(
82
86
  y: ((e.clientY - rect.top) / rect.height) * 100,
83
87
  });
84
88
  },
85
- []
89
+ [],
86
90
  );
87
91
  const handleMouseEnter = React.useCallback(
88
92
  (e: React.MouseEvent<HTMLButtonElement>) => {
@@ -91,7 +95,7 @@ export const Button = React.forwardRef<HTMLButtonElement, IButtonProperties>(
91
95
 
92
96
  setIsHovering(true);
93
97
  },
94
- []
98
+ [],
95
99
  );
96
100
  const handleMouseLeave = React.useCallback(
97
101
  (e: React.MouseEvent<HTMLButtonElement>) => {
@@ -100,7 +104,7 @@ export const Button = React.forwardRef<HTMLButtonElement, IButtonProperties>(
100
104
 
101
105
  setIsHovering(false);
102
106
  },
103
- []
107
+ [],
104
108
  );
105
109
 
106
110
  return (
@@ -136,6 +140,6 @@ export const Button = React.forwardRef<HTMLButtonElement, IButtonProperties>(
136
140
  {children}
137
141
  </ButtonWrapper>
138
142
  );
139
- }
143
+ },
140
144
  );
141
145
  Button.displayName = "Button";