@mohantn/gate-keeper 2.2.3 → 2.2.5

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.
@@ -1,261 +0,0 @@
1
- # UI/UX Design System Instructions (Store Media Client)
2
-
3
- **Scope**: All design & component files | **Version**: 3.0 | **Tags**: `dh-component-library`, `emotion`, `accessibility`, `wcag`
4
-
5
- ## 🔴 MANDATORY: Use dh-component-library First
6
- ALWAYS check dh-component-library and store-components before creating custom components:
7
-
8
- **dh-component-library**: Button, Flex, Section, TextInput, DHIcon, ErrorPage, NotificationBanner, Spinner, LoaderOverlay, Toaster, ConfirmationDialog, ModalBox, GenericTable
9
-
10
- **store-components**: PageCard, StoreDateRangePicker, TableDrawerTab, DataRow
11
-
12
- Only create custom components when library components cannot meet requirements.
13
-
14
- ## Core Design Principles
15
-
16
- ### 1. Responsive Design
17
- - **Mobile-First**: Design for 320px, then scale up
18
- - **Breakpoints**: 320px (mobile) → 768px (tablet) → 1024px (desktop) → 1440px (wide) → 1920px (ultra-wide)
19
- - **Fluid Typography**: Scale font sizes between breakpoints using `clamp()`
20
- - **Flexible Layouts**: Grid/Flexbox with max-widths; avoid fixed widths
21
-
22
- **CSS Example**:
23
- ```css
24
- /* Font scaling */
25
- h1 { font-size: clamp(24px, 5vw, 48px); }
26
-
27
- /* Responsive spacing */
28
- .container {
29
- padding: clamp(16px, 5vw, 32px);
30
- max-width: 1200px;
31
- margin: 0 auto;
32
- }
33
-
34
- /* Grid layout */
35
- .grid {
36
- display: grid;
37
- grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
38
- gap: clamp(16px, 3vw, 32px);
39
- }
40
- ```
41
-
42
- ### 2. Typography (dh-component-library Theme)
43
- - **Use theme.typography**: h1, h2, h3, body1, body2, caption
44
- - **Line Height**: Defined in theme (1.4-1.6 body, 1.2 headings)
45
- - **Never hardcode**: Always use `theme.typography.*`
46
-
47
- **Usage**:
48
- ```typescript
49
- import styled from '@emotion/styled';
50
- import { ThemeType } from 'src/types';
51
-
52
- const Title = styled.h2<{ theme?: ThemeType }>(({ theme }) => ({
53
- ...theme?.typography.h2,
54
- color: theme?.palette?.greyscale?.[700],
55
- marginBottom: '16px',
56
- }));
57
- ```
58
-
59
- ### 3. Color System (Theme Palette)
60
- - **Greyscale**: theme.palette.greyscale[50-900] (50=lightest, 900=darkest)
61
- - **Semantic**: primary, secondary, error, warning, success, info
62
- - **Contrast**: WCAG AA minimum 4.5:1 (text), 3:1 (large text/UI)
63
- - **Always use optional chaining**: `theme?.palette?.greyscale?.[200]`
64
-
65
- **Pattern**:
66
- ```typescript
67
- const FilterActions = styled(Flex)<{ theme?: ThemeType }>(({ theme }) => ({
68
- borderTop: `1px solid ${theme?.palette?.greyscale?.[200] || '#e5e7eb'}`,
69
- color: theme?.palette?.greyscale?.[700],
70
- // Provide fallback values for safety
71
- }));
72
- ```
73
-
74
- ### 4. Spacing (Theme System)
75
- - **Use theme.spacing()**: spacing(1)=8px, spacing(2)=16px, spacing(3)=24px
76
- - **Direct values for gaps**: '16px', '24px' (common in project)
77
- - **Consistent**: 4px, 8px, 12px, 16px, 24px, 32px, 48px
78
-
79
- ```typescript
80
- const Container = styled.div<{ theme?: ThemeType }>(({ theme }) => ({
81
- padding: theme?.spacing?.(2) || '16px',
82
- gap: '24px',
83
- marginBottom: '16px',
84
- }));
85
- ```
86
-
87
- ### 5. Accessibility (WCAG AA - Project Standards)
88
-
89
- **Mandatory Checks**:
90
- - ✅ Touch targets ≥ 44x44px (set in styled components)
91
- - ✅ Color contrast ≥ 4.5:1 (verify with theme palette)
92
- - ✅ data-testid on ALL interactive elements (hierarchical naming)
93
- - ✅ Keyboard navigation: Tab order, focus indicators
94
- - ✅ i18n: All text via `t('key')` from `src/I18n`
95
- - ✅ Semantic HTML: Use dh-component-library components
96
- - ✅ Skip links: Include on admin pages
97
- - ✅ ARIA: aria-label, aria-describedby when needed
98
-
99
- **Test ID Pattern**:
100
- ```typescript
101
- import { DATA_TEST_ID } from 'src/test/generic-ids';
102
-
103
- export const DATA_TEST_ID = {
104
- storeAvailability: {
105
- section: 'section-store-availability',
106
- field: {
107
- storeSearch: 'field-store-search',
108
- },
109
- button: {
110
- addStores: 'button-add-stores',
111
- },
112
- },
113
- };
114
-
115
- // Usage
116
- <Button data-testid={DATA_TEST_ID.storeAvailability.button.addStores}>
117
- {t('addStores')}
118
- </Button>
119
- ```
120
- ```
121
-
122
- ## Component Patterns (Project Standards)
123
-
124
- ### Form Components (Use dh-component-library)
125
- ```typescript
126
- import { TextInput } from 'dh-component-library';
127
- import { FormElementText } from 'src/Components/Forms/FormElements';
128
- import { t } from 'src/I18n';
129
-
130
- <FormElementText
131
- id="activation-name"
132
- label={t('activationName')}
133
- dataTestId={DATA_TEST_ID.generalInfo.field.name}
134
- isOptional={false}
135
- onChange={handleChange}
136
- onBlur={handleBlur}
137
- counterMaxLimit={255}
138
- unsafeNativeInputProps={{ placeholder: t('enterName') }}
139
- />
140
- ```
141
-
142
- ### Layout Structure
143
- ```tsx
144
- import { PageCard } from 'store-components';
145
- import { Section, Flex } from 'dh-component-library';
146
-
147
- <Section gap="24">
148
- <PageCard
149
- title={t('sectionTitle')}
150
- titleDescription={t('sectionDescription')}
151
- divider
152
- >
153
- <Flex direction="column" gap="16px">
154
- {/* Content */}
155
- </Flex>
156
- </PageCard>
157
- </Section>
158
- ```
159
-
160
- ### Styled Components Pattern
161
- ```typescript
162
- import styled from '@emotion/styled';
163
- import { Flex } from 'dh-component-library';
164
- import { ThemeType } from 'src/types';
165
-
166
- const FilterGrid = styled.div<{ theme?: ThemeType }>(({ theme }) => ({
167
- display: 'grid',
168
- gridTemplateColumns: 'repeat(auto-fit, minmax(280px, 1fr))',
169
- gap: '24px',
170
- marginBottom: '24px',
171
-
172
- '& > *': {
173
- minHeight: '44px', // Accessibility: touch targets
174
- },
175
-
176
- '@media (max-width: 768px)': {
177
- gridTemplateColumns: '1fr',
178
- gap: '16px',
179
- },
180
- }));
181
-
182
- // Always include responsive breakpoints and accessibility standards
183
- ```
184
-
185
- ### Loading States
186
- ```typescript
187
- import { LoadingSpinner } from 'src/Components/Layout/LoadingSpinner';
188
- import { DATA_TEST_ID } from 'src/test/generic-ids';
189
-
190
- // Overlay loading
191
- <LoadingSpinner withBackdrop testId={DATA_TEST_ID.loadingSpinner} />
192
-
193
- // Inline loading
194
- <LoadingSpinner size={32} />
195
- ```
196
-
197
- ### Notifications
198
- ```typescript
199
- import { NotificationBanner } from 'dh-component-library';
200
- import { t } from 'src/I18n';
201
-
202
- <NotificationBanner
203
- title={t('notificationTitle')}
204
- message={t('notificationMessage')}
205
- variant="warning" // 'success' | 'error' | 'info' | 'warning'
206
- dataTestId="notification-banner"
207
- />
208
- ```
209
-
210
- ## Common Mistakes ❌
211
-
212
- - Creating custom components when dh-component-library has equivalent
213
- - Hardcoding text instead of using `t('key')`
214
- - Missing data-testid attributes
215
- - Not using theme for colors/typography
216
- - Touch targets < 44px
217
- - Color contrast < 4.5:1
218
- - Missing optional chaining: `theme?.palette?.greyscale?.[200]`
219
- - Skipping responsive breakpoints
220
-
221
- ## Testing Checklist ✅
222
-
223
- **Test IDs**:
224
- - All interactive elements have hierarchical test IDs
225
- - Pattern: `DATA_TEST_ID.section.subsection.element`
226
- - Export from centralized file
227
-
228
- **Keyboard Navigation**:
229
- - Tab through all interactive elements
230
- - Enter/Space activate buttons
231
- - Escape closes modals
232
-
233
- **Responsive** (Test at 320px, 768px, 1024px):
234
- - Touch targets ≥ 44px
235
- - Text readable at all breakpoints
236
- - Grid layouts adapt correctly
237
-
238
- **Contrast** (Use browser DevTools):
239
- - Min 4.5:1 for text
240
- - Min 3:1 for large text/UI
241
-
242
- **i18n**:
243
- - All text uses `t('key')`
244
- - No hardcoded strings
245
-
246
- ## Tools
247
-
248
- - **dh-component-library**: Primary component library
249
- - **Emotion**: CSS-in-JS styling
250
- - **MSW**: API mocking for tests
251
- - **Cypress**: E2E testing
252
- - **axe DevTools**: Accessibility audit
253
- - **WebAIM**: Contrast checker
254
-
255
- ## Resources
256
-
257
- - [dh-component-library Docs](https://dh-component-library-docs)
258
- - [store-components API](https://store-components-docs)
259
- - [Emotion Documentation](https://emotion.sh)
260
- - [WCAG 2.1 Guidelines](https://www.w3.org/WAI/WCAG21/quickref/)
261
- - [WAI-ARIA Practices](https://www.w3.org/WAI/ARIA/apg/)