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

BILL-3514/subnav update #417

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## v2.0.0-beta.52

Add an option to pass stringToMatch prop to `SubnavigationItem`, this can be used to pass a string that is turned into a regex pattern
## v2.0.0-beta.51

Updates the prop definitions for `TopNavDropdown` so that `title` is no longer a required prop.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lob/ui-components",
"version": "2.0.0-beta.51",
"version": "2.0.0-beta.52",
"engines": {
"node": ">=14.18.2",
"npm": ">=8.3.0"
Expand Down
38 changes: 30 additions & 8 deletions src/components/Subnavigation/SubnavigationItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@
:underline="false"
:disabled="disabled"
:tabindex="disabled ? -1 : 0"
:class="['inline-block px-1 py-3 !text-gray-500 type-small-600 whitespace-nowrap focus-visible:!outline-none',
'focus-visible:before:content[``] focus-visible:before:z-10 focus-visible:before:absolute focus-visible:before:inset-0 focus-visible:before:bottom-[-3px] ',
'hover:before:content[``] hover:before:z-10 hover:before:absolute hover:before:inset-0 hover:before:bottom-[-3px] hover:before:border-b-2',
{ 'hover:!text-gray-600 focus-visible:!text-gray-600 focus-visible:before:border-b-2 hover:before:border-gray-300 focus-visible:before:border-gray-300': !active && !disabled },
{ '!text-black before:content[``] before:z-10 before:absolute before:inset-0 before:bottom-[-3px] before:border-b-2 before:border-black': active },
{ '!text-gray-300': disabled }]"
:class="[
'inline-block px-1 py-3 !text-gray-500 type-small-600 whitespace-nowrap focus-visible:!outline-none',
'focus-visible:before:content[``] focus-visible:before:z-10 focus-visible:before:absolute focus-visible:before:inset-0 focus-visible:before:bottom-[-3px] ',
'hover:before:content[``] hover:before:z-10 hover:before:absolute hover:before:inset-0 hover:before:bottom-[-3px] hover:before:border-b-2',
{
'hover:!text-gray-600 focus-visible:!text-gray-600 focus-visible:before:border-b-2 hover:before:border-gray-300 focus-visible:before:border-gray-300':
!active && !disabled
},
{
'!text-black before:content[``] before:z-10 before:absolute before:inset-0 before:bottom-[-3px] before:border-b-2 before:border-black':
active
},
{ '!text-gray-300': disabled }
]"
>
{{ title }}
<div class="flex items-center">
Expand All @@ -25,7 +33,9 @@ import LobLink from '../Link/Link';

export default {
name: 'SubnavigationItem',
components: { LobLink },
components: {
LobLink
},
props: {
title: {
type: String,
Expand All @@ -42,11 +52,23 @@ export default {
disabled: {
type: Boolean,
default: false
},
stringToMatch: {
type: String,
default: ''
}
},
computed: {
active () {
return this.matchQueryString ? this.$route.fullPath === this.to : this.$route?.fullPath?.includes(this.to);
if (this.stringToMatch) {
const pattern = new RegExp(`${this.stringToMatch}`, 'gi');
if (pattern.test(this.$route.fullPath)) {
return true;
}
}
return this.matchQueryString ?
this.$route.fullPath === this.to :
this.$route?.fullPath?.includes(this.to);
shannamurry marked this conversation as resolved.
Show resolved Hide resolved
}
}
};
Expand Down
Loading