@appdirect/design-system 0.0.5 → 0.0.7
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.
|
@@ -4,6 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { Box } from '../../Layout/Box';
|
|
5
5
|
import { Text } from '../../Typography/Text';
|
|
6
6
|
import { Title } from '../../Typography/Title';
|
|
7
|
+
import { Inline } from '../../Layout/Inline';
|
|
7
8
|
|
|
8
9
|
export type KeyInsightSize = 'xs' | 'sm' | 'md' | 'lg' | 'jumbo' | 'super-jumbo';
|
|
9
10
|
|
|
@@ -18,6 +19,10 @@ export interface KeyInsightProps {
|
|
|
18
19
|
showBorder?: boolean;
|
|
19
20
|
/** Size of the KeyInsight component */
|
|
20
21
|
size?: KeyInsightSize;
|
|
22
|
+
/** Optional content rendered inline before the value (e.g. a trend arrow or unit) */
|
|
23
|
+
leftSection?: React.ReactNode;
|
|
24
|
+
/** Optional content rendered inline after the value (e.g. a trend arrow or unit) */
|
|
25
|
+
rightSection?: React.ReactNode;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
// Size mappings for different elements
|
|
@@ -124,6 +129,14 @@ const sizeConfig = {
|
|
|
124
129
|
* </Stack>
|
|
125
130
|
*
|
|
126
131
|
* @example
|
|
132
|
+
* // With a trend indicator next to the value
|
|
133
|
+
* <KeyInsight
|
|
134
|
+
* value="42%"
|
|
135
|
+
* title="Conversion Rate"
|
|
136
|
+
* rightSection={<RiArrowUpLine size={16} color="var(--ad-color-status-success)" />}
|
|
137
|
+
* />
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
127
140
|
* // Hero metrics with jumbo size
|
|
128
141
|
* <KeyInsight
|
|
129
142
|
* value="$2.4M"
|
|
@@ -182,24 +195,29 @@ export function KeyInsight({
|
|
|
182
195
|
subtitle,
|
|
183
196
|
showBorder = false,
|
|
184
197
|
size = 'md',
|
|
198
|
+
leftSection,
|
|
199
|
+
rightSection,
|
|
185
200
|
}: KeyInsightProps) {
|
|
186
201
|
const config = sizeConfig[size];
|
|
187
|
-
|
|
202
|
+
|
|
188
203
|
return (
|
|
189
|
-
<Box
|
|
190
|
-
ta="center"
|
|
204
|
+
<Box
|
|
205
|
+
ta="center"
|
|
191
206
|
p={config.padding}
|
|
192
|
-
style={{
|
|
193
|
-
borderRight: showBorder ? '1px solid var(--ad-color-border-subtle)' : undefined
|
|
207
|
+
style={{
|
|
208
|
+
borderRight: showBorder ? '1px solid var(--ad-color-border-subtle)' : undefined
|
|
194
209
|
}}
|
|
195
210
|
>
|
|
196
|
-
<
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
211
|
+
<Inline gap="xxs" align="center" justify="center">
|
|
212
|
+
{leftSection}
|
|
213
|
+
<Title
|
|
214
|
+
order={config.valueOrder}
|
|
215
|
+
style={config.customValueStyle}
|
|
216
|
+
>
|
|
217
|
+
{value}
|
|
218
|
+
</Title>
|
|
219
|
+
{rightSection}
|
|
220
|
+
</Inline>
|
|
203
221
|
<Text
|
|
204
222
|
size={config.titleSize}
|
|
205
223
|
mt={0}
|
|
@@ -14,10 +14,10 @@ export interface NameValuePair {
|
|
|
14
14
|
valueColor?: string;
|
|
15
15
|
/** Optional weight for the value text */
|
|
16
16
|
valueWeight?: number | 'normal' | 'bold';
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
|
|
17
|
+
/** Render this pair's value as a Badge instead of plain text */
|
|
18
|
+
valueAsBadge?: boolean;
|
|
19
|
+
/** Icon-triggered action for this pair (overrides the group-level `action`) */
|
|
20
|
+
action?: NameValueItemProps['action'];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface NameValueProps {
|
|
@@ -41,12 +41,10 @@ export interface NameValueProps {
|
|
|
41
41
|
valueColor?: string;
|
|
42
42
|
/** Weight for value text */
|
|
43
43
|
valueWeight?: number | 'normal' | 'bold';
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
/** Size of the copy icons */
|
|
49
|
-
copyIconSize?: number;
|
|
44
|
+
/** Render all values as badges (can be overridden per pair) */
|
|
45
|
+
valueAsBadge?: boolean;
|
|
46
|
+
/** Icon-triggered action for all values (for single name/value usage, or as a default for all pairs) */
|
|
47
|
+
action?: NameValueItemProps['action'];
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
/**
|
|
@@ -57,62 +55,55 @@ export interface NameValueProps {
|
|
|
57
55
|
* Perfect for metadata display, specifications, statistics, or any key-value information.
|
|
58
56
|
*
|
|
59
57
|
* @example
|
|
60
|
-
* // Single name-value pair with copy
|
|
61
|
-
* <NameValue
|
|
62
|
-
* name="API Key"
|
|
63
|
-
* value="sk-1234567890abcdef"
|
|
58
|
+
* // Single name-value pair with the default copy action
|
|
59
|
+
* <NameValue
|
|
60
|
+
* name="API Key"
|
|
61
|
+
* value="sk-1234567890abcdef"
|
|
64
62
|
* valueColor="green"
|
|
65
|
-
*
|
|
66
|
-
* onCopy={(value) => navigator.clipboard.writeText(value)}
|
|
63
|
+
* action={{ onClick: (value) => navigator.clipboard.writeText(value) }}
|
|
67
64
|
* />
|
|
68
|
-
*
|
|
65
|
+
*
|
|
69
66
|
* @example
|
|
70
|
-
* // Multiple pairs with selective copy
|
|
67
|
+
* // Multiple pairs with selective copy actions
|
|
71
68
|
* const userInfo = [
|
|
72
69
|
* { name: "Name", value: "John Doe" },
|
|
73
|
-
* { name: "Email", value: "john@example.com",
|
|
74
|
-
* { name: "User ID", value: "usr_123456",
|
|
70
|
+
* { name: "Email", value: "john@example.com", action: { onClick: (v) => navigator.clipboard.writeText(v) } },
|
|
71
|
+
* { name: "User ID", value: "usr_123456", action: { onClick: (v) => navigator.clipboard.writeText(v) } },
|
|
75
72
|
* { name: "Last Login", value: "2 hours ago" }
|
|
76
73
|
* ];
|
|
77
|
-
*
|
|
78
|
-
* <NameValue
|
|
74
|
+
*
|
|
75
|
+
* <NameValue
|
|
79
76
|
* pairs={userInfo}
|
|
80
77
|
* spacing="md"
|
|
81
78
|
* />
|
|
82
|
-
*
|
|
79
|
+
*
|
|
83
80
|
* @example
|
|
84
|
-
* //
|
|
81
|
+
* // Status values as badges
|
|
85
82
|
* const serverInfo = [
|
|
86
|
-
* { name: "
|
|
87
|
-
* { name: "IP Address", value: "192.168.1.100",
|
|
88
|
-
* { name: "Port", value: "8080"
|
|
89
|
-
* { name: "Status", value: "Running" },
|
|
83
|
+
* { name: "Status", value: "Running", valueAsBadge: true },
|
|
84
|
+
* { name: "IP Address", value: "192.168.1.100", action: { onClick: (v) => navigator.clipboard.writeText(v) } },
|
|
85
|
+
* { name: "Port", value: "8080" },
|
|
90
86
|
* { name: "Uptime", value: "15 days" },
|
|
91
|
-
* { name: "Load", value: "0.68" }
|
|
92
87
|
* ];
|
|
93
|
-
*
|
|
94
|
-
* <NameValue
|
|
88
|
+
*
|
|
89
|
+
* <NameValue
|
|
95
90
|
* pairs={serverInfo}
|
|
96
91
|
* columns={3}
|
|
97
92
|
* spacing="sm"
|
|
98
93
|
* />
|
|
99
|
-
*
|
|
94
|
+
*
|
|
100
95
|
* @example
|
|
101
|
-
* // All values copyable by default
|
|
96
|
+
* // All values copyable by default, with a custom action icon for one
|
|
102
97
|
* const credentials = [
|
|
103
98
|
* { name: "Username", value: "admin" },
|
|
104
99
|
* { name: "Password", value: "secret123" },
|
|
105
100
|
* { name: "Token", value: "eyJhbGciOiJIUzI1NiIs..." },
|
|
106
|
-
* { name: "Database URL", value: "postgresql://localhost:5432/db" }
|
|
101
|
+
* { name: "Database URL", value: "postgresql://localhost:5432/db", action: { icon: <RiEditLine size={16} />, onClick: openEditDialog, label: "Edit" } },
|
|
107
102
|
* ];
|
|
108
|
-
*
|
|
109
|
-
* <NameValue
|
|
103
|
+
*
|
|
104
|
+
* <NameValue
|
|
110
105
|
* pairs={credentials}
|
|
111
|
-
*
|
|
112
|
-
* onCopy={(value) => {
|
|
113
|
-
* navigator.clipboard.writeText(value);
|
|
114
|
-
* console.log('Copied:', value);
|
|
115
|
-
* }}
|
|
106
|
+
* action={{ onClick: (value) => navigator.clipboard.writeText(value) }}
|
|
116
107
|
* columns={2}
|
|
117
108
|
* />
|
|
118
109
|
*/
|
|
@@ -127,14 +118,13 @@ export function NameValue({
|
|
|
127
118
|
nameColor = 'dimmed',
|
|
128
119
|
valueColor,
|
|
129
120
|
valueWeight = 500,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
copyIconSize = 24,
|
|
121
|
+
valueAsBadge = false,
|
|
122
|
+
action,
|
|
133
123
|
}: NameValueProps) {
|
|
134
|
-
|
|
124
|
+
|
|
135
125
|
// Create pairs array from individual props if provided
|
|
136
|
-
const allPairs = pairs || (name && value ? [{ name, value,
|
|
137
|
-
|
|
126
|
+
const allPairs = pairs || (name && value ? [{ name, value, valueAsBadge, action }] : []);
|
|
127
|
+
|
|
138
128
|
if (allPairs.length === 0) {
|
|
139
129
|
return null;
|
|
140
130
|
}
|
|
@@ -149,9 +139,8 @@ export function NameValue({
|
|
|
149
139
|
nameColor,
|
|
150
140
|
valueColor: pair.valueColor || valueColor,
|
|
151
141
|
valueWeight: pair.valueWeight || valueWeight,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
copyIconSize,
|
|
142
|
+
valueAsBadge: pair.valueAsBadge ?? valueAsBadge,
|
|
143
|
+
action: pair.action ?? action,
|
|
155
144
|
};
|
|
156
145
|
|
|
157
146
|
return <NameValueItem key={index} {...itemProps} />;
|
|
@@ -2,7 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { Inline } from '../../Layout/Inline';
|
|
3
3
|
import { Stack } from '../../Layout/Stack';
|
|
4
4
|
import { Text } from '../../Typography/Text';
|
|
5
|
-
import {
|
|
5
|
+
import { Badge } from '../../DataDisplay/Badge';
|
|
6
|
+
import { ActionIcon } from '../../Buttons/ActionIcon';
|
|
7
|
+
import { Tooltip } from '../../Overlays/Tooltip';
|
|
8
|
+
import { RiFileCopyLine } from '@remixicon/react';
|
|
6
9
|
|
|
7
10
|
export interface NameValueItemProps {
|
|
8
11
|
/** Name/label for the pair */
|
|
@@ -19,37 +22,63 @@ export interface NameValueItemProps {
|
|
|
19
22
|
valueColor?: string;
|
|
20
23
|
/** Optional weight for the value text */
|
|
21
24
|
valueWeight?: number | 'normal' | 'bold';
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
/** Render the value as a Badge instead of plain text */
|
|
26
|
+
valueAsBadge?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Icon-triggered action next to the value — the designer can assign any
|
|
29
|
+
* icon here (copy-to-clipboard, edit, etc.); this component just renders
|
|
30
|
+
* whichever icon is given and wires up the click. Omit entirely to show
|
|
31
|
+
* no action. Defaults to a copy icon when `icon` isn't provided, since
|
|
32
|
+
* copy-to-clipboard is the most common case.
|
|
33
|
+
*/
|
|
34
|
+
action?: {
|
|
35
|
+
/** Called with the item's value when the action icon is clicked */
|
|
36
|
+
onClick: (value: string) => void;
|
|
37
|
+
/** Custom icon to render (defaults to a copy icon) */
|
|
38
|
+
icon?: React.ReactNode;
|
|
39
|
+
/** Size of the icon itself */
|
|
40
|
+
iconSize?: number;
|
|
41
|
+
/** Accessible label / tooltip text */
|
|
42
|
+
label?: string;
|
|
43
|
+
};
|
|
28
44
|
}
|
|
29
45
|
|
|
30
46
|
/**
|
|
31
47
|
* NameValueItem Component
|
|
32
|
-
*
|
|
33
|
-
* A component for displaying a single name-value pair with optional
|
|
34
|
-
*
|
|
35
|
-
*
|
|
48
|
+
*
|
|
49
|
+
* A component for displaying a single name-value pair with an optional
|
|
50
|
+
* icon-triggered action (copy-to-clipboard by default, or any icon the
|
|
51
|
+
* designer assigns). Designed to be used within the NameValue component or
|
|
52
|
+
* as a standalone item.
|
|
53
|
+
*
|
|
36
54
|
* @example
|
|
37
55
|
* // Basic name-value pair
|
|
38
56
|
* <NameValueItem
|
|
39
57
|
* name="Status"
|
|
40
58
|
* value="Active"
|
|
41
59
|
* />
|
|
42
|
-
*
|
|
60
|
+
*
|
|
43
61
|
* @example
|
|
44
|
-
* // With copy
|
|
62
|
+
* // With the default copy action
|
|
45
63
|
* <NameValueItem
|
|
46
64
|
* name="API Key"
|
|
47
65
|
* value="sk-1234567890abcdef"
|
|
48
66
|
* valueColor="green"
|
|
49
|
-
*
|
|
50
|
-
* onCopy={(value) => navigator.clipboard.writeText(value)}
|
|
67
|
+
* action={{ onClick: (value) => navigator.clipboard.writeText(value) }}
|
|
51
68
|
* />
|
|
52
|
-
*
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* // With a custom action icon
|
|
72
|
+
* <NameValueItem
|
|
73
|
+
* name="Server Name"
|
|
74
|
+
* value="prod-web-01"
|
|
75
|
+
* action={{ icon: <RiEditLine size={16} />, onClick: openEditDialog, label: 'Edit' }}
|
|
76
|
+
* />
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* // Value as a badge
|
|
80
|
+
* <NameValueItem name="Status" value="Active" valueAsBadge />
|
|
81
|
+
*
|
|
53
82
|
* @example
|
|
54
83
|
* // Custom styling
|
|
55
84
|
* <NameValueItem
|
|
@@ -69,9 +98,8 @@ export function NameValueItem({
|
|
|
69
98
|
nameColor = 'dimmed',
|
|
70
99
|
valueColor,
|
|
71
100
|
valueWeight = 500,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
copyIconSize = 24,
|
|
101
|
+
valueAsBadge = false,
|
|
102
|
+
action,
|
|
75
103
|
}: NameValueItemProps) {
|
|
76
104
|
return (
|
|
77
105
|
<Stack gap={0} p="xs">
|
|
@@ -79,22 +107,33 @@ export function NameValueItem({
|
|
|
79
107
|
{name}
|
|
80
108
|
</Text>
|
|
81
109
|
<Inline gap="xs" align="center">
|
|
82
|
-
|
|
83
|
-
size={valueSize}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
110
|
+
{valueAsBadge ? (
|
|
111
|
+
<Badge size={valueSize} variant="outline" color="default">
|
|
112
|
+
{value}
|
|
113
|
+
</Badge>
|
|
114
|
+
) : (
|
|
115
|
+
<Text
|
|
116
|
+
size={valueSize}
|
|
117
|
+
fw={valueWeight}
|
|
118
|
+
c={valueColor}
|
|
119
|
+
>
|
|
120
|
+
{value}
|
|
121
|
+
</Text>
|
|
122
|
+
)}
|
|
123
|
+
{action && (
|
|
124
|
+
<Tooltip label={action.label ?? 'Copy'} position="top" withArrow>
|
|
125
|
+
<ActionIcon
|
|
126
|
+
variant="link"
|
|
127
|
+
color="gray"
|
|
128
|
+
size="xs"
|
|
129
|
+
onClick={() => action.onClick(value)}
|
|
130
|
+
aria-label={action.label ?? `Action for ${name}`}
|
|
131
|
+
>
|
|
132
|
+
{action.icon ?? <RiFileCopyLine size={action.iconSize ?? 16} />}
|
|
133
|
+
</ActionIcon>
|
|
134
|
+
</Tooltip>
|
|
96
135
|
)}
|
|
97
136
|
</Inline>
|
|
98
137
|
</Stack>
|
|
99
138
|
);
|
|
100
|
-
}
|
|
139
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appdirect/design-system",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "AppDirect Design System components. Wraps Mantine v9 with standardized props, variants, and tokens.",
|
|
5
5
|
"main": "./dist/index.ts",
|
|
6
6
|
"types": "./dist/index.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"prepublishOnly": "npm run build"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@appdirect/ad-design-tokens": "0.0.
|
|
40
|
+
"@appdirect/ad-design-tokens": "0.0.7",
|
|
41
41
|
"@mantine/dropzone": "^9.6.0",
|
|
42
42
|
"@remixicon/react": "^4.6.0",
|
|
43
43
|
"@tabler/icons-react": "^3.33.0",
|