@natachah/vanilla-frontend 0.0.2 → 0.0.3

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,67 @@
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: Components ></title>
8
+ </head>
9
+
10
+ <body data-preload>
11
+ <doc-layout>
12
+
13
+ <h2>Breadcrumb</h2>
14
+ <p>To create a breadcrumb navigation, always use <code>&lt;ol&gt;</code> with a class <code>.breadcrumb</code> inside a <code>&lt;nav&gt;</code> tag.</p>
15
+ <p>The breadcrumb will automatically be distributed horizontally.</p>
16
+ <doc-demo>
17
+ <nav aria-label="Breadcrumb navigaton">
18
+ <ol class="breadcrumb">
19
+ <li><a href="#">One</a></li>
20
+ <li><a href="#">Two</a></li>
21
+ <li><a href="#">Three</a></li>
22
+ <li aria-current="location">Four</li>
23
+ </ol>
24
+ </nav>
25
+ </doc-demo>
26
+ <div class="code-group">
27
+ <div role="tablist">
28
+ <button role="tab" aria-controls="html">HTML</button>
29
+ <button role="tab" aria-controls="scss">SCSS</button>
30
+
31
+ <button role="tab" aria-controls="css">CSS</button>
32
+ </div>
33
+ <doc-code id="html" data-type="html" role="tabpanel">
34
+ <nav aria-label="Breadcrumb navigaton">
35
+ <ol class="breadcrumb">
36
+ <li><a href="#">One</a></li>
37
+ <li><a href="#">Two</a></li>
38
+ <li><a href="#">Three</a></li>
39
+ <li aria-current="location">Four</li>
40
+ </ol>
41
+ </nav>
42
+ </doc-code>
43
+ <doc-code id="scss" data-type="scss" role="tabpanel">
44
+ @import '@natachah/vanilla-frontend/scss/_breadcrumb';
45
+ </doc-code>
46
+ <doc-code id="css" data-type="css" role="tabpanel">
47
+ --breadcrumb-divider
48
+ --breadcrumb-divider-color
49
+ --breadcrumb-gap
50
+ --breadcrumb-decoration
51
+ --breadcrumb-color
52
+ --breadcrumb-hover-color
53
+ --breadcrumb-active-color
54
+ --breadcrumb-disabled-opacity
55
+ </doc-code>
56
+ </div>
57
+
58
+ <blockquote class="warning">
59
+ <p>The custom properties for the breadcrumb is overriding the default ones in the typography setting.</p>
60
+ </blockquote>
61
+
62
+
63
+ </doc-layout>
64
+ <script type="module" src="/main.js"></script>
65
+ </body>
66
+
67
+ </html>
@@ -24,16 +24,12 @@
24
24
  <button role="tab" aria-controls="js">JS</button>
25
25
  </div>
26
26
  <doc-code id="html" data-type="html" role="tabpanel">
27
- <dialog id="cookies">
28
- <div>
29
- <div id="backdrop"></div>
30
- <button aria-expanded="false" aria-pressed="false" aria-controls="sidebar">Toggle</button>
31
- <aside id="sidebar" tabindex="0" hidden>
32
- <button aria-expanded="false" aria-pressed="false" aria-controls="sidebar">Toggle</button>
33
- My sidebar
34
- </aside>
35
- </div>
36
- </dialog>
27
+ <div id="backdrop"></div>
28
+ <button aria-expanded="false" aria-pressed="false" aria-controls="sidebar">Toggle</button>
29
+ <aside id="sidebar" tabindex="0" hidden>
30
+ <button aria-expanded="false" aria-pressed="false" aria-controls="sidebar">Toggle</button>
31
+ My sidebar
32
+ </aside>
37
33
  </doc-code>
38
34
  <doc-code id="js" data-type="js" role="tabpanel">
39
35
  import Sidebar from '@natachah/vanilla-frontend/js/utilities/_sidebar.js'
@@ -30,14 +30,15 @@
30
30
  // Can be overide by your own variables files
31
31
  @import '@natachah/vanilla-frontend/scss/variables/_root';
32
32
  @import '@natachah/vanilla-frontend/scss/variables/_setting';
33
-
33
+
34
34
  // Utilities
35
35
  @import '@natachah/vanilla-frontend/scss/utilities/_mixin';
36
36
  @import '@natachah/vanilla-frontend/scss/utilities/_reset';
37
37
  @import '@natachah/vanilla-frontend/scss/utilities/_typography';
38
-
38
+
39
39
  // Components
40
40
  @import '@natachah/vanilla-frontend/scss/_badge';
41
+ @import '@natachah/vanilla-frontend/scss/_breadcrumb';
41
42
  @import '@natachah/vanilla-frontend/scss/_button';
42
43
  @import '@natachah/vanilla-frontend/scss/_card';
43
44
  @import '@natachah/vanilla-frontend/scss/_dialog';
@@ -49,7 +50,6 @@
49
50
  @import '@natachah/vanilla-frontend/scss/_list';
50
51
  @import '@natachah/vanilla-frontend/scss/_loading';
51
52
  @import '@natachah/vanilla-frontend/scss/_media';
52
- @import '@natachah/vanilla-frontend/scss/_nav';
53
53
  @import '@natachah/vanilla-frontend/scss/_progress';
54
54
  @import '@natachah/vanilla-frontend/scss/_slider';
55
55
  @import '@natachah/vanilla-frontend/scss/_table';
@@ -64,6 +64,7 @@ class DocLayout extends HTMLElement {
64
64
  <h2>Components</h2>
65
65
  <ul>
66
66
  <li><a href="/pages/components/badge.html">Badge</a></li>
67
+ <li><a href="/pages/components/breadcrumb.html">Breadcrumb</a></li>
67
68
  <li><a href="/pages/components/button.html">Button</a></li>
68
69
  <li><a href="/pages/components/card.html">Card</a></li>
69
70
  <li><a href="/pages/components/dialog.html">Dialog</a></li>
@@ -73,7 +74,6 @@ class DocLayout extends HTMLElement {
73
74
  <li><a href="/pages/components/list.html">List</a></li>
74
75
  <li><a href="/pages/components/loading.html">Loading</a></li>
75
76
  <li><a href="/pages/components/media.html">Media</a></li>
76
- <li><a href="/pages/components/nav.html">Nav</a></li>
77
77
  <li><a href="/pages/components/progress.html">Progress</a></li>
78
78
  <li><a href="/pages/components/slider.html">Slider</a></li>
79
79
  <li><a href="/pages/components/table.html">Table</a></li>
@@ -29,6 +29,14 @@ doc-layout {
29
29
  grid-area: footer;
30
30
  }
31
31
 
32
+ > header > nav > ul {
33
+ list-style: none;
34
+ padding: 0;
35
+ margin: 0;
36
+ display: flex;
37
+ gap: 1rem;
38
+ }
39
+
32
40
  // The open/close button for the sidebar
33
41
  > header button {
34
42
 
package/js/_autofill.js CHANGED
@@ -24,7 +24,7 @@ export default class Autofill extends BaseComponent {
24
24
  constructor(el, options = {}) {
25
25
 
26
26
  // Run the SUPER constructor from BaseComponent
27
- super(el, options)
27
+ super(el, options, 'autofill')
28
28
 
29
29
  // Check for errors
30
30
  if (el.tagName !== 'SELECT' && el.tagName !== 'INPUT') throw new Error(ErrorMessage.typeOf('el', 'input|select'))
package/js/_check-all.js CHANGED
@@ -23,7 +23,7 @@ export default class CheckAll extends BaseComponent {
23
23
  constructor(el, options = {}) {
24
24
 
25
25
  // Run the SUPER constructor from BaseComponent
26
- super(el, options)
26
+ super(el, options, 'checkall')
27
27
 
28
28
  // Define the properties
29
29
  this._checkboxes = document.querySelectorAll(`input[type="checkbox"][name="${this._element.value}"]`)
package/js/_dialog.js CHANGED
@@ -24,7 +24,7 @@ export default class Dialog extends BaseComponent {
24
24
  constructor(el, options = {}) {
25
25
 
26
26
  // Run the SUPER constructor from BaseComponent
27
- super(el, options)
27
+ super(el, options, 'dialog')
28
28
 
29
29
  // Define the properties
30
30
  this._isModal = Boolean(this._element.getAttribute('aria-modal'))
package/js/_dropdown.js CHANGED
@@ -33,7 +33,7 @@ export default class Dropdown extends BaseComponent {
33
33
  if (options.closable && typeof options.closable !== 'boolean') throw new Error(ErrorMessage.typeOf('options.closable', 'boolean'))
34
34
 
35
35
  // Run the SUPER constructor from BaseComponent
36
- super(el, options)
36
+ super(el, options, 'dropdown')
37
37
 
38
38
  // Define the properties
39
39
  this._button = this._element.querySelector('[aria-controls]')
@@ -52,12 +52,12 @@ export default class Dropdown extends BaseComponent {
52
52
  #init() {
53
53
 
54
54
  // Toggle the content on click on the button
55
- this._button.addEventListener('click', () => this.#toggle())
55
+ this._button.addEventListener('click', () => this.toggle())
56
56
 
57
57
  // Close the content is click outside
58
58
  if (this._options.closable) {
59
- this._content.addEventListener('blur', (e) => {
60
- if (e.relatedTarget !== this._button) this.#toggle()
59
+ this._content.addEventListener('focusout', (e) => {
60
+ if (e.relatedTarget !== this._button && !this._content.contains(e.relatedTarget)) this.toggle()
61
61
  })
62
62
  }
63
63
 
@@ -76,9 +76,8 @@ export default class Dropdown extends BaseComponent {
76
76
  /**
77
77
  * Toggle the [hidden] and [aria-expanded] attributes
78
78
  *
79
- * @private
80
79
  */
81
- #toggle() {
80
+ toggle() {
82
81
 
83
82
  // Define new value
84
83
  const value = !this.value
package/js/_scroll.js CHANGED
@@ -44,7 +44,7 @@ export default class Scroll extends BaseComponent {
44
44
  if (options.navigation && !document.getElementById(options.navigation)) throw new Error(ErrorMessage.existById('element', options.navigation))
45
45
 
46
46
  // Run the SUPER constructor from BaseComponent
47
- super(el, options)
47
+ super(el, options, 'scroll')
48
48
 
49
49
  // Reduce animation
50
50
  const isReduced = window.matchMedia(`(prefers-reduced-motion: reduce)`) === true || window.matchMedia(`(prefers-reduced-motion: reduce)`).matches === true
package/js/_sidebar.js CHANGED
@@ -31,7 +31,7 @@ export default class Sidebar extends BaseComponent {
31
31
  if (options.breakpoint && typeof options.breakpoint !== 'number') throw new Error(ErrorMessage.typeOf('options.breakpoint', 'number'))
32
32
 
33
33
  // Run the SUPER constructor from BaseComponent
34
- super(el, options)
34
+ super(el, options, 'sidebar')
35
35
 
36
36
  // Define the properties
37
37
  this._buttons = document.querySelectorAll(`[aria-controls=${this._element.id}]`) ?? []
@@ -55,30 +55,29 @@ export default class Sidebar extends BaseComponent {
55
55
  #init() {
56
56
 
57
57
  // On load check if need to open/close the sidebar
58
- if (window.innerWidth > this._options.breakpoint && !this._isOpen) this.#toggle()
58
+ if (window.innerWidth > this._options.breakpoint && !this._isOpen) this.toggle()
59
59
 
60
60
  // On resize check if need to open/close the sidebar
61
61
  window.onresize = () => {
62
62
  clearTimeout(this._timeout)
63
63
  this._timeout = setTimeout(() => {
64
- if ((window.innerWidth <= this._options.breakpoint && this._isOpen) || (window.innerWidth > this._options.breakpoint && !this._isOpen)) this.#toggle()
64
+ if ((window.innerWidth <= this._options.breakpoint && this._isOpen) || (window.innerWidth > this._options.breakpoint && !this._isOpen)) this.toggle()
65
65
  }, 250)
66
66
  }
67
67
 
68
68
  // On click on the button toggle the sidebar
69
- this._buttons.forEach((button) => button.addEventListener('click', () => this.#toggle()))
69
+ this._buttons.forEach((button) => button.addEventListener('click', () => this.toggle()))
70
70
 
71
71
  // On click on the backdrop, close the sidebar
72
- this._backdrop.addEventListener('click', () => this.#toggle())
72
+ this._backdrop.addEventListener('click', () => this.toggle())
73
73
 
74
74
  }
75
75
 
76
76
  /**
77
77
  * Toggle the sidebar
78
78
  *
79
- * @private
80
79
  */
81
- #toggle() {
80
+ toggle() {
82
81
 
83
82
  // Change the state
84
83
  this._isOpen = !this._isOpen
package/js/_slider.js CHANGED
@@ -37,7 +37,7 @@ export default class Slider extends BaseComponent {
37
37
  if (options.autoplay && (typeof options.autoplay !== 'boolean' && typeof options.autoplay !== 'number')) throw new Error(ErrorMessage.typeOf('options.autoplay', 'boolean|number'))
38
38
 
39
39
  // Run the SUPER constructor from BaseComponent
40
- super(el, options)
40
+ super(el, options, 'slider')
41
41
 
42
42
  // Reduce animation
43
43
  const isReduced = window.matchMedia(`(prefers-reduced-motion: reduce)`) === true || window.matchMedia(`(prefers-reduced-motion: reduce)`).matches === true
package/js/_sortable.js CHANGED
@@ -24,7 +24,7 @@ export default class Sortable extends BaseComponent {
24
24
  constructor(el, options = {}) {
25
25
 
26
26
  // Run the SUPER constructor from BaseComponent
27
- super(el, options)
27
+ super(el, options, 'sortable')
28
28
 
29
29
  // Define the properties
30
30
  this._withHandle = this._element.querySelector('[data-handle]') ? true : false
package/js/_tabpanel.js CHANGED
@@ -25,7 +25,7 @@ export default class Tabpanel extends BaseComponent {
25
25
  constructor(el, options = {}) {
26
26
 
27
27
  // Run the SUPER constructor from BaseComponent
28
- super(el, options)
28
+ super(el, options, 'tabpanel')
29
29
 
30
30
  // Check for errors
31
31
  if (!el.querySelector('[role="tab"]')) throw new Error(ErrorMessage.exist('button [role="tab"]'))
package/js/_toggle.js CHANGED
@@ -25,7 +25,7 @@ export default class Toggle extends BaseComponent {
25
25
  constructor(el, options = {}) {
26
26
 
27
27
  // Run the SUPER constructor from BaseComponent
28
- super(el, options)
28
+ super(el, options, 'toggle')
29
29
 
30
30
  // Define the properties
31
31
  this._type = this._element.tagName == 'SELECT' ? 'select' : this._element.getAttribute('type') ?? 'button'
@@ -45,21 +45,21 @@ export default class Toggle extends BaseComponent {
45
45
  */
46
46
  #init() {
47
47
 
48
- // On first load run method #toggle()
49
- this.#toggle()
48
+ // On first load run method toggle()
49
+ this.toggle()
50
50
 
51
51
  if (this._type === 'button') {
52
52
 
53
53
  // CLICK for <button> and change the [aria-pressed] attribute
54
54
  this._element.addEventListener('click', () => {
55
55
  this._element.setAttribute('aria-pressed', this.value === 'false')
56
- this.#toggle()
56
+ this.toggle()
57
57
  })
58
58
 
59
59
  } else {
60
60
 
61
61
  // CHANGE for <checkbox> <radio> <select>
62
- this._element.addEventListener('change', () => this.#toggle())
62
+ this._element.addEventListener('change', () => this.toggle())
63
63
 
64
64
  }
65
65
 
@@ -69,7 +69,6 @@ export default class Toggle extends BaseComponent {
69
69
  * Define the value: <checkbox> and <radio> = :checked, <button> = [aria-pressed], <else> = value
70
70
  *
71
71
  * @return {string}
72
- * @private
73
72
  */
74
73
  get value() {
75
74
 
@@ -90,9 +89,8 @@ export default class Toggle extends BaseComponent {
90
89
  /**
91
90
  * Toggle the [hidden] and [aria-expanded] attributes
92
91
  *
93
- * @private
94
92
  */
95
- #toggle() {
93
+ toggle() {
96
94
 
97
95
  // Define the group value for <select>
98
96
  const groupValue = this._type === 'select' && this._element.querySelector('option:checked') ? this._element.querySelector('option:checked').parentElement.label ?? null : null
package/js/_tree.js CHANGED
@@ -23,7 +23,7 @@ export default class Tree extends BaseComponent {
23
23
  constructor(el, options = {}) {
24
24
 
25
25
  // Run the SUPER constructor from BaseComponent
26
- super(el, options)
26
+ super(el, options, 'tree')
27
27
 
28
28
  // Define the properties
29
29
  this._type = this._element.role == 'tree' ? 'list' : 'grid'
@@ -47,7 +47,7 @@ export default class Tree extends BaseComponent {
47
47
  this._items.forEach(item => item.addEventListener('click', (e) => {
48
48
  if (!this._withHandle || e.target.hasAttribute('data-handle')) {
49
49
  e.stopPropagation()
50
- this.#toggle(item)
50
+ this.toggle(item)
51
51
  }
52
52
  }))
53
53
 
@@ -57,9 +57,8 @@ export default class Tree extends BaseComponent {
57
57
  * Toggle the [hidden] and [aria-expanded] attributes
58
58
  *
59
59
  * @param {HTMLElement} item - The current item
60
- * @private
61
60
  */
62
- #toggle(item) {
61
+ toggle(item) {
63
62
 
64
63
  // Check for errors
65
64
  if (!(item instanceof HTMLElement)) throw new Error(ErrorMessage.instanceOf('item', 'HTMLElement'))
@@ -75,7 +74,7 @@ export default class Tree extends BaseComponent {
75
74
  children.forEach(child => child.hidden = isExpanded)
76
75
 
77
76
  // If type grid, collapse the subchildren
78
- if (this._type === 'grid' && isExpanded) children.filter(child => child.hasAttribute('aria-expanded') && child.getAttribute('aria-expanded') === 'true').forEach(child => this.#toggle(child))
77
+ if (this._type === 'grid' && isExpanded) children.filter(child => child.hasAttribute('aria-expanded') && child.getAttribute('aria-expanded') === 'true').forEach(child => this.toggle(child))
79
78
 
80
79
  // Emmit event
81
80
  this.emmitEvent('changed', { isOpen: !isExpanded })
@@ -73,7 +73,7 @@ describe('#Init()', () => {
73
73
  expect(fakeDropdownClosable._button.getAttribute('aria-pressed')).toBe('true')
74
74
  expect(fakeDropdownClosable._button.getAttribute('aria-expanded')).toBe('true')
75
75
  expect(fakeDropdownClosable._content.hidden).toBeFalsy()
76
- fireEvent.blur(fakeDropdownClosable._content)
76
+ fireEvent(fakeDropdownClosable._content, new MouseEvent('focusout'))
77
77
  expect(fakeDropdownClosable._button.getAttribute('aria-expanded')).toBe('false')
78
78
  expect(fakeDropdownClosable._button.getAttribute('aria-pressed')).toBe('false')
79
79
  expect(fakeDropdownClosable._content.hidden).toBeTruthy()
@@ -22,14 +22,14 @@ export default class BaseComponent {
22
22
  * @param {Object} options - The custom options
23
23
  * @constructor
24
24
  */
25
- constructor(el, options = {}) {
25
+ constructor(el, options = {}, name = this.constructor.name.toLowerCase()) {
26
26
 
27
27
  // Check for errors
28
28
  if (!(el instanceof HTMLElement)) throw new Error(ErrorMessage.instanceOf('el', 'HTMLElement'))
29
29
  if (!(options instanceof Object)) throw new Error(ErrorMessage.instanceOf('options', 'Object'))
30
30
 
31
31
  // Define the #NAME private properties
32
- this.#NAME = this.constructor.name.toLowerCase() ?? ''
32
+ this.#NAME = name
33
33
 
34
34
  // Define the _element property
35
35
  this._element = el
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@natachah/vanilla-frontend",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "A vanilla frontend framework",
5
5
  "keywords": [
6
6
  "html5",
@@ -0,0 +1,45 @@
1
+ ////
2
+ /// ------------------------------------------------------------------
3
+ /// Breadcrumb
4
+ /// ------------------------------------------------------------------
5
+ /// Create the breadcrumb component
6
+ ///
7
+ /// @example <nav><ol class="breadcrumb">...</ol></nav>
8
+ ///
9
+ /// @group components
10
+ /// @author Natacha Herth
11
+ /// @since 1.0.0
12
+ ///
13
+ ////
14
+
15
+ .breadcrumb {
16
+
17
+ // Reset the list style
18
+ list-style: none;
19
+ padding: 0;
20
+ margin: 0;
21
+
22
+ // Design the breadcrumb list as inline by default
23
+ display: flex;
24
+ flex-direction: row;
25
+ justify-content: start;
26
+ align-items: center;
27
+ gap: 0;
28
+
29
+ // Add a divider between links
30
+ li:not(:last-child)::after {
31
+ content: var(--breadcrumb-divider, '/');
32
+ color: var(--breadcrumb-divider-color, currentColor);
33
+ margin-inline: var(--breadcrumb-gap, .5rem);
34
+ }
35
+
36
+ // Reset the anchor CSS properties
37
+ a {
38
+ --anchor-decoration: var(--breadcrumb-decoration, currentColor);
39
+ --anchor-color: var(--breadcrumb-color, currentColor);
40
+ --anchor-hover-color: var(--breadcrumb-hover-color, var(--breadcrumb-color, currentColor));
41
+ --anchor-active-color: var(--breadcrumb-active-color, var(--breadcrumb-hover-color, var(--breadcrumb-color, currentColor)));
42
+ --anchor-disabled-opacity: var(--breadcrumb-disabled-opacity, var(--disabled-opacity));
43
+ }
44
+
45
+ }
package/scss/_button.scss CHANGED
@@ -21,6 +21,7 @@ button,
21
21
 
22
22
  // Customization for button
23
23
  display: inline-block;
24
+ text-align: center;
24
25
 
25
26
  // Define as an item
26
27
  @include as-item('button', ('focus', 'hover', 'active', 'disabled'));
@@ -6,6 +6,7 @@
6
6
  @import './utilities/_typography';
7
7
 
8
8
  @import './_badge';
9
+ @import './_breadcrumb';
9
10
  @import './_button';
10
11
  @import './_card';
11
12
  @import './_dialog';
@@ -17,7 +18,6 @@
17
18
  @import './_list';
18
19
  @import './_loading';
19
20
  @import './_media';
20
- @import './_nav';
21
21
  @import './_progress';
22
22
  @import './_slider';
23
23
  @import './_table';
@@ -1,119 +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: Components ></title>
8
- </head>
9
-
10
- <body data-preload>
11
- <doc-layout>
12
-
13
- <h1>Navigation</h1>
14
- <p>The navigation is using the native <code>&lt;ul&gt;</code> inside a <code>&lt;nav&gt;</code> tag.</p>
15
- <doc-demo>
16
- <nav aria-label="Main navigaton">
17
- <ul>
18
- <li><a href="#" aria-current="page">Link 1</a></li>
19
- <li><a href="#">Link 2</a></li>
20
- <li><a href="#">Link 3</a></li>
21
- <li><a>Link 4</a></li>
22
- <li><button class="primary">Button</button></li>
23
- </ul>
24
- </nav>
25
- </doc-demo>
26
- <div class="code-group">
27
- <div role="tablist">
28
- <button role="tab" aria-controls="html">HTML</button>
29
- <button role="tab" aria-controls="scss">SCSS</button>
30
- <button role="tab" aria-controls="css">CSS</button>
31
- </div>
32
- <doc-code id="html" data-type="html" role="tabpanel">
33
- <nav aria-label="Main navigaton">
34
- <ul>
35
- <li><a href="#" aria-current="page">Link 1</a></li>
36
- <li><a href="#">Link 2</a></li>
37
- <li><a href="#">Link 3</a></li>
38
- <li><a>Link 4</a></li>
39
- <li><button class="primary">Button</button></li>
40
- </ul>
41
- </nav>
42
- </doc-code>
43
- <doc-code id="scss" data-type="scss" role="tabpanel">
44
- @import '@natachah/vanilla-frontend/scss/_nav';
45
- </doc-code>
46
- <doc-code id="css" data-type="css" role="tabpanel">
47
- --nav-direction
48
- --nav-justify
49
- --nav-align
50
- --nav-gap
51
- --nav-decoration
52
- --nav-color
53
- --nav-hover-color
54
- --nav-active-color
55
- --nav-disabled-opacity
56
- </doc-code>
57
- </div>
58
-
59
- <blockquote class="warning">
60
- <p>The custom properties for the navigation is overriding the default ones in the typography setting.</p>
61
- </blockquote>
62
-
63
- <p>You can make a vertical menu by setting the CSS property <code>--nav-direction</code> to <code>column</code>.</p>
64
-
65
- <h2>Breadcrumb</h2>
66
- <p>To create a breadcrumb navigation, always use <code>&lt;ol&gt;</code> inside a <code>&lt;nav&gt;</code> tag.</p>
67
- <p>The breadcrumb will automatically be distributed horizontally.</p>
68
- <doc-demo>
69
- <nav aria-label="Breadcrumb navigaton">
70
- <ol>
71
- <li><a href="#">One</a></li>
72
- <li><a href="#">Two</a></li>
73
- <li><a href="#">Three</a></li>
74
- <li aria-current="location">Four</li>
75
- </ol>
76
- </nav>
77
- </doc-demo>
78
- <div class="code-group">
79
- <div role="tablist">
80
- <button role="tab" aria-controls="html">HTML</button>
81
- <button role="tab" aria-controls="scss">SCSS</button>
82
-
83
- <button role="tab" aria-controls="css">CSS</button>
84
- </div>
85
- <doc-code id="html" data-type="html" role="tabpanel">
86
- <nav aria-label="Breadcrumb navigaton">
87
- <ol>
88
- <li><a href="#">One</a></li>
89
- <li><a href="#">Two</a></li>
90
- <li><a href="#">Three</a></li>
91
- <li aria-current="location">Four</li>
92
- </ol>
93
- </nav>
94
- </doc-code>
95
- <doc-code id="scss" data-type="scss" role="tabpanel">
96
- @import '@natachah/vanilla-frontend/scss/_nav';
97
- </doc-code>
98
- <doc-code id="css" data-type="css" role="tabpanel">
99
- --breadcrumb-divider
100
- --breadcrumb-divider-color
101
- --breadcrumb-gap
102
- --breadcrumb-decoration
103
- --breadcrumb-color
104
- --breadcrumb-hover-color
105
- --breadcrumb-active-color
106
- --breadcrumb-disabled-opacity
107
- </doc-code>
108
- </div>
109
-
110
- <blockquote class="warning">
111
- <p>The custom properties for the breadcrumb is overriding the default ones in the typography setting.</p>
112
- </blockquote>
113
-
114
-
115
- </doc-layout>
116
- <script type="module" src="/main.js"></script>
117
- </body>
118
-
119
- </html>
package/scss/_nav.scss DELETED
@@ -1,72 +0,0 @@
1
- ////
2
- /// ------------------------------------------------------------------
3
- /// Nav
4
- /// ------------------------------------------------------------------
5
- /// Create the navigation component
6
- ///
7
- /// @example <nav><ul>...</ul></nav> or <nav><ol>...</ol></nav>
8
- ///
9
- /// @group components
10
- /// @author Natacha Herth
11
- /// @since 1.0.0
12
- ///
13
- ////
14
-
15
- nav {
16
-
17
- // Reset the list style
18
- ul,
19
- ol {
20
- list-style: none;
21
- padding: 0;
22
- margin: 0;
23
- }
24
-
25
- ul {
26
-
27
- // Design the nav list as inline by default
28
- display: flex;
29
- flex-direction: var(--nav-direction, row);
30
- justify-content: var(--nav-justify, start);
31
- align-items: var(--nav-align, center);
32
- gap: var(--nav-gap, 1rem);
33
-
34
- // Reset the anchor CSS properties
35
- a {
36
- --anchor-decoration: var(--nav-decoration, currentColor);
37
- --anchor-color: var(--nav-color, currentColor);
38
- --anchor-hover-color: var(--nav-hover-color, var(--nav-color, currentColor));
39
- --anchor-active-color: var(--nav-active-color, var(--nav-hover-color, var(--nav-color, currentColor)));
40
- --anchor-disabled-opacity: var(--nav-disabled-opacity, var(--disabled-opacity));
41
- }
42
-
43
- }
44
-
45
- ol {
46
-
47
- // Design the breadcrumb list as inline by default
48
- display: flex;
49
- flex-direction: row;
50
- justify-content: start;
51
- align-items: center;
52
- gap: 0;
53
-
54
- // Add a divider between links
55
- li:not(:last-child)::after {
56
- content: var(--breadcrumb-divider, '/');
57
- color: var(--breadcrumb-divider-color, currentColor);
58
- margin-inline: var(--breadcrumb-gap, .5rem);
59
- }
60
-
61
- // Reset the anchor CSS properties
62
- a {
63
- --anchor-decoration: var(--breadcrumb-decoration, currentColor);
64
- --anchor-color: var(--breadcrumb-color, currentColor);
65
- --anchor-hover-color: var(--breadcrumb-hover-color, var(--breadcrumb-color, currentColor));
66
- --anchor-active-color: var(--breadcrumb-active-color, var(--breadcrumb-hover-color, var(--breadcrumb-color, currentColor)));
67
- --anchor-disabled-opacity: var(--breadcrumb-disabled-opacity, var(--disabled-opacity));
68
- }
69
-
70
- }
71
-
72
- }