-
Notifications
You must be signed in to change notification settings - Fork 1
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
VL-29_UBreadcrumbs-new-component_Vitalii-Dudnik #342
Merged
KinduD21
merged 28 commits into
main
from
VL-29_UBreadcrumbs-new-component_Vitalii-Dudnik
Jan 21, 2025
Merged
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
78c2438
Add new "UBreadcrumbs" component
KinduD21 d76d517
Remove comment
KinduD21 bf08e23
Adjust URL markdown
KinduD21 19313c8
Adjust story description
KinduD21 1e3f34d
Merge branch 'main' into VL-29_UBreadcrumbs-new-component_Vitalii-Dudnik
KinduD21 da315fc
Adjust story text
KinduD21 0296535
Remove comment from the component
KinduD21 8ca1205
Add markdown table with link object properties for UBreadcrumbs, upda…
KinduD21 0e23693
Update slots story
KinduD21 fc5f6ca
Update styles story description
KinduD21 1154a4f
Pass icon name to divider slot
KinduD21 c8a72d2
Add separate slots for UBreadcrumbs component (as left and right slot…
KinduD21 c7a8704
Add last item in array check for divider slot
KinduD21 f3f7eaa
Add label slot
KinduD21 eaad2bf
Merge branch 'main' into VL-29_UBreadcrumbs-new-component_Vitalii-Dudnik
KinduD21 aa230e3
Remove redundant ULink props from UBreadcrumbs
KinduD21 63b48a6
Rename config keys, remove slots' wrappers
KinduD21 bd6be7f
Merge branch 'main' into VL-29_UBreadcrumbs-new-component_Vitalii-Dudnik
KinduD21 5b36852
Change left slot name, update config defaults & stories
KinduD21 592de11
Update slotProps for ULink, add ULinkSlotProps type
KinduD21 3318a5a
Adjust slots' docs
KinduD21 d581f28
Update MD docs
KinduD21 ea59a66
Small adjustments for slot's props
KinduD21 2514d91
Merge branch 'main' into VL-29_UBreadcrumbs-new-component_Vitalii-Dudnik
KinduD21 79b66c1
Update slot's docs
KinduD21 c780018
Add margin-right for each breadcrumb (to add more space after arrow i…
KinduD21 addaa2b
Update keys in config
KinduD21 ca439c6
Merge branch 'main' into VL-29_UBreadcrumbs-new-component_Vitalii-Dudnik
KinduD21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
<script setup lang="ts"> | ||
import { computed } from "vue"; | ||
import { useRoute } from "vue-router"; | ||
|
||
import useUI from "../composables/useUI.ts"; | ||
import { getDefaults } from "../utils/ui.ts"; | ||
|
@@ -12,6 +11,7 @@ import ULink from "../ui.button-link/ULink.vue"; | |
import UIcon from "../ui.image-icon/UIcon.vue"; | ||
|
||
import type { Props, Config, UBreadcrumb } from "./types.ts"; | ||
import type { ULinkSlotProps } from "../ui.button-link/types.ts"; | ||
|
||
defineOptions({ inheritAttrs: false }); | ||
|
||
|
@@ -28,20 +28,10 @@ const emit = defineEmits([ | |
"clickLink", | ||
]); | ||
|
||
const route = useRoute(); | ||
|
||
const getIconColor = computed(() => { | ||
return (link: UBreadcrumb) => (link.disabled || (!link.to && !link.href) ? "gray" : props.color); | ||
}); | ||
|
||
const isLinkActive = computed(() => { | ||
return (index: number) => { | ||
const link = props.links[index]; | ||
|
||
return route.path === link.to; | ||
}; | ||
}); | ||
|
||
function onClickLink(link: UBreadcrumb) { | ||
emit("clickLink", link); | ||
} | ||
|
@@ -64,12 +54,11 @@ const { | |
<div v-bind="breadcrumbsAttrs"> | ||
<div v-for="(link, index) in links" :key="index" v-bind="breadcrumbAttrs"> | ||
<!-- | ||
@slot Use it to add something instead of a link icon. | ||
@binding {string} icon-name | ||
@binding {number} index | ||
@binding {boolean} active | ||
--> | ||
<slot name="left" :icon-name="link.icon" :index="index" :active="isLinkActive(index)"> | ||
@slot Use it to add something instead of a link icon. | ||
@binding {string} icon-name | ||
@binding {number} index | ||
--> | ||
<slot name="icon" :icon-name="link.icon" :index="index"> | ||
<UIcon | ||
v-if="link.icon" | ||
:name="link.icon" | ||
|
@@ -84,7 +73,7 @@ const { | |
:to="link.to" | ||
:size="size" | ||
:color="color" | ||
:target-blank="targetBlank" | ||
:target="link.target || target" | ||
:custom="link.custom" | ||
:replace="link.replace" | ||
:active-class="link.activeClass" | ||
|
@@ -98,27 +87,34 @@ const { | |
:data-test="dataTest" | ||
@click="onClickLink(link)" | ||
> | ||
<!-- | ||
@slot Use it to add something instead of a link label. | ||
@binding {string} label | ||
@binding {number} index | ||
@binding {boolean} active | ||
--> | ||
<slot name="label" :label="link.label" :index="index" :active="isLinkActive(index)" /> | ||
<template #default="slotProps"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<!-- | ||
@slot Use it to add something instead of a link label. | ||
@binding {string} label | ||
@binding {number} index | ||
@binding {boolean} active | ||
--> | ||
<slot | ||
name="label" | ||
:label="link.label" | ||
:index="index" | ||
:active=" | ||
(slotProps as ULinkSlotProps).isActive || (slotProps as ULinkSlotProps).isExactActive | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I this pass values in different props will be better.
|
||
" | ||
/> | ||
</template> | ||
</ULink> | ||
|
||
<!-- | ||
@slot Use it to add something instead of the divider. | ||
@binding {string} icon-name | ||
@binding {number} index | ||
@binding {boolean} active | ||
--> | ||
@slot Use it to add something instead of the divider. | ||
@binding {string} icon-name | ||
@binding {number} index | ||
--> | ||
<slot | ||
v-if="links.length !== index + 1" | ||
name="divider" | ||
:icon-name="config.defaults.dividerIcon" | ||
:index="index" | ||
:active="isLinkActive(index)" | ||
> | ||
<UIcon | ||
v-if="links.length !== index + 1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.