Skip to content

Commit

Permalink
fix(update): replaced vue files
Browse files Browse the repository at this point in the history
  • Loading branch information
ThornWalli committed Sep 27, 2024
1 parent 973d89d commit 7512151
Show file tree
Hide file tree
Showing 20 changed files with 179 additions and 150 deletions.
21 changes: 10 additions & 11 deletions docs/src/components/content-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ The appropriate HTML element for the page structure is determined based on the `

## Properties

### abstract

- Type: `Boolean`
- Default: `false`

If set, the heading is rendered as an abstract heading. (e.g. `<slot />`)

### tag

- Type: `String`
Expand All @@ -35,7 +28,7 @@ Tag for the element.
### rootTags

- Type: `Array`
- Default: `inject('rootTags', ['main'])`
- Default: `inject('semanticRelease_rootTags', ['main'])`

Available tags for the root structure.

Expand All @@ -44,7 +37,7 @@ Available tags for the root structure.
### contentTags

- Type: `Array`
- Default: `inject('contentTags', ['article', 'section'])`
- Default: `inject('semanticRelease_contentTags', ['article', 'section'])`

Available tags for the content structure.

Expand All @@ -57,6 +50,13 @@ Available tags for the content structure.

Can be used to overwrite the level.

### debug

- Type: `Boolean`
- Default: `inject('semanticRelease_debug', false)`

If set, the following attributes are set on the element: `data-current-tag`, `data-current-level` and `data-parent-level`.

## v-slot

### default
Expand Down Expand Up @@ -85,8 +85,7 @@ Can be used to overwrite the level.
</template>
<script setup>
import ContentContainer from 'vue-semantic-structure/ContentContainer.vue';
import ContentHeadline from 'vue-semantic-structure/ContentHeadline.vue';
import { ContentContainer, ContentHeadline } from 'vue-semantic-structure';
</script>
```

Expand Down
17 changes: 8 additions & 9 deletions docs/src/components/content-headline.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ The deeper the nesting, the smaller the heading.

## Properties

### abstract

- Type: `Boolean`
- Default: `false`

If set, the heading is rendered as an abstract heading. (e.g. `<slot />`)

### tag

- Type: `String`
- Default: `null`

Tag for the element.

### debug

- Type: `Boolean`
- Default: `inject('semanticRelease_debug', false)`

If set, the following attributes are set on the element: `data-current-tag`, `data-current-level` and `data-parent-level`.

## v-slot

### default
Expand Down Expand Up @@ -62,8 +62,7 @@ Tag for the element.
</template>
<script setup>
import ContentContainer from 'vue-semantic-structure/ContentContainer.vue';
import ContentHeadline from 'vue-semantic-structure/ContentHeadline.vue';
import { ContentContainer, ContentHeadline } from 'vue-semantic-structure';
</script>
```

Expand Down
12 changes: 6 additions & 6 deletions docs/src/composables/use-content-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ const { currentTag } = useContentContainer()

## Options

| Property | Type | Description | Default Value |
| ------------- | -------- | ----------------------------------------- | ------------------------ |
| `tag` | `String` | Can be used to overwrite the tag. | `undefined` |
| `contentTags` | `Array` | Available tags for the content structure. | `['section', 'article']` |
| `rootTags` | `Array` | Available tags for the root structure. | `['main', undefined]` |
| `level` | `Number` | Can be used to overwrite the level. | `undefined` |
| Property | Type | Description | Default Value |
| ------------- | -------- | ----------------------------------------- | --------------------------------------------------------------- |
| `tag` | `String` | Can be used to overwrite the tag. | `undefined` |
| `contentTags` | `Array` | Available tags for the content structure. | `inject('semanticRelease_contentTags', ['article', 'section'])` |
| `rootTags` | `Array` | Available tags for the root structure. | `inject('semanticRelease_rootTags', ['main'])` |
| `level` | `Number` | Can be used to overwrite the level. | `undefined` |

## Return

Expand Down
3 changes: 1 addition & 2 deletions docs/src/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ If `ContentContainer` is level 2, `ContentHeadline` level 2 is rendered as `h2`.
</template>
<script setup>
import ContentContainer from 'vue-semantic-structure/ContentContainer.vue';
import ContentHeadline from 'vue-semantic-structure/ContentHeadline.vue';
import { ContentContainer, ContentHeadline } from 'vue-semantic-structure';
</script>
```

Expand Down
6 changes: 3 additions & 3 deletions docs/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The main structure is in the `<main>` tag, which contains the main components.
</template>
<script setup>
import ContentContainer from 'vue-semantic-structure/ContentContainer.vue';
import { ContentContainer } from 'vue-semantic-structure';
</script>
```

Expand Down Expand Up @@ -56,7 +56,7 @@ It is recommended to create a separate component that extends the `ContentContai
</template>
<script setup>
import ContentContainer from 'vue-semantic-structure/ContentContainer.vue';
import { ContentContainer } from 'vue-semantic-structure';
</script>
```

Expand All @@ -76,7 +76,7 @@ In comparison to the basic application, the entire content is enclosed in anothe
</template>
<script setup>
import ContentContainer from 'vue-semantic-structure/ContentContainer.vue';
import { ContentContainer } from 'vue-semantic-structure';
</script>
```

Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./ContentContainer.vue": "./dist/ContentContainer.vue",
"./ContentHeadline.vue": "./dist/ContentHeadline.vue"
}
},
"main": "./dist/index.cjs",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion playground/src/components/DebugArticleContentContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<script setup>
import { inject, provide } from 'vue';
import ContentContainer from 'vue-semantic-structure/ContentContainer.vue';
import { ContentContainer } from 'vue-semantic-structure';
const props = defineProps({
debug: {
Expand Down
2 changes: 1 addition & 1 deletion playground/src/components/DebugContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script setup>
import { inject, provide } from 'vue';
import ContentContainer from 'vue-semantic-structure/ContentContainer.vue';
import { ContentContainer } from 'vue-semantic-structure';
const props = defineProps({
debug: {
Expand Down
2 changes: 1 addition & 1 deletion playground/src/components/DebugHeadline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<script setup>
import { inject } from 'vue';
import ContentHeadline from 'vue-semantic-structure/ContentHeadline.vue';
import { ContentHeadline } from 'vue-semantic-structure';
const debug = inject('debugHeadings', false);
</script>
72 changes: 72 additions & 0 deletions src/ContentContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { h, inject, provide } from 'vue';
import useContentContainer from './useContentContainer';

const ContentContainer = {
name: 'ContentContainer',
props: {
tag: {
type: String,
default: null
},
rootTags: {
type: Array,
default() {
return inject('semanticRelease_rootTags', ['main']);
}
},
contentTags: {
type: Array,
default() {
return inject('semanticRelease_contentTags', ['article', 'section']);
}
},
level: {
type: Number,
default: undefined
},
debug: {
type: Boolean,
default() {
return inject('semanticRelease_debug', false);
}
}
},

setup(props) {
const { parentLevel, currentLevel, currentTag } = useContentContainer(props);
provide('semanticRelease_debug', props.debug);
return { parentLevel, currentLevel, currentTag };
},

render() {
const { currentTag, parentLevel, currentLevel } = this;
return h(
currentTag,
{
...this.$attrs,
...getDebugAttrs(this)
},
{
default: () =>
this.$slots.default({
currentTag,
parentLevel,
currentLevel
})
}
);
}
};

const getDebugAttrs = context => {
if (context.debug) {
return {
'data-current-tag': context.currentTag,
'data-current-level': context.currentLevel,
'data-parent-level': context.parentLevel
};
}
return {};
};

export default ContentContainer;
58 changes: 0 additions & 58 deletions src/ContentContainer.vue

This file was deleted.

53 changes: 53 additions & 0 deletions src/ContentHeadline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { h, inject } from 'vue';
import useContentHeadline from './useContentHeadline';

const ContentHeadline = {
name: 'ContentHeadline',
props: {
tag: {
type: String,
default: null
},
debug: {
type: Boolean,
default() {
return inject('semanticRelease_debug', false);
}
}
},

setup() {
const { parentLevel, currentLevel, currentTag } = useContentHeadline();
return { parentLevel, currentLevel, currentTag };
},

render() {
const { currentTag, currentLevel } = this;
return h(
currentTag,
{
...this.$attrs,
...getDebugAttrs(this)
},
{
default: () =>
this.$slots.default({
currentTag,
currentLevel
})
}
);
}
};

const getDebugAttrs = context => {
if (context.debug) {
return {
'data-current-tag': context.currentTag,
'data-current-level': context.currentLevel
};
}
return {};
};

export default ContentHeadline;
Loading

0 comments on commit 7512151

Please sign in to comment.