@waaelg/dga-design-system 0.5.1 → 0.5.4

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/README.md CHANGED
@@ -1,492 +1,511 @@
1
- # @waaelg/dga-design-system
2
-
3
- Saudi **DGA (Digital Government Authority)** design system — compiled CSS utilities, components, and optional JavaScript for interactive behavior.
4
-
5
- - Responsive 12-column grid
6
- - Typography, spacing, colors, radius, and **width/height** utilities
7
- - UI components (buttons, alerts, accordion, navbar, cards, forms, and more)
8
- - Optional JS helpers for interactive components
9
- - Built-in **IBM Plex Sans Arabic** font
10
- - RTL-friendly markup patterns
11
-
12
- ---
13
-
14
- ## Installation
15
-
16
- ```bash
17
- npm install @waaelg/dga-design-system
18
- ```
19
-
20
- The published package includes compiled assets from the `dist` folder:
21
-
22
- | Import path | Description |
23
- |-------------|-------------|
24
- | `@waaelg/dga-design-system/style.css` | All compiled styles |
25
- | `@waaelg/dga-design-system` | JavaScript component classes |
26
-
27
- ---
28
-
29
- ## Quick start
30
-
31
- ### 1. Import the stylesheet
32
-
33
- ```js
34
- import '@waaelg/dga-design-system/style.css';
35
- ```
36
-
37
- ### 2. Use `dga-*` classes in your HTML
38
-
39
- ```html
40
- <html lang="ar" dir="rtl">
41
- <body class="dga-bg-gray-25">
42
- <div class="dga-container">
43
- <div class="dga-row">
44
- <div class="dga-col-12 dga-col-md-6">
45
- <button class="dga-btn dga-btn-primary">زر أساسي</button>
46
- </div>
47
- </div>
48
- </div>
49
- </body>
50
- </html>
51
- ```
52
-
53
- ### 3. Initialize JavaScript (only when needed)
54
-
55
- Static components work with CSS alone. For **legacy HTML markup**, interactive components need a one-time JS setup. **Web components** (`<dga-*>`) handle behavior automatically.
56
-
57
- ```js
58
- import '@waaelg/dga-design-system/style.css';
59
- import '@waaelg/dga-design-system'; // registers <dga-*> elements
60
-
61
- // Legacy only:
62
- import { DGAAlert } from '@waaelg/dga-design-system';
63
- new DGAAlert();
64
- ```
65
-
66
- **Web component (no init):**
67
-
68
- ```html
69
- <dga-alert variant="success-color" title="Success" dismissible>
70
- Operation completed successfully.
71
- </dga-alert>
72
- ```
73
-
74
- ---
75
-
76
- ## Usage by project type
77
-
78
- ### Vite / React / Vue / Svelte
79
-
80
- Add the CSS import once in your entry file (`main.js`, `main.tsx`, `App.vue`, etc.):
81
-
82
- ```js
83
- import '@waaelg/dga-design-system/style.css';
84
- ```
85
-
86
- **React example**
87
-
88
- ```jsx
89
- import { useEffect } from 'react';
90
- import '@waaelg/dga-design-system/style.css';
91
- import { DGAAccordion, DGAAlert } from '@waaelg/dga-design-system';
92
-
93
- export function App() {
94
- useEffect(() => {
95
- const accordionEl = document.getElementById('faq');
96
- if (accordionEl) new DGAAccordion(accordionEl);
97
- new DGAAlert();
98
- }, []);
99
-
100
- return (
101
- <div className="dga-container">
102
- <div className="dga-acc" id="faq">
103
- <div className="dga-acc-item">
104
- <button className="dga-acc-header" aria-expanded="false">
105
- <span>السؤال الأول</span>
106
- </button>
107
- <div className="dga-acc-content">
108
- <div className="dga-acc-body">الإجابة هنا.</div>
109
- </div>
110
- </div>
111
- </div>
112
- </div>
113
- );
114
- }
115
- ```
116
-
117
- ### Next.js (App Router)
118
-
119
- Import styles in `app/layout.tsx`:
120
-
121
- ```tsx
122
- import '@waaelg/dga-design-system/style.css';
123
-
124
- export default function RootLayout({ children }: { children: React.ReactNode }) {
125
- return (
126
- <html lang="ar" dir="rtl">
127
- <body>{children}</body>
128
- </html>
129
- );
130
- }
131
- ```
132
-
133
- Use a client component for JS initialization:
134
-
135
- ```tsx
136
- 'use client';
137
-
138
- import { useEffect } from 'react';
139
- import { DGAAlert } from '@waaelg/dga-design-system';
140
-
141
- export function DGAInit() {
142
- useEffect(() => {
143
- new DGAAlert();
144
- }, []);
145
-
146
- return null;
147
- }
148
- ```
149
-
150
- ### Plain HTML
151
-
152
- ```html
153
- <!DOCTYPE html>
154
- <html lang="ar" dir="rtl">
155
- <head>
156
- <meta charset="UTF-8" />
157
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
158
- <link rel="stylesheet" href="./node_modules/@waaelg/dga-design-system/dist/style.css" />
159
- </head>
160
- <body>
161
- <button class="dga-btn dga-btn-primary">زر</button>
162
-
163
- <script type="module">
164
- import { DGAAlert } from './node_modules/@waaelg/dga-design-system/dist/index.js';
165
- new DGAAlert();
166
- </script>
167
- </body>
168
- </html>
169
- ```
170
-
171
- > **Tip:** For production, copy `dist/style.css` to your `public` folder or let your bundler handle the import.
172
-
173
- ---
174
-
175
- ## CSS-only usage
176
-
177
- Most of the design system works without JavaScript. Apply utility and component classes directly.
178
-
179
- ### Grid layout
180
-
181
- ```html
182
- <div class="dga-container">
183
- <div class="dga-row">
184
- <div class="dga-col-12 dga-col-md-6 dga-col-lg-4">Column 1</div>
185
- <div class="dga-col-12 dga-col-md-6 dga-col-lg-4">Column 2</div>
186
- <div class="dga-col-12 dga-col-md-6 dga-col-lg-4">Column 3</div>
187
- </div>
188
- </div>
189
- ```
190
-
191
- ### Common utility prefixes
192
-
193
- | Prefix | Examples |
194
- |--------|----------|
195
- | Layout | `dga-container`, `dga-row`, `dga-col-*`, `dga-d-flex`, `dga-gap-*` |
196
- | Width | `dga-w-full`, `dga-w-50`, `dga-max-w-lg`, `dga-w-screen` |
197
- | Height | `dga-h-full`, `dga-h-100`, `dga-min-h-screen`, `dga-h-4` |
198
- | Spacing | `dga-p-*`, `dga-m-*`, `dga-py-*`, `dga-px-*` |
199
- | Colors | `dga-bg-primary-500`, `dga-text-gray-700` |
200
- | Typography | `dga-text-sm`, `dga-text-xl`, `dga-fw-bold`, `dga-display-md` |
201
- | Radius | `dga-rounded-md`, `dga-rounded-lg` |
202
- | Flex direction | `dga-flex-col` / `dga-flex-column`, `dga-flex-row` |
203
-
204
- ### Included CSS components
205
-
206
- These work with markup and classes only (no JS required):
207
-
208
- - Buttons — `dga-btn`, `dga-btn-primary`, `dga-btn-neutral`, `dga-btn-subtle`, sizes `dga-btn-sm` / `dga-btn-md` / `dga-btn-lg`
209
- - Cards `dga-card`
210
- - Forms — `dga-input`, `dga-select`, `dga-textarea`, `dga-label`
211
- - Links & tags — `dga-link`, `dga-tag`
212
- - Tables — `dga-table`
213
- - Breadcrumb, divider, avatar
214
-
215
- For the full documentation index, see **[docs/README.md](./docs/README.md)**.
216
-
217
- Quick links:
218
- - [Documentation index](./docs/README.md)
219
- - [Installation](./docs/getting-started/installation.md)
220
- - [JavaScript API](./docs/getting-started/javascript-api.md)
221
- - [Web Components](./docs/getting-started/web-components.md)
222
- - [Components](./docs/README.md#components)
223
- - [Grid](./docs/foundations/grid.md) · [Colors](./docs/foundations/colors.md)
224
-
225
- ---
226
-
227
- ## JavaScript components
228
-
229
- Import from the main package entry:
230
-
231
- ```js
232
- import {
233
- DGAAccordion,
234
- DGAAlert,
235
- DGAChart,
236
- DGACodeSnippet,
237
- DGAMenuDropDown,
238
- DGAVerifyBar,
239
- } from '@waaelg/dga-design-system';
240
- ```
241
-
242
- Importing the package also registers **web components** — prefer these in Vue/React:
243
-
244
- | Web component | Legacy class |
245
- |---------------|--------------|
246
- | `<dga-alert>` | `DGAAlert` |
247
- | `<dga-accordion>` + `<dga-accordion-item>` | `DGAAccordion` |
248
- | `<dga-code-snippet>` | `DGACodeSnippet` |
249
- | `<dga-pie-chart>` | `DGAChart` |
250
- | `<dga-verify-bar>` | `DGAVerifyBar` |
251
-
252
- See [Web Components](./docs/getting-started/web-components.md) for framework setup.
253
-
254
- ### DGAAccordion (legacy)
255
-
256
- Expands and collapses accordion panels. Supports click and keyboard (Enter / Space).
257
-
258
- ```html
259
- <div class="dga-acc" id="myAccordion">
260
- <div class="dga-acc-item">
261
- <button class="dga-acc-header" aria-expanded="false">
262
- <span>Section title</span>
263
- </button>
264
- <div class="dga-acc-content">
265
- <div class="dga-acc-body">Content goes here.</div>
266
- </div>
267
- </div>
268
- </div>
269
- ```
270
-
271
- ```js
272
- new DGAAccordion(document.getElementById('myAccordion'));
273
- ```
274
-
275
- ### DGAAlert (legacy)
276
-
277
- Handles dismiss buttons on alerts. Requires `[data-alert-close]` on the close button.
278
-
279
- ```html
280
- <div class="dga-alert" data-variant="success-color">
281
- <span class="dga-alert-icon" aria-hidden="true"></span>
282
- <div class="dga-alert-content">
283
- <h4 class="dga-alert-title">Success</h4>
284
- <div class="dga-alert-body">Operation completed successfully.</div>
285
- </div>
286
- <button class="dga-alert-close" type="button" data-alert-close aria-label="Dismiss alert">×</button>
287
- </div>
288
- ```
289
-
290
- ```js
291
- new DGAAlert(); // listens on document by default
292
- ```
293
-
294
- **Variants:** `success-color`, `warning-color`, `destructive-color`, `info-color`, `neutral-color`, `success-white`, `warning-white`, `destructive-white`, `info-white`, `neutral-white`
295
-
296
- ### DGAChart (legacy)
297
-
298
- Renders a pie chart using a `conic-gradient` background.
299
-
300
- ```html
301
- <div id="myChart" class="dga-pie-chart" data-hole="false"></div>
302
- ```
303
-
304
- ```js
305
- new DGAChart(document.getElementById('myChart'), [
306
- { label: 'Item 1', from: '0%', to: '40%', color: 'var(--dga-primary-100)' },
307
- { label: 'Item 2', from: '40%', to: '100%', color: 'var(--dga-gray-200)' },
308
- ]);
309
- ```
310
-
311
- Set `data-hole="true"` on the element for a donut-style chart.
312
-
313
- ### DGACodeSnippet (legacy)
314
-
315
- Enables copy-to-clipboard on code snippet blocks.
316
-
317
- ```js
318
- new DGACodeSnippet(); // listens on document by default
319
- ```
320
-
321
- Copy buttons must use `.dga-code-snippet-inline__copy` or `.dga-code-snippet-multiline__copy`.
322
-
323
- ### DGAMenuDropDown
324
-
325
- Powers the responsive navbar with dropdown menus.
326
-
327
- ```html
328
- <nav class="dga-navbar" role="navigation">
329
- <a class="dga-navbar-brand" href="#">Brand</a>
330
- <ul class="dga-menu">
331
- <li>
332
- <a class="dga-menu-item dga-has-dropdown" href="#" role="button" aria-expanded="false" aria-haspopup="true">
333
- Menu
334
- </a>
335
- <div class="dga-dropdown">
336
- <div class="dga-dropdown-content">
337
- <ul>
338
- <li><a href="#">Link</a></li>
339
- </ul>
340
- </div>
341
- </div>
342
- </li>
343
- </ul>
344
- <button class="dga-navbar-toggler" aria-label="Toggle menu"></button>
345
- </nav>
346
- ```
347
-
348
- ```js
349
- const menu = new DGAMenuDropDown({
350
- navbar: document.querySelector('.dga-navbar'),
351
- });
352
- ```
353
-
354
- ### Web components
355
-
356
- ```html
357
- <dga-alert variant="success-color" title="Success" dismissible>Message</dga-alert>
358
-
359
- <dga-accordion>
360
- <dga-accordion-item title="Question">Answer</dga-accordion-item>
361
- </dga-accordion>
362
-
363
- <dga-code-snippet code="npm install @waaelg/dga-design-system"></dga-code-snippet>
364
-
365
- <dga-pie-chart data='[{"label":"A","from":"0%","to":"100%","color":"primary-100"}]'></dga-pie-chart>
366
-
367
- <dga-verify-bar domain=".edu.sa"></dga-verify-bar>
368
- ```
369
-
370
- ### DGAVerifyBar (legacy)
371
-
372
- Controls the Saudi government verification bar (legacy markup with fixed element IDs).
373
-
374
- Expected IDs: `dga-verify-bar`, `dga-verifyBtn`, `dga-verify-bar_content`.
375
-
376
- ```js
377
- const verifyBar = new DGAVerifyBar();
378
- const menu = new DGAMenuDropDown();
379
-
380
- // Optional: coordinate verify bar and navbar
381
- verifyBar.menu = menu;
382
- menu.verifyBar = verifyBar;
383
- ```
384
-
385
- | `<dga-verify-bar>` attribute | Default | Description |
386
- |------------------------------|---------|-------------|
387
- | `domain` | `.edu.sa` | Official domain suffix shown in the verify panel |
388
- | `registration-number` | `20250105758` | DGA registration number |
389
- | `registration-link` | DGA Raqmi URL | Link to the platform license page |
390
-
391
- ---
392
-
393
- ## RTL and Arabic
394
-
395
- The design system targets Arabic government websites. Set `dir="rtl"` and `lang="ar"` on the `<html>` element for correct layout direction. The default font is **IBM Plex Sans Arabic**, loaded automatically with the stylesheet.
396
-
397
- ---
398
-
399
- ## What's included in the npm package
400
-
401
- Only compiled files are published:
402
-
403
- ```
404
- node_modules/@waaelg/dga-design-system/
405
- ├── dist/
406
- │ ├── index.js # JavaScript components
407
- │ ├── index.js.map
408
- │ └── style.css # Compiled CSS
409
- └── package.json
410
- ```
411
-
412
- SCSS source files are **not** included in the npm package. To customize variables or mixins, clone the [repository](https://github.com/waaelg/dga-design-system) and build locally.
413
-
414
- ---
415
-
416
- ## Local development (contributors)
417
-
418
- ```bash
419
- git clone https://github.com/waaelg/dga-design-system.git
420
- cd dga-design-system
421
- npm install
422
- npm run docs:dev # documentation at http://localhost:5173
423
- npm run build # outputs dist/index.js and dist/style.css
424
- ```
425
-
426
- Documentation site (VitePress):
427
-
428
- ```bash
429
- npm run docs:dev # local docs
430
- npm run docs:build # production build
431
- ```
432
-
433
- Documentation:
434
-
435
- | File | Contents |
436
- |------|----------|
437
- | `docs/foundations/grid.md` | Grid, flexbox, layout |
438
- | `docs/foundations/width-height.md` | Width & height utilities |
439
- | `docs/foundations/colors.md` | Color tokens and utilities |
440
- | `docs/foundations/radius.md` | Border radius utilities |
441
-
442
- ---
443
-
444
- ## Troubleshooting
445
-
446
- **Styles not applied**
447
- - Confirm `import '@waaelg/dga-design-system/style.css'` runs before your app renders.
448
- - In plain HTML, verify the `<link>` path points to `dist/style.css`.
449
-
450
- **Interactive component not working**
451
- - Check that the required HTML structure and classes match the examples above.
452
- - Ensure the matching JS class is instantiated after the DOM is ready.
453
- - For alerts and code snippets, `new DGAAlert()` / `new DGACodeSnippet()` must run once.
454
-
455
- **Navbar dropdown or verify bar issues**
456
- - `DGAMenuDropDown` requires a `.dga-navbar` element with `.dga-menu` and `.dga-navbar-toggler`.
457
- - `DGAVerifyBar` requires the legacy ID-based markup (`#dga-verify-bar`, etc.), or use `<dga-verify-bar>` instead.
458
-
459
- **Vite: `does not provide an export named 'DGAAlert'`**
460
- - Stale Vite pre-bundle in `node_modules/.vite/deps/`. Clear it and restart:
461
- ```bash
462
- rm -rf node_modules/.vite
463
- npm run dev
464
- ```
465
- - Or add to `vite.config.js`:
466
- ```js
467
- export default defineConfig({
468
- optimizeDeps: {
469
- exclude: ['@waaelg/dga-design-system'],
470
- },
471
- })
472
- ```
473
-
474
- ---
475
-
476
- ## Skills for AI coding tools
477
-
478
- This repo has three parts: the **package** (`src/`, compiled to `dist/`), the **docs site** (`docs/`, VitePress), and **`skills/`** — Claude Skills that teach an AI coding assistant the actual class names, component patterns, and JS API documented above, grounded in `docs/` rather than guessed.
479
-
480
- | Skill | Covers |
481
- |-------|--------|
482
- | [`dga-vue-component`](skills/dga-vue-component/SKILL.md) | Generating Vue 3 SFCs styled with DGA |
483
- | [`dga-web-components`](skills/dga-web-components/SKILL.md) | `<dga-*>` elements and the JS class API outside Vue (plain HTML, Razor, PHP) |
484
- | [`dga-foundations`](skills/dga-foundations/SKILL.md) | Color/spacing/typography/radius/grid utility reference |
485
-
486
- If you clone this repo with **Claude Code**, these are picked up automatically via the `.claude/skills` symlink — no setup needed. Any other AI tool can be pointed directly at the `skills/<name>/SKILL.md` files.
487
-
488
- ---
489
-
490
- ## License
491
-
492
- MIT — Wael Alghamdi
1
+ # @waaelg/dga-design-system
2
+
3
+ Saudi **DGA (Digital Government Authority)** design system — compiled CSS utilities, components, and optional JavaScript for interactive behavior.
4
+
5
+ - Responsive 12-column grid
6
+ - Typography, spacing, colors, radius, and **width/height** utilities
7
+ - UI components (buttons, alerts, accordion, navbar, cards, forms, and more)
8
+ - Optional JS helpers for interactive components
9
+ - Built-in **IBM Plex Sans Arabic** font
10
+ - RTL-friendly markup patterns
11
+
12
+ ---
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @waaelg/dga-design-system
18
+ ```
19
+
20
+ The published package includes compiled assets from the `dist` folder:
21
+
22
+ | Import path | Description |
23
+ |-------------|-------------|
24
+ | `@waaelg/dga-design-system/style.css` | All compiled styles |
25
+ | `@waaelg/dga-design-system` | JavaScript component classes |
26
+
27
+ ---
28
+
29
+ ## Quick start
30
+
31
+ ### 1. Import the stylesheet
32
+
33
+ ```js
34
+ import '@waaelg/dga-design-system/style.css';
35
+ ```
36
+
37
+ ### 2. Use `dga-*` classes in your HTML
38
+
39
+ ```html
40
+ <html lang="ar" dir="rtl">
41
+ <body class="dga-bg-gray-25">
42
+ <div class="dga-container">
43
+ <div class="dga-row">
44
+ <div class="dga-col-12 dga-col-md-6">
45
+ <button class="dga-btn dga-btn-primary">زر أساسي</button>
46
+ </div>
47
+ </div>
48
+ </div>
49
+ </body>
50
+ </html>
51
+ ```
52
+
53
+ ### 3. Initialize JavaScript (only when needed)
54
+
55
+ Static components work with CSS alone. For **legacy HTML markup**, interactive components need a one-time JS setup. **Web components** (`<dga-*>`) handle behavior automatically.
56
+
57
+ ```js
58
+ import '@waaelg/dga-design-system/style.css';
59
+ import '@waaelg/dga-design-system'; // registers <dga-*> elements
60
+
61
+ // Legacy only:
62
+ import { DGAAlert } from '@waaelg/dga-design-system';
63
+ new DGAAlert();
64
+ ```
65
+
66
+ **Web component (no init):**
67
+
68
+ ```html
69
+ <dga-alert variant="success-color" title="Success" dismissible>
70
+ Operation completed successfully.
71
+ </dga-alert>
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Usage by project type
77
+
78
+ Every setup comes down to the **same two imports** — the stylesheet, plus the package entry, which registers the `<dga-*>` web components automatically:
79
+
80
+ ```js
81
+ import '@waaelg/dga-design-system/style.css';
82
+ import '@waaelg/dga-design-system';
83
+ ```
84
+
85
+ After that, drop `<dga-*>` elements anywhere in your markup — they handle their own behavior, no initialization needed. The legacy `DGA*` classes stay available for hand-wired markup; see [JavaScript components](#javascript-components).
86
+
87
+ | Environment | Where the two imports go |
88
+ |-------------|--------------------------|
89
+ | Vite · Vue · React · Svelte | Your entry file (`main.js`, `main.ts`, `main.tsx`) |
90
+ | Next.js (App Router) | CSS in `app/layout.tsx`; register components from a `'use client'` file |
91
+ | Plain HTML · PHP · Razor | `<link>` + `<script type="module">` in the page |
92
+ | No build step | Load from a [CDN](#cdn-no-build-step) |
93
+
94
+ ### Bundler apps (Vite, Vue, React, Svelte)
95
+
96
+ Add both imports once in your entry file, then use web components in any template:
97
+
98
+ ```jsx
99
+ // main.tsx
100
+ import '@waaelg/dga-design-system/style.css';
101
+ import '@waaelg/dga-design-system';
102
+ ```
103
+
104
+ ```jsx
105
+ export function App() {
106
+ return (
107
+ <div className="dga-container">
108
+ <dga-alert variant="success-color" title="نجاح" dismissible>
109
+ تمت العملية بنجاح
110
+ </dga-alert>
111
+ </div>
112
+ );
113
+ }
114
+ ```
115
+
116
+ > **Vite tip:** if an import looks stale after upgrading, add `optimizeDeps: { exclude: ['@waaelg/dga-design-system'] }` to `vite.config.js`.
117
+
118
+ ### Next.js (App Router)
119
+
120
+ Import the stylesheet in `app/layout.tsx` (a server component):
121
+
122
+ ```tsx
123
+ import '@waaelg/dga-design-system/style.css';
124
+
125
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
126
+ return (
127
+ <html lang="ar" dir="rtl">
128
+ <body>{children}</body>
129
+ </html>
130
+ );
131
+ }
132
+ ```
133
+
134
+ Web components need the browser, so register them from a client component:
135
+
136
+ ```tsx
137
+ 'use client';
138
+ import { useEffect } from 'react';
139
+
140
+ export function DGAClient() {
141
+ useEffect(() => {
142
+ import('@waaelg/dga-design-system'); // registers <dga-*> elements
143
+ }, []);
144
+ return null;
145
+ }
146
+ ```
147
+
148
+ Render `<DGAClient />` once in your layout, then use `<dga-*>` tags in any page.
149
+
150
+ ### Plain HTML / server-rendered (PHP, Razor, …)
151
+
152
+ Load the CSS and JS once, then use `<dga-*>` tags in markup. The JS is ESM-only, so the script tag **must** be `type="module"`:
153
+
154
+ ```html
155
+ <!DOCTYPE html>
156
+ <html lang="ar" dir="rtl">
157
+ <head>
158
+ <meta charset="UTF-8" />
159
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
160
+ <link rel="stylesheet" href="/assets/dga/style.css" />
161
+ </head>
162
+ <body>
163
+ <dga-alert variant="success-color" title="نجاح" dismissible>
164
+ تمت العملية بنجاح
165
+ </dga-alert>
166
+
167
+ <script type="module" src="/assets/dga/index.js"></script>
168
+ </body>
169
+ </html>
170
+ ```
171
+
172
+ Copy `dist/style.css` and `dist/index.js` into your served assets folder (`public/`, `wwwroot/`, …), or skip the copy entirely and [load from a CDN](#cdn-no-build-step).
173
+
174
+ ### CDN (no build step)
175
+
176
+ Load the package straight from **jsDelivr** or **unpkg** — no install, no bundler. The CSS works with a plain `<link>`; the JS is ESM-only, so its `<script>` **must** be `type="module"`.
177
+
178
+ ```html
179
+ <link
180
+ rel="stylesheet"
181
+ href="https://cdn.jsdelivr.net/npm/@waaelg/dga-design-system@0.5.4/dist/style.css"
182
+ />
183
+
184
+ <script type="module">
185
+ import 'https://cdn.jsdelivr.net/npm/@waaelg/dga-design-system@0.5.4/dist/index.js';
186
+ </script>
187
+ ```
188
+
189
+ Same files are on unpkg (`https://unpkg.com/@waaelg/dga-design-system@0.5.4/dist/…`). Pin a version for reproducible builds, or use `@latest` to always fetch the newest release. See the [installation docs](./docs/getting-started/installation.md#cdn-no-build-step) for a full example.
190
+
191
+ ---
192
+
193
+ ## CSS-only usage
194
+
195
+ Most of the design system works without JavaScript. Apply utility and component classes directly.
196
+
197
+ ### Grid layout
198
+
199
+ ```html
200
+ <div class="dga-container">
201
+ <div class="dga-row">
202
+ <div class="dga-col-12 dga-col-md-6 dga-col-lg-4">Column 1</div>
203
+ <div class="dga-col-12 dga-col-md-6 dga-col-lg-4">Column 2</div>
204
+ <div class="dga-col-12 dga-col-md-6 dga-col-lg-4">Column 3</div>
205
+ </div>
206
+ </div>
207
+ ```
208
+
209
+ ### Common utility prefixes
210
+
211
+ | Prefix | Examples |
212
+ |--------|----------|
213
+ | Layout | `dga-container`, `dga-row`, `dga-col-*`, `dga-d-flex`, `dga-gap-*` |
214
+ | Width | `dga-w-full`, `dga-w-50`, `dga-max-w-lg`, `dga-w-screen` |
215
+ | Height | `dga-h-full`, `dga-h-100`, `dga-min-h-screen`, `dga-h-4` |
216
+ | Spacing | `dga-p-*`, `dga-m-*`, `dga-py-*`, `dga-px-*` |
217
+ | Colors | `dga-bg-primary-500`, `dga-text-gray-700` |
218
+ | Typography | `dga-text-sm`, `dga-text-xl`, `dga-fw-bold`, `dga-display-md` |
219
+ | Radius | `dga-rounded-md`, `dga-rounded-lg` |
220
+ | Effects | `dga-shadow-xs`…`dga-shadow-3xl`, `dga-backdrop-blur-md` |
221
+ | Flex direction | `dga-flex-col` / `dga-flex-column`, `dga-flex-row` |
222
+
223
+ ### Included CSS components
224
+
225
+ These work with markup and classes only (no JS required):
226
+
227
+ - Buttons — `dga-btn`, `dga-btn-primary`, `dga-btn-neutral`, `dga-btn-subtle`, sizes `dga-btn-sm` / `dga-btn-md` / `dga-btn-lg`
228
+ - Cards — `dga-card`
229
+ - Forms `dga-input`, `dga-select`, `dga-textarea`, `dga-label`
230
+ - Links & tags — `dga-link`, `dga-tag`
231
+ - Tables — `dga-table`
232
+ - Breadcrumb, divider, avatar
233
+
234
+ For the full documentation index, see **[docs/README.md](./docs/README.md)**.
235
+
236
+ Quick links:
237
+ - [Documentation index](./docs/README.md)
238
+ - [Installation](./docs/getting-started/installation.md)
239
+ - [JavaScript API](./docs/getting-started/javascript-api.md)
240
+ - [Web Components](./docs/getting-started/web-components.md)
241
+ - [Components](./docs/README.md#components)
242
+ - [Grid](./docs/foundations/grid.md) · [Colors](./docs/foundations/colors.md)
243
+
244
+ ---
245
+
246
+ ## JavaScript components
247
+
248
+ Import from the main package entry:
249
+
250
+ ```js
251
+ import {
252
+ DGAAccordion,
253
+ DGAAlert,
254
+ DGAChart,
255
+ DGACodeSnippet,
256
+ DGAMenuDropDown,
257
+ DGAVerifyBar,
258
+ } from '@waaelg/dga-design-system';
259
+ ```
260
+
261
+ Importing the package also registers **web components** — prefer these in Vue/React:
262
+
263
+ | Web component | Legacy class |
264
+ |---------------|--------------|
265
+ | `<dga-alert>` | `DGAAlert` |
266
+ | `<dga-accordion>` + `<dga-accordion-item>` | `DGAAccordion` |
267
+ | `<dga-code-snippet>` | `DGACodeSnippet` |
268
+ | `<dga-pie-chart>` | `DGAChart` |
269
+ | `<dga-verify-bar>` | `DGAVerifyBar` |
270
+
271
+ See [Web Components](./docs/getting-started/web-components.md) for framework setup.
272
+
273
+ ### DGAAccordion (legacy)
274
+
275
+ Expands and collapses accordion panels. Supports click and keyboard (Enter / Space).
276
+
277
+ ```html
278
+ <div class="dga-acc" id="myAccordion">
279
+ <div class="dga-acc-item">
280
+ <button class="dga-acc-header" aria-expanded="false">
281
+ <span>Section title</span>
282
+ </button>
283
+ <div class="dga-acc-content">
284
+ <div class="dga-acc-body">Content goes here.</div>
285
+ </div>
286
+ </div>
287
+ </div>
288
+ ```
289
+
290
+ ```js
291
+ new DGAAccordion(document.getElementById('myAccordion'));
292
+ ```
293
+
294
+ ### DGAAlert (legacy)
295
+
296
+ Handles dismiss buttons on alerts. Requires `[data-alert-close]` on the close button.
297
+
298
+ ```html
299
+ <div class="dga-alert" data-variant="success-color">
300
+ <span class="dga-alert-icon" aria-hidden="true"></span>
301
+ <div class="dga-alert-content">
302
+ <h4 class="dga-alert-title">Success</h4>
303
+ <div class="dga-alert-body">Operation completed successfully.</div>
304
+ </div>
305
+ <button class="dga-alert-close" type="button" data-alert-close aria-label="Dismiss alert">×</button>
306
+ </div>
307
+ ```
308
+
309
+ ```js
310
+ new DGAAlert(); // listens on document by default
311
+ ```
312
+
313
+ **Variants:** `success-color`, `warning-color`, `destructive-color`, `info-color`, `neutral-color`, `success-white`, `warning-white`, `destructive-white`, `info-white`, `neutral-white`
314
+
315
+ ### DGAChart (legacy)
316
+
317
+ Renders a pie chart using a `conic-gradient` background.
318
+
319
+ ```html
320
+ <div id="myChart" class="dga-pie-chart" data-hole="false"></div>
321
+ ```
322
+
323
+ ```js
324
+ new DGAChart(document.getElementById('myChart'), [
325
+ { label: 'Item 1', from: '0%', to: '40%', color: 'var(--dga-primary-100)' },
326
+ { label: 'Item 2', from: '40%', to: '100%', color: 'var(--dga-gray-200)' },
327
+ ]);
328
+ ```
329
+
330
+ Set `data-hole="true"` on the element for a donut-style chart.
331
+
332
+ ### DGACodeSnippet (legacy)
333
+
334
+ Enables copy-to-clipboard on code snippet blocks.
335
+
336
+ ```js
337
+ new DGACodeSnippet(); // listens on document by default
338
+ ```
339
+
340
+ Copy buttons must use `.dga-code-snippet-inline__copy` or `.dga-code-snippet-multiline__copy`.
341
+
342
+ ### DGAMenuDropDown
343
+
344
+ Powers the responsive navbar with dropdown menus.
345
+
346
+ ```html
347
+ <nav class="dga-navbar" role="navigation">
348
+ <a class="dga-navbar-brand" href="#">Brand</a>
349
+ <ul class="dga-menu">
350
+ <li>
351
+ <a class="dga-menu-item dga-has-dropdown" href="#" role="button" aria-expanded="false" aria-haspopup="true">
352
+ Menu
353
+ </a>
354
+ <div class="dga-dropdown">
355
+ <div class="dga-dropdown-content">
356
+ <ul>
357
+ <li><a href="#">Link</a></li>
358
+ </ul>
359
+ </div>
360
+ </div>
361
+ </li>
362
+ </ul>
363
+ <button class="dga-navbar-toggler" aria-label="Toggle menu"></button>
364
+ </nav>
365
+ ```
366
+
367
+ ```js
368
+ const menu = new DGAMenuDropDown({
369
+ navbar: document.querySelector('.dga-navbar'),
370
+ });
371
+ ```
372
+
373
+ ### Web components
374
+
375
+ ```html
376
+ <dga-alert variant="success-color" title="Success" dismissible>Message</dga-alert>
377
+
378
+ <dga-accordion>
379
+ <dga-accordion-item title="Question">Answer</dga-accordion-item>
380
+ </dga-accordion>
381
+
382
+ <dga-code-snippet code="npm install @waaelg/dga-design-system"></dga-code-snippet>
383
+
384
+ <dga-pie-chart data='[{"label":"A","from":"0%","to":"100%","color":"primary-100"}]'></dga-pie-chart>
385
+
386
+ <dga-verify-bar domain=".edu.sa"></dga-verify-bar>
387
+ ```
388
+
389
+ ### DGAVerifyBar (legacy)
390
+
391
+ Controls the Saudi government verification bar (legacy markup with fixed element IDs).
392
+
393
+ Expected IDs: `dga-verify-bar`, `dga-verifyBtn`, `dga-verify-bar_content`.
394
+
395
+ ```js
396
+ const verifyBar = new DGAVerifyBar();
397
+ const menu = new DGAMenuDropDown();
398
+
399
+ // Optional: coordinate verify bar and navbar
400
+ verifyBar.menu = menu;
401
+ menu.verifyBar = verifyBar;
402
+ ```
403
+
404
+ | `<dga-verify-bar>` attribute | Default | Description |
405
+ |------------------------------|---------|-------------|
406
+ | `domain` | `.edu.sa` | Official domain suffix shown in the verify panel |
407
+ | `registration-number` | `20250105758` | DGA registration number |
408
+ | `registration-link` | DGA Raqmi URL | Link to the platform license page |
409
+
410
+ ---
411
+
412
+ ## RTL and Arabic
413
+
414
+ The design system targets Arabic government websites. Set `dir="rtl"` and `lang="ar"` on the `<html>` element for correct layout direction. The default font is **IBM Plex Sans Arabic**, loaded automatically with the stylesheet.
415
+
416
+ ---
417
+
418
+ ## What's included in the npm package
419
+
420
+ Only compiled files are published:
421
+
422
+ ```
423
+ node_modules/@waaelg/dga-design-system/
424
+ ├── dist/
425
+ │ ├── index.js # JavaScript components
426
+ │ ├── index.js.map
427
+ │ └── style.css # Compiled CSS
428
+ └── package.json
429
+ ```
430
+
431
+ SCSS source files are **not** included in the npm package. To customize variables or mixins, clone the [repository](https://github.com/waaelg/dga-design-system) and build locally.
432
+
433
+ ---
434
+
435
+ ## Local development (contributors)
436
+
437
+ ```bash
438
+ git clone https://github.com/waaelg/dga-design-system.git
439
+ cd dga-design-system
440
+ npm install
441
+ npm run docs:dev # documentation at http://localhost:5173
442
+ npm run build # outputs dist/index.js and dist/style.css
443
+ ```
444
+
445
+ Documentation site (VitePress):
446
+
447
+ ```bash
448
+ npm run docs:dev # local docs
449
+ npm run docs:build # production build
450
+ ```
451
+
452
+ Documentation:
453
+
454
+ | File | Contents |
455
+ |------|----------|
456
+ | `docs/foundations/grid.md` | Grid, flexbox, layout |
457
+ | `docs/foundations/width-height.md` | Width & height utilities |
458
+ | `docs/foundations/colors.md` | Color tokens and utilities |
459
+ | `docs/foundations/radius.md` | Border radius utilities |
460
+
461
+ ---
462
+
463
+ ## Troubleshooting
464
+
465
+ **Styles not applied**
466
+ - Confirm `import '@waaelg/dga-design-system/style.css'` runs before your app renders.
467
+ - In plain HTML, verify the `<link>` path points to `dist/style.css`.
468
+
469
+ **Interactive component not working**
470
+ - Check that the required HTML structure and classes match the examples above.
471
+ - Ensure the matching JS class is instantiated after the DOM is ready.
472
+ - For alerts and code snippets, `new DGAAlert()` / `new DGACodeSnippet()` must run once.
473
+
474
+ **Navbar dropdown or verify bar issues**
475
+ - `DGAMenuDropDown` requires a `.dga-navbar` element with `.dga-menu` and `.dga-navbar-toggler`.
476
+ - `DGAVerifyBar` requires the legacy ID-based markup (`#dga-verify-bar`, etc.), or use `<dga-verify-bar>` instead.
477
+
478
+ **Vite: `does not provide an export named 'DGAAlert'`**
479
+ - Stale Vite pre-bundle in `node_modules/.vite/deps/`. Clear it and restart:
480
+ ```bash
481
+ rm -rf node_modules/.vite
482
+ npm run dev
483
+ ```
484
+ - Or add to `vite.config.js`:
485
+ ```js
486
+ export default defineConfig({
487
+ optimizeDeps: {
488
+ exclude: ['@waaelg/dga-design-system'],
489
+ },
490
+ })
491
+ ```
492
+
493
+ ---
494
+
495
+ ## Skills for AI coding tools
496
+
497
+ This repo has three parts: the **package** (`src/`, compiled to `dist/`), the **docs site** (`docs/`, VitePress), and **`skills/`** — Claude Skills that teach an AI coding assistant the actual class names, component patterns, and JS API documented above, grounded in `docs/` rather than guessed.
498
+
499
+ | Skill | Covers |
500
+ |-------|--------|
501
+ | [`dga-vue-component`](skills/dga-vue-component/SKILL.md) | Generating Vue 3 SFCs styled with DGA |
502
+ | [`dga-web-components`](skills/dga-web-components/SKILL.md) | `<dga-*>` elements and the JS class API outside Vue (plain HTML, Razor, PHP) |
503
+ | [`dga-foundations`](skills/dga-foundations/SKILL.md) | Color/spacing/typography/radius/grid utility reference |
504
+
505
+ If you clone this repo with **Claude Code**, these are picked up automatically via the `.claude/skills` symlink — no setup needed. Any other AI tool can be pointed directly at the `skills/<name>/SKILL.md` files.
506
+
507
+ ---
508
+
509
+ ## License
510
+
511
+ MIT — Wael Alghamdi