@iota/apps-ui-kit 0.7.3 → 0.9.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,11 +1,8 @@
1
1
  {
2
2
  "name": "@iota/apps-ui-kit",
3
- "version": "0.7.3",
3
+ "version": "0.9.0",
4
4
  "sideEffects": false,
5
- "repository": {
6
- "type": "git",
7
- "url": "github.com:iotaledger/iota.git"
8
- },
5
+ "repository": "https://github.com/iotaledger/iota",
9
6
  "license": "Apache-2.0",
10
7
  "files": [
11
8
  "CHANGELOG.md",
@@ -30,7 +27,7 @@
30
27
  "classnames": "^2.5.1",
31
28
  "lodash.merge": "^4.6.2",
32
29
  "react-number-format": "^5.2.2",
33
- "@iota/apps-ui-icons": "0.4.2"
30
+ "@iota/apps-ui-icons": "0.7.0"
34
31
  },
35
32
  "peerDependencies": {
36
33
  "react": "^18 || ^19",
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { ButtonHtmlType, ButtonSize, ButtonType } from './button.enums';
5
+ import { forwardRef } from 'react';
5
6
  import {
6
7
  PADDINGS,
7
8
  PADDINGS_ONLY_ICON,
@@ -60,41 +61,50 @@ export interface ButtonProps {
60
61
  testId?: string;
61
62
  }
62
63
 
63
- export function Button({
64
- icon,
65
- text,
66
- disabled,
67
- onClick,
68
- fullWidth,
69
- htmlType = ButtonHtmlType.Button,
70
- size = ButtonSize.Medium,
71
- type = ButtonType.Primary,
72
- iconAfterText = false,
73
- tabIndex = 0,
74
- testId,
75
- }: ButtonProps): React.JSX.Element {
76
- const paddingClasses = icon && !text ? PADDINGS_ONLY_ICON[size] : PADDINGS[size];
77
- const textSizes = TEXT_CLASSES[size];
78
- const backgroundColors = disabled ? DISABLED_BACKGROUND_COLORS[type] : BACKGROUND_COLORS[type];
79
- const textColors = disabled ? TEXT_COLOR_DISABLED[type] : TEXT_COLORS[type];
80
- return (
81
- <button
82
- onClick={onClick}
83
- type={htmlType}
84
- className={cx(
85
- 'state-layer relative flex items-center justify-center gap-2 rounded-full transition-all duration-150 ease-in disabled:cursor-not-allowed disabled:opacity-40',
86
- paddingClasses,
87
- backgroundColors,
88
- fullWidth && 'w-full',
89
- !iconAfterText ? 'flex-row' : 'flex-row-reverse',
90
- `btn btn-${type}`,
91
- )}
92
- disabled={disabled}
93
- tabIndex={tabIndex}
94
- data-testid={testId}
95
- >
96
- {icon && <span className={cx(textColors)}>{icon}</span>}
97
- {text && <span className={cx('font-inter', textColors, textSizes)}>{text}</span>}
98
- </button>
99
- );
100
- }
64
+ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
65
+ (
66
+ {
67
+ icon,
68
+ text,
69
+ disabled,
70
+ onClick,
71
+ fullWidth,
72
+ htmlType = ButtonHtmlType.Button,
73
+ size = ButtonSize.Medium,
74
+ type = ButtonType.Primary,
75
+ iconAfterText = false,
76
+ tabIndex = 0,
77
+ testId,
78
+ },
79
+ ref,
80
+ ): React.JSX.Element => {
81
+ const paddingClasses = icon && !text ? PADDINGS_ONLY_ICON[size] : PADDINGS[size];
82
+ const textSizes = TEXT_CLASSES[size];
83
+ const backgroundColors = disabled
84
+ ? DISABLED_BACKGROUND_COLORS[type]
85
+ : BACKGROUND_COLORS[type];
86
+ const textColors = disabled ? TEXT_COLOR_DISABLED[type] : TEXT_COLORS[type];
87
+
88
+ return (
89
+ <button
90
+ ref={ref}
91
+ onClick={onClick}
92
+ type={htmlType}
93
+ className={cx(
94
+ 'state-layer relative flex items-center justify-center gap-2 rounded-full transition-all duration-150 ease-in disabled:cursor-not-allowed disabled:opacity-40',
95
+ paddingClasses,
96
+ backgroundColors,
97
+ fullWidth && 'w-full',
98
+ !iconAfterText ? 'flex-row' : 'flex-row-reverse',
99
+ `btn btn-${type}`,
100
+ )}
101
+ disabled={disabled}
102
+ tabIndex={tabIndex}
103
+ data-testid={testId}
104
+ >
105
+ {icon && <span className={cx(textColors)}>{icon}</span>}
106
+ {text && <span className={cx('font-inter', textColors, textSizes)}>{text}</span>}
107
+ </button>
108
+ );
109
+ },
110
+ );
@@ -5,10 +5,26 @@ import cx from 'classnames';
5
5
  import { RadioOn, RadioOff } from '@iota/apps-ui-icons';
6
6
 
7
7
  interface RadioButtonProps {
8
+ /**
9
+ * The id of the radio button.
10
+ */
11
+ id?: string;
12
+ /**
13
+ * The name of the radio button.
14
+ */
15
+ name?: string;
8
16
  /**
9
17
  * The label of the radio button.
10
18
  */
11
19
  label: string;
20
+ /**
21
+ * Supporting text for the label.
22
+ */
23
+ supportingLabel?: string;
24
+ /**
25
+ * The body text of the radio button.
26
+ */
27
+ body?: string;
12
28
  /**
13
29
  * The state of the radio button.
14
30
  */
@@ -24,7 +40,11 @@ interface RadioButtonProps {
24
40
  }
25
41
 
26
42
  function RadioButton({
43
+ id,
44
+ name,
27
45
  label,
46
+ supportingLabel,
47
+ body,
28
48
  isChecked,
29
49
  isDisabled,
30
50
  onChange,
@@ -33,30 +53,50 @@ function RadioButton({
33
53
 
34
54
  return (
35
55
  <label
36
- className={cx('flex flex-row gap-x-1 text-center has-[:disabled]:opacity-40', {
37
- disabled: isDisabled,
38
- 'cursor-pointer': !isDisabled,
39
- })}
56
+ className={cx(
57
+ 'flex flex-row items-center gap-x-1 text-center has-[:disabled]:opacity-40',
58
+ {
59
+ disabled: isDisabled,
60
+ 'cursor-pointer': !isDisabled,
61
+ },
62
+ )}
40
63
  >
41
64
  <div
42
- className={cx('relative flex h-10 w-10 items-center justify-center rounded-full', {
43
- 'state-layer-secondary': !isDisabled,
44
- })}
65
+ className={cx(
66
+ 'relative flex h-10 w-10 shrink-0 items-center justify-center rounded-full',
67
+ {
68
+ 'state-layer-secondary': !isDisabled,
69
+ },
70
+ )}
45
71
  >
46
72
  <input
73
+ id={id}
74
+ name={name}
47
75
  type="radio"
48
76
  checked={isChecked}
49
77
  onChange={onChange}
50
78
  disabled={isDisabled}
51
79
  className={cx('peer appearance-none')}
52
80
  />
53
- <span className="radio-icon-color peer-checked:radio-icon-checked-color peer-checked:peer-disabled:radio-icon-checked-disabled-color absolute [&_svg]:h-6 [&_svg]:w-6">
54
- <RadioIcon />
81
+ <span className="radio-icon-color peer-checked:radio-icon-checked-color peer-checked:peer-disabled:radio-icon-checked-disabled-color absolute size-6">
82
+ <RadioIcon className="size-full" />
83
+ </span>
84
+ </div>
85
+ <div className="flex flex-col items-start gap-xxs text-start">
86
+ <span className="radio-label-color inline-flex items-center justify-center gap-1 text-label-lg">
87
+ {label}
88
+ {supportingLabel && (
89
+ <span className="text-iota-neutral-60 dark:text-iota-neutral-40">
90
+ {supportingLabel}
91
+ </span>
92
+ )}
55
93
  </span>
94
+ {body && (
95
+ <p className="text-body-sm text-iota-neutral-40 dark:text-iota-neutral-60">
96
+ {body}
97
+ </p>
98
+ )}
56
99
  </div>
57
- <span className="radio-label-color inline-flex items-center justify-center text-label-lg ">
58
- {label}
59
- </span>
60
100
  </label>
61
101
  );
62
102
  }
package/src/lib/index.ts CHANGED
@@ -7,4 +7,3 @@ export * from './tailwind';
7
7
  export * from './components';
8
8
  export * from './constants';
9
9
  export * from './enums';
10
- export * from './utils';
@@ -49,3 +49,22 @@ export const Default: Story = {
49
49
  },
50
50
  },
51
51
  };
52
+
53
+ export const ExtendedRadioButton: Story = {
54
+ args: {
55
+ label: 'Label',
56
+ supportingLabel: '(Supporting label)',
57
+ body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
58
+ },
59
+ argTypes: {
60
+ label: {
61
+ control: 'text',
62
+ },
63
+ isChecked: {
64
+ control: 'boolean',
65
+ },
66
+ isDisabled: {
67
+ control: 'boolean',
68
+ },
69
+ },
70
+ };
@@ -1,8 +0,0 @@
1
- // Copyright (c) 2024 IOTA Stiftung
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- export function truncate(value: string, startLength: number = 6, endLength: number = 6): string {
5
- return value.length > startLength + endLength
6
- ? `${value.slice(0, startLength)}...${value.slice(-endLength)}`
7
- : value;
8
- }
@@ -1,4 +0,0 @@
1
- // Copyright (c) 2024 IOTA Stiftung
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- export * from './format';