@ecohouse/ui 0.1.38 → 0.1.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecohouse/ui",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Cross-platform presentation-only UI components for EcoHouse (React Native + React Native Web)",
@@ -26,7 +26,8 @@
26
26
  "default": "./src/index.ts"
27
27
  },
28
28
  "./web/fonts.css": "./src/web/styles/fonts.css",
29
- "./web/typography.css": "./src/web/styles/typography.css"
29
+ "./web/typography.css": "./src/web/styles/typography.css",
30
+ "./web/account-header.css": "./src/web/styles/account-header.css"
30
31
  },
31
32
  "files": [
32
33
  "dist",
@@ -54,7 +55,7 @@
54
55
  "storybook": "storybook dev -p 6006",
55
56
  "storybook:clean": "rm -rf node_modules/.cache/storybook node_modules/.vite storybook-static && storybook dev -p 6006",
56
57
  "build-storybook": "storybook build",
57
- "prepare": "husky"
58
+ "prepare": "node -e \"if (process.env.CI !== 'true' && process.env.HUSKY !== '0') require('child_process').execSync('husky', { stdio: 'inherit' })\""
58
59
  },
59
60
  "lint-staged": {
60
61
  "*.{js,jsx,ts,tsx,mjs}": [
@@ -0,0 +1,79 @@
1
+ import { useState } from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react-vite";
3
+ import { Pressable, StyleSheet, Text, View } from "react-native";
4
+ import { colors, fonts } from "../../theme";
5
+ import { Drawer } from "./Drawer";
6
+
7
+ const meta = {
8
+ title: "Components/Drawer",
9
+ component: Drawer,
10
+ parameters: {
11
+ backgrounds: { default: "black" },
12
+ },
13
+ } satisfies Meta<typeof Drawer>;
14
+
15
+ export default meta;
16
+ type Story = StoryObj<typeof meta>;
17
+
18
+ function DrawerDemo() {
19
+ const [open, setOpen] = useState(true);
20
+
21
+ return (
22
+ <View style={styles.page}>
23
+ <Pressable onPress={() => setOpen(true)} style={styles.openButton}>
24
+ <Text style={styles.openLabel}>Open drawer</Text>
25
+ </Pressable>
26
+
27
+ <Drawer
28
+ open={open}
29
+ onClose={() => setOpen(false)}
30
+ title="Չեղարկված ամրագրումներ"
31
+ closeAccessibilityLabel="Close drawer"
32
+ >
33
+ <View style={styles.body}>
34
+ <Text style={styles.bodyText}>Drawer body content</Text>
35
+ </View>
36
+ </Drawer>
37
+ </View>
38
+ );
39
+ }
40
+
41
+ export const Default: Story = {
42
+ args: {
43
+ open: true,
44
+ onClose: () => undefined,
45
+ children: null,
46
+ },
47
+ render: () => <DrawerDemo />,
48
+ };
49
+
50
+ const styles = StyleSheet.create({
51
+ page: {
52
+ minHeight: 360,
53
+ alignItems: "center",
54
+ justifyContent: "center",
55
+ padding: 24,
56
+ },
57
+ openButton: {
58
+ paddingHorizontal: 16,
59
+ paddingVertical: 10,
60
+ borderRadius: 40,
61
+ backgroundColor: colors.primary,
62
+ },
63
+ openLabel: {
64
+ fontFamily: fonts.sans,
65
+ fontSize: 14,
66
+ fontWeight: "600",
67
+ color: colors.white,
68
+ },
69
+ body: {
70
+ flex: 1,
71
+ padding: 24,
72
+ gap: 24,
73
+ },
74
+ bodyText: {
75
+ fontFamily: fonts.sans,
76
+ fontSize: 14,
77
+ color: colors.lightGrey,
78
+ },
79
+ });
@@ -0,0 +1,239 @@
1
+ import { forwardRef, useEffect, useMemo, useRef, type ComponentRef, type ReactNode } from "react";
2
+ import { createPortal } from "react-dom";
3
+ import {
4
+ Modal as RNModal,
5
+ Platform,
6
+ Pressable,
7
+ StyleSheet,
8
+ Text,
9
+ View,
10
+ type StyleProp,
11
+ type ViewStyle,
12
+ } from "react-native";
13
+ import { CloseIcon } from "../../icons";
14
+ import { colors, fonts } from "../../theme";
15
+ import { mergeRefs } from "../../utils/mergeRefs";
16
+ import { useApplyWebClassName } from "../../utils/useApplyWebClassName";
17
+
18
+ export interface DrawerProps {
19
+ /** Controls visibility. */
20
+ open: boolean;
21
+ /** Called on backdrop press, Escape / Android back, or header close. */
22
+ onClose: () => void;
23
+ children: ReactNode;
24
+ /** Header title. When set, the standard drawer header is rendered. */
25
+ title?: string;
26
+ /** Panel width in px. Defaults to `652`. */
27
+ width?: number;
28
+ /** Close when the dimmed backdrop is pressed. Defaults to `true`. */
29
+ closeOnBackdropPress?: boolean;
30
+ /** Accessible name for the backdrop control. Defaults to `"Close"`. */
31
+ backdropAccessibilityLabel?: string;
32
+ /** Accessible name for the header close control. Defaults to `"Close"`. */
33
+ closeAccessibilityLabel?: string;
34
+ /** Style for the drawer panel. */
35
+ style?: StyleProp<ViewStyle>;
36
+ /** Web CSS class applied to the drawer panel. */
37
+ className?: string;
38
+ }
39
+
40
+ const BACKDROP_COLOR = "#09090933";
41
+ const DEFAULT_WIDTH = 652;
42
+ const WEB_Z_INDEX = 500;
43
+ const CLOSE_ICON_SIZE = 24;
44
+
45
+ /** Plain DOM backdrop — RN StyleSheet often drops `backdrop-filter`. */
46
+ const webBackdropDomStyle = {
47
+ position: "absolute",
48
+ top: 0,
49
+ right: 0,
50
+ bottom: 0,
51
+ left: 0,
52
+ backgroundColor: BACKDROP_COLOR,
53
+ backdropFilter: "blur(18px)",
54
+ WebkitBackdropFilter: "blur(18px)",
55
+ border: "none",
56
+ padding: 0,
57
+ margin: 0,
58
+ cursor: "pointer",
59
+ } as const;
60
+
61
+ const webRootDomStyle = {
62
+ position: "fixed",
63
+ top: 0,
64
+ right: 0,
65
+ bottom: 0,
66
+ left: 0,
67
+ zIndex: WEB_Z_INDEX,
68
+ display: "flex",
69
+ justifyContent: "flex-end",
70
+ } as const;
71
+
72
+ export const Drawer = forwardRef<ComponentRef<typeof View>, DrawerProps>(function Drawer(
73
+ {
74
+ open,
75
+ onClose,
76
+ children,
77
+ title,
78
+ width = DEFAULT_WIDTH,
79
+ closeOnBackdropPress = true,
80
+ backdropAccessibilityLabel = "Close",
81
+ closeAccessibilityLabel = "Close",
82
+ style,
83
+ className,
84
+ },
85
+ forwardedRef,
86
+ ) {
87
+ const panelRef = useRef<ComponentRef<typeof View>>(null);
88
+ const setPanelRef = useMemo(() => mergeRefs(panelRef, forwardedRef), [forwardedRef]);
89
+ const resolvedClassName = className?.trim() || undefined;
90
+
91
+ useApplyWebClassName(panelRef, resolvedClassName, open && Platform.OS === "web");
92
+
93
+ useEffect(() => {
94
+ if (!open || Platform.OS !== "web") return undefined;
95
+
96
+ const previousOverflow = document.body.style.overflow;
97
+ document.body.style.overflow = "hidden";
98
+
99
+ const onKeyDown = (event: KeyboardEvent) => {
100
+ if (event.key === "Escape") onClose();
101
+ };
102
+ document.addEventListener("keydown", onKeyDown);
103
+
104
+ return () => {
105
+ document.body.style.overflow = previousOverflow;
106
+ document.removeEventListener("keydown", onKeyDown);
107
+ };
108
+ }, [open, onClose]);
109
+
110
+ const header =
111
+ title != null && title !== "" ? (
112
+ <View style={styles.header}>
113
+ <Text style={styles.title} numberOfLines={1}>
114
+ {title}
115
+ </Text>
116
+ <Pressable
117
+ accessibilityRole="button"
118
+ accessibilityLabel={closeAccessibilityLabel}
119
+ hitSlop={8}
120
+ onPress={onClose}
121
+ style={styles.closeButton}
122
+ >
123
+ <CloseIcon color={colors.white} size={CLOSE_ICON_SIZE} />
124
+ </Pressable>
125
+ </View>
126
+ ) : null;
127
+
128
+ const panel = (
129
+ <View
130
+ ref={setPanelRef}
131
+ accessibilityViewIsModal
132
+ style={[styles.panel, { width }, style]}
133
+ onStartShouldSetResponder={() => true}
134
+ >
135
+ {header}
136
+ <View style={styles.body}>{children}</View>
137
+ </View>
138
+ );
139
+
140
+ if (Platform.OS === "web") {
141
+ if (!open || typeof document === "undefined") return null;
142
+
143
+ return createPortal(
144
+ <div style={webRootDomStyle} role="presentation">
145
+ <button
146
+ type="button"
147
+ aria-label={backdropAccessibilityLabel}
148
+ disabled={!closeOnBackdropPress}
149
+ onClick={closeOnBackdropPress ? onClose : undefined}
150
+ style={webBackdropDomStyle}
151
+ />
152
+ <div
153
+ style={{
154
+ position: "relative",
155
+ zIndex: 1,
156
+ height: "100%",
157
+ maxWidth: "100%",
158
+ display: "flex",
159
+ }}
160
+ >
161
+ {panel}
162
+ </div>
163
+ </div>,
164
+ document.body,
165
+ );
166
+ }
167
+
168
+ return (
169
+ <RNModal
170
+ visible={open}
171
+ transparent
172
+ animationType="slide"
173
+ onRequestClose={onClose}
174
+ statusBarTranslucent
175
+ >
176
+ <View style={styles.root} accessibilityViewIsModal>
177
+ <Pressable
178
+ accessibilityRole="button"
179
+ accessibilityLabel={backdropAccessibilityLabel}
180
+ disabled={!closeOnBackdropPress}
181
+ onPress={closeOnBackdropPress ? onClose : undefined}
182
+ style={styles.backdrop}
183
+ />
184
+ {panel}
185
+ </View>
186
+ </RNModal>
187
+ );
188
+ });
189
+
190
+ const styles = StyleSheet.create({
191
+ root: {
192
+ flex: 1,
193
+ flexDirection: "row",
194
+ justifyContent: "flex-end",
195
+ },
196
+ backdrop: {
197
+ ...StyleSheet.absoluteFillObject,
198
+ backgroundColor: BACKDROP_COLOR,
199
+ },
200
+ panel: {
201
+ zIndex: 1,
202
+ height: "100%",
203
+ maxWidth: "100%",
204
+ backgroundColor: colors.grey800,
205
+ },
206
+ header: {
207
+ height: 65,
208
+ flexDirection: "row",
209
+ alignItems: "center",
210
+ justifyContent: "space-between",
211
+ paddingTop: 20,
212
+ paddingRight: 24,
213
+ paddingBottom: 20,
214
+ paddingLeft: 24,
215
+ borderBottomWidth: 1,
216
+ borderBottomColor: colors.grey650,
217
+ },
218
+ title: {
219
+ flex: 1,
220
+ fontFamily: fonts.sans,
221
+ fontSize: 16,
222
+ fontWeight: "600",
223
+ lineHeight: 16,
224
+ letterSpacing: 0,
225
+ color: colors.white,
226
+ marginRight: 12,
227
+ },
228
+ closeButton: {
229
+ width: CLOSE_ICON_SIZE,
230
+ height: CLOSE_ICON_SIZE,
231
+ alignItems: "center",
232
+ justifyContent: "center",
233
+ flexShrink: 0,
234
+ },
235
+ body: {
236
+ flex: 1,
237
+ minHeight: 0,
238
+ },
239
+ });
@@ -0,0 +1,2 @@
1
+ export { Drawer } from "./Drawer";
2
+ export type { DrawerProps } from "./Drawer";
@@ -98,7 +98,7 @@ const styles = StyleSheet.create({
98
98
  label: {
99
99
  fontFamily: fonts.sans,
100
100
  fontSize: 12,
101
- fontWeight: "600",
101
+ fontWeight: "700",
102
102
  lineHeight: 12,
103
103
  letterSpacing: 0,
104
104
  },
@@ -77,6 +77,9 @@ export type { FloatingActionButtonProps } from "./FloatingActionButton";
77
77
  export { Modal } from "./Modal";
78
78
  export type { ModalProps } from "./Modal";
79
79
 
80
+ export { Drawer } from "./Drawer";
81
+ export type { DrawerProps } from "./Drawer";
82
+
80
83
  export { Input } from "./Input";
81
84
  export type { InputIcon, InputProps, InputSize } from "./Input";
82
85
 
@@ -0,0 +1,25 @@
1
+ import Svg, { Path } from "react-native-svg";
2
+ import { CALENDAR_MINUS_PATH } from "./calendarMinusPath";
3
+ import { colors } from "../../theme";
4
+ import type { IconProps } from "../types";
5
+
6
+ export { CALENDAR_MINUS_PATH } from "./calendarMinusPath";
7
+
8
+ /** Native — react-native-svg (peer dependency). */
9
+ export function CalendarMinusIcon({
10
+ size = 20,
11
+ color = colors.grey200,
12
+ strokeWidth = 2,
13
+ }: IconProps) {
14
+ return (
15
+ <Svg width={size} height={size} viewBox="0 0 20 20" fill="none">
16
+ <Path
17
+ d={CALENDAR_MINUS_PATH}
18
+ stroke={color}
19
+ strokeWidth={strokeWidth}
20
+ strokeLinecap="round"
21
+ strokeLinejoin="round"
22
+ />
23
+ </Svg>
24
+ );
25
+ }
@@ -0,0 +1,31 @@
1
+ import { CALENDAR_MINUS_PATH } from "./calendarMinusPath";
2
+ import { colors } from "../../theme";
3
+ import type { IconProps } from "../types";
4
+
5
+ /** Web / Storybook — plain SVG (no react-native-svg). */
6
+ export function CalendarMinusIcon({
7
+ size = 20,
8
+ color = colors.grey200,
9
+ strokeWidth = 2,
10
+ }: IconProps) {
11
+ return (
12
+ <svg
13
+ width={size}
14
+ height={size}
15
+ viewBox="0 0 20 20"
16
+ fill="none"
17
+ xmlns="http://www.w3.org/2000/svg"
18
+ aria-hidden
19
+ >
20
+ <path
21
+ d={CALENDAR_MINUS_PATH}
22
+ stroke={color}
23
+ strokeWidth={strokeWidth}
24
+ strokeLinecap="round"
25
+ strokeLinejoin="round"
26
+ />
27
+ </svg>
28
+ );
29
+ }
30
+
31
+ export { CALENDAR_MINUS_PATH } from "./calendarMinusPath";
@@ -0,0 +1,3 @@
1
+ /** Calendar with minus mark — 20×20 viewBox. */
2
+ export const CALENDAR_MINUS_PATH =
3
+ "M12.5 14.9998H17.5M17.5 9.58317V7.33317C17.5 5.93304 17.5 5.23297 17.2275 4.69819C16.9878 4.22779 16.6054 3.84534 16.135 3.60565C15.6002 3.33317 14.9001 3.33317 13.5 3.33317H6.5C5.09987 3.33317 4.3998 3.33317 3.86502 3.60565C3.39462 3.84534 3.01217 4.22779 2.77248 4.69819C2.5 5.23297 2.5 5.93304 2.5 7.33317V14.3332C2.5 15.7333 2.5 16.4334 2.77248 16.9681C3.01217 17.4386 3.39462 17.821 3.86502 18.0607C4.3998 18.3332 5.09987 18.3332 6.5 18.3332H10.4167M17.5 8.33317H2.5M13.3333 1.6665V4.99984M6.66667 1.6665V4.99984";
@@ -0,0 +1 @@
1
+ export { CalendarMinusIcon, CALENDAR_MINUS_PATH } from "./CalendarMinusIcon";
@@ -16,6 +16,7 @@ export { BanIcon } from "./Ban";
16
16
  export { BellIcon } from "./Bell";
17
17
  export { BuildingIcon } from "./Building";
18
18
  export { CalendarIcon } from "./Calendar";
19
+ export { CalendarMinusIcon } from "./CalendarMinus";
19
20
  export { CalendarOutlineIcon } from "./CalendarOutline";
20
21
  export { CameraIcon } from "./Camera";
21
22
  export { CameraFilledIcon } from "./CameraFilled";
@@ -1,5 +1,4 @@
1
1
  import { ArrowRightIcon } from "./ArrowRight";
2
- import { ArrowLeftIcon } from "./ArrowLeft";
3
2
  import { AlertTriangleIcon } from "./AlertTriangle";
4
3
  import { AppleIcon, GooglePlayIcon } from "./Store";
5
4
  import { BagIcon } from "./Bag";
@@ -7,6 +6,7 @@ import { BanIcon } from "./Ban";
7
6
  import { BellIcon } from "./Bell";
8
7
  import { BuildingIcon } from "./Building";
9
8
  import { CalendarIcon } from "./Calendar";
9
+ import { CalendarMinusIcon } from "./CalendarMinus";
10
10
  import { CalendarOutlineIcon } from "./CalendarOutline";
11
11
  import { CameraIcon } from "./Camera";
12
12
  import { CameraFilledIcon } from "./CameraFilled";
@@ -16,7 +16,6 @@ import { ChevronDownIcon } from "./ChevronDown";
16
16
  import { ChevronLeftIcon } from "./ChevronLeft";
17
17
  import { ClockIcon } from "./Clock";
18
18
  import { CloseIcon } from "./Close";
19
- import { CurrentLocationIcon } from "./CurrentLocation";
20
19
  import { EditIcon } from "./Edit";
21
20
  import {
22
21
  BathroomsIcon,
@@ -87,13 +86,13 @@ export const icons = {
87
86
  alertTriangle: AlertTriangleIcon,
88
87
  areaExpand: AreaExpandIcon,
89
88
  apple: AppleIcon,
90
- arrowLeft: ArrowLeftIcon,
91
89
  arrowRight: ArrowRightIcon,
92
90
  bag: BagIcon,
93
91
  ban: BanIcon,
94
92
  bell: BellIcon,
95
93
  building: BuildingIcon,
96
94
  calendar: CalendarIcon,
95
+ calendarMinus: CalendarMinusIcon,
97
96
  calendarOutline: CalendarOutlineIcon,
98
97
  camera: CameraIcon,
99
98
  cameraFilled: CameraFilledIcon,
@@ -104,7 +103,6 @@ export const icons = {
104
103
  chevronLeft: ChevronLeftIcon,
105
104
  clock: ClockIcon,
106
105
  close: CloseIcon,
107
- currentLocation: CurrentLocationIcon,
108
106
  edit: EditIcon,
109
107
  clockFilled: ClockFilledIcon,
110
108
  copy: CopyIcon,
@@ -176,11 +174,9 @@ export const iconNames = Object.keys(icons) as IconName[];
176
174
 
177
175
  export const iconGroups = {
178
176
  navigation: [
179
- "arrowLeft",
180
177
  "arrowRight",
181
178
  "chevronDown",
182
179
  "chevronLeft",
183
- "currentLocation",
184
180
  "home",
185
181
  "listView",
186
182
  "locationPin",
@@ -208,6 +204,7 @@ export const iconGroups = {
208
204
  "download",
209
205
  "search",
210
206
  "calendar",
207
+ "calendarMinus",
211
208
  "calendarOutline",
212
209
  "close",
213
210
  "edit",
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@ export {
23
23
  DatePicker,
24
24
  FloatingActionButton,
25
25
  Modal,
26
+ Drawer,
26
27
  Input,
27
28
  AutocompleteInput,
28
29
  VerificationCodeInput,
@@ -73,6 +74,7 @@ export type {
73
74
  DateRange,
74
75
  FloatingActionButtonProps,
75
76
  ModalProps,
77
+ DrawerProps,
76
78
  InputIcon,
77
79
  InputProps,
78
80
  InputSize,
@@ -133,6 +135,7 @@ export {
133
135
  BellIcon,
134
136
  BuildingIcon,
135
137
  CalendarIcon,
138
+ CalendarMinusIcon,
136
139
  CalendarOutlineIcon,
137
140
  CameraIcon,
138
141
  CameraFilledIcon,
@@ -20,6 +20,7 @@ export type GreyStep = keyof typeof grey;
20
20
 
21
21
  export const colors = {
22
22
  primary: "#B46436",
23
+ primaryLight: "#E38E5E",
23
24
  black: "#000000",
24
25
  white: "#ffffff",
25
26
  whiteAlpha86: "#FFFFFFDB",
@@ -0,0 +1,22 @@
1
+ /**
2
+ * AccountHeader (web) — keep the menu control mounted to avoid a mobile refresh flash,
3
+ * but hide it on desktop (≥1024px) where the persistent sidebar is shown.
4
+ *
5
+ * Requires `menuClassName="account-header-menu"` (or rely on `#account-header-menu`).
6
+ */
7
+ @media (min-width: 1024px) {
8
+ #account-header-menu,
9
+ .account-header-menu {
10
+ display: none !important;
11
+ width: 0 !important;
12
+ height: 0 !important;
13
+ min-width: 0 !important;
14
+ min-height: 0 !important;
15
+ margin: 0 !important;
16
+ padding: 0 !important;
17
+ overflow: hidden !important;
18
+ opacity: 0 !important;
19
+ pointer-events: none !important;
20
+ position: absolute !important;
21
+ }
22
+ }