generated from lit/lit-element-starter-ts
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from halkeye/2022-10-12
2022 10 12
- Loading branch information
Showing
12 changed files
with
211 additions
and
66 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import {LitElement, html, css} from 'lit'; | ||
import {ifDefined} from 'lit/directives/if-defined.js'; | ||
import {customElement, property} from 'lit/decorators.js'; | ||
|
||
import {NavbarItemLink} from './jio-navbar'; | ||
import './jio-cdf-logo'; | ||
|
||
@customElement('jio-navbar-link') | ||
export class NavbarLink extends LitElement { | ||
static override styles = css` | ||
.nav-link { | ||
color: rgba(255, 255, 255, 0.55); | ||
display: block; | ||
padding: 0.5em 0; | ||
padding-left: 0.5rem; | ||
padding-right: 0.5rem; | ||
text-decoration: none; | ||
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out; | ||
} | ||
.dropdown-item { | ||
background-color: transparent; | ||
border: 0; | ||
clear: both; | ||
color: #212529; | ||
display: block; | ||
font-weight: 400; | ||
padding: 0.25em 1rem; | ||
text-align: inherit; | ||
text-decoration: none; | ||
white-space: nowrap; | ||
} | ||
.dropdown-item:focus, | ||
.dropdown-item:hover { | ||
background-color: #cbd3da; | ||
color: #16181b; | ||
text-decoration: none; | ||
} | ||
.dropdown-item.active, | ||
.dropdown-item:active { | ||
background-color: #007bff; | ||
color: #fff; | ||
text-decoration: none; | ||
} | ||
`; | ||
|
||
@property() | ||
menuItem: NavbarItemLink | undefined; | ||
|
||
/** | ||
* Eg plugins.jenkins.io | ||
*/ | ||
@property() | ||
property = 'https://www.jenkins.io'; | ||
|
||
@property() | ||
class = ""; | ||
|
||
override render() { | ||
if (!this.menuItem) {return;} | ||
if (Array.isArray(this.menuItem.link)) {return;} | ||
let href = this.menuItem.link; | ||
|
||
const parsedMenuItem = new URL(this.menuItem.link, 'https://www.jenkins.io'); | ||
const parsedPropertyUrl = new URL(this.property); | ||
|
||
// if its one of my properties, then its a relative link | ||
if (parsedPropertyUrl.host === parsedMenuItem.host) { | ||
href = parsedMenuItem.toString().substring(parsedMenuItem.toString().split('/').slice(0, 3).join('/').length); | ||
// if its a different property, then full url | ||
} else if (parsedPropertyUrl.host !== parsedMenuItem.host) { | ||
href = parsedMenuItem.toString(); | ||
} else { | ||
throw new Error(this.menuItem.toString()); | ||
} | ||
return html`<a class=${`nav-link ${this.class}`} title=${ifDefined(this.menuItem.title)} href=${href}> | ||
${this.menuItem.header ? html`<strong>${this.menuItem.label}</strong>` : this.menuItem.label} | ||
</a>`; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'jio-navbar-link': NavbarLink; | ||
} | ||
} | ||
|
||
|
||
|
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
Oops, something went wrong.