Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the as property in the CHeader component to use semantic tag #290

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/coreui-vue/src/components/header/CHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import { defineComponent, h } from 'vue'
const CHeader = defineComponent({
name: 'CHeader',
props: {
/**
* Component used for the root node. Either a string to use a HTML element or a component.
*/
as: {
type: String,
default: 'div',
},
/**
* Defines optional container wrapping children elements.
*
Expand Down Expand Up @@ -31,7 +38,7 @@ const CHeader = defineComponent({
setup(props, { slots }) {
return () =>
h(
'div',
props.as,
{ class: ['header', { [`header-${props.position}`]: props.position }] },
props.container
? h(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ const customWrapper = mount(Component, {
},
})

const customWrapperTwo = mount(Component, {
propsData: {
as: 'header',
},
slots: {
default: 'Default slot',
},
})

describe(`Loads and display ${ComponentName} component`, () => {
it('has a name', () => {
expect(Component.name).toMatch(ComponentName)
Expand All @@ -44,3 +53,13 @@ describe(`Customize ${ComponentName} component`, () => {
expect(customWrapper.find('.container-lg').classes('container-lg')).toBe(true)
})
})


describe(`Customize (number two) ${ComponentName} component`, () => {
it('renders correctly', () => {
expect(customWrapperTwo.html()).toMatchSnapshot()
})
it('tag name is custom', () => {
expect(customWrapperTwo.element.tagName).toBe('HEADER')
})
})
9 changes: 5 additions & 4 deletions packages/docs/api/header/CHeader.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import CHeader from '@coreui/vue/src/components/header/CHeader'

#### Props

| Prop name | Description | Type | Values | Default |
| ------------- | ------------------------------------------------------ | --------------- | ------------------------------------------------------------- | ------- |
| **container** | Defines optional container wrapping children elements. | boolean\|string | `boolean`, `'sm'`, `'md'`, `'lg'`, `'xl'`, `'xxl'`, `'fluid'` | - |
| **position** | Place header in non-static positions. | string | `'fixed'`, `'sticky'` | - |
| Prop name | Description | Type | Values | Default |
| ------------- | --------------------------------------------------------------------------------------- | --------------- | ------------------------------------------------------------- | ------- |
| **as** | Component used for the root node. Either a string to use a HTML element or a component. | string | - | 'div' |
| **container** | Defines optional container wrapping children elements. | boolean\|string | `boolean`, `'sm'`, `'md'`, `'lg'`, `'xl'`, `'xxl'`, `'fluid'` | - |
| **position** | Place header in non-static positions. | string | `'fixed'`, `'sticky'` | - |