@waaelg/dga-design-system 0.4.2

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.
@@ -0,0 +1,204 @@
1
+ # JavaScript API
2
+
3
+ The package exports **plain JavaScript classes**, not Vue/React components.
4
+
5
+ ```js
6
+ import {
7
+ DGAAccordion,
8
+ DGAAlert,
9
+ DGAChart,
10
+ DGACodeSnippet,
11
+ DGAMenuDropDown,
12
+ DGAVerifyBar,
13
+ } from '@waaelg/dga-design-on-sass'
14
+ ```
15
+
16
+ Importing the main entry also registers these custom elements:
17
+
18
+ | Element | Legacy class |
19
+ |---------|--------------|
20
+ | `<dga-alert>` | `DGAAlert` |
21
+ | `<dga-accordion>` | `DGAAccordion` |
22
+ | `<dga-code-snippet>` | `DGACodeSnippet` |
23
+ | `<dga-pie-chart>` | `DGAChart` |
24
+ | `<dga-verify-bar>` | `DGAVerifyBar` |
25
+
26
+ See [Web Components](./web-components.md) for plain HTML, ASP.NET, and framework usage.
27
+
28
+ ---
29
+
30
+ ## Important rules
31
+
32
+ 1. **Use HTML + `dga-*` classes** or **`<dga-*>` web components** — do not use `<DGAAlert />` in Vue/React.
33
+ 2. **Call `new ClassName()`** after the DOM is ready (legacy markup only).
34
+ 3. **CSS-only components** (button, card, forms) need no JavaScript.
35
+
36
+ ---
37
+
38
+ ## DGAAccordion
39
+
40
+ **Web component:** `<dga-accordion>` with `<dga-accordion-item>` — no init required.
41
+
42
+ **Legacy:** root element with class `dga-acc`
43
+
44
+ ```html
45
+ <div class="dga-acc" id="faq">
46
+ <div class="dga-acc-item">
47
+ <button class="dga-acc-header" aria-expanded="false">
48
+ <span>Question</span>
49
+ </button>
50
+ <div class="dga-acc-content">
51
+ <div class="dga-acc-body">Answer</div>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ ```
56
+
57
+ ```js
58
+ new DGAAccordion(document.getElementById('faq'))
59
+ ```
60
+
61
+ Supports click and keyboard (Enter / Space).
62
+
63
+ ---
64
+
65
+ ## DGAAlert
66
+
67
+ **Web component:** `<dga-alert variant="info-color" dismissible>` — no init required.
68
+
69
+ **Legacy:** `.dga-alert` and close button with `[data-alert-close]`
70
+
71
+ ```js
72
+ new DGAAlert() // listens on document
73
+ ```
74
+
75
+ See [Alert component](../components/alert.md).
76
+
77
+ ---
78
+
79
+ ## DGAChart
80
+
81
+ **Web component:** `<dga-pie-chart data='[...]'>` — no init required.
82
+
83
+ **Legacy:** element with class `dga-pie-chart`
84
+
85
+ ```html
86
+ <div id="chart" class="dga-pie-chart" data-hole="false"></div>
87
+ ```
88
+
89
+ ```js
90
+ new DGAChart(document.getElementById('chart'), [
91
+ { label: 'Item 1', from: '0%', to: '40%', color: 'var(--dga-primary-100)' },
92
+ { label: 'Item 2', from: '40%', to: '100%', color: 'var(--dga-gray-200)' },
93
+ ])
94
+ ```
95
+
96
+ Set `data-hole="true"` for donut style.
97
+
98
+ ---
99
+
100
+ ## DGACodeSnippet
101
+
102
+ **Web component:** `<dga-code-snippet code="...">` — no init required.
103
+
104
+ **Legacy:** initialize once for copy on manual markup:
105
+
106
+ ```js
107
+ new DGACodeSnippet()
108
+ ```
109
+
110
+ Copy buttons: `.dga-code-snippet-inline__copy` or `.dga-code-snippet-multiline__copy`
111
+
112
+ ---
113
+
114
+ ## DGAMenuDropDown
115
+
116
+ **Requires:** `.dga-navbar` with `.dga-menu` and `.dga-navbar-toggler`
117
+
118
+ ```js
119
+ new DGAMenuDropDown({ navbar: document.querySelector('.dga-navbar') })
120
+ ```
121
+
122
+ ---
123
+
124
+ ## DGAVerifyBar
125
+
126
+ **Requires:** legacy IDs: `#dga-verify-bar`, `#dga-verifyBtn`, `#dga-verify-bar_content`
127
+
128
+ ```js
129
+ const verifyBar = new DGAVerifyBar()
130
+ const menu = new DGAMenuDropDown()
131
+ verifyBar.menu = menu
132
+ menu.verifyBar = verifyBar
133
+ ```
134
+
135
+ **Alternative:** use `<dga-verify-bar>` web component (no manual init).
136
+
137
+ ---
138
+
139
+ ## Web components summary
140
+
141
+ ```html
142
+ <dga-alert variant="success-color" title="Done" dismissible>Message</dga-alert>
143
+
144
+ <dga-accordion>
145
+ <dga-accordion-item title="Question">Answer</dga-accordion-item>
146
+ </dga-accordion>
147
+
148
+ <dga-code-snippet code="npm install @waaelg/dga-design-on-sass"></dga-code-snippet>
149
+
150
+ <dga-pie-chart data='[{"label":"A","from":"0%","to":"50%","color":"primary-100"}]'></dga-pie-chart>
151
+
152
+ <dga-verify-bar></dga-verify-bar>
153
+ ```
154
+
155
+ Full guide: [Web Components](./web-components.md).
156
+
157
+ ---
158
+
159
+ ## Vue example (legacy)
160
+
161
+ ```vue
162
+ <script setup>
163
+ import { onMounted, onUnmounted } from 'vue'
164
+ import { DGAAlert } from '@waaelg/dga-design-on-sass'
165
+
166
+ let alertInstance
167
+
168
+ onMounted(() => {
169
+ alertInstance = new DGAAlert()
170
+ })
171
+
172
+ onUnmounted(() => {
173
+ alertInstance?.destroy()
174
+ })
175
+ </script>
176
+
177
+ <template>
178
+ <div class="dga-alert" data-variant="success-color">
179
+ <!-- ... -->
180
+ <button class="dga-alert-close" data-alert-close aria-label="Close">×</button>
181
+ </div>
182
+ </template>
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Vite troubleshooting
188
+
189
+ If you see `does not provide an export named 'DGAAlert'`:
190
+
191
+ ```bash
192
+ rm -rf node_modules/.vite
193
+ npm run dev
194
+ ```
195
+
196
+ See [Installation](./installation.md#vite--vue).
197
+
198
+ ---
199
+
200
+ ## Related
201
+
202
+ - [Web Components](./web-components.md)
203
+ - [Installation](./installation.md)
204
+ - [Components index](../README.md#components)
@@ -0,0 +1,89 @@
1
+ # RTL & Arabic
2
+
3
+ The DGA design system targets Saudi government websites. Arabic and RTL are first-class.
4
+
5
+ ---
6
+
7
+ ## HTML setup
8
+
9
+ ```html
10
+ <html lang="ar" dir="rtl">
11
+ ```
12
+
13
+ | Attribute | Value | Purpose |
14
+ |-----------|-------|---------|
15
+ | `lang` | `ar` | Arabic language |
16
+ | `dir` | `rtl` | Right-to-left layout |
17
+
18
+ For bilingual pages, set `dir` on a wrapper instead of `<html>`:
19
+
20
+ ```html
21
+ <div dir="rtl" lang="ar">
22
+ <!-- Arabic content -->
23
+ </div>
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Font
29
+
30
+ **IBM Plex Sans Arabic** loads automatically with the stylesheet:
31
+
32
+ ```scss
33
+ body {
34
+ font-family: "IBM Plex Sans Arabic", sans-serif;
35
+ }
36
+ ```
37
+
38
+ No extra font import is required when using `@waaelg/dga-design-on-sass/style.css`.
39
+
40
+ ---
41
+
42
+ ## Logical properties
43
+
44
+ Components use logical CSS where possible (`border-inline-start`, `text-align: start`) so they work in both RTL and LTR.
45
+
46
+ | Physical | Logical (preferred) |
47
+ |----------|---------------------|
48
+ | `dga-text-left` | `dga-text-start` |
49
+ | `dga-text-right` | `dga-text-end` |
50
+ | `dga-pl-*` | works; axis follows direction |
51
+
52
+ ---
53
+
54
+ ## Button icons
55
+
56
+ Use `dga-btn__icon` for icons inside buttons. In RTL, icon placement follows flex direction.
57
+
58
+ ```html
59
+ <button class="dga-btn dga-btn-primary dga-btn-md">
60
+ الاجراء الرئيسي
61
+ <img class="dga-btn__icon" src="arrow.svg" alt="" />
62
+ </button>
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Grid and flex
68
+
69
+ Grid and flex utilities are direction-aware when using `start` / `end`:
70
+
71
+ ```html
72
+ <div class="dga-d-flex dga-justify-content-start dga-gap-4">
73
+ <button class="dga-btn dga-btn-primary">زر</button>
74
+ </div>
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Verify bar
80
+
81
+ The Saudi government verification bar is Arabic by default. Use `<dga-verify-bar>` or the verify bar markup from `verify-bar.html`.
82
+
83
+ ---
84
+
85
+ ## Related
86
+
87
+ - [Installation](./installation.md)
88
+ - [Typography](../foundations/typography.md)
89
+ - [Grid](../foundations/grid.md)
@@ -0,0 +1,134 @@
1
+ # Web Components
2
+
3
+ Web components are **standard HTML** — they work anywhere you can write markup and load a script: static HTML, **ASP.NET Core (`.cshtml`)**, PHP, Blazor (with script import), Vue, React, etc.
4
+
5
+ Importing `@waaelg/dga-design-on-sass` registers these custom elements:
6
+
7
+ | Element | Legacy alternative |
8
+ |---------|-------------------|
9
+ | `<dga-alert>` | `DGAAlert` + HTML markup |
10
+ | `<dga-accordion>` + `<dga-accordion-item>` | `DGAAccordion` + HTML markup |
11
+ | `<dga-code-snippet>` | `DGACodeSnippet` + HTML markup |
12
+ | `<dga-pie-chart>` | `DGAChart` + HTML markup |
13
+ | `<dga-verify-bar>` | `DGAVerifyBar` + fixed IDs |
14
+
15
+ No manual `customElements.define` or `new ClassName()` is required.
16
+
17
+ ---
18
+
19
+ ## Plain HTML
20
+
21
+ ```html
22
+ <!DOCTYPE html>
23
+ <html lang="ar" dir="rtl">
24
+ <head>
25
+ <link rel="stylesheet" href="./node_modules/@waaelg/dga-design-on-sass/dist/style.css" />
26
+ </head>
27
+ <body>
28
+ <dga-alert variant="success-color" title="نجاح" dismissible>
29
+ تمت العملية بنجاح
30
+ </dga-alert>
31
+
32
+ <script type="module">
33
+ import './node_modules/@waaelg/dga-design-on-sass/dist/index.js'
34
+ </script>
35
+ </body>
36
+ </html>
37
+ ```
38
+
39
+ ---
40
+
41
+ ## ASP.NET Core (Razor / `.cshtml`)
42
+
43
+ Copy `dist/style.css` and `dist/index.js` into `wwwroot/lib/dga/` (or reference them from `node_modules` via LibMan / build step).
44
+
45
+ **`_Layout.cshtml`**
46
+
47
+ ```html
48
+ <link rel="stylesheet" href="~/lib/dga/style.css" asp-append-version="true" />
49
+ <script type="module" src="~/lib/dga/index.js" asp-append-version="true"></script>
50
+ ```
51
+
52
+ **View (e.g. `Index.cshtml`)**
53
+
54
+ ```html
55
+ <dga-alert variant="success-color" title="@Model.Title" dismissible>
56
+ @Model.Message
57
+ </dga-alert>
58
+
59
+ <dga-accordion>
60
+ <dga-accordion-item title="السؤال الأول">
61
+ @Html.Raw(Model.FaqAnswer)
62
+ </dga-accordion-item>
63
+ </dga-accordion>
64
+ ```
65
+
66
+ Custom element tag names are lowercase in HTML — Razor outputs them like any other markup. No Vue/React setup needed.
67
+
68
+ For `dga-pie-chart`, pass JSON in the `data` attribute (escape quotes in Razor or build the attribute server-side).
69
+
70
+ ---
71
+
72
+ ## Bundlers (Vite, webpack, etc.)
73
+
74
+ ```js
75
+ import '@waaelg/dga-design-on-sass/style.css'
76
+ import '@waaelg/dga-design-on-sass'
77
+ ```
78
+
79
+ Then use `<dga-alert>`, `<dga-accordion>`, etc. in your templates.
80
+
81
+ ---
82
+
83
+ ## Framework notes (Vue / React)
84
+
85
+ These are **not** Vue or React components — do not import them as `<DGAAlert />`. Use the HTML tags directly after importing the package.
86
+
87
+ **Vue 3** — if the compiler warns about unknown tags:
88
+
89
+ ```js
90
+ // vite.config.js
91
+ export default defineConfig({
92
+ vue: {
93
+ compilerOptions: {
94
+ isCustomElement: (tag) => tag.startsWith('dga-'),
95
+ },
96
+ },
97
+ })
98
+ ```
99
+
100
+ **React** — use lowercase tag names in JSX. TypeScript may need `declare global` for `dga-*` intrinsic elements.
101
+
102
+ Framework-specific examples: [Installation](./installation.md).
103
+
104
+ ---
105
+
106
+ ## Events
107
+
108
+ | Element | Event | When |
109
+ |---------|-------|------|
110
+ | `<dga-alert>` | `dga-alert-dismiss` | User clicks dismiss |
111
+ | `<dga-code-snippet>` | `dga-code-copy` | Copy succeeds |
112
+
113
+ ```js
114
+ document.querySelector('dga-alert')?.addEventListener('dga-alert-dismiss', () => {
115
+ console.log('Alert dismissed')
116
+ })
117
+ ```
118
+
119
+ ---
120
+
121
+ ## When to use legacy classes
122
+
123
+ - Existing HTML with `dga-*` classes already in place
124
+ - Multi-tab code snippets with custom tab logic
125
+ - Verify bar integrated with legacy navbar IDs
126
+
127
+ Component docs describe both options: [Alert](../components/alert.md), [Accordion](../components/accordion.md), [Code snippet](../components/code-snippet.md), [Pie chart](../components/chart.md), [Verify bar](../components/verify-bar.md).
128
+
129
+ ---
130
+
131
+ ## Related
132
+
133
+ - [Installation](./installation.md)
134
+ - [JavaScript API](./javascript-api.md)
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@waaelg/dga-design-system",
3
+ "version": "0.4.2",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./dist/index.js",
7
+ "./style.css": "./dist/style.css"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "docs"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/waaelg/dga-design-system.git"
17
+ },
18
+ "scripts": {
19
+ "dev": "vite",
20
+ "build": "vite build",
21
+ "preview": "vite preview"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^24.9.1",
25
+ "sass": "^1.93.2",
26
+ "vite": "^7.1.7"
27
+ },
28
+ "dependencies": {
29
+ "@popperjs/core": "^2.11.8",
30
+ "@tailwindcss/vite": "^4.1.16",
31
+ "tailwindcss": "^4.1.16"
32
+ },
33
+ "keywords": [
34
+ "dga",
35
+ "saudi",
36
+ "design-system",
37
+ "sass"
38
+ ],
39
+ "author": "Wael Alghamdi",
40
+ "license": "MIT"
41
+ }