Skip to content

Commit

Permalink
[OPTIONS] Added in chrome options UI with themes and custom bookmark… (
Browse files Browse the repository at this point in the history
…#66)

* [OPTIONS] Added in chrome options UI with themess and custom bookmark folder location

* [OPTIONS] Fixed yarn issues

* [OPTIONS] further edits

* [OPTIONS] Formatted BookmarkIndicator

* 2.8.0

* [OPTIONS] Don't use actual bookmarks in list of options (only use folders)
  • Loading branch information
briangonzalez authored May 1, 2017
1 parent 982ba86 commit ed72c7c
Show file tree
Hide file tree
Showing 19 changed files with 937 additions and 576 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ npm-debug.log

dist/
packages/
.vscode/
29 changes: 29 additions & 0 deletions app/component/bookmark-indicator.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<span v-if="bookmarkFolder">
Currently your tabs are stored in: <strong>{{ bookmarkFolder.title }} ({{ bookmarkFolder.id }}</strong>).
</span>
</template>

<script>
import BookmarkManager from '../../lib/bookmark-manager.js';
import { mapState } from 'vuex';
import store from '../store/index.js';
import ChromePromise from 'chrome-promise';
const chromep = new ChromePromise();
export default {
asyncComputed: {
async bookmarkFolder() {
const id = this.bookmarkFolderId;
return BookmarkManager.getTidyFolder();
}
},
computed: {
...mapState([
'bookmarkFolderId',
]),
}
}
</script>
65 changes: 65 additions & 0 deletions app/component/bookmark-selector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import Vue from 'vue';
import store from '../store/index.js';

import Multiselect from 'vue-multiselect'

import ChromePromise from 'chrome-promise';
const chromep = new ChromePromise();

import BookmarkManager from '../../lib/bookmark-manager.js';

import { mapState } from 'vuex';

const createComponent = (bookmarks) => {
return {
render (h) {
return (
<span class="bookmark-selector">
<multiselect
value={this.bookmarkFolderId}
placeholder="Search for folder"
options={bookmarks}
track-by={"value"}
label="label"
option-height={50}
deselect-label={""}
max-height={150}
onSelect={this.onSelect}>
</multiselect>

<a onClick={this.reset} style="cursor: pointer; margin-top: 5px; display: inline-block;">Reset to default</a>
</span>
)
},

components: {
Multiselect
},

methods: {
onSelect(selection) {
store.commit('SET_BOOKMARK_FOLDER_ID', selection.value);
},
reset() {
store.commit('SET_BOOKMARK_FOLDER_ID', null);
},
},

computed: {
...mapState([
'bookmarkFolderId',
]),
},

data() {
return {
bookmarks
}
},
}
}

Vue.component('BookmarkSelector', async (resolve, reject) => {
const bookmarks = await BookmarkManager.getBookmarkFolders();
resolve(createComponent(bookmarks));
});
26 changes: 22 additions & 4 deletions app/component/dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<span class="sep">/</span>
<Import/>
<span class="sep">/</span>
<ToggleTheme/>
<SettingsLauncher/>
</span>
</header>

Expand All @@ -24,7 +24,7 @@

<footer>
useful software by <a href="http://www.eggplanet.io/" target="_blank">eggplanet</a> |
<a href="https://github.com/eggplanetio/tidytab/issues" target="_blank">file a bug</a> |
<a href="https://github.com/eggplanetio/tidytab/issues" target="_blank">file a bug or request a feature</a> |
v{{ version }} |
{{ theme }} theme
</footer>
Expand All @@ -36,7 +36,7 @@ import DashboardStats from './dashboard-stats.vue';
import Export from './export.vue';
import Import from './import.vue';
import Search from './search.vue';
import ToggleTheme from './toggle-theme.vue';
import SettingsLauncher from './settings-launcher.vue';
import TabGroup from './tab-group.vue';
import { mapState } from 'vuex';
Expand All @@ -49,8 +49,25 @@ export default {
Export,
Import,
Search,
SettingsLauncher,
TabGroup,
ToggleTheme,
},
head: {
link() {
const theme = this.theme;
if (!theme) return;
const href = `../styles/dashboard-${theme}.css`;
return [
{ rel: 'stylesheet', type: 'text/css', href, id: 'theme' },
];
},
},
watch: {
theme() {
this.$emit('updateHead');
}
},
props: [
Expand Down Expand Up @@ -111,6 +128,7 @@ footer {
a {
color: rgba($color-primary, 0.9);
text-decoration: underline;
}
}
</style>
152 changes: 152 additions & 0 deletions app/component/options.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<template lang="html">
<form action="">
<ul>

<li>
<h2>
Dashboard Theme
</h2>
<p>
Choose a dashboard theme.
</p>
<p>
<ThemeSelector/>
</p>
</li>

<li>
<h2>
Tab Storage
</h2>
<p>
TidyTab uses your bookmarks to store each individual group after you tidy.
</p>
<p>
<BookmarkIndicator/>
</p>
<p>
<BookmarkSelector/>
</p>
</li>

<div v-if="enableTabSavingStrategy">
<li>
<h2>
Tab-Saving Strategy
</h2>
<p>
By default, TidyTab will create a unique group for each tidy. This can get cumbersome
when you often tidy one or two tabs. This will not affect already tidied tabs.
Pro-tip: if you'd like to move bookmarks around, you can simply open the
<a href="chrome://bookmarks/" target="_blank">Bookmark Manager</a> and move things around there.

</p>
<input type="radio" name="save-strategy"> Group by date added <br>
<input type="radio" name="save-strategy" checked="checked"> Each tidy gets its own group (default)
</li>
</div>
</ul>

</form>
</template>

<script>
import ThemeSelector from './theme-selector.vue';
import BookmarkSelector from './bookmark-selector.js';
import BookmarkIndicator from './bookmark-indicator.vue';
export default {
data: () => ({
enableTabSavingStrategy: false,
}),
components: {
ThemeSelector,
BookmarkIndicator,
},
}
</script>

<style scoped="true" lang="sass">
@import '../styles/colors';
@import '../styles/settings';
form {
line-height: 1.7;
padding: $size-unit;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
margin-bottom: $size-unit;
}
input[type="text"],
select {
display: block;
width: 100%;
}
h2 {
margin-top: 0;
font-size: $font-size;
display: block;
margin-bottom: $size-unit/2;
strong {
display: block;
}
}
p {
margin-top: 0;
}
#folder {
margin-bottom: $size-unit/2;
}
select[multiple="multiple"],
select[multiple="multiple"]:hover {
background: none;
padding: 0;
}
img.toolbar-icon {
height: $size-unit;
&.light {
background: black;
}
}
</style>

<style lang="sass">
@import "../styles/colors";
@import "../styles/settings";
.bookmark-selector {
.multiselect {
font-size: 13px;
}
.multiselect__tags {
padding-top: 6px;
border-radius: 0;
}
input[type="text"].multiselect__input {
border: none;
}
}
</style>

<style src="vue-multiselect/dist/vue-multiselect.min.css"></style>
21 changes: 21 additions & 0 deletions app/component/settings-launcher.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<a @click="launchSettings()">
Settings
</a>
</template>

<script>
import store from '../store/index.js';
export default {
methods: {
launchSettings() {
chrome.runtime.openOptionsPage();
}
}
}
</script>

<style scoped lang="sass">
@import "../styles/settings";
@import "../styles/colors";
</style>
35 changes: 35 additions & 0 deletions app/component/theme-selector.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<template>
<select id="theme" v-model="theme" @change="onThemeSelect">
<option v-for="theme in THEMES" :value="theme">{{ theme }}</option>
</select>
</template>

<script>
import BookmarkSelector from './bookmark-selector.js';
import BookmarkIndicator from './bookmark-indicator.vue';
import store from '../store/index.js';
import { THEMES } from '../store/index.js';
import ChromePromise from 'chrome-promise';
const chromep = new ChromePromise();
import { mapState } from 'vuex';
export default {
data: () => ({
enableTabSavingStrategy: false,
THEMES
}),
methods: {
onThemeSelect(e) {
store.commit('SET_THEME', e.target.value);
},
},
computed: {
...mapState([
'theme',
]),
},
}
</script>
Loading

0 comments on commit ed72c7c

Please sign in to comment.