Skip to content
This repository has been archived by the owner on Dec 22, 2020. It is now read-only.

Commit

Permalink
rebuilt rg repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg committed Sep 13, 2015
1 parent e9602fa commit dd1e61a
Show file tree
Hide file tree
Showing 40 changed files with 3,935 additions and 1,114 deletions.
12 changes: 4 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
# Contributing

First of all, Pull Requests, suggestions or comments about RiotGear are all welcome and valued. To start contributing to the libraray please follow the below steps:
First of all, Pull Requests, suggestions or comments about RiotGear are all welcome and valued. To start contributing follow these steps:

## Step 1

If you haven't done so already please **<a href="https://github.com/RiotGear/rg/issues">raise an issue</a>**. Stating what you would like and how you think it should work.
**Fork the repo!**

## Step 2

We will review your suggestion and in the case of new components, **we will create a new repo** with a starter project.
Write some code...

## Step 3

**Fork the repo!** - once we've created the new repo you'll have the ability to fork it and start work.

## Step 4

Please **work in the DEV branch** make PRs from your upto date dev branch to ours so that we can review your changes.
**Submit your Pull Request to our DEV branch** so that we can review the code before merging into master.

## Sit back

Expand Down
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,21 @@ If you'd like to suggest new components or enhancements to existing ones please

### Contributing

First of all, Pull Requests, suggestions or comments about RiotGear are all welcome and valued. To start contributing to the libraray please follow the below steps:
First of all, Pull Requests, suggestions or comments about RiotGear are all welcome and valued. To start contributing follow these steps:

#### Step 1
## Step 1

If you haven't done so already please **<a href="https://github.com/RiotGear/rg/issues">raise an issue</a>**. Stating what you would like and how you think it should work.
**Fork the repo!**

#### Step 2
## Step 2

We will review your suggestion and in the case of new components, **we will create a new repo** with a starter project.
Write some code...

#### Step 3
## Step 3

**Fork the repo!** - once we've created the new repo you'll have the ability to fork it and start work.
**Submit your Pull Request to our DEV branch** so that we can review the code before merging into master.

#### Step 4

Please **work in the DEV branch**, make PRs from your upto date dev branch to ours so that we can review your changes.

#### Sit back
## Sit back

At some point your changes will get merged in and we'll publish a new version of RiotGear! Yay!

Expand Down
3 changes: 3 additions & 0 deletions _travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "0.12"
94 changes: 94 additions & 0 deletions components/alert/rg-alert.tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<rg-alert>

<div each="{ opts.alerts }" class="alert { type }" onclick="{ onclick }">
<a class="close" aria-label="Close" onclick="{ parent.remove }" if="{ dismissable != false }">
<span aria-hidden="true">&times;</span>
</a>

<div class="body">
{ msg }
</div>
</div>

<script>
this.on('update', () => {
opts.alerts.forEach((alert) => {
alert.id = Math.random().toString(36).substr(2, 8)
if (!alert.timer && alert.timeout) {
alert.startTimer = () => {
alert.timer = window.setTimeout(() => {
opts.alerts.splice(opts.alerts.indexOf(alert), 1)
if (alert.onclose) alert.onclose()
this.update()
}, alert.timeout)
}
alert.startTimer()
}
})
})

this.remove = (e) => {
e.stopPropagation()
if (e.item.onclose) e.item.onclose()
window.clearTimeout(e.item.timer)
opts.alerts.splice(opts.alerts.indexOf(e.item), 1)
}
</script>

<style scoped>

:scope {
font-size: 0.9em;
position: relative;
top: 0;
right: 0;
left: 0;
width: 100%;
}

.alert {
position: relative;
margin-bottom: 15px;
}

.body {
padding: 15px 35px 15px 15px;
}

.close {
position: absolute;
top: 50%;
right: 20px;
line-height: 12px;
margin-top: -6px;
font-size: 18px;
border: 0;
background-color: transparent;
color: rgba(0, 0, 0, 0.5);
cursor: pointer;
outline: none;
}

.danger {
color: #8f1d2e;
background-color: #ffced8;
}

.information {
color: #31708f;
background-color: #d9edf7;
}

.success {
color: #2d8f40;
background-color: #ccf7d4;
}

.warning {
color: #c06329;
background-color: #f7dfd0;
}

</style>

</rg-alert>
186 changes: 186 additions & 0 deletions components/autocomplete/rg-autocomplete.tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<rg-autocomplete>

<div class="container { open: opened }" style="width: { width }">
<input type="{ opts.type || 'text' }" name="textbox"
placeholder="{ opts.placeholder }"
onkeydown="{ handleKeys }"
oninput="{ filterItems }"
onfocus="{ filterItems }">

<div class="dropdown { open: opened }" show="{ opened }">
<div class="list">
<ul>
<li each="{ filteredItems }"
onclick="{ parent.select }"
class="item { active: active }">
{ text }
</li>
</ul>
</div>
</div>
</div>

<script>
this.opened = true
this.textbox.value = opts.value || ''

this.filterItems = () => {
this.filteredItems = opts.items.filter((item) => {
item.active = false;
if (this.textbox.value.length == 0 ||
item.text.toString().toLowerCase().indexOf(this.textbox.value.toString().toLowerCase()) > -1) {
return true
}
})
if (this.filteredItems.length > 0) {
this.opened = true
}
if (opts.onfilter) {
opts.onfilter()
}
this.update()
}

this.handleKeys = (e) => {
var length = this.filteredItems.length
if (length > 0 && [13, 38, 40].indexOf(e.keyCode) > -1) {
this.opened = true
e.preventDefault()
// Get the currently selected item
var activeIndex = null
for (var i = 0; i < length; i++) {
var item = this.filteredItems[i]
if (item.active) {
activeIndex = i
break
}
}

// We're leaving this item
if (activeIndex != null) this.filteredItems[activeIndex].active = false

if (e.keyCode == 38) {
// Move the active state to the next item lower down the index
if (activeIndex == null || activeIndex == 0)
this.filteredItems[length - 1].active = true
else
this.filteredItems[activeIndex - 1].active = true
} else if (e.keyCode == 40) {
// Move the active state to the next item higher up the index
if (activeIndex == null || activeIndex == length - 1)
this.filteredItems[0].active = true
else
this.filteredItems[activeIndex + 1].active = true
} else if (e.keyCode == 13 && activeIndex != null)
this.select({ item: this.filteredItems[activeIndex] })
}
return true
};

this.select = (item) => {
item = item.item
if (opts.onselect) opts.onselect(item)
this.textbox.value = item.text
this.opened = false
}

this.closeDropdown = (e) => {
if (!this.root.contains(e.target)) {
if (opts.onclose && this.opened) opts.onclose()
this.opened = false
this.update()
}
};

this.on('mount', () => {
document.addEventListener('click', this.closeDropdown)
document.addEventListener('focus', this.closeDropdown, true)
this.width = this.textbox.getBoundingClientRect().width + 'px'
var dd = this.root.querySelector('.dropdown')
dd.style.width = this.width
dd.style.position = 'absolute'
this.opened = opts.opened
this.update()
})

this.on('unmount', () => {
document.removeEventListener('click', this.closeDropdown)
document.removeEventListener('focus', this.closeDropdown, true)
})
</script>

<style scoped>

.container {
position: relative;
display: inline-block;
cursor: pointer;
}

.container.open {
-webkit-box-shadow: 0 2px 10px -4px #444;
-moz-box-shadow: 0 2px 10px -4px #444;
box-shadow: 0 2px 10px -4px #444;
}

input {
font-size: 1em;
padding: 10px;
border: 1px solid #D3D3D3;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
outline: none;
}

.container.open input {
}

.dropdown {
position: relative;
background-color: white;
border: 1px solid #D3D3D3;
border-top: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow-y: auto;
overflow-x: hidden;
}

.dropdown.open {
-webkit-box-shadow: 0 2px 10px -4px #444;
-moz-box-shadow: 0 2px 10px -4px #444;
box-shadow: 0 2px 10px -4px #444;
}

ul, li {
list-style: none;
padding: 0;
margin: 0;
}

li {
padding: 10px;
border-top: 1px solid #E8E8E8;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

li:first-child {
border-top: 0;
}

li:hover {
background-color: #f3f3f3;
}

li.active,
li:hover.active {
background-color: #ededed;
}


</style>
</rg-autocomplete>
Loading

0 comments on commit dd1e61a

Please sign in to comment.