@campxdev/react-native-blueprint 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +358 -0
- package/lib/module/app/_layout.js +23 -0
- package/lib/module/app/_layout.js.map +1 -0
- package/lib/module/assets/icons/weather_icons/drizzle.png +0 -0
- package/lib/module/assets/icons/weather_icons/foggy.png +0 -0
- package/lib/module/assets/icons/weather_icons/freezing_rain.png +0 -0
- package/lib/module/assets/icons/weather_icons/partly_cloudy.png +0 -0
- package/lib/module/assets/icons/weather_icons/rainy.png +0 -0
- package/lib/module/assets/icons/weather_icons/showers.png +0 -0
- package/lib/module/assets/icons/weather_icons/sunny_weather.png +0 -0
- package/lib/module/assets/icons/weather_icons/thunderstorm.png +0 -0
- package/lib/module/assets/icons/weather_icons/thunderstorm_hail.png +0 -0
- package/lib/module/components/theme-config.js +265 -0
- package/lib/module/components/theme-config.js.map +1 -0
- package/lib/module/components/ui/Accordion.js +228 -0
- package/lib/module/components/ui/Accordion.js.map +1 -0
- package/lib/module/components/ui/Alert-Dialog.js +266 -0
- package/lib/module/components/ui/Alert-Dialog.js.map +1 -0
- package/lib/module/components/ui/Alert.js +107 -0
- package/lib/module/components/ui/Alert.js.map +1 -0
- package/lib/module/components/ui/AppBar.js +403 -0
- package/lib/module/components/ui/AppBar.js.map +1 -0
- package/lib/module/components/ui/Aspect-Ratio.js +27 -0
- package/lib/module/components/ui/Aspect-Ratio.js.map +1 -0
- package/lib/module/components/ui/Avatar.js +97 -0
- package/lib/module/components/ui/Avatar.js.map +1 -0
- package/lib/module/components/ui/Badge.js +127 -0
- package/lib/module/components/ui/Badge.js.map +1 -0
- package/lib/module/components/ui/Bottom-Sheet.js +144 -0
- package/lib/module/components/ui/Bottom-Sheet.js.map +1 -0
- package/lib/module/components/ui/Button.js +88 -0
- package/lib/module/components/ui/Button.js.map +1 -0
- package/lib/module/components/ui/Card.js +176 -0
- package/lib/module/components/ui/Card.js.map +1 -0
- package/lib/module/components/ui/Checkbox.js +65 -0
- package/lib/module/components/ui/Checkbox.js.map +1 -0
- package/lib/module/components/ui/Collapsible.js +42 -0
- package/lib/module/components/ui/Collapsible.js.map +1 -0
- package/lib/module/components/ui/Context-Menu.js +287 -0
- package/lib/module/components/ui/Context-Menu.js.map +1 -0
- package/lib/module/components/ui/Custom-Card.js +202 -0
- package/lib/module/components/ui/Custom-Card.js.map +1 -0
- package/lib/module/components/ui/Dialog.js +202 -0
- package/lib/module/components/ui/Dialog.js.map +1 -0
- package/lib/module/components/ui/Dropdown-Menu.js +421 -0
- package/lib/module/components/ui/Dropdown-Menu.js.map +1 -0
- package/lib/module/components/ui/Floating-Action.js +50 -0
- package/lib/module/components/ui/Floating-Action.js.map +1 -0
- package/lib/module/components/ui/Greeting-Card.js +392 -0
- package/lib/module/components/ui/Greeting-Card.js.map +1 -0
- package/lib/module/components/ui/Hover-Card.js +96 -0
- package/lib/module/components/ui/Hover-Card.js.map +1 -0
- package/lib/module/components/ui/Icon.js +73 -0
- package/lib/module/components/ui/Icon.js.map +1 -0
- package/lib/module/components/ui/Input.js +74 -0
- package/lib/module/components/ui/Input.js.map +1 -0
- package/lib/module/components/ui/Label.js +44 -0
- package/lib/module/components/ui/Label.js.map +1 -0
- package/lib/module/components/ui/Menubar.js +375 -0
- package/lib/module/components/ui/Menubar.js.map +1 -0
- package/lib/module/components/ui/Native-Only-Animated-View.js +41 -0
- package/lib/module/components/ui/Native-Only-Animated-View.js.map +1 -0
- package/lib/module/components/ui/NavBar.js +352 -0
- package/lib/module/components/ui/NavBar.js.map +1 -0
- package/lib/module/components/ui/Popover.js +101 -0
- package/lib/module/components/ui/Popover.js.map +1 -0
- package/lib/module/components/ui/Progress.js +124 -0
- package/lib/module/components/ui/Progress.js.map +1 -0
- package/lib/module/components/ui/Radio-Group.js +75 -0
- package/lib/module/components/ui/Radio-Group.js.map +1 -0
- package/lib/module/components/ui/Select.js +269 -0
- package/lib/module/components/ui/Select.js.map +1 -0
- package/lib/module/components/ui/Separator.js +58 -0
- package/lib/module/components/ui/Separator.js.map +1 -0
- package/lib/module/components/ui/SizedBox.js +101 -0
- package/lib/module/components/ui/SizedBox.js.map +1 -0
- package/lib/module/components/ui/Skeleton.js +57 -0
- package/lib/module/components/ui/Skeleton.js.map +1 -0
- package/lib/module/components/ui/Slider.js +169 -0
- package/lib/module/components/ui/Slider.js.map +1 -0
- package/lib/module/components/ui/Switch.js +55 -0
- package/lib/module/components/ui/Switch.js.map +1 -0
- package/lib/module/components/ui/Table.js +150 -0
- package/lib/module/components/ui/Table.js.map +1 -0
- package/lib/module/components/ui/Tabs.js +106 -0
- package/lib/module/components/ui/Tabs.js.map +1 -0
- package/lib/module/components/ui/Text.js +69 -0
- package/lib/module/components/ui/Text.js.map +1 -0
- package/lib/module/components/ui/Textarea.js +88 -0
- package/lib/module/components/ui/Textarea.js.map +1 -0
- package/lib/module/components/ui/Theme-Toggle.js +156 -0
- package/lib/module/components/ui/Theme-Toggle.js.map +1 -0
- package/lib/module/components/ui/Toast.js +101 -0
- package/lib/module/components/ui/Toast.js.map +1 -0
- package/lib/module/components/ui/Toggle-Group.js +129 -0
- package/lib/module/components/ui/Toggle-Group.js.map +1 -0
- package/lib/module/components/ui/Toggle.js +106 -0
- package/lib/module/components/ui/Toggle.js.map +1 -0
- package/lib/module/components/ui/Tooltip.js +106 -0
- package/lib/module/components/ui/Tooltip.js.map +1 -0
- package/lib/module/components/ui/index.js +45 -0
- package/lib/module/components/ui/index.js.map +1 -0
- package/lib/module/index.js +19 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/lib/ThemeProvider.js +173 -0
- package/lib/module/lib/ThemeProvider.js.map +1 -0
- package/lib/module/lib/cornerRadius.js +164 -0
- package/lib/module/lib/cornerRadius.js.map +1 -0
- package/lib/module/lib/fonts.js +25 -0
- package/lib/module/lib/fonts.js.map +1 -0
- package/lib/module/lib/theme.js +212 -0
- package/lib/module/lib/theme.js.map +1 -0
- package/lib/module/lib/utils.js +137 -0
- package/lib/module/lib/utils.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/package.json +208 -0
- package/src/app/_layout.tsx +25 -0
- package/src/assets/icons/weather_icons/drizzle.png +0 -0
- package/src/assets/icons/weather_icons/foggy.png +0 -0
- package/src/assets/icons/weather_icons/freezing_rain.png +0 -0
- package/src/assets/icons/weather_icons/partly_cloudy.png +0 -0
- package/src/assets/icons/weather_icons/rainy.png +0 -0
- package/src/assets/icons/weather_icons/showers.png +0 -0
- package/src/assets/icons/weather_icons/sunny_weather.png +0 -0
- package/src/assets/icons/weather_icons/thunderstorm.png +0 -0
- package/src/assets/icons/weather_icons/thunderstorm_hail.png +0 -0
- package/src/components/theme-config.ts +331 -0
- package/src/components/ui/Accordion.tsx +253 -0
- package/src/components/ui/Alert-Dialog.tsx +295 -0
- package/src/components/ui/Alert.tsx +137 -0
- package/src/components/ui/AppBar.tsx +551 -0
- package/src/components/ui/Aspect-Ratio.tsx +25 -0
- package/src/components/ui/Avatar.tsx +103 -0
- package/src/components/ui/Badge.tsx +121 -0
- package/src/components/ui/Bottom-Sheet.tsx +224 -0
- package/src/components/ui/Button.tsx +100 -0
- package/src/components/ui/Card.tsx +185 -0
- package/src/components/ui/Checkbox.tsx +81 -0
- package/src/components/ui/Collapsible.tsx +40 -0
- package/src/components/ui/Context-Menu.tsx +407 -0
- package/src/components/ui/Custom-Card.tsx +226 -0
- package/src/components/ui/Dialog.tsx +240 -0
- package/src/components/ui/Dropdown-Menu.tsx +544 -0
- package/src/components/ui/Floating-Action.tsx +54 -0
- package/src/components/ui/Greeting-Card.tsx +471 -0
- package/src/components/ui/Hover-Card.tsx +101 -0
- package/src/components/ui/Icon.tsx +75 -0
- package/src/components/ui/Input.tsx +90 -0
- package/src/components/ui/Label.tsx +48 -0
- package/src/components/ui/Menubar.tsx +509 -0
- package/src/components/ui/Native-Only-Animated-View.tsx +37 -0
- package/src/components/ui/NavBar.tsx +397 -0
- package/src/components/ui/Popover.tsx +110 -0
- package/src/components/ui/Progress.tsx +138 -0
- package/src/components/ui/Radio-Group.tsx +79 -0
- package/src/components/ui/Select.tsx +344 -0
- package/src/components/ui/Separator.tsx +68 -0
- package/src/components/ui/SizedBox.tsx +116 -0
- package/src/components/ui/Skeleton.tsx +55 -0
- package/src/components/ui/Slider.tsx +222 -0
- package/src/components/ui/Switch.tsx +67 -0
- package/src/components/ui/Table.tsx +170 -0
- package/src/components/ui/Tabs.tsx +119 -0
- package/src/components/ui/Text.tsx +73 -0
- package/src/components/ui/Textarea.tsx +93 -0
- package/src/components/ui/Theme-Toggle.tsx +204 -0
- package/src/components/ui/Toast.tsx +127 -0
- package/src/components/ui/Toggle-Group.tsx +160 -0
- package/src/components/ui/Toggle.tsx +122 -0
- package/src/components/ui/Tooltip.tsx +117 -0
- package/src/components/ui/index.ts +42 -0
- package/src/index.tsx +24 -0
- package/src/lib/ThemeProvider.tsx +204 -0
- package/src/lib/cornerRadius.ts +160 -0
- package/src/lib/fonts.ts +28 -0
- package/src/lib/theme.ts +151 -0
- package/src/lib/utils.ts +146 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { FloatingAction as RNFloatingAction } from 'react-native-floating-action';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
/**
|
|
7
|
+
* FloatingAction Component
|
|
8
|
+
*
|
|
9
|
+
* A customizable floating action button (FAB) component with support for multiple actions.
|
|
10
|
+
* Based on react-native-floating-action with additional styling capabilities.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { FloatingAction } from 'react-native-blueprint';
|
|
15
|
+
*
|
|
16
|
+
* const actions = [
|
|
17
|
+
* {
|
|
18
|
+
* text: 'Add',
|
|
19
|
+
* icon: require('./add-icon.png'),
|
|
20
|
+
* name: 'bt_add',
|
|
21
|
+
* position: 1
|
|
22
|
+
* },
|
|
23
|
+
* {
|
|
24
|
+
* text: 'Delete',
|
|
25
|
+
* icon: require('./delete-icon.png'),
|
|
26
|
+
* name: 'bt_delete',
|
|
27
|
+
* position: 2
|
|
28
|
+
* }
|
|
29
|
+
* ];
|
|
30
|
+
*
|
|
31
|
+
* <FloatingAction
|
|
32
|
+
* actions={actions}
|
|
33
|
+
* onPressItem={(name) => {
|
|
34
|
+
* console.log(`Selected button: ${name}`);
|
|
35
|
+
* }}
|
|
36
|
+
* />
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export const FloatingAction = /*#__PURE__*/React.forwardRef(({
|
|
40
|
+
className: _className,
|
|
41
|
+
...props
|
|
42
|
+
}, ref) => {
|
|
43
|
+
return /*#__PURE__*/_jsx(RNFloatingAction, {
|
|
44
|
+
ref: ref,
|
|
45
|
+
...props
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
FloatingAction.displayName = 'FloatingAction';
|
|
49
|
+
export default FloatingAction;
|
|
50
|
+
//# sourceMappingURL=Floating-Action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","FloatingAction","RNFloatingAction","jsx","_jsx","forwardRef","className","_className","props","ref","displayName"],"sourceRoot":"../../../../src","sources":["components/ui/Floating-Action.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,cAAc,IAAIC,gBAAgB,QAAQ,8BAA8B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AASlF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMH,cAA6C,gBAAGD,KAAK,CAACK,UAAU,CAG3E,CAAC;EAAEC,SAAS,EAAEC,UAAU;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EAC9C,oBAAOL,IAAA,CAACF,gBAAgB;IAACO,GAAG,EAAEA,GAAI;IAAA,GAAKD;EAAK,CAAG,CAAC;AAClD,CAAC,CAAC;AAEFP,cAAc,CAACS,WAAW,GAAG,gBAAgB;AAE7C,eAAeT,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Image, Pressable, StyleSheet, View, useColorScheme } from 'react-native';
|
|
5
|
+
import { cssInterop } from 'nativewind';
|
|
6
|
+
import { cn } from "../../lib/utils.js";
|
|
7
|
+
import { CustomCard } from "./Custom-Card.js";
|
|
8
|
+
import { Text } from "./Text.js";
|
|
9
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
|
+
cssInterop(View, {
|
|
11
|
+
className: 'style'
|
|
12
|
+
});
|
|
13
|
+
cssInterop(Pressable, {
|
|
14
|
+
className: 'style'
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Weather data structure for the greeting card
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Weather icon mappings for different weather conditions
|
|
23
|
+
*/
|
|
24
|
+
const WEATHER_ICONS = {
|
|
25
|
+
sunny: require('../../assets/icons/weather_icons/sunny_weather.png'),
|
|
26
|
+
partlyCloudy: require('../../assets/icons/weather_icons/partly_cloudy.png'),
|
|
27
|
+
foggy: require('../../assets/icons/weather_icons/foggy.png'),
|
|
28
|
+
drizzle: require('../../assets/icons/weather_icons/drizzle.png'),
|
|
29
|
+
rainy: require('../../assets/icons/weather_icons/rainy.png'),
|
|
30
|
+
freezingRain: require('../../assets/icons/weather_icons/freezing_rain.png'),
|
|
31
|
+
showers: require('../../assets/icons/weather_icons/showers.png'),
|
|
32
|
+
thunderstorm: require('../../assets/icons/weather_icons/thunderstorm.png'),
|
|
33
|
+
thunderstormHail: require('../../assets/icons/weather_icons/thunderstorm_hail.png')
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Converts a weather code from Open-Meteo API to a description and icon
|
|
38
|
+
*
|
|
39
|
+
* @param {number} code - Weather code from Open-Meteo API (0-99)
|
|
40
|
+
* @returns {Object} Object containing description and icon path
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* const weatherInfo = getWeatherDescription(0);
|
|
45
|
+
* // Returns: { description: 'Clear Sky (Sunny)', weatherImage: ... }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export function getWeatherDescription(code) {
|
|
49
|
+
const weatherMap = {
|
|
50
|
+
'0': {
|
|
51
|
+
description: 'Clear Sky (Sunny)',
|
|
52
|
+
icon: 'sunny'
|
|
53
|
+
},
|
|
54
|
+
'1,2,3': {
|
|
55
|
+
description: 'Partly Cloudy',
|
|
56
|
+
icon: 'partlyCloudy'
|
|
57
|
+
},
|
|
58
|
+
'45,48': {
|
|
59
|
+
description: 'Foggy',
|
|
60
|
+
icon: 'foggy'
|
|
61
|
+
},
|
|
62
|
+
'51,53,55': {
|
|
63
|
+
description: 'Drizzle',
|
|
64
|
+
icon: 'drizzle'
|
|
65
|
+
},
|
|
66
|
+
'56,57': {
|
|
67
|
+
description: 'Freezing Drizzle',
|
|
68
|
+
icon: 'drizzle'
|
|
69
|
+
},
|
|
70
|
+
'61,63,65': {
|
|
71
|
+
description: 'Rainy',
|
|
72
|
+
icon: 'rainy'
|
|
73
|
+
},
|
|
74
|
+
'66,67': {
|
|
75
|
+
description: 'Freezing Rain',
|
|
76
|
+
icon: 'freezingRain'
|
|
77
|
+
},
|
|
78
|
+
'80,81,82': {
|
|
79
|
+
description: 'Showers',
|
|
80
|
+
icon: 'showers'
|
|
81
|
+
},
|
|
82
|
+
'95': {
|
|
83
|
+
description: 'Thunderstorm',
|
|
84
|
+
icon: 'thunderstorm'
|
|
85
|
+
},
|
|
86
|
+
'96,99': {
|
|
87
|
+
description: 'Thunderstorm with Hail',
|
|
88
|
+
icon: 'thunderstormHail'
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
for (const [codes, info] of Object.entries(weatherMap)) {
|
|
92
|
+
if (codes.split(',').map(Number).includes(code)) {
|
|
93
|
+
return {
|
|
94
|
+
description: info.description,
|
|
95
|
+
weatherImage: WEATHER_ICONS[info.icon]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
description: 'Unknown Weather',
|
|
101
|
+
weatherImage: WEATHER_ICONS.sunny
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Returns a greeting based on the current time of day
|
|
107
|
+
*
|
|
108
|
+
* @returns {string} Time-appropriate greeting
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```tsx
|
|
112
|
+
* const greeting = getTimeBasedGreeting();
|
|
113
|
+
* // Returns: "Good Morning" (if it's morning)
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export function getTimeBasedGreeting() {
|
|
117
|
+
const hour = new Date().getHours();
|
|
118
|
+
if (hour >= 5 && hour < 12) {
|
|
119
|
+
return 'Good Morning';
|
|
120
|
+
} else if (hour >= 12 && hour < 17) {
|
|
121
|
+
return 'Good Afternoon';
|
|
122
|
+
} else if (hour >= 17 && hour < 21) {
|
|
123
|
+
return 'Good Evening';
|
|
124
|
+
} else {
|
|
125
|
+
return 'Good Night';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Formats a date to a readable string format
|
|
131
|
+
*
|
|
132
|
+
* @param {Date} date - Date to format
|
|
133
|
+
* @returns {string} Formatted date string (e.g., "Monday, 16 October")
|
|
134
|
+
*/
|
|
135
|
+
export function formatDate(date) {
|
|
136
|
+
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
137
|
+
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
138
|
+
const dayName = days[date.getDay()];
|
|
139
|
+
const day = date.getDate();
|
|
140
|
+
const monthName = months[date.getMonth()];
|
|
141
|
+
return `${dayName}, ${day} ${monthName}`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Fetches weather data from Open-Meteo API
|
|
146
|
+
*
|
|
147
|
+
* @param {number} latitude - Latitude coordinate
|
|
148
|
+
* @param {number} longitude - Longitude coordinate
|
|
149
|
+
* @returns {Promise<Weather | null>} Weather data or null if fetch fails
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```tsx
|
|
153
|
+
* const weather = await fetchWeather(37.7749, -122.4194);
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export async function fetchWeather(latitude, longitude) {
|
|
157
|
+
const url = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t=temperature_2m,weathercode`;
|
|
158
|
+
try {
|
|
159
|
+
const response = await fetch(url);
|
|
160
|
+
if (response.ok) {
|
|
161
|
+
const data = await response.json();
|
|
162
|
+
const temperature = data.current?.temperature_2m ?? 0;
|
|
163
|
+
const weatherCode = data.current?.weathercode ?? 0;
|
|
164
|
+
const weatherInfo = getWeatherDescription(weatherCode);
|
|
165
|
+
return {
|
|
166
|
+
temperature,
|
|
167
|
+
weatherDescription: weatherInfo.description,
|
|
168
|
+
weatherImage: weatherInfo.weatherImage,
|
|
169
|
+
weatherCode,
|
|
170
|
+
lastUpdated: new Date()
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
} catch (error) {
|
|
175
|
+
console.error('Failed to fetch weather:', error);
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Props for the GreetingCard component
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* GreetingCard - A personalized greeting card with weather information
|
|
186
|
+
*
|
|
187
|
+
* Displays a personalized greeting with the user's name, current date, and optional
|
|
188
|
+
* weather information fetched from Open-Meteo API. Includes an optional action button
|
|
189
|
+
* (e.g., "View Schedule"). Weather data is automatically cached for 15 minutes.
|
|
190
|
+
*
|
|
191
|
+
* @component
|
|
192
|
+
* @example
|
|
193
|
+
* ```tsx
|
|
194
|
+
* // Basic usage without weather
|
|
195
|
+
* <GreetingCard
|
|
196
|
+
* userName="John Doe"
|
|
197
|
+
* actionText="View Schedule"
|
|
198
|
+
* onPress={() => navigation.navigate('Schedule')}
|
|
199
|
+
* />
|
|
200
|
+
*
|
|
201
|
+
* // With automatic weather fetching (provide both lat and lng)
|
|
202
|
+
* <GreetingCard
|
|
203
|
+
* userName="Jane Smith"
|
|
204
|
+
* lat={37.7749}
|
|
205
|
+
* lng={-122.4194}
|
|
206
|
+
* actionText="View Dashboard"
|
|
207
|
+
* onPress={() => console.log('Card pressed')}
|
|
208
|
+
* />
|
|
209
|
+
*
|
|
210
|
+
* // Custom greeting without action
|
|
211
|
+
* <GreetingCard
|
|
212
|
+
* userName="Alice"
|
|
213
|
+
* customGreeting="Welcome back"
|
|
214
|
+
* showAction={false}
|
|
215
|
+
* />
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @property {string} userName - User's full name to display in greeting (required)
|
|
219
|
+
* @property {number} [lat] - Latitude coordinate for weather fetching (optional)
|
|
220
|
+
* @property {number} [lng] - Longitude coordinate for weather fetching (optional)
|
|
221
|
+
* @property {string} [customGreeting] - Override the time-based greeting
|
|
222
|
+
* @property {Date} [date] - Custom date to display (defaults to current date)
|
|
223
|
+
* @property {string} [actionText="View Details"] - Text for the action button
|
|
224
|
+
* @property {Function} [onPress] - Handler called when card or action is pressed
|
|
225
|
+
* @property {string} [className] - Additional Tailwind classes for styling
|
|
226
|
+
* @property {boolean} [showAction=true] - Whether to show the action button section
|
|
227
|
+
* @property {number} [cacheDuration=900000] - Cache duration in ms (default: 15 min)
|
|
228
|
+
*/
|
|
229
|
+
export function GreetingCard({
|
|
230
|
+
userName,
|
|
231
|
+
lat,
|
|
232
|
+
lng,
|
|
233
|
+
customGreeting,
|
|
234
|
+
date = new Date(),
|
|
235
|
+
actionText = 'View Details',
|
|
236
|
+
onPress,
|
|
237
|
+
className,
|
|
238
|
+
showAction = true,
|
|
239
|
+
cacheDuration = 15 * 60 * 1000 // 15 minutes
|
|
240
|
+
}) {
|
|
241
|
+
const colorScheme = useColorScheme();
|
|
242
|
+
const isDark = colorScheme === 'dark';
|
|
243
|
+
const [weather, setWeather] = React.useState(null);
|
|
244
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
245
|
+
const cacheRef = React.useRef(null);
|
|
246
|
+
|
|
247
|
+
// Dynamic styles based on theme
|
|
248
|
+
const dynamicStyles = React.useMemo(() => ({
|
|
249
|
+
separator: {
|
|
250
|
+
...styles.separator,
|
|
251
|
+
backgroundColor: isDark ? 'rgba(255, 255, 255, 0.15)' : 'rgba(0, 0, 0, 0.1)'
|
|
252
|
+
}
|
|
253
|
+
}), [isDark]);
|
|
254
|
+
React.useEffect(() => {
|
|
255
|
+
const loadWeather = async () => {
|
|
256
|
+
if (lat === undefined || lng === undefined) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const now = Date.now();
|
|
260
|
+
|
|
261
|
+
// Check cache
|
|
262
|
+
if (cacheRef.current && now - cacheRef.current.timestamp < cacheDuration) {
|
|
263
|
+
setWeather(cacheRef.current.data);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
setIsLoading(true);
|
|
267
|
+
try {
|
|
268
|
+
const weatherData = await fetchWeather(lat, lng);
|
|
269
|
+
setWeather(weatherData);
|
|
270
|
+
cacheRef.current = {
|
|
271
|
+
data: weatherData,
|
|
272
|
+
timestamp: now
|
|
273
|
+
};
|
|
274
|
+
} catch (error) {
|
|
275
|
+
console.error('Error loading weather:', error);
|
|
276
|
+
} finally {
|
|
277
|
+
setIsLoading(false);
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
loadWeather();
|
|
281
|
+
}, [lat, lng, cacheDuration]);
|
|
282
|
+
const greeting = customGreeting || getTimeBasedGreeting();
|
|
283
|
+
const formattedDate = formatDate(date);
|
|
284
|
+
const CardWrapper = onPress ? Pressable : View;
|
|
285
|
+
const wrapperProps = onPress ? {
|
|
286
|
+
onPress,
|
|
287
|
+
android_ripple: {
|
|
288
|
+
color: 'rgba(0, 0, 0, 0.1)'
|
|
289
|
+
}
|
|
290
|
+
} : {};
|
|
291
|
+
return /*#__PURE__*/_jsx(CardWrapper, {
|
|
292
|
+
...wrapperProps,
|
|
293
|
+
children: /*#__PURE__*/_jsx(CustomCard, {
|
|
294
|
+
cornerRadius: 20,
|
|
295
|
+
cornerSmoothing: 1,
|
|
296
|
+
className: cn('border-primary/20 dark:border-primary/30', className),
|
|
297
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
298
|
+
style: styles.contentWrapper,
|
|
299
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
300
|
+
style: styles.headerSection,
|
|
301
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
302
|
+
style: styles.greetingText,
|
|
303
|
+
children: [/*#__PURE__*/_jsxs(Text, {
|
|
304
|
+
className: "text-sm font-semibold text-card-foreground dark:text-card-foreground",
|
|
305
|
+
children: ["Hi ", userName, ","]
|
|
306
|
+
}), /*#__PURE__*/_jsxs(Text, {
|
|
307
|
+
className: "mt-1.5 text-xs tracking-wider text-muted-foreground dark:text-muted-foreground",
|
|
308
|
+
children: [greeting, ", ", formattedDate]
|
|
309
|
+
})]
|
|
310
|
+
}), (weather || isLoading) && /*#__PURE__*/_jsx(View, {
|
|
311
|
+
style: styles.weatherContainer,
|
|
312
|
+
children: isLoading ? /*#__PURE__*/_jsx(Text, {
|
|
313
|
+
className: "text-xs text-muted-foreground dark:text-muted-foreground",
|
|
314
|
+
children: "Loading..."
|
|
315
|
+
}) : weather && /*#__PURE__*/_jsxs(_Fragment, {
|
|
316
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
317
|
+
style: styles.weatherRow,
|
|
318
|
+
children: [/*#__PURE__*/_jsx(Image, {
|
|
319
|
+
source: weather.weatherImage,
|
|
320
|
+
style: styles.weatherIcon,
|
|
321
|
+
resizeMode: "contain"
|
|
322
|
+
}), /*#__PURE__*/_jsxs(Text, {
|
|
323
|
+
className: "ml-1 text-xs text-card-foreground dark:text-card-foreground",
|
|
324
|
+
children: [Math.round(weather.temperature), "\xB0 C"]
|
|
325
|
+
})]
|
|
326
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
327
|
+
className: "mt-0.5 text-xs text-muted-foreground/70 dark:text-muted-foreground/70",
|
|
328
|
+
children: weather.weatherDescription
|
|
329
|
+
})]
|
|
330
|
+
})
|
|
331
|
+
})]
|
|
332
|
+
}), showAction && /*#__PURE__*/_jsxs(_Fragment, {
|
|
333
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
334
|
+
style: dynamicStyles.separator
|
|
335
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
336
|
+
style: styles.actionSection,
|
|
337
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
338
|
+
className: "text-sm font-semibold text-card-foreground dark:text-card-foreground",
|
|
339
|
+
children: actionText
|
|
340
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
341
|
+
className: "text-2xl text-primary dark:text-primary",
|
|
342
|
+
children: "\u203A"
|
|
343
|
+
})]
|
|
344
|
+
})]
|
|
345
|
+
})]
|
|
346
|
+
})
|
|
347
|
+
})
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
GreetingCard.displayName = 'GreetingCard';
|
|
351
|
+
const styles = StyleSheet.create({
|
|
352
|
+
weatherIcon: {
|
|
353
|
+
width: 40,
|
|
354
|
+
height: 35
|
|
355
|
+
},
|
|
356
|
+
contentWrapper: {
|
|
357
|
+
margin: -24 // Counteract CustomCard's default padding of 24
|
|
358
|
+
},
|
|
359
|
+
headerSection: {
|
|
360
|
+
flexDirection: 'row',
|
|
361
|
+
alignItems: 'flex-start',
|
|
362
|
+
justifyContent: 'space-between',
|
|
363
|
+
paddingHorizontal: 20,
|
|
364
|
+
paddingTop: 20,
|
|
365
|
+
paddingBottom: 16
|
|
366
|
+
},
|
|
367
|
+
greetingText: {
|
|
368
|
+
flex: 1
|
|
369
|
+
},
|
|
370
|
+
weatherContainer: {
|
|
371
|
+
marginLeft: 12,
|
|
372
|
+
alignItems: 'flex-end'
|
|
373
|
+
},
|
|
374
|
+
weatherRow: {
|
|
375
|
+
flexDirection: 'row',
|
|
376
|
+
alignItems: 'center'
|
|
377
|
+
},
|
|
378
|
+
separator: {
|
|
379
|
+
height: 1,
|
|
380
|
+
marginVertical: 8
|
|
381
|
+
},
|
|
382
|
+
actionSection: {
|
|
383
|
+
flexDirection: 'row',
|
|
384
|
+
alignItems: 'center',
|
|
385
|
+
justifyContent: 'space-between',
|
|
386
|
+
paddingHorizontal: 20,
|
|
387
|
+
paddingBottom: 12,
|
|
388
|
+
paddingTop: 4
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
export { WEATHER_ICONS };
|
|
392
|
+
//# sourceMappingURL=Greeting-Card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Image","Pressable","StyleSheet","View","useColorScheme","cssInterop","cn","CustomCard","Text","jsxs","_jsxs","jsx","_jsx","Fragment","_Fragment","className","WEATHER_ICONS","sunny","require","partlyCloudy","foggy","drizzle","rainy","freezingRain","showers","thunderstorm","thunderstormHail","getWeatherDescription","code","weatherMap","description","icon","codes","info","Object","entries","split","map","Number","includes","weatherImage","getTimeBasedGreeting","hour","Date","getHours","formatDate","date","days","months","dayName","getDay","day","getDate","monthName","getMonth","fetchWeather","latitude","longitude","url","response","fetch","ok","data","json","temperature","current","temperature_2m","weatherCode","weathercode","weatherInfo","weatherDescription","lastUpdated","error","console","GreetingCard","userName","lat","lng","customGreeting","actionText","onPress","showAction","cacheDuration","colorScheme","isDark","weather","setWeather","useState","isLoading","setIsLoading","cacheRef","useRef","dynamicStyles","useMemo","separator","styles","backgroundColor","useEffect","loadWeather","undefined","now","timestamp","weatherData","greeting","formattedDate","CardWrapper","wrapperProps","android_ripple","color","children","cornerRadius","cornerSmoothing","style","contentWrapper","headerSection","greetingText","weatherContainer","weatherRow","source","weatherIcon","resizeMode","Math","round","actionSection","displayName","create","width","height","margin","flexDirection","alignItems","justifyContent","paddingHorizontal","paddingTop","paddingBottom","flex","marginLeft","marginVertical"],"sourceRoot":"../../../../src","sources":["components/ui/Greeting-Card.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SACEC,KAAK,EACLC,SAAS,EACTC,UAAU,EACVC,IAAI,EACJC,cAAc,QACT,cAAc;AACrB,SAASC,UAAU,QAAQ,YAAY;AACvC,SAASC,EAAE,QAAQ,oBAAiB;AACpC,SAASC,UAAU,QAAQ,kBAAe;AAC1C,SAASC,IAAI,QAAQ,WAAQ;AAAC,SAAAC,IAAA,IAAAC,KAAA,EAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA;AAE9BT,UAAU,CAACF,IAAI,EAAE;EAAEY,SAAS,EAAE;AAAQ,CAAC,CAAC;AACxCV,UAAU,CAACJ,SAAS,EAAE;EAAEc,SAAS,EAAE;AAAQ,CAAC,CAAC;;AAE7C;AACA;AACA;;AAcA;AACA;AACA;AACA,MAAMC,aAAa,GAAG;EACpBC,KAAK,EAAEC,OAAO,CAAC,oDAAoD,CAAC;EACpEC,YAAY,EAAED,OAAO,CAAC,oDAAoD,CAAC;EAC3EE,KAAK,EAAEF,OAAO,CAAC,4CAA4C,CAAC;EAC5DG,OAAO,EAAEH,OAAO,CAAC,8CAA8C,CAAC;EAChEI,KAAK,EAAEJ,OAAO,CAAC,4CAA4C,CAAC;EAC5DK,Y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iBAAiB,EAAE,EAAE;IACrBE,aAAa,EAAE,EAAE;IACjBD,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF,SAASrH,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeOnlyAnimatedView } from "./Native-Only-Animated-View.js";
|
|
4
|
+
import { TextClassContext } from "./Text.js";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
import * as HoverCardPrimitive from '@rn-primitives/hover-card';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { Platform, StyleSheet } from 'react-native';
|
|
9
|
+
import { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
10
|
+
import { FullWindowOverlay as RNFullWindowOverlay } from 'react-native-screens';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Root component for hover card - provides context for trigger and content
|
|
14
|
+
*
|
|
15
|
+
* @component
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <HoverCard>
|
|
19
|
+
* <HoverCardTrigger>
|
|
20
|
+
* <Text>Hover over me</Text>
|
|
21
|
+
* </HoverCardTrigger>
|
|
22
|
+
* <HoverCardContent>
|
|
23
|
+
* <Text>Additional information appears here</Text>
|
|
24
|
+
* </HoverCardContent>
|
|
25
|
+
* </HoverCard>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
29
|
+
const HoverCard = HoverCardPrimitive.Root;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Trigger component that shows hover card content on hover/press
|
|
33
|
+
*
|
|
34
|
+
* @component
|
|
35
|
+
*/
|
|
36
|
+
const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Full window overlay wrapper for iOS, Fragment for other platforms
|
|
40
|
+
*/
|
|
41
|
+
const FullWindowOverlay = Platform.OS === 'ios' ? RNFullWindowOverlay : React.Fragment;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Content container for hover card
|
|
45
|
+
*
|
|
46
|
+
* Displays rich content in a popover when hovering over or pressing the trigger.
|
|
47
|
+
* Includes smooth fade animations and proper positioning.
|
|
48
|
+
*
|
|
49
|
+
* @component
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* <HoverCardContent align="center" sideOffset={8}>
|
|
53
|
+
* <View className="gap-2">
|
|
54
|
+
* <Text className="font-semibold">User Profile</Text>
|
|
55
|
+
* <Text className="text-sm">Additional details about the user</Text>
|
|
56
|
+
* </View>
|
|
57
|
+
* </HoverCardContent>
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @accessibility
|
|
61
|
+
* - Content is announced by screen readers
|
|
62
|
+
* - Proper focus management on web
|
|
63
|
+
*/
|
|
64
|
+
function HoverCardContent({
|
|
65
|
+
className,
|
|
66
|
+
align = 'center',
|
|
67
|
+
sideOffset = 4,
|
|
68
|
+
...props
|
|
69
|
+
}) {
|
|
70
|
+
return /*#__PURE__*/_jsx(HoverCardPrimitive.Portal, {
|
|
71
|
+
children: /*#__PURE__*/_jsx(FullWindowOverlay, {
|
|
72
|
+
children: /*#__PURE__*/_jsx(HoverCardPrimitive.Overlay, {
|
|
73
|
+
style: Platform.select({
|
|
74
|
+
native: StyleSheet.absoluteFill
|
|
75
|
+
}),
|
|
76
|
+
children: /*#__PURE__*/_jsx(NativeOnlyAnimatedView, {
|
|
77
|
+
entering: FadeIn,
|
|
78
|
+
exiting: FadeOut,
|
|
79
|
+
children: /*#__PURE__*/_jsx(TextClassContext.Provider, {
|
|
80
|
+
value: "text-popover-foreground",
|
|
81
|
+
children: /*#__PURE__*/_jsx(HoverCardPrimitive.Content, {
|
|
82
|
+
align: align,
|
|
83
|
+
sideOffset: sideOffset,
|
|
84
|
+
className: cn('bg-popover border-border outline-hidden z-50 w-64 rounded-md border p-4 shadow-md shadow-black/5', Platform.select({
|
|
85
|
+
web: cn('animate-in fade-in-0 zoom-in-95 origin-(--radix-hover-card-content-transform-origin) cursor-default [&>*]:cursor-auto', props.side === 'bottom' && 'slide-in-from-top-2', props.side === 'top' && 'slide-in-from-bottom-2')
|
|
86
|
+
}), className),
|
|
87
|
+
...props
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
export { HoverCard, HoverCardContent, HoverCardTrigger };
|
|
96
|
+
//# sourceMappingURL=Hover-Card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeOnlyAnimatedView","TextClassContext","cn","HoverCardPrimitive","React","Platform","StyleSheet","FadeIn","FadeOut","FullWindowOverlay","RNFullWindowOverlay","jsx","_jsx","HoverCard","Root","HoverCardTrigger","Trigger","OS","Fragment","HoverCardContent","className","align","sideOffset","props","Portal","children","Overlay","style","select","native","absoluteFill","entering","exiting","Provider","value","Content","web","side"],"sourceRoot":"../../../../src","sources":["components/ui/Hover-Card.tsx"],"mappings":";;AAAA,SAASA,sBAAsB,QAAQ,gCAA6B;AACpE,SAASC,gBAAgB,QAAQ,WAAQ;AACzC,SAASC,EAAE,QAAQ,oBAAiB;AACpC,OAAO,KAAKC,kBAAkB,MAAM,2BAA2B;AAC/D,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AACnD,SAASC,MAAM,EAAEC,OAAO,QAAQ,yBAAyB;AACzD,SAASC,iBAAiB,IAAIC,mBAAmB,QAAQ,sBAAsB;;AAE/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAfA,SAAAC,GAAA,IAAAC,IAAA;AAgBA,MAAMC,SAAS,GAAGV,kBAAkB,CAACW,IAAI;;AAEzC;AACA;AACA;AACA;AACA;AACA,M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C;IAAC,CACZ;EAAC,CACK,CAAC;AAEhC;AAEA,SAASV,SAAS,EAAEM,gBAAgB,EAAEJ,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
import { cssInterop } from 'nativewind';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props for Icon component
|
|
8
|
+
*
|
|
9
|
+
* @extends LucideProps - All Lucide icon properties (size, color, strokeWidth, etc.)
|
|
10
|
+
* @property {LucideIcon} as - The Lucide icon component to render
|
|
11
|
+
* @property {string} [className] - Tailwind classes for styling (supports NativeWind)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { Home } from 'lucide-react-native';
|
|
16
|
+
* <Icon as={Home} size={24} className="text-primary" />
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
+
function IconImpl({
|
|
21
|
+
as: IconComponent,
|
|
22
|
+
...props
|
|
23
|
+
}) {
|
|
24
|
+
return /*#__PURE__*/_jsx(IconComponent, {
|
|
25
|
+
...props
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
cssInterop(IconImpl, {
|
|
29
|
+
className: {
|
|
30
|
+
target: 'style',
|
|
31
|
+
nativeStyleToProp: {
|
|
32
|
+
height: 'size',
|
|
33
|
+
width: 'size'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Universal icon wrapper for Lucide icons
|
|
40
|
+
*
|
|
41
|
+
* Provides consistent styling and sizing for Lucide React Native icons across the application.
|
|
42
|
+
* Automatically handles platform-specific sizing and color theming.
|
|
43
|
+
*
|
|
44
|
+
* @component
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* import { Settings, User, ChevronRight } from 'lucide-react-native';
|
|
48
|
+
*
|
|
49
|
+
* // Basic icon
|
|
50
|
+
* <Icon as={Settings} />
|
|
51
|
+
*
|
|
52
|
+
* // Sized icon with custom color
|
|
53
|
+
* <Icon as={User} size={32} className="text-primary" />
|
|
54
|
+
*
|
|
55
|
+
* // Icon with stroke width
|
|
56
|
+
* <Icon as={ChevronRight} size={20} strokeWidth={2.5} />
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
function Icon({
|
|
60
|
+
as: IconComponent,
|
|
61
|
+
className,
|
|
62
|
+
size = 14,
|
|
63
|
+
...props
|
|
64
|
+
}) {
|
|
65
|
+
return /*#__PURE__*/_jsx(IconImpl, {
|
|
66
|
+
as: IconComponent,
|
|
67
|
+
className: cn('text-foreground', className),
|
|
68
|
+
size: size,
|
|
69
|
+
...props
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export { Icon };
|
|
73
|
+
//# sourceMappingURL=Icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cn","cssInterop","jsx","_jsx","IconImpl","as","IconComponent","props","className","target","nativeStyleToProp","height","width","Icon","size"],"sourceRoot":"../../../../src","sources":["components/ui/Icon.tsx"],"mappings":";;AAAA,SAASA,EAAE,QAAQ,oBAAiB;AAEpC,SAASC,UAAU,QAAQ,YAAY;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAZA,SAAAC,GAAA,IAAAC,IAAA;AAkBA,SAASC,QAAQA,CAAC;EAAEC,EAAE,EAAEC,aAAa;EAAE,GAAGC;AAAiB,CAAC,EAAE;EAC5D,oBAAOJ,IAAA,CAACG,aAAa;IAAA,GAAKC;EAAK,CAAG,CAAC;AACrC;AAEAN,UAAU,CAACG,QAAQ,EAAE;EACnBI,SAAS,EAAE;IACTC,MAAM,EAAE,OAAO;IACfC,iBAAiB,EAAE;MACjBC,MAAM,EAAE,MAAM;MACdC,KAAK,EAAE;IACT;EACF;AACF,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,IAAIA,CAAC;EACZR,EAAE,EAAEC,aAAa;EACjBE,SAAS;EACTM,IAAI,GAAG,EAAE;EACT,GAAGP;AACM,CAAC,EAAE;EACZ,oBACEJ,IAAA,CAACC,QAAQ;IACPC,EAAE,EAAEC,aAAc;IAClBE,SAAS,EAAER,EAAE,CAAC,iBAAiB,EAAEQ,SAAS,CAAE;IAC5CM,IAAI,EAAEA,IAAK;IAAA,GACPP;EAAK,CACV,CAAC;AAEN;AAEA,SAASM,IAAI","ignoreList":[]}
|