@app-studio/web 0.9.35 → 0.9.37
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/dist/components/Calendar/Calendar/Calendar.props.d.ts +8 -0
- package/dist/components/KanbanBoard/KanbanBoard/KanbanBoard.props.d.ts +5 -0
- package/dist/components/KanbanBoard/KanbanBoard/KanbanBoard.state.d.ts +7 -3
- package/dist/components/OKR/OKR/OKR.props.d.ts +72 -0
- package/dist/components/OKR/OKR/OKR.style.d.ts +19 -0
- package/dist/components/OKR/OKR/OKR.view.d.ts +4 -0
- package/dist/components/OKR/OKR.d.ts +4 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/pages/okr.page.d.ts +3 -0
- package/dist/web.cjs.development.js +774 -199
- package/dist/web.cjs.development.js.map +1 -1
- package/dist/web.cjs.production.min.js +1 -1
- package/dist/web.cjs.production.min.js.map +1 -1
- package/dist/web.esm.js +774 -200
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.development.js +774 -199
- package/dist/web.umd.development.js.map +1 -1
- package/dist/web.umd.production.min.js +1 -1
- package/dist/web.umd.production.min.js.map +1 -1
- package/docs/README.md +2 -1
- package/docs/components/Calendar.mdx +3 -0
- package/docs/components/Flow.mdx +1 -0
- package/docs/components/KanbanBoard.mdx +4 -0
- package/docs/components/OKR.mdx +475 -0
- package/docs/components/Title.mdx +1 -0
- package/docs/components/Tree.mdx +1 -0
- package/docs/components.md +178 -0
- package/package.json +1 -1
- package/docs/api-reference/README.md +0 -103
- package/docs/api-reference/data-display/flow.md +0 -220
- package/docs/api-reference/data-display/tree.md +0 -210
- package/docs/api-reference/form/chat-input.md +0 -206
- package/docs/api-reference/utility/button.md +0 -145
- package/docs/api-reference/utility/title.md +0 -301
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
# Tree
|
|
2
|
-
|
|
3
|
-
The Tree component is used for displaying hierarchical data with expandable/collapsible nodes. It supports both a compound component pattern and a data-driven approach.
|
|
4
|
-
|
|
5
|
-
## Import
|
|
6
|
-
|
|
7
|
-
```jsx
|
|
8
|
-
import { Tree } from '@app-studio/web';
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Props
|
|
12
|
-
|
|
13
|
-
| Prop | Type | Default | Description |
|
|
14
|
-
| ---- | ---- | ------- | ----------- |
|
|
15
|
-
| children | React.ReactNode | undefined | Child elements for compound component pattern (e.g., `<Tree.Item />`) |
|
|
16
|
-
| items | TreeNode[] | undefined | Data-driven approach: array of tree nodes |
|
|
17
|
-
| size | 'sm' \| 'md' \| 'lg' | 'md' | Size of the tree items |
|
|
18
|
-
| variant | 'default' \| 'outline' \| 'filled' | 'default' | Visual variant of the tree items |
|
|
19
|
-
| defaultExpandedItems | string[] | [] | IDs of initially expanded items (uncontrolled mode) |
|
|
20
|
-
| expandedItems | string[] | undefined | IDs of expanded items (controlled mode) |
|
|
21
|
-
| onExpandedItemsChange | (expandedItems: string[]) => void | undefined | Callback when expanded items change |
|
|
22
|
-
| onItemSelect | (itemId: string, item?: TreeNode) => void | undefined | Callback when an item is selected |
|
|
23
|
-
| selectedItem | string | undefined | ID of the currently selected item (controlled mode) |
|
|
24
|
-
| defaultSelectedItem | string | undefined | ID of the initially selected item (uncontrolled mode) |
|
|
25
|
-
| multiSelect | boolean | false | Whether to allow multiple selection |
|
|
26
|
-
| allowDragAndDrop | boolean | false | Whether to enable drag and drop functionality |
|
|
27
|
-
| dragHandleIcon | React.ReactNode | undefined | Custom icon to use for the drag handle |
|
|
28
|
-
| onItemsReorder | (items: TreeNode[]) => void | undefined | Callback when items are reordered via drag and drop |
|
|
29
|
-
| onDragStart | (itemId: string, event: React.DragEvent) => void | undefined | Callback when drag starts on an item |
|
|
30
|
-
| onDragEnd | (itemId: string) => void | undefined | Callback when drag ends |
|
|
31
|
-
| views | object | {} | Custom styling for different parts of the component |
|
|
32
|
-
|
|
33
|
-
## TreeNode Structure
|
|
34
|
-
|
|
35
|
-
The `TreeNode` interface defines the structure of nodes in the data-driven approach:
|
|
36
|
-
|
|
37
|
-
```tsx
|
|
38
|
-
interface TreeNode {
|
|
39
|
-
id: string;
|
|
40
|
-
label: string;
|
|
41
|
-
icon?: React.ReactNode;
|
|
42
|
-
children?: TreeNode[];
|
|
43
|
-
disabled?: boolean;
|
|
44
|
-
data?: any;
|
|
45
|
-
style?: ViewProps;
|
|
46
|
-
isDragging?: boolean;
|
|
47
|
-
draggable?: boolean;
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Examples
|
|
52
|
-
|
|
53
|
-
### Compound Component Pattern
|
|
54
|
-
|
|
55
|
-
```jsx
|
|
56
|
-
import React from 'react';
|
|
57
|
-
import { Tree } from '@app-studio/web';
|
|
58
|
-
import { FolderIcon, FileIcon } from '@app-studio/web';
|
|
59
|
-
|
|
60
|
-
export const CompoundTree = () => {
|
|
61
|
-
return (
|
|
62
|
-
<Tree defaultExpandedItems={['parent-1']}>
|
|
63
|
-
<Tree.Item value="parent-1" icon={<FolderIcon />}>
|
|
64
|
-
<Tree.ItemLabel>Parent Item 1</Tree.ItemLabel>
|
|
65
|
-
<Tree.ItemContent>
|
|
66
|
-
<Tree.Item value="child-1-1" icon={<FileIcon />}>
|
|
67
|
-
<Tree.ItemLabel>Child Item 1.1</Tree.ItemLabel>
|
|
68
|
-
</Tree.Item>
|
|
69
|
-
<Tree.Item value="child-1-2" icon={<FileIcon />}>
|
|
70
|
-
<Tree.ItemLabel>Child Item 1.2</Tree.ItemLabel>
|
|
71
|
-
</Tree.Item>
|
|
72
|
-
</Tree.ItemContent>
|
|
73
|
-
</Tree.Item>
|
|
74
|
-
<Tree.Item value="parent-2" icon={<FolderIcon />}>
|
|
75
|
-
<Tree.ItemLabel>Parent Item 2</Tree.ItemLabel>
|
|
76
|
-
<Tree.ItemContent>
|
|
77
|
-
<Tree.Item value="child-2-1" icon={<FileIcon />}>
|
|
78
|
-
<Tree.ItemLabel>Child Item 2.1</Tree.ItemLabel>
|
|
79
|
-
</Tree.Item>
|
|
80
|
-
</Tree.ItemContent>
|
|
81
|
-
</Tree.Item>
|
|
82
|
-
</Tree>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Data-Driven Approach
|
|
88
|
-
|
|
89
|
-
```jsx
|
|
90
|
-
import React from 'react';
|
|
91
|
-
import { Tree } from '@app-studio/web';
|
|
92
|
-
import { FolderIcon, FileIcon } from '@app-studio/web';
|
|
93
|
-
|
|
94
|
-
export const DataDrivenTree = () => {
|
|
95
|
-
const treeNodes = [
|
|
96
|
-
{
|
|
97
|
-
id: 'parent-1',
|
|
98
|
-
label: 'Parent Item 1',
|
|
99
|
-
icon: <FolderIcon />,
|
|
100
|
-
children: [
|
|
101
|
-
{ id: 'child-1-1', label: 'Child Item 1.1', icon: <FileIcon /> },
|
|
102
|
-
{ id: 'child-1-2', label: 'Child Item 1.2', icon: <FileIcon /> }
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
id: 'parent-2',
|
|
107
|
-
label: 'Parent Item 2',
|
|
108
|
-
icon: <FolderIcon />,
|
|
109
|
-
children: [
|
|
110
|
-
{ id: 'child-2-1', label: 'Child Item 2.1', icon: <FileIcon /> }
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
|
-
];
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<Tree
|
|
117
|
-
items={treeNodes}
|
|
118
|
-
defaultExpandedItems={['parent-1']}
|
|
119
|
-
onItemSelect={(itemId, item) => console.log(`Selected: ${itemId}`, item)}
|
|
120
|
-
/>
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### With Drag and Drop
|
|
126
|
-
|
|
127
|
-
```jsx
|
|
128
|
-
import React, { useState } from 'react';
|
|
129
|
-
import { Tree } from '@app-studio/web';
|
|
130
|
-
import { FolderIcon, FileIcon } from '@app-studio/web';
|
|
131
|
-
|
|
132
|
-
export const DraggableTree = () => {
|
|
133
|
-
const [menuItems, setMenuItems] = useState([
|
|
134
|
-
{
|
|
135
|
-
id: 'menu-1',
|
|
136
|
-
label: 'Menu Item 1',
|
|
137
|
-
icon: <FolderIcon />,
|
|
138
|
-
children: [
|
|
139
|
-
{ id: 'submenu-1-1', label: 'Submenu Item 1.1', icon: <FileIcon /> }
|
|
140
|
-
]
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
id: 'menu-2',
|
|
144
|
-
label: 'Menu Item 2',
|
|
145
|
-
icon: <FolderIcon />,
|
|
146
|
-
children: [
|
|
147
|
-
{ id: 'submenu-2-1', label: 'Submenu Item 2.1', icon: <FileIcon /> }
|
|
148
|
-
]
|
|
149
|
-
}
|
|
150
|
-
]);
|
|
151
|
-
|
|
152
|
-
return (
|
|
153
|
-
<Tree
|
|
154
|
-
items={menuItems}
|
|
155
|
-
allowDragAndDrop={true}
|
|
156
|
-
onItemsReorder={setMenuItems}
|
|
157
|
-
onDragStart={(itemId) => console.log(`Started dragging: ${itemId}`)}
|
|
158
|
-
onDragEnd={(itemId) => console.log(`Finished dragging: ${itemId}`)}
|
|
159
|
-
/>
|
|
160
|
-
);
|
|
161
|
-
};
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## Compound Components
|
|
165
|
-
|
|
166
|
-
The Tree component uses a compound component pattern with the following sub-components:
|
|
167
|
-
|
|
168
|
-
```jsx
|
|
169
|
-
Tree.Item // Represents a tree node
|
|
170
|
-
Tree.ItemLabel // The clickable label part of a tree node
|
|
171
|
-
Tree.ItemContent // Container for child nodes
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
## Customization
|
|
175
|
-
|
|
176
|
-
The Tree component can be customized using the `views` prop:
|
|
177
|
-
|
|
178
|
-
```jsx
|
|
179
|
-
<Tree
|
|
180
|
-
// ...other props
|
|
181
|
-
views={{
|
|
182
|
-
container: { /* styles for the root container */ },
|
|
183
|
-
item: { /* styles for each tree item */ },
|
|
184
|
-
itemLabel: { /* styles for the clickable label part */ },
|
|
185
|
-
itemContent: { /* styles for the children wrapper */ },
|
|
186
|
-
icon: { /* styles for the item's main icon */ },
|
|
187
|
-
expandIcon: { /* styles for the expand/collapse chevron icon */ },
|
|
188
|
-
draggedItem: { /* styles for the item being dragged */ },
|
|
189
|
-
dragHandle: { /* styles for the drag handle icon */ },
|
|
190
|
-
}}
|
|
191
|
-
/>
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## Accessibility
|
|
195
|
-
|
|
196
|
-
The Tree component implements the following accessibility features:
|
|
197
|
-
|
|
198
|
-
- Keyboard navigation for expanding/collapsing nodes
|
|
199
|
-
- ARIA attributes for tree structure
|
|
200
|
-
- Focus management for interactive elements
|
|
201
|
-
- Proper contrast for selected and hovered states
|
|
202
|
-
|
|
203
|
-
## Best Practices
|
|
204
|
-
|
|
205
|
-
- Use consistent icons for similar node types
|
|
206
|
-
- Provide clear labels for all nodes
|
|
207
|
-
- Implement proper error handling for drag and drop operations
|
|
208
|
-
- Consider the depth of your tree structure (avoid deeply nested trees)
|
|
209
|
-
- Use the `onItemSelect` callback to handle item selection
|
|
210
|
-
- Implement undo/redo functionality for drag and drop operations when needed
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
# ChatInput
|
|
2
|
-
|
|
3
|
-
The ChatInput component is a customizable chat input field with support for file uploads and prompt examples.
|
|
4
|
-
|
|
5
|
-
## Import
|
|
6
|
-
|
|
7
|
-
```jsx
|
|
8
|
-
import { ChatInput } from '@app-studio/web';
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Props
|
|
12
|
-
|
|
13
|
-
| Prop | Type | Default | Description |
|
|
14
|
-
| ---- | ---- | ------- | ----------- |
|
|
15
|
-
| onSubmit | (message: string, options?: { model_name?: string; enable_thinking?: boolean }) => void | required | Callback function when the form is submitted |
|
|
16
|
-
| placeholder | string | 'Say what you want and Kimmy will surprise you' | Placeholder text for the input |
|
|
17
|
-
| loading | boolean | false | Whether the input is in a loading state |
|
|
18
|
-
| disabled | boolean | false | Whether the input is disabled |
|
|
19
|
-
| isAgentRunning | boolean | false | Whether an agent is currently running |
|
|
20
|
-
| onStopAgent | () => void | undefined | Callback function to stop the agent |
|
|
21
|
-
| autoFocus | boolean | true | Whether to auto focus the input |
|
|
22
|
-
| value | string | undefined | Controlled value for the input |
|
|
23
|
-
| onChange | (value: string) => void | undefined | Callback function when the input value changes |
|
|
24
|
-
| onFileBrowse | () => void | undefined | Callback function when the file browser is opened |
|
|
25
|
-
| sandboxId | string | undefined | ID of the sandbox |
|
|
26
|
-
| hideAttachments | boolean | false | Whether to hide the attachment button |
|
|
27
|
-
| title | string | undefined | Title for the chat input |
|
|
28
|
-
| showGuideTip | boolean | false | Whether to show the guide tip |
|
|
29
|
-
| guideVideoUrl | string | undefined | URL for the guide video |
|
|
30
|
-
| onGuideClose | () => void | undefined | Callback function when the guide tip is closed |
|
|
31
|
-
| promptExamples | PromptExample[] | [] | List of prompt examples |
|
|
32
|
-
| onPromptExampleSelect | (example: PromptExample) => void | undefined | Callback function when a prompt example is selected |
|
|
33
|
-
| size | 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' | 'md' | Size of the chat input |
|
|
34
|
-
| shape | 'default' \| 'sharp' \| 'rounded' \| 'pillShaped' | 'rounded' | Shape of the chat input |
|
|
35
|
-
| variant | 'default' \| 'outline' \| 'none' | 'default' | Visual variant of the chat input |
|
|
36
|
-
| views | object | {} | Custom styling for different parts of the component |
|
|
37
|
-
|
|
38
|
-
## Interfaces
|
|
39
|
-
|
|
40
|
-
### PromptExample
|
|
41
|
-
|
|
42
|
-
```tsx
|
|
43
|
-
interface PromptExample {
|
|
44
|
-
id: string;
|
|
45
|
-
text: string;
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### UploadedFile
|
|
50
|
-
|
|
51
|
-
```tsx
|
|
52
|
-
interface UploadedFile {
|
|
53
|
-
name: string;
|
|
54
|
-
path: string;
|
|
55
|
-
size: number;
|
|
56
|
-
type: string;
|
|
57
|
-
localUrl?: string;
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### ChatInputHandles
|
|
62
|
-
|
|
63
|
-
```tsx
|
|
64
|
-
interface ChatInputHandles {
|
|
65
|
-
getPendingFiles: () => File[];
|
|
66
|
-
clearPendingFiles: () => void;
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Examples
|
|
71
|
-
|
|
72
|
-
### Basic Usage
|
|
73
|
-
|
|
74
|
-
```jsx
|
|
75
|
-
import React, { useState } from 'react';
|
|
76
|
-
import { ChatInput } from '@app-studio/web';
|
|
77
|
-
import { View } from 'app-studio';
|
|
78
|
-
|
|
79
|
-
export const BasicChatInput = () => {
|
|
80
|
-
const [inputValue, setInputValue] = useState('');
|
|
81
|
-
|
|
82
|
-
const handleSubmit = (message) => {
|
|
83
|
-
console.log('Message submitted:', message);
|
|
84
|
-
setInputValue('');
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<View width="100%">
|
|
89
|
-
<ChatInput
|
|
90
|
-
onSubmit={handleSubmit}
|
|
91
|
-
value={inputValue}
|
|
92
|
-
onChange={setInputValue}
|
|
93
|
-
placeholder="Type your message here..."
|
|
94
|
-
/>
|
|
95
|
-
</View>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### With Prompt Examples
|
|
101
|
-
|
|
102
|
-
```jsx
|
|
103
|
-
import React, { useState } from 'react';
|
|
104
|
-
import { ChatInput } from '@app-studio/web';
|
|
105
|
-
import { View } from 'app-studio';
|
|
106
|
-
|
|
107
|
-
export const ChatInputWithPromptExamples = () => {
|
|
108
|
-
const [inputValue, setInputValue] = useState('');
|
|
109
|
-
|
|
110
|
-
// Example prompt suggestions
|
|
111
|
-
const promptExamples = [
|
|
112
|
-
{ id: '1', text: 'Tell me a joke' },
|
|
113
|
-
{ id: '2', text: 'What is the weather today?' },
|
|
114
|
-
{ id: '3', text: 'How do I create a React component?' },
|
|
115
|
-
];
|
|
116
|
-
|
|
117
|
-
const handleSubmit = (message) => {
|
|
118
|
-
console.log('Message submitted:', message);
|
|
119
|
-
setInputValue('');
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<View width="100%">
|
|
124
|
-
<ChatInput
|
|
125
|
-
onSubmit={handleSubmit}
|
|
126
|
-
value={inputValue}
|
|
127
|
-
onChange={setInputValue}
|
|
128
|
-
promptExamples={promptExamples}
|
|
129
|
-
/>
|
|
130
|
-
</View>
|
|
131
|
-
);
|
|
132
|
-
};
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### With File Uploads
|
|
136
|
-
|
|
137
|
-
```jsx
|
|
138
|
-
import React, { useRef } from 'react';
|
|
139
|
-
import { ChatInput, ChatInputHandles } from '@app-studio/web';
|
|
140
|
-
import { View } from 'app-studio';
|
|
141
|
-
|
|
142
|
-
export const ChatInputWithFileUploads = () => {
|
|
143
|
-
const chatInputRef = useRef<ChatInputHandles>(null);
|
|
144
|
-
|
|
145
|
-
const handleSubmit = (message) => {
|
|
146
|
-
// Get any pending files
|
|
147
|
-
const pendingFiles = chatInputRef.current?.getPendingFiles() || [];
|
|
148
|
-
console.log('Message submitted:', message);
|
|
149
|
-
console.log('Pending files:', pendingFiles);
|
|
150
|
-
|
|
151
|
-
// Clear pending files after submission
|
|
152
|
-
chatInputRef.current?.clearPendingFiles();
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<View width="100%">
|
|
157
|
-
<ChatInput
|
|
158
|
-
ref={chatInputRef}
|
|
159
|
-
onSubmit={handleSubmit}
|
|
160
|
-
hideAttachments={false}
|
|
161
|
-
/>
|
|
162
|
-
</View>
|
|
163
|
-
);
|
|
164
|
-
};
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
## Customization
|
|
168
|
-
|
|
169
|
-
The ChatInput component can be customized using the `views` prop:
|
|
170
|
-
|
|
171
|
-
```jsx
|
|
172
|
-
<ChatInput
|
|
173
|
-
// ...other props
|
|
174
|
-
views={{
|
|
175
|
-
container: { /* styles for the main container */ },
|
|
176
|
-
content: { /* styles for the content wrapper */ },
|
|
177
|
-
editableInput: { /* styles for the editable input */ },
|
|
178
|
-
header: { /* styles for the header */ },
|
|
179
|
-
title: { /* styles for the title */ },
|
|
180
|
-
guideTip: { /* styles for the guide tip */ },
|
|
181
|
-
promptExamples: { /* styles for the prompt examples container */ },
|
|
182
|
-
promptExampleItem: { /* styles for each prompt example item */ },
|
|
183
|
-
attachments: { /* styles for the attachments container */ },
|
|
184
|
-
attachmentItem: { /* styles for each attachment item */ },
|
|
185
|
-
submitButton: { /* styles for the submit button */ },
|
|
186
|
-
fileButton: { /* styles for the file button */ },
|
|
187
|
-
}}
|
|
188
|
-
/>
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## Accessibility
|
|
192
|
-
|
|
193
|
-
The ChatInput component implements the following accessibility features:
|
|
194
|
-
|
|
195
|
-
- Keyboard navigation for submitting messages (Enter key)
|
|
196
|
-
- ARIA attributes for interactive elements
|
|
197
|
-
- Focus management for the input field
|
|
198
|
-
- Proper contrast for text and buttons
|
|
199
|
-
|
|
200
|
-
## Best Practices
|
|
201
|
-
|
|
202
|
-
- Provide clear placeholder text to guide users
|
|
203
|
-
- Handle file uploads appropriately on the server side
|
|
204
|
-
- Implement proper error handling for message submission
|
|
205
|
-
- Use the `loading` state to indicate when a message is being processed
|
|
206
|
-
- Provide feedback to users when messages are sent successfully
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
# Button
|
|
2
|
-
|
|
3
|
-
The Button component is used to trigger an action or event.
|
|
4
|
-
|
|
5
|
-
## Import
|
|
6
|
-
|
|
7
|
-
```jsx
|
|
8
|
-
import { Button } from '@app-studio/web';
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Props
|
|
12
|
-
|
|
13
|
-
| Prop | Type | Default | Description |
|
|
14
|
-
| ---- | ---- | ------- | ----------- |
|
|
15
|
-
| variant | 'filled' \| 'outline' \| 'ghost' \| 'link' | 'filled' | The visual style of the button |
|
|
16
|
-
| size | 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' | 'md' | The size of the button |
|
|
17
|
-
| shape | 'sharp' \| 'rounded' \| 'pillShaped' | 'rounded' | The shape of the button |
|
|
18
|
-
| iconPosition | 'left' \| 'right' \| 'top' \| 'bottom' | 'left' | The position of the icon relative to the button text |
|
|
19
|
-
| loaderPosition | 'left' \| 'right' | 'left' | The position of the loader relative to the button text |
|
|
20
|
-
| backgroundColor | string | - | The background color of the button |
|
|
21
|
-
| color | string | - | The color of the button text |
|
|
22
|
-
| isAuto | boolean | false | Whether the button should automatically adjust its width |
|
|
23
|
-
| isFilled | boolean | false | Whether the button should fill its container width |
|
|
24
|
-
| isDisabled | boolean | false | Whether the button is disabled |
|
|
25
|
-
| isLoading | boolean | false | Whether the button is in a loading state |
|
|
26
|
-
| isIconRounded | boolean | false | Whether the icon should have rounded corners |
|
|
27
|
-
| icon | React.ReactNode | - | The icon to display in the button |
|
|
28
|
-
| children | React.ReactNode | - | The content of the button |
|
|
29
|
-
| to | string | - | The URL to navigate to when the button is clicked (turns the button into a link) |
|
|
30
|
-
| isExternal | boolean | false | Whether the link should open in a new tab |
|
|
31
|
-
| shadow | Shadow | - | The shadow style of the button |
|
|
32
|
-
| onClick | () => void | - | The function to call when the button is clicked |
|
|
33
|
-
| views | ButtonStyles | {} | Custom styles for different parts of the button |
|
|
34
|
-
| themeMode | 'light' \| 'dark' | - | Optional theme mode override |
|
|
35
|
-
|
|
36
|
-
## Examples
|
|
37
|
-
|
|
38
|
-
### Basic Button
|
|
39
|
-
|
|
40
|
-
```jsx
|
|
41
|
-
<Button onClick={() => alert('Button clicked!')}>Click Me</Button>
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### Button Variants
|
|
45
|
-
|
|
46
|
-
```jsx
|
|
47
|
-
<>
|
|
48
|
-
<Button variant="filled">Filled</Button>
|
|
49
|
-
<Button variant="outline">Outline</Button>
|
|
50
|
-
<Button variant="ghost">Ghost</Button>
|
|
51
|
-
<Button variant="link">Link</Button>
|
|
52
|
-
</>
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Button Sizes
|
|
56
|
-
|
|
57
|
-
```jsx
|
|
58
|
-
<>
|
|
59
|
-
<Button size="xs">Extra Small</Button>
|
|
60
|
-
<Button size="sm">Small</Button>
|
|
61
|
-
<Button size="md">Medium</Button>
|
|
62
|
-
<Button size="lg">Large</Button>
|
|
63
|
-
<Button size="xl">Extra Large</Button>
|
|
64
|
-
</>
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Button with Icon
|
|
68
|
-
|
|
69
|
-
```jsx
|
|
70
|
-
import { DustBinIcon } from '@app-studio/web';
|
|
71
|
-
|
|
72
|
-
<Button icon={<DustBinIcon widthHeight={16} />}>Delete</Button>
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Button with Icon Position
|
|
76
|
-
|
|
77
|
-
```jsx
|
|
78
|
-
import { DustBinIcon } from '@app-studio/web';
|
|
79
|
-
|
|
80
|
-
<>
|
|
81
|
-
<Button icon={<DustBinIcon widthHeight={16} />} iconPosition="left">Left Icon</Button>
|
|
82
|
-
<Button icon={<DustBinIcon widthHeight={16} />} iconPosition="right">Right Icon</Button>
|
|
83
|
-
<Button icon={<DustBinIcon widthHeight={16} />} iconPosition="top">Top Icon</Button>
|
|
84
|
-
<Button icon={<DustBinIcon widthHeight={16} />} iconPosition="bottom">Bottom Icon</Button>
|
|
85
|
-
</>
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Loading Button
|
|
89
|
-
|
|
90
|
-
```jsx
|
|
91
|
-
<Button isLoading>Loading</Button>
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Disabled Button
|
|
95
|
-
|
|
96
|
-
```jsx
|
|
97
|
-
<Button isDisabled>Disabled</Button>
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### Link Button
|
|
101
|
-
|
|
102
|
-
```jsx
|
|
103
|
-
<Button to="/dashboard" variant="link">Go to Dashboard</Button>
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### External Link Button
|
|
107
|
-
|
|
108
|
-
```jsx
|
|
109
|
-
<Button to="https://example.com" isExternal variant="link">External Link</Button>
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Custom Styled Button
|
|
113
|
-
|
|
114
|
-
```jsx
|
|
115
|
-
<Button
|
|
116
|
-
views={{
|
|
117
|
-
container: {
|
|
118
|
-
backgroundColor: '#6200ee',
|
|
119
|
-
borderRadius: 8,
|
|
120
|
-
boxShadow: '0 4px 6px rgba(0, 0, 0, 0.1)',
|
|
121
|
-
},
|
|
122
|
-
}}
|
|
123
|
-
>
|
|
124
|
-
Custom Styled Button
|
|
125
|
-
</Button>
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Accessibility
|
|
129
|
-
|
|
130
|
-
The Button component:
|
|
131
|
-
|
|
132
|
-
- Uses the native `<button>` element for proper keyboard navigation and screen reader support
|
|
133
|
-
- Supports the `aria-disabled` attribute when disabled
|
|
134
|
-
- Maintains proper focus states for keyboard users
|
|
135
|
-
- Uses appropriate color contrast for text and background
|
|
136
|
-
|
|
137
|
-
## Best Practices
|
|
138
|
-
|
|
139
|
-
- Use clear, concise text that describes the action
|
|
140
|
-
- Use the appropriate variant for the context (primary actions should use 'filled')
|
|
141
|
-
- Include an icon only when it adds meaning or clarity
|
|
142
|
-
- Avoid using too many buttons in close proximity
|
|
143
|
-
- Use consistent button styles throughout your application
|
|
144
|
-
- Consider the visual hierarchy of multiple buttons (primary, secondary actions)
|
|
145
|
-
- Use the `isLoading` state for actions that take time to complete
|