@natachah/vanilla-frontend 0.1.5 → 0.1.7

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.
@@ -96,6 +96,10 @@
96
96
  --anchor-hover-color
97
97
  --anchor-active-color
98
98
  --anchor-disabled-opacity
99
+ --anchor-focus-size
100
+ --anchor-focus-style
101
+ --anchor-focus-color
102
+ --anchor-focus-offset
99
103
  </doc-code>
100
104
  </div>
101
105
 
@@ -151,7 +151,7 @@
151
151
  </doc-code>
152
152
  <doc-code id="scss" data-type="scss" role="tabpanel">
153
153
  $outline-variations: (
154
- card
154
+ card
155
155
  );
156
156
  </doc-code>
157
157
  </div>
@@ -176,7 +176,7 @@
176
176
  </doc-code>
177
177
  <doc-code id="scss" data-type="scss" role="tabpanel">
178
178
  $color-variations: (
179
- card: (primary)
179
+ card: (primary)
180
180
  );
181
181
  </doc-code>
182
182
  </div>
@@ -27,7 +27,7 @@
27
27
  <doc-demo>
28
28
  <button aria-controls="demoDialog">Open the dialog</button>
29
29
  <dialog id="demoDialog" class="demo-dialog">
30
- <h3>Hey this is a dialog as non-modal !</h3>
30
+ <h3 tabindex="0">Hey this is a dialog as non-modal !</h3>
31
31
  <p>Hello there !</p>
32
32
  <button data-dialog-close>Close the dialog</button>
33
33
  </dialog>
@@ -82,6 +82,8 @@
82
82
  </doc-code>
83
83
  </div>
84
84
 
85
+ <blockquote class="note">Add a <code>tabindex="0"</code> to the heading to focus on it when opened !</blockquote>
86
+
85
87
  <p>To work properly you must have a <code>&lt;button&gt;</code> in your page with the attribute <code>aria-controls=&quot;IdOfDialogToOpen&quot;</code> that will open the dialog.</p>
86
88
  <p>And inside your <code>&lt;dialog&gt;</code> you should have a <code>&lt;button&gt;</code> with the attribute <code>data-dialog-close</code> to close the dialog.</p>
87
89
 
@@ -92,7 +94,7 @@
92
94
  <doc-demo>
93
95
  <button aria-controls="demoDialogLayout">Open the dialog</button>
94
96
  <dialog id="demoDialogLayout" class="demo-dialog" aria-modal="true">
95
- <header>This is a header</header>
97
+ <header tabindex="0">This is a header</header>
96
98
  <div>
97
99
  <p>This is the content</p>
98
100
  <p>This dialog is a modal</p>
@@ -104,7 +106,7 @@
104
106
 
105
107
  <doc-code>
106
108
  <dialog id="myDialog" class="demo-dialog" aria-modal="true">
107
- <header>This is a header</header>
109
+ <header tabindex="0">This is a header</header>
108
110
  <div>
109
111
  <p>This is the content</p>
110
112
  <button data-dialog-close>Close</button>
@@ -182,11 +184,11 @@
182
184
  <doc-code id="js" data-type="js" role="tabpanel">
183
185
  const demoDialogFormJS = document.getElementById('myDialog')
184
186
  if (demoDialogFormJS) {
185
- new Dialog(demoDialogFormJS)
186
- demoDialogFormJS.addEventListener('dialog:submited', (e) => {
187
- const value = e.detail.form.querySelector('input').value
188
- document.getElementById('favorite').innerText = value
189
- })
187
+ new Dialog(demoDialogFormJS)
188
+ demoDialogFormJS.addEventListener('dialog:submited', (e) => {
189
+ const value = e.detail.form.querySelector('input').value
190
+ document.getElementById('favorite').innerText = value
191
+ })
190
192
  }
191
193
  </doc-code>
192
194
  </div>
@@ -316,13 +318,13 @@
316
318
  <doc-code data-type="js">
317
319
  // E.G. basic opening
318
320
  document.getElementById('myDialogID').addEventListener('dialog:opening', () => {
319
- console.log('The dialog is opening')
321
+ console.log('The dialog is opening')
320
322
  })
321
323
 
322
324
  // E.G. with form value
323
325
  document.getElementById('myDialogID').addEventListener('dialog:submited', (e) => {
324
- const theHTMLForm = e.detail.form
325
- ...
326
+ const theHTMLForm = e.detail.form
327
+ ...
326
328
  })
327
329
  </doc-code>
328
330
 
@@ -0,0 +1,80 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Documentations: Javascript > Drawer</title>
8
+ </head>
9
+
10
+ <body data-preload>
11
+ <doc-layout>
12
+
13
+ <h1>Drawer</h1>
14
+ <p>The drawer component make you able to toggle a drawer with a button and resize window.</p>
15
+
16
+ <p>You can use the classes <code>.drawer</code>, <code>.drawer-button</code> and the id <code>backdrop</code> to quickly design the drawer with some nice animations</p>
17
+
18
+ <div class="code-group">
19
+ <div role="tablist">
20
+ <button role="tab" aria-controls="html">HTML</button>
21
+ <button role="tab" aria-controls="scss">SCSS</button>
22
+ <button role="tab" aria-controls="css">CSS</button>
23
+ <button role="tab" aria-controls="js">JS</button>
24
+ </div>
25
+ <doc-code id="html" data-type="html" role="tabpanel">
26
+ <div id="backdrop"></div>
27
+ <button class="drawer-button" aria-expanded="false" aria-pressed="false" aria-controls="drawer" aria-label="Toggle the drawer">
28
+ <svg viewbox="0 0 100 100" width="100%">
29
+ <rect width="100" height="10" x="0" y="10" rx="0"></rect>
30
+ <rect width="100" height="10" x="0" y="45" rx="0"></rect>
31
+ <rect width="100" height="10" x="0" y="80" rx="0"></rect>
32
+ </svg>
33
+ </button>
34
+ <div id="drawer" class="drawer" tabindex="0" hidden>
35
+ My awsome drawer !
36
+ </div>
37
+ </doc-code>
38
+ <doc-code id="scss" data-type="scss" role="tabpanel">
39
+ @use '@natachah/vanilla-frontend/scss/components/drawer';
40
+ </doc-code>
41
+ <doc-code id="css" data-type="css" role="tabpanel">
42
+ --drawer-display
43
+ --drawer-background
44
+ --drawer-index
45
+ --drawer-position
46
+ --drawer-width
47
+ --drawer-height
48
+ --drawer-max-width
49
+ --drawer-max-height
50
+ --drawer-origin
51
+ --drawer-animation
52
+ --drawer-trasnform
53
+ --drawer-backdrop-color
54
+ --drawer-backdrop-filter
55
+ --svg-line-size
56
+ </doc-code>
57
+ <doc-code id="js" data-type="js" role="tabpanel">
58
+ import Drawer from '@natachah/vanilla-frontend/js/utilities/_drawer.js'
59
+ const drawer = document.getElementById('drawer')
60
+ if (drawer) new Drawer(drawer, { breakpoint : 960 })
61
+ </doc-code>
62
+ </div>
63
+
64
+ <blockquote class="note">The <code>#backdrop</code> must be a child of the <code>&lt;body&gt;</code> ! <br> And the default CSS breakpoint to view the backdrop is 960px</blockquote>
65
+
66
+ <h2>Javascript</h2>
67
+ <p>This component is mostly in javascript, to use it you must import the javascript file and create a new Drawer object.</p>
68
+ <p>You can customize the breakpoint when initiate the component.</p>
69
+ <p>You can have a <b>Backdrop</b> if you want to make it more like a drawer opening on the front of the content.</p>
70
+
71
+ <blockquote>
72
+ <p>Main use case are sidebar menu or main navigation menu.</p>
73
+ <p>This documentation use the drawer as an exemple for the sidebar on the left !</p>
74
+ </blockquote>
75
+
76
+ </doc-layout>
77
+ <script type="module" src="/main.js"></script>
78
+ </body>
79
+
80
+ </html>
@@ -126,7 +126,7 @@
126
126
  </doc-code>
127
127
  <doc-code id="scss" data-type="scss" role="tabpanel">
128
128
  $outline-variations: (
129
- list
129
+ list
130
130
  );
131
131
  </doc-code>
132
132
  </div>
@@ -161,7 +161,7 @@
161
161
  </doc-code>
162
162
  <doc-code id="scss" data-type="scss" role="tabpanel">
163
163
  $color-variations: (
164
- list: (primary)
164
+ list: (primary)
165
165
  );
166
166
  </doc-code>
167
167
  </div>
@@ -14,10 +14,10 @@
14
14
  <p>The scroll component make you able to add some <code>&lt;button&gt;</code> to go on the top or bottom of an element.</p>
15
15
  <doc-demo>
16
16
  <nav id="demoScrollNav">
17
- <ul>
18
- <li><a href="#target1" aria-current="location">One</a></li>
19
- <li><a href="#target2">Two</a></li>
20
- <li><a href="#target3">Three</a></li>
17
+ <ul class="list">
18
+ <li><a role="button" href="#target1" aria-current="location">One</a></li>
19
+ <li><a role="button" href="#target2">Two</a></li>
20
+ <li><a role="button" href="#target3">Three</a></li>
21
21
  <li><button data-scroll-bottom="demoScrollSpy">Scroll to the bottom</button></li>
22
22
  <li><button data-scroll-top="demoScrollSpy">Scroll to the top</button></li>
23
23
  </ul>
@@ -76,8 +76,8 @@
76
76
  <doc-code data-type="js">
77
77
  const myPanel = document.getElementById('myPanel')
78
78
  myPanel.addEventListener('tabpanel:changed', (e) => {
79
- const thecurrentButton = e.detail.current
80
- console.log('It has changed !')
79
+ const thecurrentButton = e.detail.current
80
+ console.log('It has changed !')
81
81
  })
82
82
  </doc-code>
83
83
 
@@ -15,7 +15,7 @@
15
15
  <p>The button must have an <code>aria-controls=&quot;IdOfElement&quot;</code>, an <code>aria-expanded</code> and a <code>aria-pressed</code> attributes.</p>
16
16
  <doc-demo>
17
17
  <button class="demo-toggle" aria-controls="collapse" aria-expanded="false" aria-pressed="false">Toggle</button>
18
- <div id="collapse" hidden>
18
+ <div id="collapse" tabindex="0" hidden>
19
19
  Hello there !
20
20
  </div>
21
21
  </doc-demo>
@@ -27,7 +27,7 @@
27
27
  </div>
28
28
  <doc-code id="html" data-type="html" role="tabpanel">
29
29
  <button id="toggle" aria-controls="collapse" aria-expanded="false" aria-pressed="false">Toggle</button>
30
- <div id="collapse" hidden>
30
+ <div id="collapse" tabindex="0" hidden>
31
31
  Hello there !
32
32
  </div>
33
33
  </doc-code>
@@ -179,7 +179,7 @@
179
179
  <doc-code data-type="js">
180
180
  const myToggle = document.getElementById('myToggle')
181
181
  myToggle.addEventListener('toggle:changed', () => {
182
- console.log('It has changed !')
182
+ console.log('It has changed !')
183
183
  })
184
184
  </doc-code>
185
185
 
@@ -24,13 +24,13 @@
24
24
  <button role="link" aria-controls="treelist" aria-expanded="false">
25
25
  1: Inventore, perspiciatis (Open)
26
26
  </button>
27
- <ul id="treelist" hidden>
27
+ <ul id="treelist" tabindex="0" hidden>
28
28
  <li>2: Lorem</li>
29
29
  <li>
30
30
  <button role="link" aria-controls="subtreelist" aria-expanded="false">
31
31
  2: Adipisci (Open)
32
32
  </button>
33
- <ul id="subtreelist" hidden>
33
+ <ul id="subtreelist" tabindex="0" hidden>
34
34
  <li>3: Lorem</li>
35
35
  <li>3: Adipisci</li>
36
36
  <li>3: Facilis</li>
@@ -55,13 +55,13 @@
55
55
  <button role="link" aria-controls="treelist" aria-expanded="false">
56
56
  1: Inventore, perspiciatis (Open)
57
57
  </button>
58
- <ul id="treelist" hidden>
58
+ <ul id="treelist" tabindex="0" hidden>
59
59
  <li>2: Lorem</li>
60
60
  <li>
61
61
  <button role="link" aria-controls="subtreelist" aria-expanded="false">
62
62
  2: Adipisci (Open)
63
63
  </button>
64
- <ul id="subtreelist" hidden>
64
+ <ul id="subtreelist" tabindex="0" hidden>
65
65
  <li>3: Lorem</li>
66
66
  <li>3: Adipisci</li>
67
67
  <li>3: Facilis</li>
@@ -94,13 +94,13 @@
94
94
  <tr aria-level="1" aria-expanded="false" aria-controls="row1 row2 row3">
95
95
  <td>1: Cum, dolorum (open me)</td>
96
96
  </tr>
97
- <tr id="row1" aria-level="2" hidden>
97
+ <tr id="row1" aria-level="2" tabindex="0" hidden>
98
98
  <td>2: Lorem</td>
99
99
  </tr>
100
100
  <tr id="row2" aria-level="2" aria-expanded="false" aria-controls="row2-1 row2-2" hidden>
101
101
  <td>2: Quo (open me)</td>
102
102
  </tr>
103
- <tr id="row2-1" aria-level="3" hidden>
103
+ <tr id="row2-1" aria-level="3" tabindex="0" hidden>
104
104
  <td>2.1: Quo</td>
105
105
  </tr>
106
106
  <tr id="row2-2" aria-level="3" hidden>
@@ -125,13 +125,13 @@
125
125
  <tr aria-level="1" aria-expanded="false" aria-controls="row1 row2 row3">
126
126
  <td>1: Cum, dolorum (open me)</td>
127
127
  </tr>
128
- <tr id="row1" aria-level="2" hidden>
128
+ <tr id="row1" aria-level="2" tabindex="0" hidden>
129
129
  <td>2: Lorem</td>
130
130
  </tr>
131
131
  <tr id="row2" aria-level="2" aria-expanded="false" aria-controls="row2-1 row2-2" hidden>
132
132
  <td>2: Quo (open me)</td>
133
133
  </tr>
134
- <tr id="row2-1" aria-level="3" hidden>
134
+ <tr id="row2-1" aria-level="3" tabindex="0" hidden>
135
135
  <td>2.1: Quo</td>
136
136
  </tr>
137
137
  <tr id="row2-2" aria-level="3" hidden>
@@ -159,15 +159,12 @@
159
159
  <tr aria-level="1" aria-expanded="false" aria-controls="rowExpandable">
160
160
  <td>
161
161
  <span data-handle="tree">
162
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
163
- <path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"></path>
164
- </svg>
165
162
  (open me)
166
163
  </span>
167
164
  </td>
168
165
  <td>1: Cum, dolorum</td>
169
166
  </tr>
170
- <tr id="rowExpandable" aria-level="2" hidden>
167
+ <tr id="rowExpandable" aria-level="2" tabindex="0" hidden>
171
168
  <td></td>
172
169
  <td>1.1: Lorem</td>
173
170
  </tr>
@@ -188,7 +185,7 @@
188
185
  </td>
189
186
  <td>1: Cum, dolorum</td>
190
187
  </tr>
191
- <tr id="rowExpandable" aria-level="2" hidden>
188
+ <tr id="rowExpandable" aria-level="2" tabindex="0" hidden>
192
189
  <td></td>
193
190
  <td>1.1: Lorem</td>
194
191
  </tr>
@@ -28,60 +28,69 @@
28
28
  <doc-code data-type="scss">
29
29
  :root {
30
30
 
31
- // Typography
32
- --font-size: 16px;
33
- --line-height: 1.5;
34
- --font-family: Arial;
35
- --font-weight: normal;
36
-
37
- --font-size-h1: 2.25em; // 36px
38
- --font-size-h2: 2.00em; // 32px
39
- --font-size-h3: 1.75em; // 28px
40
- --font-size-h4: 1.50em; // 24px
41
- --font-size-h5: 1.25em; // 20px
42
- --font-size-h6: 1.125em; // 18px
43
- --font-size-large: 1.125em; // 18px
44
- --font-size-small: .875em; // 14px
45
-
46
- // Anchor
47
- --decoration: none;
48
-
49
- // Layouts
50
- --padding-inline: .75em;
51
- --padding-block: .5em;
52
-
53
- // Border
54
- --border-size: 1px;
55
- --border-style: solid;
56
- --border-radius: .25rem;
57
-
58
- // Focus (outline)
59
- --focus-size: 3px;
60
- --focus-style: solid;
61
- --focus-offset: 0;
62
- --focus-opacity: 50%;
63
-
64
- // Hover (color-mix)
65
- --hover-color: black;
66
- --hover-percent: 5%;
67
-
68
- // Active (color-mix)
69
- --active-color: black;
70
- --active-percent: 10%;
71
-
72
- // Disabled
73
- --disabled-opacity: 50%;
74
-
75
- // Colors
76
- --color-body: white;
77
- --color-font: black;
78
- --color-primary: #B790E5;
79
- --color-error: #DC3030;
80
- --color-success: #008A00;
81
- --color-warning: #FFA500;
82
-
83
- // Contrasts
84
- --color-warning-contrast: black;
31
+ // Typography
32
+ --font-size: 16px;
33
+ --line-height: 1.5;
34
+ --font-family: Arial;
35
+ --font-weight: normal;
36
+
37
+ --font-size-h1: 2.25em; // 36px
38
+ --font-size-h2: 2.00em; // 32px
39
+ --font-size-h3: 1.75em; // 28px
40
+ --font-size-h4: 1.50em; // 24px
41
+ --font-size-h5: 1.25em; // 20px
42
+ --font-size-h6: 1.125em; // 18px
43
+ --font-size-large: 1.125em; // 18px
44
+ --font-size-small: .875em; // 14px
45
+
46
+ // Anchor
47
+ --decoration: none;
48
+
49
+ // Layouts
50
+ --padding-inline: .75em;
51
+ --padding-block: .5em;
52
+
53
+ // Border
54
+ --border-size: 1px;
55
+ --border-style: solid;
56
+ --border-radius: .25rem;
57
+
58
+ // Focus (outline)
59
+ --focus-size: 3px;
60
+ --focus-style: solid;
61
+ --focus-offset: 0;
62
+ --focus-opacity: 50%;
63
+
64
+ // Hover (color-mix)
65
+ --hover-color: black;
66
+ --hover-percent: 5%;
67
+
68
+ // Active (color-mix)
69
+ --active-color: black;
70
+ --active-percent: 10%;
71
+
72
+ // Disabled
73
+ --disabled-opacity: 50%;
74
+
75
+ // Colors
76
+ --color-body: white;
77
+ --color-font: black;
78
+ --color-primary: #B790E5;
79
+ --color-error: #DC3030;
80
+ --color-success: #008A00;
81
+ --color-warning: #FFA500;
82
+
83
+ // Contrasts
84
+ --color-warning-contrast: black;
85
+
86
+ // Icons
87
+ --icon-date: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="black" viewBox="0 0 16 16"><path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z" /></svg>');
88
+ --icon-time: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71V3.5z" /><path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0z" /></svg>');
89
+ --icon-file: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z" /><path d="M7.646 1.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 2.707V11.5a.5.5 0 0 1-1 0V2.707L5.354 4.854a.5.5 0 1 1-.708-.708l3-3z" /></svg>');
90
+ --icon-select: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z" /></svg>');
91
+ --icon-radio: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="white" viewBox="0 0 16 16"><circle cx="8" cy="8" r="8" /></svg>');
92
+ --icon-check: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="white" viewBox="0 0 16 16"><path d="M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.267.267 0 0 1 .02-.022z" /></svg>');
93
+ --icon-switch: var(--icon-radio);
85
94
 
86
95
  }
87
96
  </doc-code>
@@ -129,28 +138,28 @@
129
138
  <doc-code data-type="scss">
130
139
  @forward '@natachah/vanilla-frontend/scss/abstracts/_options.scss' with (
131
140
 
132
- $colors: (
133
- primary,
134
- success,
135
- error,
136
- warning
137
- );
138
-
139
- $color-variations: (
140
- badge: $colors,
141
- button: $colors,
142
- card: $colors,
143
- disclosure: $colors,
144
- list: $colors
145
- );
146
-
147
- $outline-variations: (
148
- badge,
149
- button,
150
- card,
151
- disclosure,
152
- list
153
- );
141
+ $colors: (
142
+ primary,
143
+ success,
144
+ error,
145
+ warning
146
+ );
147
+
148
+ $color-variations: (
149
+ badge: $colors,
150
+ button: $colors,
151
+ card: $colors,
152
+ disclosure: $colors,
153
+ list: $colors
154
+ );
155
+
156
+ $outline-variations: (
157
+ badge,
158
+ button,
159
+ card,
160
+ disclosure,
161
+ list
162
+ );
154
163
  );
155
164
  </doc-code>
156
165
 
@@ -164,16 +173,16 @@
164
173
 
165
174
  <doc-code data-type="scss">
166
175
  @use '@natachah/vanilla-frontend/scss/abstracts/_default.scss' with (
167
- $item-properties: (
168
- color: var(--color-font),
169
- background: transparent,
170
- border-size: var(--border-size),
171
- border-style: var(--border-style),
172
- border-color: transparent,
173
- border-radius: var(--border-radius),
174
- padding-inline: var(--padding-inline),
175
- padding-block: var(--padding-block)
176
- );
176
+ $item-properties: (
177
+ color: var(--color-font),
178
+ background: transparent,
179
+ border-size: var(--border-size),
180
+ border-style: var(--border-style),
181
+ border-color: transparent,
182
+ border-radius: var(--border-radius),
183
+ padding-inline: var(--padding-inline),
184
+ padding-block: var(--padding-block)
185
+ );
177
186
  );
178
187
  </doc-code>
179
188
 
@@ -80,6 +80,7 @@
80
80
  import Consent from "@natachah/vanilla-frontend/js/_consent"
81
81
  import Dialog from "@natachah/vanilla-frontend/js/_dialog"
82
82
  import Dropdown from "@natachah/vanilla-frontend/js/_dropdown"
83
+ import Drawer from "@natachah/vanilla-frontend/js/_drawer"
83
84
  import Scroll from "@natachah/vanilla-frontend/js/_scroll"
84
85
  import Slider from "@natachah/vanilla-frontend/js/_slider"
85
86
  import Sortable from "@natachah/vanilla-frontend/js/_sortable"
@@ -113,7 +113,7 @@
113
113
  </doc-code>
114
114
  <doc-code id="setting" data-type="scss" role="tabpanel">
115
115
  $outline-variations: (
116
- my-component-name
116
+ my-component-name
117
117
  );
118
118
  </doc-code>
119
119
  </div>
@@ -144,7 +144,7 @@
144
144
  </doc-code>
145
145
  <doc-code id="setting" data-type="scss" role="tabpanel">
146
146
  $color-variations: (
147
- my-component-name: (primary, other-color)
147
+ my-component-name: (primary, other-color)
148
148
  );
149
149
  </doc-code>
150
150
  </div>
@@ -185,9 +185,9 @@
185
185
  </doc-code>
186
186
  <doc-code id="scss" data-type="scss" role="tabpanel">
187
187
  @container (max-width:800px) {
188
- table {
189
- @include as-responsive-table()
190
- }
188
+ table {
189
+ @include as-responsive-table()
190
+ }
191
191
  }
192
192
  </doc-code>
193
193
  <doc-code id="css" data-type="css" role="tabpanel">
@@ -219,11 +219,11 @@
219
219
  </doc-code>
220
220
  <doc-code id="scss" data-type="scss" role="tabpanel">
221
221
  #wider {
222
- @include flex-grid-wider-column(3)
222
+ @include flex-grid-wider-column(3)
223
223
  }
224
224
 
225
225
  #offset {
226
- @include flex-grid-offset-column(2)
226
+ @include flex-grid-offset-column(2)
227
227
  }
228
228
  </doc-code>
229
229
  </div>
@@ -61,7 +61,7 @@ class DocCode extends HTMLElement {
61
61
  const type = this.getAttribute('data-type') ?? 'html'
62
62
 
63
63
  // Clean the code
64
- let content = type === 'html' ? this.innerHTML : this.textContent
64
+ let content = type === 'html' || type === 'scss' ? this.innerHTML : this.textContent
65
65
  var pattern = content.match(/\s*\n[\t\s]*/)
66
66
  content = content.replace(new RegExp(pattern, "g"), '\n').replaceAll('=""', '')
67
67
  content = content.trim()
@@ -4,7 +4,7 @@ class DocLayout extends HTMLElement {
4
4
  this.innerHTML = `
5
5
  <div id="backdrop"></div>
6
6
  <header>
7
- <button aria-expanded="false" aria-pressed="false" aria-controls="sidebar" aria-label="Toggle the sidebar navigation">
7
+ <button class="drawer-button" aria-expanded="false" aria-pressed="false" aria-controls="sidebar" aria-label="Toggle the sidebar navigation">
8
8
  <svg viewbox="0 0 100 100" width="100%">
9
9
  <rect width="100" height="10" x="0" y="10" rx="0"></rect>
10
10
  <rect width="100" height="10" x="0" y="45" rx="0"></rect>
@@ -18,7 +18,7 @@ class DocLayout extends HTMLElement {
18
18
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pin-angle" viewBox="0 0 16 16">
19
19
  <path d="M9.828.722a.5.5 0 0 1 .354.146l4.95 4.95a.5.5 0 0 1 0 .707c-.48.48-1.072.588-1.503.588-.177 0-.335-.018-.46-.039l-3.134 3.134a6 6 0 0 1 .16 1.013c.046.702-.032 1.687-.72 2.375a.5.5 0 0 1-.707 0l-2.829-2.828-3.182 3.182c-.195.195-1.219.902-1.414.707s.512-1.22.707-1.414l3.182-3.182-2.828-2.829a.5.5 0 0 1 0-.707c.688-.688 1.673-.767 2.375-.72a6 6 0 0 1 1.013.16l3.134-3.133a3 3 0 0 1-.04-.461c0-.43.108-1.022.589-1.503a.5.5 0 0 1 .353-.146m.122 2.112v-.002zm0-.002v.002a.5.5 0 0 1-.122.51L6.293 6.878a.5.5 0 0 1-.511.12H5.78l-.014-.004a5 5 0 0 0-.288-.076 5 5 0 0 0-.765-.116c-.422-.028-.836.008-1.175.15l5.51 5.509c.141-.34.177-.753.149-1.175a5 5 0 0 0-.192-1.054l-.004-.013v-.001a.5.5 0 0 1 .12-.512l3.536-3.535a.5.5 0 0 1 .532-.115l.096.022c.087.017.208.034.344.034q.172.002.343-.04L9.927 2.028q-.042.172-.04.343a1.8 1.8 0 0 0 .062.46z"/>
20
20
  </svg>
21
- 0.1.5
21
+ 0.1.7
22
22
  </span>
23
23
  </li>
24
24
  <li>
@@ -36,7 +36,7 @@ class DocLayout extends HTMLElement {
36
36
  </ul>
37
37
  </nav>
38
38
  </header>
39
- <aside id="sidebar" tabindex="0" hidden>
39
+ <aside id="sidebar" class="drawer" tabindex="0" hidden>
40
40
  <header>
41
41
  <a href="/index.html">
42
42
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-rocket" viewBox="0 0 16 16">
@@ -73,6 +73,7 @@ class DocLayout extends HTMLElement {
73
73
  <li><a href="/pages/components/card.html">Card</a></li>
74
74
  <li><a href="/pages/components/dialog.html">Dialog</a></li>
75
75
  <li><a href="/pages/components/disclosure.html">Disclosure</a></li>
76
+ <li><a href="/pages/components/drawer.html">Drawer</a></li>
76
77
  <li><a href="/pages/components/dropdown.html">Dropdown</a></li>
77
78
  <li><a href="/pages/components/form.html">Form</a></li>
78
79
  <li><a href="/pages/components/list.html">List</a></li>
@@ -88,7 +89,6 @@ class DocLayout extends HTMLElement {
88
89
  <li><a href="/pages/javascript/comfort.html">Comfort</a></li>
89
90
  <li><a href="/pages/javascript/consent.html">Consent</a></li>
90
91
  <li><a href="/pages/javascript/cookie.html">Cookie</a></li>
91
- <li><a href="/pages/javascript/drawer.html">Drawer</a></li>
92
92
  <li><a href="/pages/javascript/form.html">Form helper</a></li>
93
93
  <li><a href="/pages/javascript/scroll.html">Scroll</a></li>
94
94
  <li><a href="/pages/javascript/sortable.html">Sortable</a></li>
@@ -37,43 +37,6 @@ doc-layout {
37
37
  gap: 1rem;
38
38
  }
39
39
 
40
- // The open/close button for the sidebar
41
- > header button {
42
-
43
- rect {
44
- transition: y .25s ease-in-out .25s, rotate .25s ease-in-out, opacity 0ms .25s;
45
- transform-origin: center;
46
- }
47
-
48
- // Active
49
- &[aria-expanded=true] {
50
-
51
- // Define the rectangle transition for the reverse animation
52
- rect {
53
- transition: y .25s ease-in-out, rotate .25s ease-in-out .25s, opacity 0ms .25s;
54
- }
55
-
56
- // Remove the middle bar
57
- rect:not(:first-child, :last-child) {
58
- opacity: 0;
59
- }
60
-
61
- // Change the first bar
62
- rect:first-child {
63
- y: calc(50% - var(--svg-line-size, 10px) / 2);
64
- rotate: 45deg;
65
- }
66
-
67
- // Change the last bar
68
- rect:last-child {
69
- y: calc(50% - var(--svg-line-size, 10px) / 2);
70
- rotate: -45deg;
71
- }
72
-
73
- }
74
-
75
- }
76
-
77
40
  > main {
78
41
  grid-area: main;
79
42
  overflow-y: auto;
@@ -81,38 +44,14 @@ doc-layout {
81
44
 
82
45
  aside {
83
46
 
47
+ --drawer-display: grid;
48
+ --drawer-transform: translatex(-100%);
49
+
84
50
  // Set the grid for the sidebar based on the parent grid
85
51
  grid-area: aside;
86
- display: grid !important;
87
52
  grid-template-rows: subgrid;
88
53
  grid-template-areas: "header" "main" "footer";
89
54
 
90
- // Make the sidebar as stiky for mobile
91
- position: sticky;
92
- z-index: 2;
93
- top: 0;
94
- width: 320px;
95
- max-width: 80vw;
96
- height: 100vh;
97
-
98
- // Animation
99
- transition: all .5s ease-in-out;
100
- transform-origin: left;
101
- transform: none;
102
-
103
- // Show the sidebar
104
- pointer-events: initial;
105
- visibility: visible;
106
- transform: translateX(0);
107
-
108
- // Hide the sidebar
109
- &[hidden] {
110
- pointer-events: none;
111
- overflow: hidden auto;
112
- visibility: hidden;
113
- transform: translateX(-100%);
114
- }
115
-
116
55
  // Design the nav
117
56
  > nav {
118
57
  overflow-y: auto;
@@ -131,34 +70,6 @@ doc-layout {
131
70
  }
132
71
  }
133
72
 
134
- #backdrop {
135
- // Design the backdrop
136
- position: fixed;
137
- inset: 0;
138
- z-index: 1;
139
- background-color: rgba(0, 0, 0, .25);
140
- backdrop-filter: blur(.25rem);
141
-
142
- // Animation
143
- transition: all .5s ease-in-out;
144
-
145
- // By default it's hidden
146
- pointer-events: none;
147
- visibility: hidden;
148
- opacity: 0;
149
- }
150
-
151
- // Make backdrop visible if breakpoint
152
- @media (max-width:960px) {
153
- &:has(aside:not([hidden])) {
154
- #backdrop {
155
- visibility: visible;
156
- pointer-events: initial;
157
- opacity: 1;
158
- }
159
- }
160
- }
161
-
162
73
  @media (min-width: 960px) {
163
74
  &:has(aside:not([hidden])) {
164
75
  grid-template-columns: 320px 1fr;
package/js/_toggle.js CHANGED
@@ -103,6 +103,8 @@ export default class Toggle extends BaseComponent {
103
103
  // Toggle the [hidden] attribute
104
104
  toggable.hidden = this.value !== toggleValue && groupValue !== toggleValue
105
105
 
106
+ if (!toggable.hidden && toggable.hasAttribute('tabindex')) toggable.focus()
107
+
106
108
  })
107
109
 
108
110
  // Update the [aria-expanded] attribute if there is any toggables visible
package/js/_tree.js CHANGED
@@ -72,6 +72,12 @@ export default class Tree extends BaseComponent {
72
72
  // Toggle the [hidden] attribute on the children
73
73
  children.forEach(child => child.hidden = isExpanded)
74
74
 
75
+ // Set the focus on the required child
76
+ if (!isExpanded) {
77
+ const childToFocus = children.find(el => el.hasAttribute('tabindex')) ?? null
78
+ if (childToFocus) childToFocus.focus()
79
+ }
80
+
75
81
  // If type grid, collapse the subchildren
76
82
  if (this._type === 'grid' && isExpanded) children.filter(child => child.hasAttribute('aria-expanded') && child.getAttribute('aria-expanded') === 'true').forEach(child => this.toggle(child))
77
83
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@natachah/vanilla-frontend",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "A vanilla frontend framework",
5
5
  "keywords": [
6
6
  "html5",
@@ -65,45 +65,37 @@ summary {
65
65
  }
66
66
 
67
67
  // Force the hidden
68
- [hidden] {
68
+ [hidden=true],
69
+ [hidden=""] {
69
70
  display: none !important;
70
71
  }
71
72
 
73
+ // Change cursor for item with aria-control or data-handle
74
+ [aria-controls]:not(:has([data-handle])),
75
+ [data-handle] {
76
+ cursor: pointer;
77
+ }
78
+
72
79
  // Change cursor for draggable
73
80
  [draggable] {
74
81
 
75
- &:not(:has([data-handle])),
76
- [data-handle] {
82
+ &:not(:has([data-handle=sortable])),
83
+ [data-handle=sortable] {
77
84
  cursor: grab;
78
85
  }
79
86
 
80
87
  &[aria-grabbed=true],
81
- &[aria-grabbed=true] [data-handle] {
88
+ &[aria-grabbed=true] [data-handle=sortable] {
82
89
  cursor: grabbing;
83
90
  }
84
91
 
85
92
  }
86
93
 
87
- // Change cursor for tree + basic animation on svg
88
- [aria-controls],
89
- [data-handle] {
90
- cursor: pointer;
91
- }
92
-
93
- [aria-controls][aria-expanded=true] [data-handle] > svg {
94
- transform: rotate(90deg);
95
- }
96
-
97
- // Reduce animation on scroll for #target
94
+ // Reduce animation on scroll for #target + data-handle SVG
98
95
  @media screen and (prefers-reduced-motion: no-preference) {
99
96
  :has(:target) {
100
97
  scroll-behavior: smooth;
101
98
  }
102
-
103
- [data-handle] > svg {
104
- transition: all .25s ease-in-out;
105
- }
106
-
107
99
  }
108
100
 
109
101
  // Define the bases for the body
@@ -0,0 +1,117 @@
1
+ ////
2
+ /// ------------------------------------------------------------------
3
+ /// Drawer
4
+ /// ------------------------------------------------------------------
5
+ /// Create the drawer component
6
+ ///
7
+ ///
8
+ /// @group components
9
+ /// @author Natacha Herth
10
+ ///
11
+ ////
12
+
13
+ .drawer {
14
+
15
+ // Design
16
+ display: var(--drawer-display, block);
17
+ background-color: var(--drawer-background, var(--color-body));
18
+
19
+ // Make the drawer as sticky for mobile
20
+ position: sticky;
21
+ z-index: var(--drawer-index, 2);
22
+ inset: var(--drawer-position, 0);
23
+
24
+ // Set the size
25
+ width: var(--drawer-width, 320px);
26
+ height: var(--drawer-height, 100vh);
27
+ max-width: var(--drawer-max-width, 80dvw);
28
+ max-height: var(--drawer-max-height, 100dvh);
29
+
30
+ // For animation
31
+ transform-origin: var(--drawer-origin, left);
32
+ transform: none;
33
+
34
+ // Show
35
+ pointer-events: initial;
36
+ visibility: visible;
37
+ transform: translateX(0);
38
+ opacity: 1;
39
+
40
+ // Animation
41
+ @media screen and (prefers-reduced-motion: no-preference) {
42
+ transition: var(--drawer-animation, all 0.5s ease-in-out);
43
+ }
44
+
45
+ // Hide the drawer
46
+ &[hidden] {
47
+ pointer-events: none;
48
+ overflow: hidden;
49
+ visibility: hidden;
50
+ transform: var(--drawer-transform, translatex(100%));
51
+ opacity: 0;
52
+ display: var(--drawer-display, block) !important; // ! REQUIRED to avoid the display:none of [hidden]
53
+ }
54
+
55
+ }
56
+
57
+ .drawer-button {
58
+ rect {
59
+ transform-origin: center;
60
+
61
+ @media screen and (prefers-reduced-motion: no-preference) {
62
+ transition: y .25s ease-in-out .25s, rotate .25s ease-in-out, opacity 0ms .25s;
63
+ }
64
+ }
65
+
66
+ // Active
67
+ &[aria-expanded=true] {
68
+
69
+ // Remove the middle bar
70
+ rect:not(:first-child, :last-child) {
71
+ opacity: 0;
72
+ }
73
+
74
+ // Change the first bar
75
+ rect:first-child {
76
+ y: calc(50% - var(--svg-line-size, 10px) / 2);
77
+ rotate: 45deg;
78
+ }
79
+
80
+ // Change the last bar
81
+ rect:last-child {
82
+ y: calc(50% - var(--svg-line-size, 10px) / 2);
83
+ rotate: -45deg;
84
+ }
85
+
86
+ }
87
+ }
88
+
89
+ body #backdrop {
90
+ // Design the backdrop
91
+ position: fixed;
92
+ inset: 0;
93
+ z-index: 1;
94
+ background: var(--drawer-backdrop-background, var(--backdrop-color, rgba(black, .75)));
95
+ backdrop-filter: var(--drawer-backdrop-filter, var(--backdrop-filter, blur(.5rem)));
96
+
97
+ // By default it's hidden
98
+ pointer-events: none;
99
+ visibility: hidden;
100
+ opacity: 0;
101
+
102
+ // Animation
103
+ @media screen and (prefers-reduced-motion: no-preference) {
104
+ transition: all .5s ease-in-out;
105
+ }
106
+ }
107
+
108
+ // Make backdrop visible if breakpoint
109
+ @media (max-width:960px) {
110
+ body:has(.drawer:not([hidden])) {
111
+ #backdrop {
112
+ visibility: visible;
113
+ pointer-events: initial;
114
+ opacity: 1;
115
+ }
116
+ }
117
+ }
@@ -116,7 +116,7 @@ select {
116
116
  width: $size;
117
117
  border: none;
118
118
  border-radius: $size;
119
- box-shadow: calc(-400px - $size / 2) 0 0 400px color-mix(in srgb, var(--range-color, currentColor), transparent 75%);
119
+ box-shadow: calc(-1000px - $size / 2) 0 0 1000px color-mix(in srgb, var(--range-color, currentColor), transparent 75%);
120
120
  }
121
121
 
122
122
  padding: calc($size / 2) 0;
@@ -4,6 +4,7 @@
4
4
  @forward "./card";
5
5
  @forward "./dialog";
6
6
  @forward "./disclosure";
7
+ @forward "./drawer";
7
8
  @forward "./dropdown";
8
9
  @forward "./form";
9
10
  @forward "./group";
@@ -1,50 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Documentations: Javascript > Drawer</title>
8
- </head>
9
-
10
- <body data-preload>
11
- <doc-layout>
12
-
13
- <h1>Drawer</h1>
14
- <p>The drawer component make you able to toggle a drawer with a button and resize window.</p>
15
-
16
- <h2>Javascript</h2>
17
- <p>This component is only in javascript, to use it you must import the javascript file and create a new Drawer object.</p>
18
- <p>You can customize the breakpoint when initiate the component.</p>
19
- <p>You can have a <b>Backdrop</b> if you want to make it more like a drawer opening on the front of the content.</p>
20
-
21
- <blockquote>
22
- <p>Main use case are sidebar menu or main navigation menu.</p>
23
- <p>This documentation use the drawer as an exemple for the sidebar on the left !</p>
24
- </blockquote>
25
-
26
- <div class="code-group">
27
- <div role="tablist">
28
- <button role="tab" aria-controls="html">HTML</button>
29
- <button role="tab" aria-controls="js">JS</button>
30
- </div>
31
- <doc-code id="html" data-type="html" role="tabpanel">
32
- <div id="backdrop"></div>
33
- <button aria-expanded="false" aria-pressed="false" aria-controls="drawer">Toggle</button>
34
- <aside id="drawer" tabindex="0" hidden>
35
- <button aria-expanded="false" aria-pressed="false" aria-controls="drawer">Toggle</button>
36
- My drawer
37
- </aside>
38
- </doc-code>
39
- <doc-code id="js" data-type="js" role="tabpanel">
40
- import Drawer from '@natachah/vanilla-frontend/js/utilities/_drawer.js'
41
- const drawer = document.getElementById('drawer')
42
- if (drawer) new Drawer(drawer, { breakpoint : 960 })
43
- </doc-code>
44
- </div>
45
-
46
- </doc-layout>
47
- <script type="module" src="/main.js"></script>
48
- </body>
49
-
50
- </html>
Binary file