@natachah/vanilla-frontend 0.2.7 → 0.2.9
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/.gitlab-ci.yml +5 -1
- package/docs/pages/base/media.html +2 -0
- package/docs/pages/javascript/toggle.html +4 -2
- package/docs/pages/quick-start/customization.html +1 -0
- package/docs/src/js/doc-layout.js +1 -1
- package/js/_drawer.js +12 -0
- package/js/_toggle.js +12 -3
- package/js/tests/toggle.test.js +15 -9
- package/natachah-vanilla-frontend-0.2.9.tgz +0 -0
- package/package.json +1 -1
- package/scss/abstracts/_mixins.scss +1 -1
- package/scss/base/_media.scss +2 -0
- package/scss/base/_typography.scss +1 -1
- package/scss/themes/_root.scss +1 -0
- package/natachah-vanilla-frontend-0.2.7.tgz +0 -0
package/.gitlab-ci.yml
CHANGED
|
@@ -41,8 +41,12 @@ publish-job:
|
|
|
41
41
|
environment: production
|
|
42
42
|
rules:
|
|
43
43
|
- if: $CI_COMMIT_REF_NAME == "production"
|
|
44
|
+
id_tokens:
|
|
45
|
+
NPM_ID_TOKEN:
|
|
46
|
+
aud: "npm:registry.npmjs.org"
|
|
47
|
+
SIGSTORE_ID_TOKEN:
|
|
48
|
+
aud: sigstore
|
|
44
49
|
script:
|
|
45
|
-
- echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > .npmrc
|
|
46
50
|
- echo "Fichiers dans le répertoire public avant publication :"
|
|
47
51
|
- ls -R public
|
|
48
52
|
- npm pack
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
--image-width
|
|
35
35
|
--image-height
|
|
36
36
|
--image-fit
|
|
37
|
+
--image-position
|
|
37
38
|
--image-ratio
|
|
38
39
|
</doc-code>
|
|
39
40
|
</div>
|
|
@@ -106,6 +107,7 @@
|
|
|
106
107
|
--video-width
|
|
107
108
|
--video-height
|
|
108
109
|
--video-fit
|
|
110
|
+
--video-position
|
|
109
111
|
--video-ratio
|
|
110
112
|
</doc-code>
|
|
111
113
|
</div>
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
|
|
120
120
|
<p>The component also work with <code><select></code> and it support the <code><optgroup></code>.</p>
|
|
121
121
|
<doc-demo>
|
|
122
|
-
<select class="demo-toggle" name="select" aria-controls="selectA selectB selectG" aria-expanded="false">
|
|
122
|
+
<select class="demo-toggle" name="select" aria-controls="selectA selectB selectG selectNot" aria-expanded="false">
|
|
123
123
|
<option value="null">--</option>
|
|
124
124
|
<option value="A">aaa</option>
|
|
125
125
|
<option value="B">bbb</option>
|
|
@@ -131,10 +131,11 @@
|
|
|
131
131
|
<div id="selectA" data-toggle-when="A" hidden>Hello there, I'm A !</div>
|
|
132
132
|
<div id="selectB" data-toggle-when="B" hidden>Hello there, I'm B !</div>
|
|
133
133
|
<div id="selectG" data-toggle-when="group" hidden>Hello there, I'm GROUP for C or D !</div>
|
|
134
|
+
<div id="selectNot" data-toggle-when-not="A" hidden>Hello there, I'm present if not A !</div>
|
|
134
135
|
</doc-demo>
|
|
135
136
|
|
|
136
137
|
<doc-code>
|
|
137
|
-
<select name="select" aria-controls="selectA selectB selectG" aria-expanded="false">
|
|
138
|
+
<select name="select" aria-controls="selectA selectB selectG selectNot" aria-expanded="false">
|
|
138
139
|
<option value="null">--</option>
|
|
139
140
|
<option value="A">aaa</option>
|
|
140
141
|
<option value="B">bbb</option>
|
|
@@ -147,6 +148,7 @@
|
|
|
147
148
|
<div id="selectA" data-toggle-when="A" hidden>Hello there, I'm A !</div>
|
|
148
149
|
<div id="selectB" data-toggle-when="B" hidden>Hello there, I'm B !</div>
|
|
149
150
|
<div id="selectG" data-toggle-when="mygroup" hidden>Hello there, I'm GROUP for C or D !</div>
|
|
151
|
+
<div id="selectNot" data-toggle-when-not="A" hidden>Hello there, I'm present if not A !</div>
|
|
150
152
|
</doc-code>
|
|
151
153
|
|
|
152
154
|
<h2>Javascript</h2>
|
|
@@ -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.2.
|
|
21
|
+
0.2.9v
|
|
22
22
|
</span>
|
|
23
23
|
</li>
|
|
24
24
|
<li>
|
package/js/_drawer.js
CHANGED
|
@@ -92,6 +92,14 @@ export default class Drawer extends BaseComponent {
|
|
|
92
92
|
// On click on the backdrop, close the drawer
|
|
93
93
|
if (this._backdrop) this._backdrop.addEventListener('click', () => this.toggle())
|
|
94
94
|
|
|
95
|
+
// On esc close
|
|
96
|
+
this._element.addEventListener('keydown', (e) => {
|
|
97
|
+
if (e.key === 'Escape') {
|
|
98
|
+
e.preventDefault()
|
|
99
|
+
this.toggle(false)
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
95
103
|
}
|
|
96
104
|
|
|
97
105
|
defineDrawerByBreakpoint() {
|
|
@@ -114,8 +122,12 @@ export default class Drawer extends BaseComponent {
|
|
|
114
122
|
this._element.removeAttribute('role')
|
|
115
123
|
this._element.removeAttribute('aria-modal')
|
|
116
124
|
|
|
125
|
+
// Deactivate the trap
|
|
126
|
+
this._trap.deactivate()
|
|
127
|
+
|
|
117
128
|
// The drawer should be cookie or open
|
|
118
129
|
drawerStatus = this._cookie ? this._cookie.get('drawer-is-open') : true
|
|
130
|
+
|
|
119
131
|
}
|
|
120
132
|
|
|
121
133
|
if (drawerStatus != this._isOpen) this.toggle(drawerStatus)
|
package/js/_toggle.js
CHANGED
|
@@ -92,16 +92,25 @@ export default class Toggle extends BaseComponent {
|
|
|
92
92
|
toggle() {
|
|
93
93
|
|
|
94
94
|
// Define the group value for <select>
|
|
95
|
-
const
|
|
95
|
+
const selectedOption = this._element.options?.[this._element.selectedIndex]
|
|
96
|
+
const groupValue = (this._type === 'select' && selectedOption) ? (selectedOption.parentElement.label ?? null) : null
|
|
96
97
|
|
|
97
98
|
// Check for each toggables elements
|
|
98
99
|
this._toggables.forEach(toggable => {
|
|
99
100
|
|
|
100
101
|
// Define if there is a [data-toggle-when] attribute, otherwise check on the true value
|
|
101
|
-
|
|
102
|
+
let toggleValue = toggable.getAttribute('data-toggle-when') ?? null
|
|
103
|
+
|
|
104
|
+
// Define if there a [data-toggle-when-not] attribute
|
|
105
|
+
const toggleNotValue = toggable.getAttribute('data-toggle-when-not') ?? null
|
|
102
106
|
|
|
103
107
|
// Toggle the [hidden] attribute
|
|
104
|
-
|
|
108
|
+
if (this.value !== 'null' && toggleNotValue !== null) {
|
|
109
|
+
toggable.hidden = toggleNotValue === this.value
|
|
110
|
+
} else {
|
|
111
|
+
toggleValue = toggleValue ?? 'true'
|
|
112
|
+
toggable.hidden = this.value !== toggleValue && groupValue !== toggleValue
|
|
113
|
+
}
|
|
105
114
|
|
|
106
115
|
if (!toggable.hidden) {
|
|
107
116
|
const focus = toggable.getAttribute('tabindex') === '0' ? toggable : toggable.querySelector('[tabindex="0"]') ?? toggable.querySelector('button, a, input')
|
package/js/tests/toggle.test.js
CHANGED
|
@@ -38,16 +38,17 @@ beforeAll(() => {
|
|
|
38
38
|
'<input id="fakeRadioB" type="radio" name="fake-radio" aria-controls="fakeCollapseRadioB" aria-expanded="false">' +
|
|
39
39
|
'<div id="fakeCollapseRadioA" hidden></div>' +
|
|
40
40
|
'<div id="fakeCollapseRadioB" hidden></div>' +
|
|
41
|
-
'<select id="fakeSelect" aria-controls="fakeCollapseSelectA fakeCollapseSelectB
|
|
41
|
+
'<select id="fakeSelect" aria-controls="fakeCollapseSelectA fakeCollapseSelectB fakeCollapseSelectG fakeCollapseSelectN" aria-expanded="false">' +
|
|
42
42
|
'<option value="null"></option>' +
|
|
43
43
|
'<option value="A"></option>' +
|
|
44
|
-
'<optgroup label="
|
|
44
|
+
'<optgroup label="group">' +
|
|
45
45
|
'<option value="B"></option>' +
|
|
46
46
|
'</optgroup>' +
|
|
47
47
|
'</select>' +
|
|
48
48
|
'<div id="fakeCollapseSelectA" data-toggle-when="A" hidden></div>' +
|
|
49
49
|
'<div id="fakeCollapseSelectB" data-toggle-when="B" hidden></div>' +
|
|
50
|
-
'<div id="fakeCollapseSelectG" data-toggle-when="
|
|
50
|
+
'<div id="fakeCollapseSelectG" data-toggle-when="group" hidden></div>' +
|
|
51
|
+
'<div id="fakeCollapseSelectN" data-toggle-when-not="A" hidden></div>'
|
|
51
52
|
|
|
52
53
|
fakeToggleButton = new Toggle(document.getElementById('fakeButton'))
|
|
53
54
|
fakeToggleCheckbox = new Toggle(document.getElementById('fakeCheckbox'))
|
|
@@ -67,7 +68,7 @@ describe('Structure of the class', () => {
|
|
|
67
68
|
expect(fakeToggleRadioA._type).toBe('radio')
|
|
68
69
|
expect(fakeToggleSelect._type).toBe('select')
|
|
69
70
|
expect(fakeToggleButton._toggables).toStrictEqual([...document.querySelectorAll('#fakeCollapse')])
|
|
70
|
-
expect(fakeToggleSelect._toggables).toStrictEqual([...document.querySelectorAll('#fakeCollapseSelectA, #fakeCollapseSelectB, #
|
|
71
|
+
expect(fakeToggleSelect._toggables).toStrictEqual([...document.querySelectorAll('#fakeCollapseSelectA, #fakeCollapseSelectB, #fakeCollapseSelectG, #fakeCollapseSelectN')])
|
|
71
72
|
})
|
|
72
73
|
|
|
73
74
|
})
|
|
@@ -160,22 +161,27 @@ describe('#Toggle()', () => {
|
|
|
160
161
|
test('Toggle the [hidden] attribute on the <div>', () => {
|
|
161
162
|
const divA = document.getElementById('fakeCollapseSelectA')
|
|
162
163
|
const divB = document.getElementById('fakeCollapseSelectB')
|
|
163
|
-
const
|
|
164
|
+
const divG = document.getElementById('fakeCollapseSelectG')
|
|
165
|
+
const divN = document.getElementById('fakeCollapseSelectN')
|
|
164
166
|
expect(divA.hidden).toBeTruthy()
|
|
165
167
|
expect(divB.hidden).toBeTruthy()
|
|
166
|
-
expect(
|
|
168
|
+
expect(divG.hidden).toBeTruthy()
|
|
169
|
+
expect(divN.hidden).toBeTruthy()
|
|
167
170
|
fireEvent.change(fakeToggleSelect._element, { target: { value: 'A' } })
|
|
168
171
|
expect(divA.hidden).toBeFalsy()
|
|
169
172
|
expect(divB.hidden).toBeTruthy()
|
|
170
|
-
expect(
|
|
173
|
+
expect(divG.hidden).toBeTruthy()
|
|
174
|
+
expect(divN.hidden).toBeTruthy()
|
|
171
175
|
fireEvent.change(fakeToggleSelect._element, { target: { value: 'B' } })
|
|
172
176
|
expect(divA.hidden).toBeTruthy()
|
|
173
177
|
expect(divB.hidden).toBeFalsy()
|
|
174
|
-
expect(
|
|
178
|
+
expect(divG.hidden).toBeFalsy()
|
|
179
|
+
expect(divN.hidden).toBeFalsy()
|
|
175
180
|
fireEvent.change(fakeToggleSelect._element, { target: { value: 'null' } })
|
|
176
181
|
expect(divA.hidden).toBeTruthy()
|
|
177
182
|
expect(divB.hidden).toBeTruthy()
|
|
178
|
-
expect(
|
|
183
|
+
expect(divG.hidden).toBeTruthy()
|
|
184
|
+
expect(divN.hidden).toBeTruthy()
|
|
179
185
|
})
|
|
180
186
|
|
|
181
187
|
})
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
|
|
97
97
|
&:focus,
|
|
98
98
|
&:focus-visible {
|
|
99
|
-
outline: var(--#{$name}-outline-size, var(--outline-size)) var(--#{$name}-outline-style, var(--outline-style)) var(--#{$name}-outline-color,
|
|
99
|
+
outline: var(--#{$name}-outline-size, var(--outline-size)) var(--#{$name}-outline-style, var(--outline-style)) var(--#{$name}-outline-color, var(--outline-color));
|
|
100
100
|
outline-offset: var(--#{$name}-outline-offset, var(--outline-offset));
|
|
101
101
|
}
|
|
102
102
|
|
package/scss/base/_media.scss
CHANGED
|
@@ -15,6 +15,7 @@ img {
|
|
|
15
15
|
width: var(--image-width, auto);
|
|
16
16
|
height: var(--image-height, auto);
|
|
17
17
|
object-fit: var(--image-fit, cover);
|
|
18
|
+
object-position: var(--image-position, center);
|
|
18
19
|
aspect-ratio: var(--image-ratio, auto);
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -22,6 +23,7 @@ video {
|
|
|
22
23
|
width: var(--video-width, 100%);
|
|
23
24
|
height: var(--video-height, auto);
|
|
24
25
|
object-fit: var(--video-fit, cover);
|
|
26
|
+
object-position: var(--video-position, center);
|
|
25
27
|
aspect-ratio: var(--video-ratio, 16/9);
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -33,7 +33,7 @@ button[role=link] {
|
|
|
33
33
|
&:focus,
|
|
34
34
|
&:focus-visible {
|
|
35
35
|
color: var(--anchor-focus-color, var(--anchor-hover-color, var(--anchor-color, currentColor)));
|
|
36
|
-
outline: var(--anchor-outline-size, var(--outline-size)) var(--anchor-outline-style, var(--outline-style)) var(--anchor-outline-color,
|
|
36
|
+
outline: var(--anchor-outline-size, var(--outline-size)) var(--anchor-outline-style, var(--outline-style)) var(--anchor-outline-color, var(--outline-color));
|
|
37
37
|
outline-offset: var(--anchor-outline-offset, var(--outline-offset));
|
|
38
38
|
}
|
|
39
39
|
|
package/scss/themes/_root.scss
CHANGED
|
Binary file
|