@iota/apps-ui-kit 0.6.0 → 0.7.1
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/CHANGELOG.md +29 -0
- package/dist/index.d.ts +219 -34
- package/dist/index.es.js +3429 -6082
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +28 -160
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +11 -4
- package/src/lib/components/atoms/badge/badge.classes.ts +18 -18
- package/src/lib/components/atoms/badge/badge.enums.ts +1 -1
- package/src/lib/components/atoms/button/Button.tsx +1 -0
- package/src/lib/components/atoms/button/button-variants/ButtonPill.tsx +1 -1
- package/src/lib/components/atoms/button/button.classes.ts +12 -12
- package/src/lib/components/atoms/button-segment/ButtonSegment.tsx +1 -1
- package/src/lib/components/atoms/button-segment/buttonSegment.classes.ts +15 -36
- package/src/lib/components/atoms/checkbox/Checkbox.tsx +19 -9
- package/src/lib/components/atoms/divider/divider.classes.ts +1 -1
- package/src/lib/components/atoms/header/Header.tsx +1 -1
- package/src/lib/components/atoms/image/Image.tsx +32 -0
- package/src/lib/components/atoms/image/index.ts +4 -0
- package/src/lib/components/atoms/index.ts +4 -1
- package/src/lib/components/atoms/info-box/InfoBox.tsx +2 -8
- package/src/lib/components/atoms/info-box/infoBox.classes.ts +8 -9
- package/src/lib/components/atoms/key-value-info/KeyValueInfo.tsx +5 -5
- package/src/lib/components/atoms/label-text/LabelText.tsx +4 -6
- package/src/lib/components/atoms/list-item/ListItem.tsx +4 -5
- package/src/lib/components/atoms/loading-indicator/LoadingIndicator.tsx +1 -1
- package/src/lib/components/atoms/media-fallback/MediaFallback.tsx +12 -0
- package/src/lib/components/atoms/media-fallback/index.ts +4 -0
- package/src/lib/components/atoms/panel/Panel.tsx +2 -4
- package/src/lib/components/atoms/radio-button/RadioButton.tsx +5 -9
- package/src/lib/components/atoms/secondary-text/SecondaryText.tsx +3 -2
- package/src/lib/components/atoms/skeleton/Skeleton.tsx +6 -23
- package/src/lib/components/atoms/snackbar/snackbar.classes.ts +8 -8
- package/src/lib/components/atoms/toggle/toggle.classes.ts +6 -6
- package/src/lib/components/atoms/tooltip/Tooltip.tsx +3 -2
- package/src/lib/components/atoms/video/Video.tsx +33 -0
- package/src/lib/components/atoms/video/index.ts +4 -0
- package/src/lib/components/atoms/video/video.constants.ts +31 -0
- package/src/lib/components/index.ts +0 -2
- package/src/lib/components/molecules/account/Account.tsx +4 -4
- package/src/lib/components/molecules/address/Address.tsx +1 -1
- package/src/lib/components/molecules/asset-media-renderer/AssetMediaRenderer.tsx +50 -0
- package/src/lib/components/molecules/asset-media-renderer/index.ts +4 -0
- package/src/lib/components/molecules/card/CardAction.tsx +3 -5
- package/src/lib/components/molecules/card/CardBody.tsx +3 -2
- package/src/lib/components/molecules/card/card.classes.ts +3 -3
- package/src/lib/components/molecules/chip/Chip.tsx +59 -18
- package/src/lib/components/molecules/chip/chip.classes.ts +37 -15
- package/src/lib/components/molecules/chip/chip.enums.ts +10 -2
- package/src/lib/components/molecules/chip/index.ts +1 -0
- package/src/lib/components/molecules/display-stats/DisplayStats.tsx +2 -2
- package/src/lib/components/molecules/display-stats/displayStats.classes.ts +6 -6
- package/src/lib/components/molecules/dropdown/Dropdown.tsx +1 -1
- package/src/lib/components/molecules/index.ts +2 -0
- package/src/lib/components/molecules/input/Input.tsx +37 -22
- package/src/lib/components/molecules/input/InputWrapper.tsx +1 -1
- package/src/lib/components/molecules/input/TextArea.tsx +4 -8
- package/src/lib/components/molecules/input/input.classes.ts +7 -8
- package/src/lib/components/molecules/navbar-item/NavbarItem.tsx +0 -1
- package/src/lib/components/molecules/navbar-item/NavbarItemHorizontal.tsx +1 -1
- package/src/lib/components/molecules/navbar-item/NavbarItemVertical.tsx +1 -1
- package/src/lib/components/molecules/navbar-item/navbarItem.classes.ts +4 -4
- package/src/lib/components/molecules/search/Search.tsx +10 -7
- package/src/lib/components/molecules/search/search.classes.ts +5 -5
- package/src/lib/components/molecules/segmented-button/segmentedButton.classes.ts +2 -2
- package/src/lib/components/molecules/select/Select.tsx +29 -16
- package/src/lib/components/molecules/table-cell/TableCell.tsx +2 -2
- package/src/lib/components/molecules/table-header-cell/TableHeaderCell.tsx +2 -2
- package/src/lib/components/molecules/title/Title.tsx +3 -3
- package/src/lib/components/{atoms → molecules}/visual-asset-card/VisualAssetCard.tsx +26 -40
- package/src/lib/components/organisms/accordion/Accordion.tsx +2 -3
- package/src/lib/components/organisms/accordion/accordion.classes.ts +1 -1
- package/src/lib/components/organisms/dialog/Dialog.tsx +39 -24
- package/src/lib/components/organisms/navbar/Navbar.tsx +2 -2
- package/src/lib/components/organisms/navbar/NavbarSlideout.tsx +1 -1
- package/src/lib/components/organisms/table/Table.tsx +2 -2
- package/src/lib/constants/colors.constants.ts +114 -8
- package/src/lib/enums/index.ts +1 -0
- package/src/lib/enums/theme.enums.ts +8 -0
- package/src/lib/index.ts +2 -0
- package/src/lib/styles/base.css +137 -0
- package/src/lib/styles/components.css +735 -0
- package/src/lib/styles/fonts.css +2 -0
- package/src/lib/styles/index.css +10 -141
- package/src/lib/styles/utilities.css +61 -0
- package/src/lib/styles/variables/dark-variables.css +262 -0
- package/src/lib/styles/variables/general-variables.css +9 -0
- package/src/lib/styles/variables/light-variables.css +276 -0
- package/src/lib/styles/variables/names-variables.css +270 -0
- package/src/lib/tailwind/base.presets.ts +17 -8
- package/src/lib/tailwind/constants/customColors.constants.ts +13 -0
- package/src/lib/tailwind/constants/fontFamily.constants.ts +8 -0
- package/src/lib/tailwind/constants/fontSizes.constants.ts +9 -9
- package/src/lib/tailwind/constants/gradients.constants.ts +6 -0
- package/src/lib/tailwind/constants/index.ts +1 -0
- package/src/lib/tailwind/plugins.ts +4 -0
- package/src/storybook/blocks/Showcase.tsx +2 -2
- package/src/storybook/blocks/TypeSet.tsx +3 -3
- package/src/storybook/blocks/TypeSetItem.tsx +3 -3
- package/src/storybook/constants/gradients.constants.ts +8 -0
- package/src/storybook/helpers/formatGradientNames.ts +15 -0
- package/src/storybook/stories/atoms/Skeleton.stories.tsx +6 -6
- package/src/storybook/stories/atoms/Tooltip.stories.tsx +4 -2
- package/src/storybook/stories/atoms/VisualAssetCard.stories.tsx +3 -2
- package/src/storybook/stories/components/DocsSyncTheme.tsx +20 -0
- package/src/storybook/stories/components/VariableSpacingShowcase.tsx +2 -2
- package/src/storybook/stories/components/index.ts +1 -0
- package/src/storybook/stories/design-tokens/colors.stories.mdx +21 -0
- package/src/storybook/stories/design-tokens/icons.stories.mdx +2 -0
- package/src/storybook/stories/design-tokens/typeset.stories.mdx +2 -0
- package/src/storybook/stories/design-tokens/variable-spacing.stories.mdx +2 -1
- package/src/storybook/stories/molecules/Account.stories.tsx +3 -1
- package/src/storybook/stories/molecules/Chip.stories.tsx +5 -0
- package/src/storybook/stories/molecules/Input.stories.tsx +79 -2
- package/src/storybook/stories/molecules/Search.stories.tsx +2 -2
- package/src/storybook/stories/molecules/TableCell.stories.tsx +1 -1
- package/src/storybook/stories/molecules/TextArea.stories.tsx +1 -1
- package/src/storybook/stories/organisms/Dialog.stories.tsx +54 -28
- /package/src/lib/components/{atoms → molecules}/visual-asset-card/index.ts +0 -0
- /package/src/lib/components/{atoms → molecules}/visual-asset-card/visualAssetCard.enums.ts +0 -0
|
@@ -2,43 +2,26 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import cx from 'classnames';
|
|
5
|
+
import React from 'react';
|
|
5
6
|
|
|
6
|
-
interface SkeletonLoaderProps {
|
|
7
|
-
/**
|
|
8
|
-
* Width class for the skeleton div.
|
|
9
|
-
*/
|
|
10
|
-
widthClass?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Height class for the skeleton div.
|
|
13
|
-
*/
|
|
14
|
-
heightClass?: string;
|
|
7
|
+
interface SkeletonLoaderProps extends Pick<React.HTMLAttributes<HTMLDivElement>, 'className'> {
|
|
15
8
|
/**
|
|
16
9
|
* If true, the skeleton will use darker neutral colors.
|
|
17
10
|
*/
|
|
18
11
|
hasSecondaryColors?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Whether the class `rounded-full` should be applied. Defaults to true.
|
|
21
|
-
*/
|
|
22
|
-
isRounded?: boolean;
|
|
23
12
|
}
|
|
24
13
|
|
|
25
14
|
export function Skeleton({
|
|
26
15
|
children,
|
|
27
|
-
|
|
28
|
-
heightClass = 'h-3',
|
|
16
|
+
className,
|
|
29
17
|
hasSecondaryColors,
|
|
30
|
-
isRounded = true,
|
|
31
18
|
}: React.PropsWithChildren<SkeletonLoaderProps>): React.JSX.Element {
|
|
32
19
|
return (
|
|
33
20
|
<div
|
|
34
21
|
className={cx(
|
|
35
|
-
'animate-pulse rounded-full',
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
isRounded && 'rounded-full',
|
|
39
|
-
hasSecondaryColors
|
|
40
|
-
? 'bg-neutral-80 dark:bg-neutral-10'
|
|
41
|
-
: 'bg-neutral-90 dark:bg-neutral-12',
|
|
22
|
+
'h-3 w-full animate-pulse rounded-full',
|
|
23
|
+
hasSecondaryColors ? 'skeleton-secondary-bg' : 'skeleton-bg',
|
|
24
|
+
className,
|
|
42
25
|
)}
|
|
43
26
|
>
|
|
44
27
|
{children}
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
import { SnackbarType } from './snackbar.enums';
|
|
5
5
|
|
|
6
6
|
export const TEXT_COLOR: Record<SnackbarType, string> = {
|
|
7
|
-
[SnackbarType.Default]: 'text-
|
|
8
|
-
[SnackbarType.Error]: 'text-
|
|
9
|
-
[SnackbarType.Warning]: 'text-
|
|
10
|
-
[SnackbarType.Success]: 'text-
|
|
7
|
+
[SnackbarType.Default]: 'text-on-default',
|
|
8
|
+
[SnackbarType.Error]: 'text-on-error',
|
|
9
|
+
[SnackbarType.Warning]: 'text-on-warning',
|
|
10
|
+
[SnackbarType.Success]: 'text-on-success',
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export const BACKGROUND_COLOR: Record<SnackbarType, string> = {
|
|
14
|
-
[SnackbarType.Default]: 'bg-
|
|
15
|
-
[SnackbarType.Error]: 'bg-error-
|
|
16
|
-
[SnackbarType.Warning]: 'bg-warning-
|
|
17
|
-
[SnackbarType.Success]: 'bg-
|
|
14
|
+
[SnackbarType.Default]: 'bg-default-surface',
|
|
15
|
+
[SnackbarType.Error]: 'bg-error-surface',
|
|
16
|
+
[SnackbarType.Warning]: 'bg-warning-surface',
|
|
17
|
+
[SnackbarType.Success]: 'bg-success-surface',
|
|
18
18
|
};
|
|
@@ -6,9 +6,9 @@ import { ToggleSize } from './toggle.enums';
|
|
|
6
6
|
export const TOGGLE = 'relative inline-flex items-center p-xxs border rounded-full cursor-pointer';
|
|
7
7
|
|
|
8
8
|
export const TOGGLE_STATES = {
|
|
9
|
-
active: 'bg-
|
|
10
|
-
inactive: '
|
|
11
|
-
disabledActive: 'bg-
|
|
9
|
+
active: 'toggle-bg-active toggle-border-active',
|
|
10
|
+
inactive: 'toggle-bg-inactive toggle-border-inactive',
|
|
11
|
+
disabledActive: 'toggle-bg-disabled-active toggle-border-disabled-active',
|
|
12
12
|
disabled: 'opacity-40 cursor-not-allowed',
|
|
13
13
|
};
|
|
14
14
|
|
|
@@ -29,8 +29,8 @@ export const TOGGLE_THUMB_POSITION = {
|
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
export const TOGGLE_THUMB_COLOR = {
|
|
32
|
-
unchecked: '
|
|
33
|
-
checked: '
|
|
32
|
+
unchecked: 'toggle-thumb-color',
|
|
33
|
+
checked: 'toggle-thumb-color-checked',
|
|
34
34
|
};
|
|
35
35
|
export const TOGGLE_THUMB_SIZE = {
|
|
36
36
|
[ToggleSize.Small]: 'h-3 w-3',
|
|
@@ -38,4 +38,4 @@ export const TOGGLE_THUMB_SIZE = {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export const TOGGLE_CONTAINER = 'inline-flex items-center gap-2';
|
|
41
|
-
export const TOGGLE_LABEL = 'text-label-lg
|
|
41
|
+
export const TOGGLE_LABEL = 'text-label-lg toggle-label-color';
|
|
@@ -97,8 +97,9 @@ export function Tooltip({
|
|
|
97
97
|
};
|
|
98
98
|
}, [visible]);
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
// z-[9999999999]: needed because we must exceed the popup’s ≈2 147 483 647 z-index;
|
|
101
|
+
// otherwise the tooltip renders but stays invisible inside a Chrome extension
|
|
102
|
+
const base = 'z-[9999999999] w-max rounded p-xs tooltip-bg tooltip-text-color';
|
|
102
103
|
|
|
103
104
|
return (
|
|
104
105
|
<>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright (c) 2025 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import { VIDEO_AUTOPLAY_FLAGS, VIDEO_AUTOPLAY_FLAGS_NO_CONTROLS } from './video.constants';
|
|
6
|
+
|
|
7
|
+
export interface VideoProps {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the video should autoplay.
|
|
10
|
+
*/
|
|
11
|
+
isAutoPlayEnabled?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* If the video controls should be disabled.
|
|
14
|
+
*/
|
|
15
|
+
disableControls?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const Video = forwardRef<
|
|
19
|
+
HTMLVideoElement,
|
|
20
|
+
React.ComponentPropsWithoutRef<'video'> & VideoProps
|
|
21
|
+
>(({ width = '100%', height = 'auto', isAutoPlayEnabled, disableControls, ...props }, ref) => {
|
|
22
|
+
const videoProps = isAutoPlayEnabled
|
|
23
|
+
? disableControls
|
|
24
|
+
? VIDEO_AUTOPLAY_FLAGS_NO_CONTROLS
|
|
25
|
+
: VIDEO_AUTOPLAY_FLAGS
|
|
26
|
+
: { preload: 'metadata', autoPlay: false };
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<video ref={ref} width={width} height={height} {...videoProps} {...props}>
|
|
30
|
+
Your browser does not support the video tag.
|
|
31
|
+
</video>
|
|
32
|
+
);
|
|
33
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright (c) 2025 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export const VIDEO_AUTOPLAY_FLAGS: Partial<
|
|
5
|
+
Omit<React.VideoHTMLAttributes<HTMLVideoElement>, 'src'>
|
|
6
|
+
> = {
|
|
7
|
+
autoPlay: true,
|
|
8
|
+
muted: true,
|
|
9
|
+
playsInline: true,
|
|
10
|
+
controls: true,
|
|
11
|
+
controlsList: 'nodownload',
|
|
12
|
+
disablePictureInPicture: true,
|
|
13
|
+
preload: 'auto',
|
|
14
|
+
loop: true,
|
|
15
|
+
width: '100%',
|
|
16
|
+
height: 'auto',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const VIDEO_AUTOPLAY_FLAGS_NO_CONTROLS: Partial<
|
|
20
|
+
Omit<React.VideoHTMLAttributes<HTMLVideoElement>, 'src'>
|
|
21
|
+
> = {
|
|
22
|
+
autoPlay: true,
|
|
23
|
+
muted: true,
|
|
24
|
+
playsInline: true,
|
|
25
|
+
controls: false,
|
|
26
|
+
disablePictureInPicture: true,
|
|
27
|
+
preload: 'auto',
|
|
28
|
+
loop: true,
|
|
29
|
+
width: '100%',
|
|
30
|
+
height: 'auto',
|
|
31
|
+
};
|
|
@@ -129,7 +129,7 @@ export function Account({
|
|
|
129
129
|
<Avatar isLocked={isLocked} />
|
|
130
130
|
<div className="flex flex-col items-start py-xs">
|
|
131
131
|
<div className="flex items-center space-x-2">
|
|
132
|
-
<span className="font-inter text-title-md
|
|
132
|
+
<span className="account-title-color font-inter text-title-md">
|
|
133
133
|
{title}
|
|
134
134
|
</span>
|
|
135
135
|
{badgeText && badgeType ? (
|
|
@@ -153,7 +153,7 @@ export function Account({
|
|
|
153
153
|
</div>
|
|
154
154
|
</div>
|
|
155
155
|
<div className="z-10 ml-auto flex items-center space-x-2 [&_button]:h-5 [&_button]:w-5 [&_svg]:h-5 [&_svg]:w-5">
|
|
156
|
-
<div className="flex items-center space-x-2 [&_button:not(.locked)]:hidden group-hover:[&_button:not(.locked)]:flex
|
|
156
|
+
<div className="account-icon-color flex items-center space-x-2 [&_button:not(.locked)]:hidden group-hover:[&_button:not(.locked)]:flex">
|
|
157
157
|
{onOptionsClick && (
|
|
158
158
|
<ButtonUnstyled onClick={onOptionsClick}>
|
|
159
159
|
<MoreHoriz />
|
|
@@ -180,9 +180,9 @@ export function Account({
|
|
|
180
180
|
{showSelected && (
|
|
181
181
|
<ButtonUnstyled>
|
|
182
182
|
{isSelected ? (
|
|
183
|
-
<CheckmarkFilled className="h-5 w-5
|
|
183
|
+
<CheckmarkFilled className="account-check-active-color h-5 w-5" />
|
|
184
184
|
) : (
|
|
185
|
-
<RadioOff className="h-5 w-5
|
|
185
|
+
<RadioOff className="account-check-inactive-color h-5 w-5" />
|
|
186
186
|
)}
|
|
187
187
|
</ButtonUnstyled>
|
|
188
188
|
)}
|
|
@@ -78,7 +78,7 @@ export function Address({
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
return (
|
|
81
|
-
<div className="group flex flex-row items-center gap-1
|
|
81
|
+
<div className="address-text-color group flex flex-row items-center gap-1">
|
|
82
82
|
<span className={cx('font-inter text-body-sm')}>{text}</span>
|
|
83
83
|
{isCopyable && (
|
|
84
84
|
<ButtonUnstyled
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { VisualAssetType } from '../visual-asset-card/visualAssetCard.enums';
|
|
5
|
+
import { Video, ImageWithFallback, Image } from '../../atoms';
|
|
6
|
+
import type { VideoProps } from '../../atoms';
|
|
7
|
+
|
|
8
|
+
export interface AssetMediaRendererProps extends VideoProps {
|
|
9
|
+
/**
|
|
10
|
+
* The source of the media to be displayed.
|
|
11
|
+
*/
|
|
12
|
+
src: string;
|
|
13
|
+
/**
|
|
14
|
+
* The type of the asset to be displayed.
|
|
15
|
+
*/
|
|
16
|
+
assetType: VisualAssetType;
|
|
17
|
+
/**
|
|
18
|
+
* Alt text for the image..
|
|
19
|
+
*/
|
|
20
|
+
altText?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to show a fallback image if the main image fails to load.
|
|
23
|
+
*/
|
|
24
|
+
showFallback?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function AssetMediaRenderer({
|
|
28
|
+
src,
|
|
29
|
+
isAutoPlayEnabled,
|
|
30
|
+
assetType,
|
|
31
|
+
altText: alt,
|
|
32
|
+
showFallback,
|
|
33
|
+
disableControls,
|
|
34
|
+
}: AssetMediaRendererProps): React.JSX.Element {
|
|
35
|
+
if (assetType === VisualAssetType.Video) {
|
|
36
|
+
return (
|
|
37
|
+
<Video
|
|
38
|
+
src={src}
|
|
39
|
+
isAutoPlayEnabled={isAutoPlayEnabled}
|
|
40
|
+
disableControls={disableControls}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (showFallback) {
|
|
46
|
+
return <ImageWithFallback src={src} alt={alt} />;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return <Image src={src} alt={alt} />;
|
|
50
|
+
}
|
|
@@ -37,7 +37,7 @@ export function CardAction({
|
|
|
37
37
|
return (
|
|
38
38
|
<div
|
|
39
39
|
onClick={handleActionClick}
|
|
40
|
-
className="
|
|
40
|
+
className="card-action-link-color shrink-0 [&_svg]:h-5 [&_svg]:w-5"
|
|
41
41
|
>
|
|
42
42
|
{icon ? icon : <ArrowRight />}
|
|
43
43
|
</div>
|
|
@@ -48,12 +48,10 @@ export function CardAction({
|
|
|
48
48
|
return (
|
|
49
49
|
<div className="shrink-0 text-right">
|
|
50
50
|
{title && (
|
|
51
|
-
<div className="font-inter text-label-md
|
|
52
|
-
{title}
|
|
53
|
-
</div>
|
|
51
|
+
<div className="card-action-title-color font-inter text-label-md">{title}</div>
|
|
54
52
|
)}
|
|
55
53
|
{subtitle && (
|
|
56
|
-
<div className="font-inter text-label-sm
|
|
54
|
+
<div className="card-action-subtitle-color font-inter text-label-sm">
|
|
57
55
|
{subtitle}
|
|
58
56
|
</div>
|
|
59
57
|
)}
|
|
@@ -39,12 +39,13 @@ export function CardBody({
|
|
|
39
39
|
})}
|
|
40
40
|
>
|
|
41
41
|
<div
|
|
42
|
-
className={cx('
|
|
42
|
+
className={cx('card-body-title-color font-inter text-title-md', {
|
|
43
43
|
truncate: isTextTruncated,
|
|
44
44
|
})}
|
|
45
45
|
>
|
|
46
46
|
{title}
|
|
47
47
|
</div>
|
|
48
|
+
|
|
48
49
|
{tooltipText ? (
|
|
49
50
|
<Tooltip text={tooltipText} position={tooltipPosition}>
|
|
50
51
|
{icon}
|
|
@@ -60,7 +61,7 @@ export function CardBody({
|
|
|
60
61
|
</div>
|
|
61
62
|
{subtitle && (
|
|
62
63
|
<div
|
|
63
|
-
className={cx('font-inter text-body-md
|
|
64
|
+
className={cx('card-body-subtitle-color font-inter text-body-md', {
|
|
64
65
|
truncate: isTextTruncated,
|
|
65
66
|
})}
|
|
66
67
|
>
|
|
@@ -14,8 +14,8 @@ export const IMAGE_VARIANT_CLASSES: { [key in ImageShape]: string } = {
|
|
|
14
14
|
|
|
15
15
|
export const IMAGE_BG_CLASSES: { [key in ImageType]: string } = {
|
|
16
16
|
[ImageType.Placeholder]: '',
|
|
17
|
-
[ImageType.BgSolid]: '
|
|
18
|
-
[ImageType.BgWhite]: 'bg-white
|
|
17
|
+
[ImageType.BgSolid]: 'card-image-bg-solid',
|
|
18
|
+
[ImageType.BgWhite]: 'card-image-bg-white',
|
|
19
19
|
[ImageType.BgTransparent]: '',
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -23,5 +23,5 @@ export const CARD_TYPE_CLASSES: Record<CardType, string> = {
|
|
|
23
23
|
[CardType.Default]: 'border border-transparent',
|
|
24
24
|
[CardType.Outlined]:
|
|
25
25
|
'border border-shader-neutral-light-8 dark:border-shader-primary-dark-8 p-xs',
|
|
26
|
-
[CardType.Filled]: 'border border-transparent
|
|
26
|
+
[CardType.Filled]: 'border border-transparent card-filled-bg p-xs',
|
|
27
27
|
};
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
// Copyright (c) 2024 IOTA Stiftung
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { ButtonUnstyled } from '@/components/atoms/button';
|
|
5
|
+
import { Close } from '@iota/apps-ui-icons';
|
|
4
6
|
import cx from 'classnames';
|
|
5
|
-
import { ChipState } from './chip.enums';
|
|
6
7
|
import {
|
|
7
|
-
BORDER_CLASSES,
|
|
8
8
|
BACKGROUND_CLASSES,
|
|
9
|
+
BG_SELECTED_OUTLINE,
|
|
10
|
+
BG_SELECTED_OVERLAY,
|
|
11
|
+
BORDER_CLASSES,
|
|
12
|
+
CLOSE_ICON_INTERACTIVE,
|
|
13
|
+
FOCUS_CLASSES,
|
|
9
14
|
ROUNDED_CLASS,
|
|
10
15
|
STATE_LAYER_CLASSES,
|
|
11
16
|
TEXT_COLOR,
|
|
12
|
-
|
|
17
|
+
TEXT_COLOR_SELECTED_OUTLINE,
|
|
13
18
|
} from './chip.classes';
|
|
14
|
-
import {
|
|
15
|
-
import { Close } from '@iota/apps-ui-icons';
|
|
19
|
+
import { ChipSize, ChipType } from './chip.enums';
|
|
16
20
|
|
|
17
21
|
interface ChipProps {
|
|
18
22
|
/**
|
|
@@ -51,29 +55,53 @@ interface ChipProps {
|
|
|
51
55
|
* The button is disabled or not.
|
|
52
56
|
*/
|
|
53
57
|
disabled?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The type of the Chip
|
|
60
|
+
*/
|
|
61
|
+
type?: ChipType;
|
|
62
|
+
/**
|
|
63
|
+
* The size of the chip.
|
|
64
|
+
*/
|
|
65
|
+
size?: ChipSize;
|
|
54
66
|
}
|
|
55
67
|
|
|
56
68
|
export function Chip({
|
|
57
69
|
label,
|
|
58
|
-
|
|
70
|
+
type = ChipType.Outline,
|
|
59
71
|
selected,
|
|
72
|
+
showClose,
|
|
60
73
|
onClose,
|
|
61
74
|
onClick,
|
|
62
75
|
avatar,
|
|
63
76
|
leadingElement,
|
|
64
77
|
trailingElement,
|
|
65
78
|
disabled,
|
|
79
|
+
size = ChipSize.Default,
|
|
66
80
|
}: ChipProps) {
|
|
67
|
-
const
|
|
81
|
+
const isOutlineSelected = type === ChipType.Outline && selected;
|
|
82
|
+
const outlineStyle = selected
|
|
83
|
+
? type === ChipType.Outline
|
|
84
|
+
? 'outline-transparent names:outline-names-neutral-20'
|
|
85
|
+
: 'chip-outline-color'
|
|
86
|
+
: 'outline-transparent';
|
|
87
|
+
|
|
88
|
+
const focusOutlineStyle = cx(
|
|
89
|
+
'group-focus:chip-outline-color-active',
|
|
90
|
+
type === ChipType.Outline && 'names:group-focus:outline-transparent',
|
|
91
|
+
);
|
|
92
|
+
const selectedOverlayBg =
|
|
93
|
+
selected && !disabled && type !== ChipType.Outline ? BG_SELECTED_OVERLAY : '';
|
|
94
|
+
|
|
68
95
|
return (
|
|
69
96
|
<ButtonUnstyled
|
|
70
97
|
onClick={onClick}
|
|
71
98
|
className={cx(
|
|
72
|
-
'border
|
|
99
|
+
'group border disabled:opacity-40',
|
|
73
100
|
ROUNDED_CLASS,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
101
|
+
isOutlineSelected
|
|
102
|
+
? BG_SELECTED_OUTLINE[ChipType.Outline]
|
|
103
|
+
: BACKGROUND_CLASSES[type],
|
|
104
|
+
selected ? 'border-transparent' : BORDER_CLASSES[type],
|
|
77
105
|
)}
|
|
78
106
|
disabled={disabled}
|
|
79
107
|
>
|
|
@@ -82,22 +110,35 @@ export function Chip({
|
|
|
82
110
|
'flex h-full w-full flex-row items-center gap-x-2',
|
|
83
111
|
avatar ? 'py-xxs' : 'py-[6px]',
|
|
84
112
|
avatar ? 'pl-xxs' : leadingElement ? 'pl-xs' : 'pl-sm',
|
|
113
|
+
showClose ? 'pr-xs' : 'pr-sm',
|
|
85
114
|
ROUNDED_CLASS,
|
|
115
|
+
isOutlineSelected
|
|
116
|
+
? TEXT_COLOR_SELECTED_OUTLINE[ChipType.Outline]
|
|
117
|
+
: TEXT_COLOR[type],
|
|
118
|
+
outlineStyle,
|
|
119
|
+
!disabled && focusOutlineStyle,
|
|
86
120
|
!disabled && STATE_LAYER_CLASSES,
|
|
87
|
-
|
|
88
|
-
|
|
121
|
+
FOCUS_CLASSES,
|
|
122
|
+
selectedOverlayBg,
|
|
89
123
|
)}
|
|
90
124
|
>
|
|
91
125
|
{avatar ?? leadingElement}
|
|
92
|
-
<span className=
|
|
126
|
+
<span className={cx(size === ChipSize.Small ? 'text-label-md' : 'text-body-md')}>
|
|
127
|
+
{label}
|
|
128
|
+
</span>
|
|
93
129
|
{trailingElement}
|
|
94
130
|
{showClose && (
|
|
95
|
-
<
|
|
131
|
+
<div
|
|
96
132
|
onClick={onClose}
|
|
97
|
-
className=
|
|
133
|
+
className={cx(disabled ? 'cursor-default' : 'cursor-pointer')}
|
|
98
134
|
>
|
|
99
|
-
<Close
|
|
100
|
-
|
|
135
|
+
<Close
|
|
136
|
+
className={cx(
|
|
137
|
+
'h-4 w-4 transition-opacity duration-150',
|
|
138
|
+
disabled ? '' : selected ? 'opacity-100' : CLOSE_ICON_INTERACTIVE,
|
|
139
|
+
)}
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
101
142
|
)}
|
|
102
143
|
</span>
|
|
103
144
|
</ButtonUnstyled>
|
|
@@ -1,32 +1,54 @@
|
|
|
1
1
|
// Copyright (c) 2024 IOTA Stiftung
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { ChipType } from './chip.enums';
|
|
5
5
|
|
|
6
6
|
export const ROUNDED_CLASS = 'rounded-full';
|
|
7
7
|
|
|
8
|
-
export const BACKGROUND_CLASSES: Record<
|
|
9
|
-
[
|
|
10
|
-
[
|
|
8
|
+
export const BACKGROUND_CLASSES: Record<ChipType, string> = {
|
|
9
|
+
[ChipType.Outline]: 'bg-transparent',
|
|
10
|
+
[ChipType.Elevated]: 'chip-bg-elevated',
|
|
11
|
+
[ChipType.Success]: 'bg-success-surface',
|
|
12
|
+
[ChipType.Brand]: 'chip-bg-brand',
|
|
13
|
+
[ChipType.Error]: 'bg-error-surface',
|
|
11
14
|
};
|
|
12
15
|
|
|
13
|
-
const STATE_LAYER_OUTLINE =
|
|
14
|
-
'outline outline-1
|
|
16
|
+
export const STATE_LAYER_OUTLINE =
|
|
17
|
+
'outline outline-1 hover:chip-outline-color-hover active:chip-outline-color-active';
|
|
15
18
|
|
|
16
|
-
const STATE_LAYER_BG_CLASSES =
|
|
17
|
-
'hover:bg-
|
|
19
|
+
export const STATE_LAYER_BG_CLASSES =
|
|
20
|
+
'hover:chip-bg-color-hover active:chip-bg-color-active group-focus:chip-bg-color-focus';
|
|
18
21
|
|
|
19
22
|
export const STATE_LAYER_CLASSES = `${STATE_LAYER_OUTLINE} ${STATE_LAYER_BG_CLASSES}`;
|
|
20
23
|
|
|
21
|
-
export const
|
|
22
|
-
[
|
|
23
|
-
[ChipState.Selected]: 'border-transparent',
|
|
24
|
+
export const BG_SELECTED_OUTLINE: Partial<Record<ChipType, string>> = {
|
|
25
|
+
[ChipType.Outline]: 'chip-bg-selected-outline',
|
|
24
26
|
};
|
|
25
27
|
|
|
26
|
-
export const
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
export const BG_SELECTED_OVERLAY = 'chip-bg-selected-overlay';
|
|
29
|
+
|
|
30
|
+
export const TEXT_COLOR_SELECTED_OUTLINE: Partial<Record<ChipType, string>> = {
|
|
31
|
+
[ChipType.Outline]: 'chip-text-secondary',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const BORDER_CLASSES: Record<ChipType, string> = {
|
|
35
|
+
[ChipType.Outline]: 'chip-border-default',
|
|
36
|
+
[ChipType.Elevated]: 'border-transparent',
|
|
37
|
+
[ChipType.Success]: 'border-success-surface',
|
|
38
|
+
[ChipType.Brand]: 'chip-border-color-brand',
|
|
39
|
+
[ChipType.Error]: 'border-error-surface',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const TEXT_COLOR: Record<ChipType, string> = {
|
|
43
|
+
[ChipType.Outline]: 'chip-text-default',
|
|
44
|
+
[ChipType.Elevated]: 'chip-text-secondary',
|
|
45
|
+
[ChipType.Success]: 'chip-text-secondary',
|
|
46
|
+
[ChipType.Brand]: 'chip-text-brand',
|
|
47
|
+
[ChipType.Error]: 'chip-text-secondary',
|
|
29
48
|
};
|
|
30
49
|
|
|
31
50
|
export const FOCUS_CLASSES =
|
|
32
|
-
'focus-visible:shadow-[0_0_0_2px] focus-visible:
|
|
51
|
+
'focus-visible:shadow-[0_0_0_2px] focus-visible:chip-focus-ring focus-visible:outline-none';
|
|
52
|
+
|
|
53
|
+
export const CLOSE_ICON_INTERACTIVE =
|
|
54
|
+
'chip-close-icon-opacity group-hover:opacity-100 group-focus:opacity-100 group-active:opacity-100';
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
// Copyright (c) 2024 IOTA Stiftung
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
export enum
|
|
4
|
+
export enum ChipType {
|
|
5
|
+
Outline = 'outline',
|
|
6
|
+
Elevated = 'elevated',
|
|
7
|
+
Success = 'success',
|
|
8
|
+
Brand = 'brand',
|
|
9
|
+
Error = 'error',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export enum ChipSize {
|
|
13
|
+
Small = 'small',
|
|
5
14
|
Default = 'default',
|
|
6
|
-
Selected = 'selected',
|
|
7
15
|
}
|
|
@@ -120,7 +120,7 @@ export function DisplayStats({
|
|
|
120
120
|
</Tooltip>
|
|
121
121
|
)}
|
|
122
122
|
</div>
|
|
123
|
-
{icon && <span className="
|
|
123
|
+
{icon && <span className="display-stats-icon-color">{icon}</span>}
|
|
124
124
|
</div>
|
|
125
125
|
<div className="flex w-full flex-row items-baseline gap-xxs">
|
|
126
126
|
<span className={cx('break-all', valueClass)}>{value}</span>
|
|
@@ -132,7 +132,7 @@ export function DisplayStats({
|
|
|
132
132
|
{copyText && (
|
|
133
133
|
<div className="self-center">
|
|
134
134
|
<ButtonUnstyled onClick={handleCopyClick}>
|
|
135
|
-
<Copy className="
|
|
135
|
+
<Copy className="display-stats-copy-icon-color" />
|
|
136
136
|
</ButtonUnstyled>
|
|
137
137
|
</div>
|
|
138
138
|
)}
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
import { DisplayStatsType, DisplayStatsSize } from './displayStats.enums';
|
|
5
5
|
|
|
6
6
|
export const BACKGROUND_CLASSES: Record<DisplayStatsType, string> = {
|
|
7
|
-
[DisplayStatsType.Default]: '
|
|
8
|
-
[DisplayStatsType.Highlight]: '
|
|
9
|
-
[DisplayStatsType.Secondary]: '
|
|
7
|
+
[DisplayStatsType.Default]: 'display-stats-bg-default',
|
|
8
|
+
[DisplayStatsType.Highlight]: 'display-stats-bg-highlight',
|
|
9
|
+
[DisplayStatsType.Secondary]: 'display-stats-bg-secondary',
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export const TEXT_CLASSES: Record<DisplayStatsType, string> = {
|
|
13
|
-
[DisplayStatsType.Default]: '
|
|
14
|
-
[DisplayStatsType.Highlight]: '
|
|
15
|
-
[DisplayStatsType.Secondary]: '
|
|
13
|
+
[DisplayStatsType.Default]: 'display-stats-text-default',
|
|
14
|
+
[DisplayStatsType.Highlight]: 'display-stats-text-highlight',
|
|
15
|
+
[DisplayStatsType.Secondary]: 'display-stats-text-secondary',
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export const SIZE_CLASSES: Record<DisplayStatsSize, string> = {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
export function Dropdown({ children }: React.PropsWithChildren): React.JSX.Element {
|
|
5
5
|
return (
|
|
6
|
-
<ul className="list-none rounded-lg border
|
|
6
|
+
<ul className="dropdown-bg dropdown-border-color list-none rounded-lg border py-xs">
|
|
7
7
|
{children}
|
|
8
8
|
</ul>
|
|
9
9
|
);
|