Skip to content

Commit e3a5c2e

Browse files
committed
fix(update): adde inherit props; update docs
1 parent bece841 commit e3a5c2e

File tree

5 files changed

+51
-51
lines changed

5 files changed

+51
-51
lines changed

docs/src/components/content-container.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The `ContentContainer` is used to map the depth of the element structure.
1010

1111
With each nested `ContentContainer` the element structure becomes one level deeper (`level`).
1212

13-
The appropriate HTML element for the page structure is determined based on the `level`. (e.g. `main`, `section`, `article`)
13+
The appropriate HTML element for the page structure is determined based on the `level`. (e.g. `main`, `article`, `section`)
1414

1515
## Properties
1616

@@ -28,19 +28,23 @@ If set, the heading is rendered as an abstract heading. (e.g. `<slot />`)
2828

2929
Tag for the element.
3030

31-
### contentTags
31+
### rootTags
3232

3333
- Type: `Array`
34-
- Default: `['section', 'article']`
34+
- Default: `inject('rootTags', ['main'])`
3535

36-
Available tags for the content structure.
36+
Available tags for the root structure.
3737

38-
### rootTags
38+
*If not set, the value is inherited from the parent element.*
39+
40+
### contentTags
3941

4042
- Type: `Array`
41-
- Default: `['main', null]`
43+
- Default: `inject('contentTags', ['article', 'section'])`
4244

43-
Available tags for the root structure.
45+
Available tags for the content structure.
46+
47+
*If not set, the value is inherited from the parent element.*
4448

4549
### level
4650

@@ -64,15 +68,13 @@ Can be used to overwrite the level.
6468
```vue
6569
<template>
6670
<ContentContainer>
67-
<div>
71+
<header>
6872
<ContentHeadline> Primary Headline (h1) </ContentHeadline>
69-
</div>
73+
</header>
7074
<ContentContainer>
7175
<ContentHeadline> Secondary Headline (h2) </ContentHeadline>
7276
<ContentContainer>
73-
<ContentContainer>
74-
<ContentHeadline> Tertiary Headline (h3) </ContentHeadline>
75-
</ContentContainer>
77+
<ContentHeadline> Tertiary Headline (h3) </ContentHeadline>
7678
</ContentContainer>
7779
</ContentContainer>
7880
</ContentContainer>
@@ -81,15 +83,13 @@ Can be used to overwrite the level.
8183

8284
```html
8385
<main>
84-
<div>
86+
<header>
8587
<h1> Primary Headline (h1) </h1>
86-
</div>
88+
</header>
8789
<article>
8890
<h2> Secondary Headline (h2) </h2>
8991
<section>
90-
<article>
91-
<h3> Tertiary Headline (h3) </h3>
92-
</article>
92+
<h3> Tertiary Headline (h3) </h3>
9393
</section>
9494
</article>
9595
</main>

docs/src/components/content-headline.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,13 @@ Tag for the element.
4545
```vue
4646
<template>
4747
<ContentContainer>
48-
<div>
48+
<header>
4949
<ContentHeadline> Primary Headline (h1) </ContentHeadline>
50-
</div>
50+
</header>
5151
<ContentContainer>
5252
<ContentHeadline> Secondary Headline (h2) </ContentHeadline>
5353
<ContentContainer>
54-
<ContentContainer>
55-
<ContentHeadline> Tertiary Headline (h3) </ContentHeadline>
56-
</ContentContainer>
54+
<ContentHeadline> Tertiary Headline (h3) </ContentHeadline>
5755
</ContentContainer>
5856
</ContentContainer>
5957
</ContentContainer>
@@ -62,15 +60,13 @@ Tag for the element.
6260

6361
```html
6462
<main>
65-
<div>
63+
<header>
6664
<h1> Primary Headline (h1) </h1>
67-
</div>
65+
</header>
6866
<article>
6967
<h2> Secondary Headline (h2) </h2>
7068
<section>
71-
<article>
72-
<h3> Tertiary Headline (h3) </h3>
73-
</article>
69+
<h3> Tertiary Headline (h3) </h3>
7470
</section>
7571
</article>
7672
</main>

docs/src/usage.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ The main structure is in the `<main>` tag, which contains the main components.
1212

1313
::: code-group
1414

15-
```html [HTML]
16-
<main>
17-
<header class="hero">…</header>
18-
<section class="text-image">…</section>
19-
<section class="gallery">…</section>
20-
</main>
21-
```
22-
2315
```vue [Vue]
2416
<template>
2517
<ContentContainer>
@@ -30,6 +22,14 @@ The main structure is in the `<main>` tag, which contains the main components.
3022
</template>
3123
```
3224

25+
```html [HTML]
26+
<main>
27+
<header class="hero">…</header>
28+
<section class="text-image">…</section>
29+
<section class="gallery">…</section>
30+
</main>
31+
```
32+
3333
:::
3434

3535
## Advance Usage
@@ -60,16 +60,6 @@ In comparison to the basic application, the entire content is enclosed in anothe
6060

6161
::: code-group
6262

63-
```html [HTML]
64-
<main>
65-
<article>
66-
<header class="hero">…</header>
67-
<section class="text-image">…</section>
68-
<section class="gallery">…</section>
69-
</article>
70-
</main>
71-
```
72-
7363
```vue [Vue]
7464
<template>
7565
<CustomContentContainer>
@@ -82,4 +72,14 @@ In comparison to the basic application, the entire content is enclosed in anothe
8272
</template>
8373
```
8474

75+
```html [HTML]
76+
<main>
77+
<article>
78+
<header class="hero">…</header>
79+
<section class="text-image">…</section>
80+
<section class="gallery">…</section>
81+
</article>
82+
</main>
83+
```
84+
8585
:::

src/ContentContainer.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
</template>
1818

1919
<script>
20+
import { inject } from 'vue';
2021
import useContentContainer from './useContentContainer.js';
2122
2223
export default {
@@ -31,16 +32,16 @@ export default {
3132
type: String,
3233
default: null
3334
},
34-
contentTags: {
35+
rootTags: {
3536
type: Array,
3637
default() {
37-
return ['article', 'section'];
38+
return inject('rootTags', ['main']);
3839
}
3940
},
40-
rootTags: {
41+
contentTags: {
4142
type: Array,
4243
default() {
43-
return ['main'];
44+
return inject('contentTags', ['article', 'section']);
4445
}
4546
},
4647
level: {

src/useContentContainer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ import { provide, inject, computed } from 'vue';
22

33
export default function useContentContainer({ tag, contentTags, rootTags, level } = {}) {
44
tag = tag || null;
5-
contentTags = contentTags || ['article', 'section'];
6-
rootTags = rootTags || ['main'];
5+
rootTags = rootTags || inject('contentTags', ['main']);
6+
contentTags = contentTags || inject('contentTags', ['article', 'section']);
77
level = level || undefined;
88

9+
provide('rootTags', rootTags);
10+
provide('contentTags', contentTags);
11+
912
const parentLevel = inject('parentLevel', 0);
1013
const currentLevel = computed(() => (level !== undefined ? level : parentLevel + 1));
1114
const currentTag = computed(() => {

0 commit comments

Comments
 (0)