Skip to content

Commit

Permalink
Merge pull request #913 from Infineon/907-navbar-implement-an-href-pr…
Browse files Browse the repository at this point in the history
…operty-for-the-logo

added the logohref prop in navbar
  • Loading branch information
tishoyanchev authored Jan 18, 2024
2 parents 373794d + 302732a commit cb92c5f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/stencil-components/vanilla-cdn/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<body>

<div>
<ifx-navbar application-name="Application name" fixed="false">
<ifx-navbar application-name="Application name" fixed="false" logo-href="https://google.com" logo-href-target = "_self">
<ifx-navbar-item hide-label="false" icon="calendar16" slot="left-item" target="_blank"
href="https://google.com">Menu Item1</ifx-navbar-item>
<ifx-navbar-item slot="left-item">Menu Item</ifx-navbar-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IfxNavbar, IfxNavbarMenuItem, IfxSearchBar, IfxNavbarItem, IfxNavbarMen
function Navbar() {
return (
<div>
<IfxNavbar application-name="Application name" fixed="false">
<IfxNavbar application-name="Application name" fixed="false" logo-href="https://google.com">
<IfxNavbarItem hide-label="false" icon="calendar16" slot="left-item" target="_blank" href="https://google.com">Menu Item1</IfxNavbarItem>
<IfxNavbarItem slot="left-item">Menu Item</IfxNavbarItem>
<IfxNavbarItem slot="left-item">Menu Item</IfxNavbarItem>
Expand Down
4 changes: 3 additions & 1 deletion packages/components-vue/lib/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ export const IfxMultiselect = /*@__PURE__*/ defineContainer<JSX.IfxMultiselect>(
export const IfxNavbar = /*@__PURE__*/ defineContainer<JSX.IfxNavbar>('ifx-navbar', undefined, [
'applicationName',
'fixed',
'showLogoAndAppname'
'showLogoAndAppname',
'logoHref',
'logoHrefTarget'
]);


Expand Down
11 changes: 9 additions & 2 deletions packages/components/src/components/navbar/navbar.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,26 @@ export default {
searchBarIsOpen: false,
searchBarShowCloseButton: true,
navbarPositionFixed: false,
showLogoAndAppname: true
showLogoAndAppname: true,
logoHref: "http://google.com",
logoHrefTarget: "_self",
},
argTypes: {
icon: {
options: Object.values(icons).map(i => i['name']),
control: { type: 'select' }
},
logoHrefTarget: {
description: "If not '_self' or '_blank' or '_parent', then set to '_self' by default",
options: ["_self", "_blank", "_parent"],
control: { type: 'radio' }
}
}
};


const DefaultTemplate = (args) =>
`<ifx-navbar show-logo-and-appname="${args.showLogoAndAppname}" application-name="${args.applicationName}" fixed="${args.navbarPositionFixed}">
`<ifx-navbar show-logo-and-appname="${args.showLogoAndAppname}" application-name="${args.applicationName}" fixed="${args.navbarPositionFixed}" logo-href="${args.logoHref}" logo-href-target="${args.logoHrefTarget}">
<ifx-navbar-item hide-label="${args.hideLabel}" icon="${args.icon}" slot="left-item" target="${args.navbBarItemTarget}" href="${args.navbBarItemHref}">Menu Item 1</ifx-navbar-item>
<ifx-navbar-item hide-label="${args.hideLabel}" slot="left-item">Menu Item</ifx-navbar-item>
<ifx-navbar-item hide-label="${args.hideLabel}" slot="left-item">Menu Item</ifx-navbar-item>
Expand Down
21 changes: 20 additions & 1 deletion packages/components/src/components/navbar/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export class Navbar {
@Prop() fixed: boolean = true;
@Prop() showLogoAndAppname: boolean = true;
@State() searchBarIsOpen: boolean = false;
@Prop() logoHref: string = "";
@State() internalLogoHref: string = ""
@Prop() logoHrefTarget: string = '_self';
@State() internalLogoHrefTarget: string = '_self';



Expand Down Expand Up @@ -179,12 +183,27 @@ export class Navbar {
// }
}

handleLogoHrefAndTarget(){
if(this.logoHref.trim() === "") {
this.internalLogoHref = undefined;
}else{
this.internalLogoHref = this.logoHref;
}

if(['_self', '_blank', '_parent'].includes(this.logoHrefTarget.trim())){
this.internalLogoHrefTarget = this.logoHrefTarget;
}else{
this.internalLogoHrefTarget = '_self';
}
}

componentWillLoad() {
const dropdownMenu = this.el.querySelector('ifx-navbar-menu')
const leftMenuItems = this.el.querySelectorAll('[slot="left-item"]')
if (!leftMenuItems.length && !dropdownMenu) {
this.hasLeftMenuItems = false;
}
this.handleLogoHrefAndTarget();
}


Expand All @@ -197,7 +216,7 @@ export class Navbar {
{this.showLogoAndAppname &&
<div class="navbar__container-left-logo">
<div class="navbar__container-left-logo-default">
<a href="javascript:void(0)">
<a href={this.internalLogoHref} target = {this.internalLogoHrefTarget}>
<svg width="91" height="40" viewBox="0 0 91 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_2396_2480)">
<path d="M67.691 26.7766C71.0884 26.7766 72.1461 23.1841 72.1461 19.8802C72.1461 15.4536 70.2871 13.1441 67.691 13.1441C64.4219 13.1441 63.2681 16.7367 63.3001 19.9443C63.3322 23.1199 64.2296 26.7766 67.691 26.7766ZM66.0244 19.8481C66.0244 18.533 66.0244 15.4536 67.691 15.4536C69.4859 15.4536 69.4218 18.5009 69.4218 19.9123C69.4218 21.2595 69.4218 24.5313 67.7551 24.5313C65.9603 24.4992 66.0244 21.2274 66.0244 19.8481ZM57.8195 26.7766C59.1976 26.7766 60.3835 26.2313 61.5053 25.0445L60.5117 23.1841C59.7425 24.018 58.9733 24.4671 58.0438 24.4671C57.2746 24.4671 56.6336 24.018 56.249 23.2482C55.9285 22.5746 55.8644 21.8048 55.8644 20.9708V20.7142H61.6335V20.1368C61.6335 17.282 61.2809 15.7102 60.3835 14.5234C59.7104 13.6253 58.7169 13.1441 57.499 13.1441C56.2169 13.1441 55.1593 13.7215 54.39 14.8442C53.5567 16.0631 53.2042 17.699 53.2042 19.9443C53.1721 24.2426 54.8708 26.7766 57.8195 26.7766ZM57.531 15.2612C58.172 15.2612 58.5566 15.614 58.813 16.1914C59.0053 16.7046 59.1015 17.5707 59.1015 18.5971H55.8644C55.8964 16.3197 56.3772 15.2612 57.531 15.2612ZM74.2614 26.4559H76.7614V16.8329C77.3703 16.0952 78.0754 15.6782 78.5882 15.6782C78.9087 15.6782 79.2292 15.7423 79.4215 15.9989C79.6138 16.2876 79.71 16.7046 79.71 17.699V26.4559H82.21V16.5442C82.21 15.6782 82.1138 14.8121 81.601 14.1706C81.1523 13.5932 80.4472 13.2404 79.5497 13.2404C78.3959 13.2404 77.2101 13.914 76.569 14.6838C76.537 14.0102 76.3126 13.3687 76.2485 13.1441L73.9089 13.7536C74.0371 14.4593 74.2294 15.3253 74.2294 16.8971V26.4559H74.2614ZM45.2236 14.6838C45.1915 14.0102 44.9672 13.3687 44.9031 13.1441L42.5634 13.7536C42.6916 14.4593 42.8839 15.3253 42.8839 16.8971V26.4238H45.3838V16.8008C45.9928 16.0631 46.6979 15.6461 47.2107 15.6461C47.5312 15.6461 47.8517 15.7102 48.044 15.9669C48.2363 16.2555 48.3325 16.6725 48.3325 17.6669V26.4238H50.8324V16.5442C50.8324 15.6782 50.7363 14.8121 50.2235 14.1706C49.7748 13.5932 49.0696 13.2404 48.1722 13.2404C47.0505 13.2404 45.8646 13.914 45.2236 14.6838ZM14.6473 9.07042C16.1216 9.07042 17.3075 7.88359 17.3075 6.40807C17.3075 4.93256 16.1216 3.74573 14.6473 3.74573C13.173 3.74573 11.9871 4.93256 11.9871 6.40807C11.9871 7.88359 13.173 9.07042 14.6473 9.07042ZM26.9227 26.4559V16.5442C26.9227 15.6782 26.8265 14.8121 26.3137 14.1706C25.865 13.5932 25.1599 13.2404 24.2625 13.2404C23.1087 13.2404 21.9228 13.914 21.2818 14.6838C21.2497 14.0102 21.0254 13.3687 20.9613 13.1441L18.6536 13.7857C18.7818 14.4913 18.9741 15.3574 18.9741 16.9291V26.4559H21.4741V16.8329C22.0831 16.0952 22.7882 15.6782 23.301 15.6782C23.6215 15.6782 23.942 15.7423 24.1343 15.9989C24.3266 16.2876 24.4227 16.7046 24.4227 17.699V26.4559H26.9227ZM38.4289 8.36474C37.4994 8.36474 36.7622 9.10249 36.7622 10.0327C36.7622 10.9629 37.4994 11.7007 38.3968 11.7007C39.3263 11.7007 40.0634 10.9629 40.0634 10.0327C40.0634 9.10249 39.3263 8.36474 38.4289 8.36474ZM13.4614 26.4559H15.9614V10.8346L13.4614 11.1554V26.4559ZM33.8777 9.90441C34.3264 9.90441 34.7751 10.0648 35.0635 10.2893L35.7687 8.33266C35.0956 7.85151 34.3584 7.62698 33.429 7.62698C32.788 7.62698 32.1149 7.78736 31.5059 8.26851C30.897 8.78173 30.256 9.80818 30.256 11.7328C30.256 12.5667 30.288 13.4328 30.288 13.4328H29.4226V15.6461H30.288V26.4238H32.8521V15.6782H34.743L35.2238 13.4649H32.8841V11.4762C32.8841 10.5139 33.2687 9.90441 33.8777 9.90441ZM37.1468 26.4559H39.6788V13.2404L37.1468 13.5611V26.4559Z" fill="#005DA9" />
Expand Down

0 comments on commit cb92c5f

Please sign in to comment.