-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(Dotnav): added first dotnav component
- Loading branch information
1 parent
75b5a3d
commit 81f43f4
Showing
8 changed files
with
179 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { LitElement, Component, html, css } from '@rxdi/lit-html'; | ||
|
||
@Component({ | ||
selector: 'dotnav-view-component', | ||
style: css` | ||
.container { | ||
padding: 50px; | ||
background: white; | ||
color: #666; | ||
} | ||
`, | ||
template(this: DotnavViewComponent) { | ||
return html` | ||
<div class="container"> | ||
<h1>Horizontal</h1> | ||
<rx-dotnav orientation="row"> | ||
<a></a> | ||
<a></a> | ||
<a></a> | ||
<a></a> | ||
</rx-dotnav> | ||
<h1>Vertical</h1> | ||
<rx-dotnav orientation="column"> | ||
<a></a> | ||
<a></a> | ||
<a></a> | ||
<a></a> | ||
</rx-dotnav> | ||
</div> | ||
`; | ||
} | ||
}) | ||
export class DotnavViewComponent extends LitElement {} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
# Divider Component | ||
|
||
Pull request: https://github.com/rxdi/ui-kit/pull/14 | ||
|
||
|
||
##### Usage | ||
|
||
```typescript | ||
import { DotnavComponent } from '@rxdi/ui-kit/dotnav'; | ||
|
||
@Module({ | ||
components: [DotnavComponent], | ||
}) | ||
export class AppModule {} | ||
``` | ||
|
||
|
||
```html | ||
<rx-dotnav orientation="row"> | ||
<a></a> | ||
<a></a> | ||
<a></a> | ||
<a></a> | ||
</rx-dotnav> | ||
<rx-dotnav orientation="column"> | ||
<a></a> | ||
<a></a> | ||
<a></a> | ||
<a></a> | ||
</rx-dotnav> | ||
``` | ||
|
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,95 @@ | ||
import { | ||
Component, | ||
LitElement, | ||
html, | ||
property, | ||
css, | ||
styleMap | ||
} from '@rxdi/lit-html'; | ||
|
||
/** | ||
* @customElement rx-dotnav | ||
*/ | ||
@Component({ | ||
selector: 'rx-dotnav', | ||
style: css` | ||
a { | ||
display: block; | ||
cursor: pointer; | ||
box-sizing: border-box; | ||
width: 10px; | ||
height: 10px; | ||
border-radius: 50%; | ||
background: transparent; | ||
text-indent: 100%; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
border: 1px solid rgba(102, 102, 102, 0.4); | ||
transition: 0.2s ease-in-out; | ||
transition-property: background-color, border-color; | ||
} | ||
.focus { | ||
background-color: rgba(102, 102, 102, 0.6); | ||
outline: none; | ||
border-color: transparent; | ||
} | ||
`, | ||
template(this: DotnavComponent) { | ||
return html` | ||
${this.orientation === 'row' | ||
? html` | ||
<style> | ||
a { | ||
margin-top: 0px; | ||
margin-right: 12px; | ||
} | ||
</style> | ||
` | ||
: html` | ||
<style> | ||
a { | ||
margin-top: 12px; | ||
margin-right: 0px; | ||
} | ||
</style> | ||
`} | ||
<div | ||
style=${styleMap({ | ||
display: 'flex', | ||
'flex-direction': this.orientation | ||
})} | ||
> | ||
${this.dots} | ||
</div> | ||
`; | ||
} | ||
}) | ||
export class DotnavComponent extends LitElement { | ||
@property({ type: String }) | ||
public orientation: 'row' | 'column' = 'row'; | ||
|
||
@property({ type: Array }) | ||
private dots: HTMLAnchorElement[]; | ||
|
||
OnUpdateFirst() { | ||
this.dots = this.selectAllHrefs(); | ||
this.attachListeners(); | ||
} | ||
|
||
private selectAllHrefs() { | ||
return [...Array.from(this.querySelectorAll('a'))]; | ||
} | ||
|
||
private attachListeners() { | ||
this.dots.forEach(el => this.attachListener(el)); | ||
} | ||
|
||
private attachListener(el: HTMLElement) { | ||
el.addEventListener('click', () => this.focusElement(el)); | ||
} | ||
|
||
private focusElement(el: HTMLElement) { | ||
this.dots.forEach(d => d.classList.remove('focus')); | ||
el.classList.add('focus'); | ||
} | ||
} |
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,9 @@ | ||
import { DotnavComponent } from './dotnav.component'; | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'rx-dotnet': DotnavComponent; | ||
} | ||
} | ||
|
||
export * from './dotnav.component'; |