@app-studio/web 0.9.31 → 0.9.32
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/docs/components/Accordion.mdx +158 -0
- package/docs/components/Alert.mdx +123 -0
- package/docs/components/AspectRatio.mdx +55 -0
- package/docs/components/Avatar.mdx +85 -0
- package/docs/components/Background.mdx +522 -0
- package/docs/components/Badge.mdx +220 -0
- package/docs/components/Button.mdx +272 -0
- package/docs/components/Calendar.mdx +274 -0
- package/docs/components/Card.mdx +341 -0
- package/docs/components/Carousel.mdx +411 -0
- package/docs/components/Center.mdx +474 -0
- package/docs/components/Chart.mdx +232 -0
- package/docs/components/ChatInput.mdx +373 -0
- package/docs/components/Checkbox.mdx +66 -0
- package/docs/components/ColorInput.mdx +209 -0
- package/docs/components/ComboBox.mdx +364 -0
- package/docs/components/Command.mdx +252 -0
- package/docs/components/ContextMenu.mdx +219 -0
- package/docs/components/CountryPicker.mdx +123 -0
- package/docs/components/DatePicker.mdx +77 -0
- package/docs/components/DragAndDrop.mdx +539 -0
- package/docs/components/DropdownMenu.mdx +205 -0
- package/docs/components/File.mdx +8 -0
- package/docs/components/Flow.mdx +257 -0
- package/docs/components/Form.mdx +681 -0
- package/docs/components/Formik.mdx +621 -0
- package/docs/components/Gradient.mdx +271 -0
- package/docs/components/Horizontal.mdx +40 -0
- package/docs/components/HoverCard.mdx +140 -0
- package/docs/components/Icon.mdx +438 -0
- package/docs/components/Label.mdx +438 -0
- package/docs/components/Link.mdx +83 -0
- package/docs/components/Loader.mdx +527 -0
- package/docs/components/Menubar.mdx +124 -0
- package/docs/components/Message.mdx +571 -0
- package/docs/components/Modal.mdx +533 -0
- package/docs/components/NavigationMenu.mdx +165 -0
- package/docs/components/Pagination.mdx +150 -0
- package/docs/components/Password.mdx +121 -0
- package/docs/components/Resizable.mdx +148 -0
- package/docs/components/Select.mdx +126 -0
- package/docs/components/Separator.mdx +121 -0
- package/docs/components/Sidebar.mdx +147 -0
- package/docs/components/Slider.mdx +232 -0
- package/docs/components/Switch.mdx +62 -0
- package/docs/components/Table.mdx +409 -0
- package/docs/components/Tabs.mdx +215 -0
- package/docs/components/TagInput.mdx +528 -0
- package/docs/components/Text.mdx +163 -0
- package/docs/components/TextArea.mdx +136 -0
- package/docs/components/TextField.mdx +225 -0
- package/docs/components/Title.mdx +535 -0
- package/docs/components/Toast.mdx +165 -0
- package/docs/components/Toggle.mdx +141 -0
- package/docs/components/ToggleGroup.mdx +165 -0
- package/docs/components/Tooltip.mdx +191 -0
- package/docs/components/Tree.mdx +340 -0
- package/docs/components/Uploader.mdx +426 -0
- package/docs/components/Vertical.mdx +566 -0
- package/package.json +1 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# Calendar
|
|
2
|
+
|
|
3
|
+
A flexible calendar component with day, week, and month views for displaying and managing events. Features intelligent navigation (day-by-day, week-by-week, month-by-month), interactive hover cards for events and days, custom event rendering, and comprehensive styling customization.
|
|
4
|
+
|
|
5
|
+
### **Import**
|
|
6
|
+
```tsx
|
|
7
|
+
import { Calendar } from '@app-studio/web';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### **Default**
|
|
11
|
+
```tsx
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { Calendar } from '../Calendar';
|
|
14
|
+
|
|
15
|
+
export const DefaultCalendar = () => {
|
|
16
|
+
return <Calendar />;
|
|
17
|
+
};
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### **With Events**
|
|
21
|
+
Display events in the calendar with customizable event objects. Hover over events to see detailed information in a popup card, and hover over day cells to see a summary of the day's events.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import React from 'react';
|
|
25
|
+
import { Calendar } from '../Calendar';
|
|
26
|
+
import { CalendarEvent } from '../Calendar/Calendar.props';
|
|
27
|
+
|
|
28
|
+
export const CalendarWithEvents = () => {
|
|
29
|
+
const events: CalendarEvent[] = [
|
|
30
|
+
{
|
|
31
|
+
id: 1,
|
|
32
|
+
title: 'Team Meeting',
|
|
33
|
+
start: new Date(2025, 9, 15, 10, 0),
|
|
34
|
+
end: new Date(2025, 9, 15, 11, 0),
|
|
35
|
+
description: 'Weekly team sync-up',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 2,
|
|
39
|
+
title: 'Project Deadline',
|
|
40
|
+
start: new Date(2025, 9, 18, 17, 0),
|
|
41
|
+
description: 'Submit final deliverables',
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
return <Calendar events={events} />;
|
|
46
|
+
};
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Interactive Features:**
|
|
50
|
+
- **Event Hover Cards**: Hover over any event to see full details including title, date, time, and description
|
|
51
|
+
- **Smart Navigation**: Navigation buttons automatically adapt to the current view (Previous/Next Day, Week, or Month)
|
|
52
|
+
- **Fixed Cell Dimensions**: All day cells maintain consistent width (minimum 180px) and height for uniform layout
|
|
53
|
+
- **Scrollable Content**: Events within each day cell scroll independently while maintaining cell dimensions
|
|
54
|
+
|
|
55
|
+
### **Day View**
|
|
56
|
+
Show a single day with all events for that day.
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import React from 'react';
|
|
60
|
+
import { Calendar } from '../Calendar';
|
|
61
|
+
|
|
62
|
+
export const DayViewCalendar = () => {
|
|
63
|
+
return <Calendar initialView="day" />;
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### **Week View**
|
|
68
|
+
Display a full week with events across all days.
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import React from 'react';
|
|
72
|
+
import { Calendar } from '../Calendar';
|
|
73
|
+
|
|
74
|
+
export const WeekViewCalendar = () => {
|
|
75
|
+
return <Calendar initialView="week" />;
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### **Month View**
|
|
80
|
+
Show the entire month with events distributed across days.
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import React from 'react';
|
|
84
|
+
import { Calendar } from '../Calendar';
|
|
85
|
+
|
|
86
|
+
export const MonthViewCalendar = () => {
|
|
87
|
+
return <Calendar initialView="month" />;
|
|
88
|
+
};
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### **Custom Event Rendering**
|
|
92
|
+
Customize how events are displayed using the `renderEvent` prop.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import React from 'react';
|
|
96
|
+
import { Vertical, Horizontal } from 'app-studio';
|
|
97
|
+
import { Calendar } from '../Calendar';
|
|
98
|
+
import { CalendarEvent, CalendarRenderEventContext } from '../Calendar/Calendar.props';
|
|
99
|
+
import { Text } from '../../Text/Text';
|
|
100
|
+
|
|
101
|
+
export const CustomRenderCalendar = () => {
|
|
102
|
+
const events: CalendarEvent[] = [
|
|
103
|
+
{
|
|
104
|
+
id: 1,
|
|
105
|
+
title: 'High Priority Meeting',
|
|
106
|
+
start: new Date(2025, 9, 15, 10, 0),
|
|
107
|
+
metadata: { priority: 'high' },
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
const renderEvent = (event: CalendarEvent, context: CalendarRenderEventContext) => {
|
|
112
|
+
const priority = event.metadata?.priority as string;
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<Vertical
|
|
116
|
+
gap={8}
|
|
117
|
+
padding={12}
|
|
118
|
+
borderRadius={12}
|
|
119
|
+
backgroundColor="color.error.50"
|
|
120
|
+
borderWidth={1}
|
|
121
|
+
borderStyle="solid"
|
|
122
|
+
borderColor="color.error.200"
|
|
123
|
+
>
|
|
124
|
+
<Text fontWeight="600">{event.title}</Text>
|
|
125
|
+
<Text fontSize={12} color="color.error.600">{priority}</Text>
|
|
126
|
+
</Vertical>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
return <Calendar events={events} renderEvent={renderEvent} />;
|
|
131
|
+
};
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### **Week Starts On**
|
|
135
|
+
Configure which day the week starts on (0 = Sunday, 1 = Monday, etc.).
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import React from 'react';
|
|
139
|
+
import { Calendar } from '../Calendar';
|
|
140
|
+
|
|
141
|
+
export const WeekStartsOnMonday = () => {
|
|
142
|
+
return <Calendar weekStartsOn={1} />;
|
|
143
|
+
};
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### **Custom Styles**
|
|
147
|
+
Customize the appearance of calendar elements using the `views` prop.
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
import React from 'react';
|
|
151
|
+
import { Calendar } from '../Calendar';
|
|
152
|
+
|
|
153
|
+
export const CustomStyledCalendar = () => {
|
|
154
|
+
return (
|
|
155
|
+
<Calendar
|
|
156
|
+
views={{
|
|
157
|
+
container: {
|
|
158
|
+
backgroundColor: 'color.primary.50',
|
|
159
|
+
borderColor: 'color.primary.300',
|
|
160
|
+
},
|
|
161
|
+
headerTitle: {
|
|
162
|
+
color: 'color.primary.700',
|
|
163
|
+
fontSize: 24,
|
|
164
|
+
},
|
|
165
|
+
event: {
|
|
166
|
+
backgroundColor: 'color.primary.100',
|
|
167
|
+
borderColor: 'color.primary.400',
|
|
168
|
+
},
|
|
169
|
+
}}
|
|
170
|
+
/>
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### **Fixed Height with Scrolling**
|
|
176
|
+
Set a fixed height for the calendar with scrollable content areas.
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
import React from 'react';
|
|
180
|
+
import { Calendar } from '../Calendar';
|
|
181
|
+
|
|
182
|
+
export const FixedHeightCalendar = () => {
|
|
183
|
+
const events = [
|
|
184
|
+
{
|
|
185
|
+
id: 1,
|
|
186
|
+
title: 'Team Meeting',
|
|
187
|
+
start: new Date(2025, 9, 15, 10, 0),
|
|
188
|
+
end: new Date(2025, 9, 15, 11, 0),
|
|
189
|
+
},
|
|
190
|
+
// ... more events
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
return <Calendar events={events} height="600px" initialView="week" />;
|
|
194
|
+
};
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Props
|
|
198
|
+
|
|
199
|
+
| Prop | Type | Description | Default |
|
|
200
|
+
| -------------- | ----------------------- | -------------------------------------------------------------- | ----------- |
|
|
201
|
+
| events | CalendarEvent[] | Array of events to display in the calendar. | [] |
|
|
202
|
+
| initialDate | Date \| string | Starting date displayed in the calendar. | new Date() |
|
|
203
|
+
| initialView | 'day' \| 'week' \| 'month' | Initial visible view. | 'month' |
|
|
204
|
+
| weekStartsOn | 0-6 | First day of the week (0 = Sunday, 1 = Monday, etc.). | 0 |
|
|
205
|
+
| height | string \| number | Height of the calendar container (enables scrolling). | '800px' |
|
|
206
|
+
| renderEvent | function | Custom render method for events. | - |
|
|
207
|
+
| onDateChange | function | Callback when the visible anchor date changes. | - |
|
|
208
|
+
| onViewChange | function | Callback when the active view changes. | - |
|
|
209
|
+
| views | CalendarViews | Customize styling of calendar areas. | - |
|
|
210
|
+
|
|
211
|
+
## CalendarEvent Interface
|
|
212
|
+
|
|
213
|
+
| Property | Type | Description |
|
|
214
|
+
| ----------- | --------------------- | ------------------------------------------------ |
|
|
215
|
+
| id | string \| number | Unique identifier for the event. |
|
|
216
|
+
| title | string | Event title shown in the calendar cell. |
|
|
217
|
+
| start | Date \| string | Start date/time of the event. |
|
|
218
|
+
| end | Date \| string | Optional end date/time of the event. |
|
|
219
|
+
| description | string | Optional description or supporting information. |
|
|
220
|
+
| metadata | Record<string, unknown> | Additional metadata for the event. |
|
|
221
|
+
|
|
222
|
+
## CalendarViews Interface
|
|
223
|
+
|
|
224
|
+
Customize the appearance of different calendar elements. All elements support the `views` prop for complete customization:
|
|
225
|
+
|
|
226
|
+
### Container & Layout
|
|
227
|
+
- `container` - Main calendar container (ViewProps)
|
|
228
|
+
- `header` - Header section (ViewProps)
|
|
229
|
+
- `grid` - Calendar grid container (ViewProps)
|
|
230
|
+
|
|
231
|
+
### Header Elements
|
|
232
|
+
- `headerTitle` - Title text in header (TextProps)
|
|
233
|
+
- `navigation` - Navigation buttons container (ViewProps)
|
|
234
|
+
- `navigationButton` - Navigation button props (ButtonProps)
|
|
235
|
+
- `viewSwitcher` - View switcher buttons container (ViewProps)
|
|
236
|
+
- `viewButton` - View button props (ButtonProps)
|
|
237
|
+
|
|
238
|
+
### Weekday Header
|
|
239
|
+
- `weekdayRow` - Weekday row container (ViewProps)
|
|
240
|
+
- `weekdayHeader` - Individual weekday header cell (ViewProps)
|
|
241
|
+
- `weekdayLabel` - Weekday label text (TextProps)
|
|
242
|
+
|
|
243
|
+
### Week & Day Structure
|
|
244
|
+
- `weekRow` - Week row container (ViewProps)
|
|
245
|
+
- `dayColumn` - Individual day column/cell (ViewProps)
|
|
246
|
+
- `dayHeader` - Day header within cell (ViewProps)
|
|
247
|
+
- `dayNumber` - Day number text (TextProps)
|
|
248
|
+
- `dayMeta` - Day metadata text (TextProps)
|
|
249
|
+
|
|
250
|
+
### Events
|
|
251
|
+
- `events` - Events container within day (ViewProps)
|
|
252
|
+
- `event` - Individual event container (ViewProps)
|
|
253
|
+
- `eventTitle` - Event title text (TextProps)
|
|
254
|
+
- `eventTime` - Event time text (TextProps)
|
|
255
|
+
- `emptyState` - Empty state text when no events (TextProps)
|
|
256
|
+
|
|
257
|
+
### Example: Complete Customization
|
|
258
|
+
|
|
259
|
+
```tsx
|
|
260
|
+
<Calendar
|
|
261
|
+
events={events}
|
|
262
|
+
views={{
|
|
263
|
+
container: { backgroundColor: 'color.gray.50', padding: 32 },
|
|
264
|
+
headerTitle: { fontSize: 24, color: 'color.primary.700' },
|
|
265
|
+
weekdayRow: { backgroundColor: 'color.primary.50', borderRadius: 8 },
|
|
266
|
+
weekdayLabel: { fontSize: 16, fontWeight: '700' },
|
|
267
|
+
dayColumn: { padding: 20, borderRadius: 16, borderWidth: 2 },
|
|
268
|
+
dayNumber: { fontSize: 20, color: 'color.primary.700' },
|
|
269
|
+
event: { padding: 16, backgroundColor: 'color.primary.100' },
|
|
270
|
+
eventTitle: { fontSize: 16, fontWeight: '700' },
|
|
271
|
+
}}
|
|
272
|
+
/>
|
|
273
|
+
```
|
|
274
|
+
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# Card
|
|
2
|
+
|
|
3
|
+
A flexible container component for organizing and displaying content.
|
|
4
|
+
|
|
5
|
+
### **Import**
|
|
6
|
+
```tsx
|
|
7
|
+
import { Card } from '@app-studio/web';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### **Default**
|
|
11
|
+
```tsx
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { Card } from '../Card';
|
|
14
|
+
import { Text } from '../../Text/Text';
|
|
15
|
+
|
|
16
|
+
export const DefaultDemo = () => {
|
|
17
|
+
return (
|
|
18
|
+
<Card>
|
|
19
|
+
<Text>This is a default card with simple content.</Text>
|
|
20
|
+
</Card>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### **Variants**
|
|
26
|
+
Different visual styles for the card.
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import React from 'react';
|
|
30
|
+
import { Card } from '../Card';
|
|
31
|
+
import { Text } from '../../Text/Text';
|
|
32
|
+
import { Vertical } from 'app-studio';
|
|
33
|
+
|
|
34
|
+
export const VariantsDemo = () => {
|
|
35
|
+
return (
|
|
36
|
+
<Vertical gap={20}>
|
|
37
|
+
<Card variant="default">
|
|
38
|
+
<Text>Default Card</Text>
|
|
39
|
+
<Text color="color.gray.500">
|
|
40
|
+
This is a card with the default variant.
|
|
41
|
+
</Text>
|
|
42
|
+
</Card>
|
|
43
|
+
|
|
44
|
+
<Card variant="outlined">
|
|
45
|
+
<Text>Outlined Card</Text>
|
|
46
|
+
<Text color="color.gray.500">
|
|
47
|
+
This card has a border around it.
|
|
48
|
+
</Text>
|
|
49
|
+
</Card>
|
|
50
|
+
|
|
51
|
+
<Card variant="elevated">
|
|
52
|
+
<Text>Elevated Card</Text>
|
|
53
|
+
<Text color="color.gray.500">
|
|
54
|
+
This card has a shadow to give it an elevated appearance.
|
|
55
|
+
</Text>
|
|
56
|
+
</Card>
|
|
57
|
+
</Vertical>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### **Structured Layout**
|
|
63
|
+
Using Card.Header, Card.Content, and Card.Footer for structured layout.
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import React from 'react';
|
|
67
|
+
import { Card } from '../Card';
|
|
68
|
+
import { Text } from '../../Text/Text';
|
|
69
|
+
import { Horizontal } from 'app-studio';
|
|
70
|
+
import { Button } from '../../Button/Button';
|
|
71
|
+
|
|
72
|
+
export const StructuredDemo = () => {
|
|
73
|
+
return (
|
|
74
|
+
<Card>
|
|
75
|
+
<Card.Header>
|
|
76
|
+
<Text fontWeight="bold" fontSize={18}>Card Title</Text>
|
|
77
|
+
</Card.Header>
|
|
78
|
+
|
|
79
|
+
<Card.Content>
|
|
80
|
+
<Text>
|
|
81
|
+
This card uses the structured layout with separate header, content, and footer sections.
|
|
82
|
+
The content area is where the main information goes.
|
|
83
|
+
</Text>
|
|
84
|
+
</Card.Content>
|
|
85
|
+
|
|
86
|
+
<Card.Footer>
|
|
87
|
+
<Horizontal justifyContent="flex-end" gap={10}>
|
|
88
|
+
<Button variant="outline">Cancel</Button>
|
|
89
|
+
<Button>Submit</Button>
|
|
90
|
+
</Horizontal>
|
|
91
|
+
</Card.Footer>
|
|
92
|
+
</Card>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### **Shapes**
|
|
98
|
+
Different corner styles for the card.
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import React from 'react';
|
|
102
|
+
import { Card } from '../Card';
|
|
103
|
+
import { Text } from '../../Text/Text';
|
|
104
|
+
import { Vertical } from 'app-studio';
|
|
105
|
+
import { Shape } from '../Card/Card.type';
|
|
106
|
+
|
|
107
|
+
export const ShapesDemo = () => {
|
|
108
|
+
const shapes: Shape[] = ['sharp', 'rounded', 'pillShaped'];
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<Vertical gap={20}>
|
|
112
|
+
{shapes.map((shape) => (
|
|
113
|
+
<Card key={shape} shape={shape} variant="outlined">
|
|
114
|
+
<Text fontWeight="bold">{shape} Card</Text>
|
|
115
|
+
<Text color="color.gray.500">
|
|
116
|
+
This card has {shape === 'sharp' ? 'no' : shape} corners.
|
|
117
|
+
</Text>
|
|
118
|
+
</Card>
|
|
119
|
+
))}
|
|
120
|
+
</Vertical>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### **Sizes**
|
|
126
|
+
Different padding sizes for the card.
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import React from 'react';
|
|
130
|
+
import { Card } from '../Card';
|
|
131
|
+
import { Text } from '../../Text/Text';
|
|
132
|
+
import { Vertical } from 'app-studio';
|
|
133
|
+
import { Size } from '../Card/Card.type';
|
|
134
|
+
|
|
135
|
+
export const SizesDemo = () => {
|
|
136
|
+
const sizes: Size[] = ['sm', 'md', 'lg'];
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<Vertical gap={20}>
|
|
140
|
+
{sizes.map((size) => (
|
|
141
|
+
<Card key={size} size={size} variant="outlined">
|
|
142
|
+
<Text fontWeight="bold">{size.toUpperCase()} Size</Text>
|
|
143
|
+
<Text color="color.gray.500">
|
|
144
|
+
This card has {size} padding.
|
|
145
|
+
</Text>
|
|
146
|
+
</Card>
|
|
147
|
+
))}
|
|
148
|
+
</Vertical>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### **Custom Styling**
|
|
154
|
+
Customize the appearance of the card.
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
import React from 'react';
|
|
158
|
+
import { Card } from '../Card';
|
|
159
|
+
import { Text } from '../../Text/Text';
|
|
160
|
+
import { Horizontal } from 'app-studio';
|
|
161
|
+
import { Button } from '../../Button/Button';
|
|
162
|
+
|
|
163
|
+
export const CustomDemo = () => {
|
|
164
|
+
return (
|
|
165
|
+
<Card
|
|
166
|
+
views={{
|
|
167
|
+
container: {
|
|
168
|
+
backgroundColor: 'color.blue.50',
|
|
169
|
+
borderRadius: '16px',
|
|
170
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.1)',
|
|
171
|
+
},
|
|
172
|
+
header: {
|
|
173
|
+
backgroundColor: 'color.blue.500',
|
|
174
|
+
color: 'color.white',
|
|
175
|
+
padding: '16px',
|
|
176
|
+
borderBottomWidth: '0',
|
|
177
|
+
},
|
|
178
|
+
content: {
|
|
179
|
+
padding: '24px',
|
|
180
|
+
},
|
|
181
|
+
footer: {
|
|
182
|
+
padding: '16px',
|
|
183
|
+
backgroundColor: 'color.gray.50',
|
|
184
|
+
borderTopWidth: '0',
|
|
185
|
+
},
|
|
186
|
+
}}
|
|
187
|
+
>
|
|
188
|
+
<Card.Header>
|
|
189
|
+
<Text fontWeight="bold" fontSize={18} color="white">
|
|
190
|
+
Custom Styled Card
|
|
191
|
+
</Text>
|
|
192
|
+
</Card.Header>
|
|
193
|
+
|
|
194
|
+
<Card.Content>
|
|
195
|
+
<Text>
|
|
196
|
+
This card has custom styling applied to all its parts.
|
|
197
|
+
You can customize the container, header, content, and footer.
|
|
198
|
+
</Text>
|
|
199
|
+
</Card.Content>
|
|
200
|
+
|
|
201
|
+
<Card.Footer>
|
|
202
|
+
<Horizontal justifyContent="flex-end" gap={10}>
|
|
203
|
+
<Button variant="outline">Cancel</Button>
|
|
204
|
+
<Button>Submit</Button>
|
|
205
|
+
</Horizontal>
|
|
206
|
+
</Card.Footer>
|
|
207
|
+
</Card>
|
|
208
|
+
);
|
|
209
|
+
};
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### **Context-Based Styling**
|
|
213
|
+
The Card component uses a context-based styling system that allows styles to be passed down from the parent Card to its child components (Header, Content, Footer).
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
import React from 'react';
|
|
217
|
+
import { Card } from '../Card';
|
|
218
|
+
import { Text } from '../../Text/Text';
|
|
219
|
+
import { Button } from '../../Button/Button';
|
|
220
|
+
import { Horizontal } from 'app-studio';
|
|
221
|
+
|
|
222
|
+
export const ContextStylingDemo = () => {
|
|
223
|
+
return (
|
|
224
|
+
<Card
|
|
225
|
+
views={{
|
|
226
|
+
// These styles will be passed down to all child components via context
|
|
227
|
+
container: {
|
|
228
|
+
backgroundColor: 'color.blue.50',
|
|
229
|
+
borderRadius: '12px',
|
|
230
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.1)',
|
|
231
|
+
},
|
|
232
|
+
header: {
|
|
233
|
+
backgroundColor: 'color.blue.100',
|
|
234
|
+
padding: '16px',
|
|
235
|
+
borderBottomColor: 'color.blue.200',
|
|
236
|
+
},
|
|
237
|
+
content: {
|
|
238
|
+
padding: '24px',
|
|
239
|
+
},
|
|
240
|
+
footer: {
|
|
241
|
+
backgroundColor: 'color.blue.100',
|
|
242
|
+
padding: '16px',
|
|
243
|
+
borderTopColor: 'color.blue.200',
|
|
244
|
+
},
|
|
245
|
+
}}
|
|
246
|
+
>
|
|
247
|
+
<Card.Header>
|
|
248
|
+
<Text fontWeight="bold" fontSize={18}>
|
|
249
|
+
Context-Based Styling
|
|
250
|
+
</Text>
|
|
251
|
+
</Card.Header>
|
|
252
|
+
|
|
253
|
+
<Card.Content>
|
|
254
|
+
<Text>
|
|
255
|
+
This card demonstrates the improved context-based styling system.
|
|
256
|
+
The styles defined in the Card's "views" prop are automatically
|
|
257
|
+
passed down to the Header, Content, and Footer components.
|
|
258
|
+
</Text>
|
|
259
|
+
</Card.Content>
|
|
260
|
+
|
|
261
|
+
<Card.Footer>
|
|
262
|
+
<Horizontal justifyContent="flex-end" gap={10}>
|
|
263
|
+
<Button variant="outline">Cancel</Button>
|
|
264
|
+
<Button>Submit</Button>
|
|
265
|
+
</Horizontal>
|
|
266
|
+
</Card.Footer>
|
|
267
|
+
</Card>
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### **Theme Mode Support**
|
|
273
|
+
The Card component supports both light and dark themes through the `themeMode` prop.
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
import React from 'react';
|
|
277
|
+
import { Card } from '../Card';
|
|
278
|
+
import { Text } from '../../Text/Text';
|
|
279
|
+
import { Horizontal, Vertical } from 'app-studio';
|
|
280
|
+
import { Button } from '../../Button/Button';
|
|
281
|
+
|
|
282
|
+
export const DarkModeExample = () => {
|
|
283
|
+
return (
|
|
284
|
+
<Vertical gap={20}>
|
|
285
|
+
<Text fontSize={20} fontWeight="bold">Light Mode Cards</Text>
|
|
286
|
+
<Horizontal gap={20} alignItems="flex-start">
|
|
287
|
+
<Card variant="default" themeMode="light">
|
|
288
|
+
<Card.Header>
|
|
289
|
+
<Text fontWeight="bold">Default Card (Light)</Text>
|
|
290
|
+
</Card.Header>
|
|
291
|
+
<Card.Content>
|
|
292
|
+
<Text>This card uses light mode styling.</Text>
|
|
293
|
+
</Card.Content>
|
|
294
|
+
<Card.Footer>
|
|
295
|
+
<Button size="sm">Action</Button>
|
|
296
|
+
</Card.Footer>
|
|
297
|
+
</Card>
|
|
298
|
+
|
|
299
|
+
<Card variant="outlined" themeMode="light">
|
|
300
|
+
<Card.Header>
|
|
301
|
+
<Text fontWeight="bold">Outlined Card (Light)</Text>
|
|
302
|
+
</Card.Header>
|
|
303
|
+
<Card.Content>
|
|
304
|
+
<Text>This card uses light mode styling with an outline.</Text>
|
|
305
|
+
</Card.Content>
|
|
306
|
+
<Card.Footer>
|
|
307
|
+
<Button size="sm">Action</Button>
|
|
308
|
+
</Card.Footer>
|
|
309
|
+
</Card>
|
|
310
|
+
</Horizontal>
|
|
311
|
+
|
|
312
|
+
<Text fontSize={20} fontWeight="bold" marginTop={40}>Dark Mode Cards</Text>
|
|
313
|
+
<Horizontal gap={20} alignItems="flex-start">
|
|
314
|
+
<Card variant="default" themeMode="dark">
|
|
315
|
+
<Card.Header>
|
|
316
|
+
<Text fontWeight="bold">Default Card (Dark)</Text>
|
|
317
|
+
</Card.Header>
|
|
318
|
+
<Card.Content>
|
|
319
|
+
<Text>This card uses dark mode styling.</Text>
|
|
320
|
+
</Card.Content>
|
|
321
|
+
<Card.Footer>
|
|
322
|
+
<Button size="sm">Action</Button>
|
|
323
|
+
</Card.Footer>
|
|
324
|
+
</Card>
|
|
325
|
+
|
|
326
|
+
<Card variant="outlined" themeMode="dark">
|
|
327
|
+
<Card.Header>
|
|
328
|
+
<Text fontWeight="bold">Outlined Card (Dark)</Text>
|
|
329
|
+
</Card.Header>
|
|
330
|
+
<Card.Content>
|
|
331
|
+
<Text>This card uses dark mode styling with an outline.</Text>
|
|
332
|
+
</Card.Content>
|
|
333
|
+
<Card.Footer>
|
|
334
|
+
<Button size="sm">Action</Button>
|
|
335
|
+
</Card.Footer>
|
|
336
|
+
</Card>
|
|
337
|
+
</Horizontal>
|
|
338
|
+
</Vertical>
|
|
339
|
+
);
|
|
340
|
+
};
|
|
341
|
+
```
|