- App.tsx: full navigation (Auth stack + Main tabs with 5 screens) - Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen - HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors - MapScreen: interactive map with layer toggles (6 layers) - MarketplaceScreen: categories (6), products (5), search - ChatScreen: AI chat with quick prompts (4), bot responses - ProfileScreen: user info, stats, menu (9 items), logout - AlertsScreen: alert list with severity, acknowledge - SensorsScreen: sensor list with type filters (6 types), search - ZonesScreen: zone cards with stats - SettingsScreen: language picker (FR/EN/ES/DE), privacy, about - Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n - Hooks: useSensors, useAlerts, useNotifications, useLocation - Components: Card, Button, LoadingSpinner, ErrorBoundary, Header - Services: iotService, notificationService (with axios API client) - Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN) - Theme: colors.ts with full design system (Blue Ocean palette) - Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
/**
|
|
* Utility function to extract styles in separate objects
|
|
*
|
|
* @param styles The style object you want to filter
|
|
* @param filters The filters by which you want to split the styles
|
|
* @returns An array of filtered style objects:
|
|
* - The first style object contains the properties that didn't match any filter
|
|
* - After that there will be a style object for each filter you passed in the same order as the matching filters
|
|
* - A style property will exist in a single style object, the first filter it matched
|
|
*/
|
|
export function splitStyles(styles, ...filters) {
|
|
if (process.env.NODE_ENV !== 'production' && filters.length === 0) {
|
|
console.error('No filters were passed when calling splitStyles');
|
|
}
|
|
|
|
// `Object.entries` will be used to iterate over the styles and `Object.fromEntries` will be called before returning
|
|
// Entries which match the given filters will be temporarily stored in `newStyles`
|
|
const newStyles = filters.map(() => []);
|
|
|
|
// Entries which match no filter
|
|
const rest = [];
|
|
|
|
// Iterate every style property
|
|
outer: for (const item of Object.entries(styles)) {
|
|
// Check each filter
|
|
for (let i = 0; i < filters.length; i++) {
|
|
// Check if filter matches
|
|
if (filters[i](item[0])) {
|
|
newStyles[i].push(item); // Push to temporary filtered entries array
|
|
continue outer; // Skip to checking next style property
|
|
}
|
|
}
|
|
|
|
// Adds to rest styles if not filtered
|
|
rest.push(item);
|
|
}
|
|
|
|
// Put unmatched styles in the beginning
|
|
newStyles.unshift(rest);
|
|
|
|
// Convert arrays of entries into objects
|
|
return newStyles.map(styles => Object.fromEntries(styles));
|
|
}
|
|
//# sourceMappingURL=splitStyles.js.map
|