Skip to content

Commit e70b9e5

Browse files
committed
refactor: migrate from component property to as
1 parent 95cf2c7 commit e70b9e5

File tree

17 files changed

+91
-91
lines changed

17 files changed

+91
-91
lines changed

packages/coreui-vue/src/components/dropdown/CDropdownToggle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ const CDropdownToggle = defineComponent({
176176
CButton,
177177
{
178178
...togglerProps.value,
179+
as: props.as,
179180
color: props.color,
180-
component: props.as,
181181
disabled: props.disabled,
182182
shape: props.shape,
183183
size: props.size,

packages/coreui-vue/src/components/nav/CNavLink.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ const CNavLink = defineComponent({
3030
h(
3131
CLink,
3232
{
33-
class: 'nav-link',
33+
as: props.as,
3434
active: props.active,
35-
component: props.as,
35+
class: 'nav-link',
3636
disabled: props.disabled,
3737
href: props.href,
3838
},

packages/coreui-vue/src/components/pagination/CPaginationItem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ const CPaginationItem = defineComponent({
4141
? h(
4242
CLink,
4343
{
44+
as: component,
4445
class: ['page-link'],
45-
component: component,
4646
href: props.href,
4747
},
4848
{

packages/docs/.vuepress/theme-coreui/src/client/components/Header.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<CDropdownItem
2929
:active="colorMode === 'light'"
3030
class="d-flex align-items-center"
31-
component="button"
31+
as="button"
3232
type="button"
3333
@click="setColorMode('light')"
3434
>
@@ -37,7 +37,7 @@
3737
<CDropdownItem
3838
:active="colorMode === 'dark'"
3939
class="d-flex align-items-center"
40-
component="button"
40+
as="button"
4141
type="button"
4242
@click="setColorMode('dark')"
4343
>
@@ -46,7 +46,7 @@
4646
<CDropdownItem
4747
:active="colorMode === 'auto'"
4848
class="d-flex align-items-center"
49-
component="button"
49+
as="button"
5050
type="button"
5151
@click="setColorMode('auto')"
5252
>
@@ -62,7 +62,7 @@
6262
<CButton
6363
class="d-lg-inline-block my-2 my-md-0 ms-md-3"
6464
color="primary"
65-
component="a"
65+
as="a"
6666
href="https://coreui.io/vue/docs/getting-started/introduction.html"
6767
variant="outline"
6868
>
@@ -79,7 +79,7 @@
7979
<CButton
8080
class="d-lg-inline-block my-2 my-md-0 ms-md-3"
8181
color="primary"
82-
component="a"
82+
as="a"
8383
href="https://coreui.io/pricing/?framework=vue&docs=coreui-header-button"
8484
>
8585
Get CoreUI PRO

packages/docs/components/button.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ The `<CButton>` component are designed for `<button>` , `<a>` or `<input>` el
4747
If you're using `<CButton>` component as `<a>` elements that are used to trigger functionality ex. collapsing content, these links should be given a `role="button"` to adequately communicate their meaning to assistive technologies such as screen readers.
4848

4949
::: demo
50-
<CButton component="a" color="primary" href="#" role="button">Link</CButton>
50+
<CButton as="a" color="primary" href="#" role="button">Link</CButton>
5151
<CButton type="submit" color="primary">Button</CButton>
52-
<CButton component="input" type="button" color="primary" value="Input"/>
53-
<CButton component="input" type="submit" color="primary" value="Submit"/>
54-
<CButton component="input" type="reset" color="primary" value="Reset"/>
52+
<CButton as="input" type="button" color="primary" value="Input"/>
53+
<CButton as="input" type="submit" color="primary" value="Submit"/>
54+
<CButton as="input" type="reset" color="primary" value="Reset"/>
5555
:::
5656
```vue
57-
<CButton component="a" color="primary" href="#" role="button">Link</CButton>
57+
<CButton as="a" color="primary" href="#" role="button">Link</CButton>
5858
<CButton type="submit" color="primary">Button</CButton>
59-
<CButton component="input" type="button" color="primary" value="Input"/>
60-
<CButton component="input" type="submit" color="primary" value="Submit"/>
61-
<CButton component="input" type="reset" color="primary" value="Reset"/>
59+
<CButton as="input" type="button" color="primary" value="Input"/>
60+
<CButton as="input" type="submit" color="primary" value="Submit"/>
61+
<CButton as="input" type="reset" color="primary" value="Reset"/>
6262
```
6363

6464
## Outline buttons
@@ -197,12 +197,12 @@ Disabled buttons using the `<a>` component act a little different:
197197
`<a>`s don't support the `disabled` attribute, so CoreUI has to add `.disabled` class to make buttons look inactive. CoreUI also has to add to the disabled button component `aria-disabled="true"` attribute to show the state of the component to assistive technologies.
198198

199199
::: demo
200-
<CButton component="a" href="#" color="primary" size="lg" disabled>Primary link</CButton>
201-
<CButton component="a" href="#" color="secondary" size="lg" disabled>Link</CButton>
200+
<CButton as="a" href="#" color="primary" size="lg" disabled>Primary link</CButton>
201+
<CButton as="a" href="#" color="secondary" size="lg" disabled>Link</CButton>
202202
:::
203203
```vue
204-
<CButton component="a" href="#" color="primary" size="lg" disabled>Primary link</CButton>
205-
<CButton component="a" href="#" color="secondary" size="lg" disabled>Link</CButton>
204+
<CButton as="a" href="#" color="primary" size="lg" disabled>Primary link</CButton>
205+
<CButton as="a" href="#" color="secondary" size="lg" disabled>Link</CButton>
206206
```
207207

208208
The `.disabled` class uses `pointer-events: none` to try to disable the link functionality of `<a>`s, but that CSS property is not yet standardized. Besides, even in browsers that do support `pointer-events: none`, keyboard navigation remains unaffected, meaning that sighted keyboard users and users of assistive technologies will still be able to activate these links. So to be safe, we automatically add a `tabindex="-1"` attribute on disabled links (to prevent them from receiving keyboard focus) and use custom JavaScript to disable their functionality.

packages/docs/components/card.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,11 @@ Add an optional header and/or footer within a card.
241241
</CCard>
242242
```
243243

244-
Card headers can be styled by adding ex. `component="h5"`.
244+
Card headers can be styled by adding ex. `as="h5"`.
245245

246246
::: demo
247247
<CCard>
248-
<CCardHeader component="h5">Header</CCardHeader>
248+
<CCardHeader as="h5">Header</CCardHeader>
249249
<CCardBody>
250250
<CCardTitle>Special title treatment</CCardTitle>
251251
<CCardText>With supporting text below as a natural lead-in to additional content.</CCardText>
@@ -255,7 +255,7 @@ Card headers can be styled by adding ex. `component="h5"`.
255255
:::
256256
```vue
257257
<CCard>
258-
<CCardHeader component="h5">Header</CCardHeader>
258+
<CCardHeader as="h5">Header</CCardHeader>
259259
<CCardBody>
260260
<CCardTitle>Special title treatment</CCardTitle>
261261
<CCardText>With supporting text below as a natural lead-in to additional content.</CCardText>

packages/docs/components/dropdown.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ And with `<a>` elements:
4343

4444
::: demo
4545
<CDropdown color="secondary" togglerText="Dropdown button">
46-
<CDropdownToggle component="a" color="primary">Dropdown Button</CDropdownToggle>
46+
<CDropdownToggle as="a" color="primary">Dropdown Button</CDropdownToggle>
4747
<CDropdownMenu>
4848
<CDropdownItem href="#">Action</CDropdownItem>
4949
<CDropdownItem href="#">Another action</CDropdownItem>
@@ -53,7 +53,7 @@ And with `<a>` elements:
5353
:::
5454
```vue
5555
<CDropdown color="secondary" togglerText="Dropdown button">
56-
<CDropdownToggle component="a" color="primary">Dropdown Button</CDropdownToggle>
56+
<CDropdownToggle as="a" color="primary">Dropdown Button</CDropdownToggle>
5757
<CDropdownMenu>
5858
<CDropdownItem href="#">Action</CDropdownItem>
5959
<CDropdownItem href="#">Another action</CDropdownItem>

packages/docs/components/list-group.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -76,43 +76,43 @@ Add `disabled` boolean property to a `<CListGroupItem>` to make it appear disabl
7676

7777
## Links and buttons
7878

79-
Use `<a>`s or `<button>`s to create _actionable_ list group items with hover, disabled, and active states by adding `component="a|button"`. We separate these pseudo-classes to ensure list groups made of non-interactive elements (like `<li>`s or `<div>`s) don't provide a click or tap affordance.
79+
Use `<a>`s or `<button>`s to create _actionable_ list group items with hover, disabled, and active states by adding `as="a|button"`. We separate these pseudo-classes to ensure list groups made of non-interactive elements (like `<li>`s or `<div>`s) don't provide a click or tap affordance.
8080

8181
::: demo
8282
<CListGroup>
83-
<CListGroupItem component="a" href="#" active>Cras justo odio</CListGroupItem>
84-
<CListGroupItem component="a" href="#">Dapibus ac facilisis in</CListGroupItem>
85-
<CListGroupItem component="a" href="#">Morbi leo risus</CListGroupItem>
86-
<CListGroupItem component="a" href="#">Porta ac consectetur ac</CListGroupItem>
87-
<CListGroupItem component="a" href="#" disabled>Vestibulum at eros</CListGroupItem>
83+
<CListGroupItem as="a" href="#" active>Cras justo odio</CListGroupItem>
84+
<CListGroupItem as="a" href="#">Dapibus ac facilisis in</CListGroupItem>
85+
<CListGroupItem as="a" href="#">Morbi leo risus</CListGroupItem>
86+
<CListGroupItem as="a" href="#">Porta ac consectetur ac</CListGroupItem>
87+
<CListGroupItem as="a" href="#" disabled>Vestibulum at eros</CListGroupItem>
8888
</CListGroup>
8989
:::
9090
```vue
9191
<CListGroup>
92-
<CListGroupItem component="a" href="#" active>Cras justo odio</CListGroupItem>
93-
<CListGroupItem component="a" href="#">Dapibus ac facilisis in</CListGroupItem>
94-
<CListGroupItem component="a" href="#">Morbi leo risus</CListGroupItem>
95-
<CListGroupItem component="a" href="#">Porta ac consectetur ac</CListGroupItem>
96-
<CListGroupItem component="a" href="#" disabled>Vestibulum at eros</CListGroupItem>
92+
<CListGroupItem as="a" href="#" active>Cras justo odio</CListGroupItem>
93+
<CListGroupItem as="a" href="#">Dapibus ac facilisis in</CListGroupItem>
94+
<CListGroupItem as="a" href="#">Morbi leo risus</CListGroupItem>
95+
<CListGroupItem as="a" href="#">Porta ac consectetur ac</CListGroupItem>
96+
<CListGroupItem as="a" href="#" disabled>Vestibulum at eros</CListGroupItem>
9797
</CListGroup>
9898
```
9999

100100
::: demo
101101
<CListGroup>
102-
<CListGroupItem component="button" active>Cras justo odio</CListGroupItem>
103-
<CListGroupItem component="button">Dapibus ac facilisis in</CListGroupItem>
104-
<CListGroupItem component="button">Morbi leo risus</CListGroupItem>
105-
<CListGroupItem component="button">Porta ac consectetur ac</CListGroupItem>
106-
<CListGroupItem component="button" disabled>Vestibulum at eros</CListGroupItem>
102+
<CListGroupItem as="button" active>Cras justo odio</CListGroupItem>
103+
<CListGroupItem as="button">Dapibus ac facilisis in</CListGroupItem>
104+
<CListGroupItem as="button">Morbi leo risus</CListGroupItem>
105+
<CListGroupItem as="button">Porta ac consectetur ac</CListGroupItem>
106+
<CListGroupItem as="button" disabled>Vestibulum at eros</CListGroupItem>
107107
</CListGroup>
108108
:::
109109
```vue
110110
<CListGroup>
111-
<CListGroupItem component="button" active>Cras justo odio</CListGroupItem>
112-
<CListGroupItem component="button">Dapibus ac facilisis in</CListGroupItem>
113-
<CListGroupItem component="button">Morbi leo risus</CListGroupItem>
114-
<CListGroupItem component="button">Porta ac consectetur ac</CListGroupItem>
115-
<CListGroupItem component="button" disabled>Vestibulum at eros</CListGroupItem>
111+
<CListGroupItem as="button" active>Cras justo odio</CListGroupItem>
112+
<CListGroupItem as="button">Dapibus ac facilisis in</CListGroupItem>
113+
<CListGroupItem as="button">Morbi leo risus</CListGroupItem>
114+
<CListGroupItem as="button">Porta ac consectetur ac</CListGroupItem>
115+
<CListGroupItem as="button" disabled>Vestibulum at eros</CListGroupItem>
116116
</CListGroup>
117117
```
118118

@@ -183,14 +183,14 @@ Contextual classes also work with `<a>`s or `<button>`s. Note the addition of th
183183

184184
::: demo
185185
<CListGroup>
186-
<CListGroupItem component="a" href="#">Dapibus ac facilisis in</CListGroupItem>
187-
<CListGroupItem v-for="(item) in ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark']" component="a" href="#" :color="item">A simple {{item}} list group item</CListGroupItem>
186+
<CListGroupItem as="a" href="#">Dapibus ac facilisis in</CListGroupItem>
187+
<CListGroupItem v-for="(item) in ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark']" as="a" href="#" :color="item">A simple {{item}} list group item</CListGroupItem>
188188
</CListGroup>
189189
:::
190190
```vue
191191
<CListGroup>
192-
<CListGroupItem component="a" href="#">Dapibus ac facilisis in</CListGroupItem>
193-
<CListGroupItem v-for="(item) in ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark']" component="a" href="#" :color="item">A simple {{item}} list group item</CListGroupItem>
192+
<CListGroupItem as="a" href="#">Dapibus ac facilisis in</CListGroupItem>
193+
<CListGroupItem v-for="(item) in ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark']" as="a" href="#" :color="item">A simple {{item}} list group item</CListGroupItem>
194194
</CListGroup>
195195
```
196196

@@ -223,23 +223,23 @@ Add nearly any HTML within, even for linked list groups like the one below, with
223223

224224
::: demo
225225
<CListGroup>
226-
<CListGroupItem component="a" href="#" active>
226+
<CListGroupItem as="a" href="#" active>
227227
<div class="d-flex w-100 justify-content-between">
228228
<h5 class="mb-1">List group item heading</h5>
229229
<small>3 days ago</small>
230230
</div>
231231
<p class="mb-1">Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</p>
232232
<small>Donec id elit non mi porta.</small>
233233
</CListGroupItem>
234-
<CListGroupItem component="a" href="#">
234+
<CListGroupItem as="a" href="#">
235235
<div class="d-flex w-100 justify-content-between">
236236
<h5 class="mb-1">List group item heading</h5>
237237
<small class="text-body-secondary">3 days ago</small>
238238
</div>
239239
<p class="mb-1">Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</p>
240240
<small class="text-body-secondary">Donec id elit non mi porta.</small>
241241
</CListGroupItem>
242-
<CListGroupItem component="a" href="#">
242+
<CListGroupItem as="a" href="#">
243243
<div class="d-flex w-100 justify-content-between">
244244
<h5 class="mb-1">List group item heading</h5>
245245
<small class="text-body-secondary">3 days ago</small>
@@ -251,23 +251,23 @@ Add nearly any HTML within, even for linked list groups like the one below, with
251251
:::
252252
```vue
253253
<CListGroup>
254-
<CListGroupItem component="a" href="#" active>
254+
<CListGroupItem as="a" href="#" active>
255255
<div class="d-flex w-100 justify-content-between">
256256
<h5 class="mb-1">List group item heading</h5>
257257
<small>3 days ago</small>
258258
</div>
259259
<p class="mb-1">Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</p>
260260
<small>Donec id elit non mi porta.</small>
261261
</CListGroupItem>
262-
<CListGroupItem component="a" href="#">
262+
<CListGroupItem as="a" href="#">
263263
<div class="d-flex w-100 justify-content-between">
264264
<h5 class="mb-1">List group item heading</h5>
265265
<small class="text-body-secondary">3 days ago</small>
266266
</div>
267267
<p class="mb-1">Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</p>
268268
<small class="text-body-secondary">Donec id elit non mi porta.</small>
269269
</CListGroupItem>
270-
<CListGroupItem component="a" href="#">
270+
<CListGroupItem as="a" href="#">
271271
<div class="d-flex w-100 justify-content-between">
272272
<h5 class="mb-1">List group item heading</h5>
273273
<small class="text-body-secondary">3 days ago</small>

packages/docs/components/navbar.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ And because we use classes for our navs, you can avoid the list-based approach e
237237
<CNavbarBrand href="#">Navbar</CNavbarBrand>
238238
<CNavbarToggler aria-label="Toggle navigation" aria-expanded={visible} @click="visible = !visible"/>
239239
<CCollapse class="navbar-collapse" :visible="visible">
240-
<CNavbarNav component="nav">
240+
<CNavbarNav as="nav">
241241
<CNavLink href="#" active>
242242
Home
243243
</CNavLink>
@@ -255,7 +255,7 @@ And because we use classes for our navs, you can avoid the list-based approach e
255255
<CNavbarBrand href="#">Navbar</CNavbarBrand>
256256
<CNavbarToggler aria-label="Toggle navigation" aria-expanded={visible} @click="visible = !visible"/>
257257
<CCollapse class="navbar-collapse" :visible="visible">
258-
<CNavbarNav component="nav">
258+
<CNavbarNav as="nav">
259259
<CNavLink href="#" active>
260260
Home
261261
</CNavLink>

packages/docs/components/navs-tabs.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Classes are used throughout, so your markup can be super flexible. Use `<ul>`s l
5656

5757
::: demo
5858

59-
<CNav component="nav">
59+
<CNav as="nav">
6060
<CNavLink href="#" active>
6161
Active
6262
</CNavLink>
@@ -70,7 +70,7 @@ Classes are used throughout, so your markup can be super flexible. Use `<ul>`s l
7070
:::
7171
```vue
7272
73-
<CNav component="nav">
73+
<CNav as="nav">
7474
<CNavLink href="#" active>
7575
Active
7676
</CNavLink>
@@ -495,7 +495,7 @@ For equal-width elements, use `layout="justified"`. All horizontal space will be
495495
If you need responsive nav variations, consider using a series of [flexbox utilities](https://coreui.io/docs/utilities/flex). While more verbose, these utilities offer greater customization across responsive breakpoints. In the example below, our nav will be stacked on the lowest breakpoint, then adapt to a horizontal layout that fills the available width starting from the small breakpoint.
496496

497497
::: demo
498-
<CNav component="nav" variant="pills" class="flex-column flex-sm-row">
498+
<CNav as="nav" variant="pills" class="flex-column flex-sm-row">
499499
<CNavLink href="#" active>
500500
Active
501501
</CNavLink>
@@ -507,7 +507,7 @@ If you need responsive nav variations, consider using a series of [flexbox utili
507507
</CNav>
508508
:::
509509
```vue
510-
<CNav component="nav" variant="pills" class="flex-column flex-sm-row">
510+
<CNav as="nav" variant="pills" class="flex-column flex-sm-row">
511511
<CNavLink href="#" active>
512512
Active
513513
</CNavLink>

packages/docs/components/placeholder.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ In the example below, we take a typical card component and recreate it with plac
3030
</CCardBody>
3131
</CCard>
3232
<CCard style="width: 18rem">
33-
<CCardImage component="svg" orientation="top" width="100%" height="162" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder" preserveAspectRatio="xMidYMid slice" focusable="false">
33+
<CCardImage as="svg" orientation="top" width="100%" height="162" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder" preserveAspectRatio="xMidYMid slice" focusable="false">
3434
<title>Placeholder</title><rect width="100%" height="100%" fill="#868e96"></rect>
3535
</CCardImage>
3636
<CCardBody>
@@ -62,7 +62,7 @@ In the example below, we take a typical card component and recreate it with plac
6262
</CCardBody>
6363
</CCard>
6464
<CCard style="width: 18rem">
65-
<CCardImage component="svg" orientation="top" width="100%" height="162" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder" preserveAspectRatio="xMidYMid slice" focusable="false">
65+
<CCardImage as="svg" orientation="top" width="100%" height="162" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder" preserveAspectRatio="xMidYMid slice" focusable="false">
6666
<title>Placeholder</title><rect width="100%" height="100%" fill="#868e96"></rect>
6767
</CCardImage>
6868
<CCardBody>
@@ -170,19 +170,19 @@ The size of `<CPlaceholder>`s are based on the typographic style of the parent e
170170
Animate placeholders with `animation="glow"` or `animation="wave"` to better convey the perception of something being _actively_ loaded.
171171

172172
:::demo
173-
<CPlaceholder component="p" animation="glow">
173+
<CPlaceholder as="p" animation="glow">
174174
<CPlaceholder :xs="12" />
175175
</CPlaceholder>
176-
<CPlaceholder component="p" animation="wave">
176+
<CPlaceholder as="p" animation="wave">
177177
<CPlaceholder :xs="12" />
178178
</CPlaceholder>
179179
:::
180180
```vue
181-
<CPlaceholder component="p" animation="glow">
181+
<CPlaceholder as="p" animation="glow">
182182
<CPlaceholder :xs="12" />
183183
</CPlaceholder>
184184
185-
<CPlaceholder component="p" animation="wave">
185+
<CPlaceholder as="p" animation="wave">
186186
<CPlaceholder :xs="12" />
187187
</CPlaceholder>
188188
```

0 commit comments

Comments
 (0)