-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nav): add basic category nav and tagging
- Loading branch information
Showing
33 changed files
with
1,038 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<nav | ||
class="uk-background-muted uk-border-right" | ||
{{did-insert (perform this.fetchCategories)}} | ||
> | ||
<div | ||
class="uk-padding-small uk-margin-top uk-width-1 uk-text-bold uk-border-horizontal" | ||
> | ||
<div class="uk-text-center"> | ||
Kategorien | ||
</div> | ||
</div> | ||
<ul class="uk-nav uk-width-medium uk-margin-top"> | ||
{{#each this.categories as |category|}} | ||
<CategoryNav::Category @category={{category}} @selected={{eq category.id @selected}} /> | ||
{{else}} | ||
No categories | ||
{{/each}} | ||
</ul> | ||
</nav> |
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,13 @@ | ||
import Component from "@glimmer/component"; | ||
import { lastValue, task } from "ember-concurrency-decorators"; | ||
import { inject as service } from "@ember/service"; | ||
|
||
export default class CategoryNavComponent extends Component { | ||
@service store; | ||
|
||
@lastValue("fetchCategories") categories; | ||
@task | ||
*fetchCategories() { | ||
return yield this.store.findAll("category"); | ||
} | ||
} |
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,17 @@ | ||
<li class="category-nav--category"> | ||
<LinkTo @query={{hash category=@category.id}} class={{if @slected "active"}}> | ||
<div class="uk-flex uk-flex-middle"> | ||
<div> | ||
<FaIcon | ||
@icon="folder" | ||
@size="2x" | ||
class="uk-margin-right" | ||
{{set-style color=@category.color}} | ||
/> | ||
</div> | ||
<div> | ||
{{@category.name}} | ||
</div> | ||
</div> | ||
</LinkTo> | ||
</li> |
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,18 @@ | ||
<div | ||
class="document-card uk-card uk-card-body uk-border-rounded-circular uk-padding-remove" | ||
> | ||
<div class="uk-card-media-top uk-text-center uk-border-bottom uk-padding"> | ||
<FaIcon | ||
@icon="file-alt" | ||
@prefix="far" | ||
@size="7x" | ||
{{set-style color=@document.category.color}} | ||
/> | ||
</div> | ||
<div | ||
class="uk-card-body uk-padding-small uk-flex uk-flex-between document-name" | ||
> | ||
{{@document.name}} | ||
<FaIcon @icon="ellipsis-v" /> | ||
</div> | ||
</div> |
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,16 @@ | ||
<div | ||
class="uk-padding-small uk-overflow-auto uk-flex-center" | ||
uk-grid | ||
...attributes | ||
{{did-insert (perform this.fetchDocuments)}} | ||
{{did-update (perform this.fetchDocuments) @filters}} | ||
> | ||
{{#each this.documents as |document|}} | ||
{{! This wrapper div is needed for the uk-grid spacing between elements }} | ||
<div> | ||
<DocumentCard @document={{document}} /> | ||
</div> | ||
{{else}} | ||
No documents | ||
{{/each}} | ||
</div> |
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,16 @@ | ||
import Component from "@glimmer/component"; | ||
import { lastValue, task } from "ember-concurrency-decorators"; | ||
import { inject as service } from "@ember/service"; | ||
|
||
export default class DocumentGridComponent extends Component { | ||
@service store; | ||
|
||
@lastValue("fetchDocuments") documents; | ||
@task | ||
*fetchDocuments() { | ||
return yield this.store.query("document", { | ||
include: "category", | ||
...this.args.filters, | ||
}); | ||
} | ||
} |
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,10 @@ | ||
<div class="uk-height-1-1" uk-form-custom ...attributes> | ||
<input type="file" multiple {{on "change" this.upload}} /> | ||
<button | ||
class="uk-button uk-button-primary uk-height-1-1" | ||
type="button" | ||
tabindex="-1" | ||
> | ||
Upload File | ||
</button> | ||
</div> |
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 Component from "@glimmer/component"; | ||
import { inject as service } from "@ember/service"; | ||
import { action } from "@ember/object"; | ||
|
||
export default class FileUploadButtonComponent extends Component { | ||
@service notification; | ||
|
||
@action upload() {} | ||
} |
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,10 @@ | ||
<div class="uk-background-muted uk-padding-small uk-border-bottom"> | ||
<form class="uk-background-default uk-search uk-search-default uk-width-1"> | ||
<a href="" uk-search-icon></a> | ||
<input | ||
type="search" | ||
class="uk-search-input uk-background-default" | ||
placeholder="Search..." | ||
/> | ||
</form> | ||
</div> |
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,19 @@ | ||
<div | ||
class="uk-border uk-padding-small uk-width-expand" | ||
...attributes | ||
{{did-insert (perform this.fetchTags)}} | ||
{{did-update (perform this.fetchTags) @filters}} | ||
> | ||
{{#each this.tags as |tag|}} | ||
<span | ||
class="uk-badge {{ | ||
if (contains tag.id @selectedTags) "uk-background-secondary" | ||
}}" | ||
{{on "click" (fn this.toggleTag tag)}} | ||
> | ||
{{tag.name}} | ||
</span> | ||
{{else}} | ||
No tags... | ||
{{/each}} | ||
</div> |
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,29 @@ | ||
import Component from "@glimmer/component"; | ||
import { lastValue, task } from "ember-concurrency-decorators"; | ||
import { inject as service } from "@ember/service"; | ||
import { action } from "@ember/object"; | ||
|
||
export default class TagFilterComponent extends Component { | ||
@service store; | ||
@service router; | ||
|
||
@lastValue("fetchTags") tags; | ||
|
||
@task | ||
*fetchTags() { | ||
return yield this.store.query("tag", { | ||
...this.args.filters, | ||
}); | ||
} | ||
|
||
@action | ||
toggleTag(tag) { | ||
this.router.transitionTo({ | ||
queryParams: { | ||
tags: this.args.selectedTags.includes(tag.id) | ||
? this.args.selectedTags.filter((tagId) => tag.id !== tagId) | ||
: [...this.args.selectedTags, tag.id], | ||
}, | ||
}); | ||
} | ||
} |
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,8 @@ | ||
import Controller from "@ember/controller"; | ||
import { tracked } from "@glimmer/tracking"; | ||
|
||
export default class ApplicationController extends Controller { | ||
queryParams = ["category", "tags"]; | ||
@tracked category; | ||
@tracked tags = []; | ||
} |
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,10 @@ | ||
import Model, { attr, hasMany } from "@ember-data/model"; | ||
|
||
export default class CategoryModel extends Model { | ||
@attr name; | ||
@attr description; | ||
@attr color; | ||
|
||
|
||
@hasMany documents; | ||
} |
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 Model, { attr, belongsTo, hasMany } from "@ember-data/model"; | ||
|
||
export default class DocumentModel extends Model { | ||
@attr name; | ||
@attr description; | ||
|
||
@belongsTo category; | ||
@hasMany tags; | ||
} |
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 Model, { attr, hasMany } from "@ember-data/model"; | ||
|
||
export default class TagModel extends Model { | ||
@attr name; | ||
@attr description; | ||
|
||
@hasMany documents; | ||
|
||
} |
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,7 @@ | ||
import { modifier } from "ember-modifier"; | ||
|
||
export default modifier(function setStyle(element, _, styles) { | ||
Object.entries(styles).forEach(([key, value]) => { | ||
element.style[key] = value; | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1 +1,20 @@ | ||
<h2 id="title">Welcome to Ember</h2> | ||
<div class="uk-flex uk-flex-1 uk-height-1-1 uk-border uk-background-default"> | ||
<CategoryNav @selected={{this.category}} /> | ||
<section class="uk-width-1 uk-flex uk-flex-column uk-overflow-hidden"> | ||
<Search /> | ||
|
||
<div class="uk-flex uk-flex-middle uk-padding-small"> | ||
<FileUploadButton /> | ||
<TagFilter | ||
@filters={{hash category=this.category}} | ||
@selectedTags={{this.tags}} | ||
class="uk-margin-left" | ||
/> | ||
</div> | ||
|
||
<DocumentGrid | ||
@filters={{hash category=this.category}} | ||
class="uk-border-top" | ||
/> | ||
</section> | ||
</div> |
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 @@ | ||
export { default } from 'ember-alexandria/models/category'; |
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 @@ | ||
export { default } from 'ember-alexandria/models/document'; |
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 @@ | ||
export { default } from 'ember-alexandria/models/tag'; |
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,37 @@ | ||
@use "ember-uikit/variables-theme" as uikit; | ||
|
||
[class*="uk-border"] { | ||
border: uikit.$global-border-width solid uikit.$global-border; | ||
} | ||
|
||
.uk-border-horizontal { | ||
border-style: solid none; | ||
} | ||
|
||
.uk-border-top { | ||
border-style: solid none none none; | ||
} | ||
|
||
.uk-border-bottom { | ||
border-style: none none solid none; | ||
} | ||
|
||
.uk-border-left { | ||
border-style: none none none solid; | ||
} | ||
|
||
.uk-border-right { | ||
border-style: none solid none none; | ||
} | ||
|
||
.uk-border-rounded { | ||
border-radius: uikit.$border-rounded-border-radius; | ||
|
||
&-circular { | ||
border-radius: calc(#{uikit.$border-rounded-border-radius} * 2); | ||
} | ||
|
||
&-angular { | ||
border-radius: calc(#{uikit.$border-rounded-border-radius} / 2); | ||
} | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@use "ember-uikit" as uikit; | ||
|
||
.document-card { | ||
min-width: 200px; | ||
|
||
transition: box-shadow uikit.$animation-duration, | ||
color uikit.$animation-duration, border uikit.$animation-duration; | ||
|
||
&:hover { | ||
@extend .uk-box-shadow-medium; | ||
// border: none; | ||
} | ||
|
||
.document-name { | ||
font-size: 1rem; | ||
} | ||
} |
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,20 @@ | ||
@use "ember-uikit" as uikit; | ||
|
||
@mixin active { | ||
background: uikit.$background-default-background; | ||
} | ||
|
||
.uk-nav .category-nav--category a { | ||
transition: background uikit.$animation-duration, | ||
box-shadow uikit.$animation-duration, color uikit.$animation-duration; | ||
padding: 10px 0 10px 50px; | ||
|
||
&.active { | ||
@include active; | ||
} | ||
|
||
&:hover { | ||
@include active; | ||
@extend .uk-box-shadow-small; | ||
} | ||
} |
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,5 @@ | ||
@use "custom-uikit-rules"; | ||
|
||
// Components | ||
@use "components/category-nav/category"; | ||
@use "components/document-card"; |
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,6 @@ | ||
module.exports = function () { | ||
return { | ||
"free-solid-svg-icons": ["folder", "ellipsis-v"], | ||
"free-regular-svg-icons": ["file-alt"], | ||
}; | ||
}; |
Oops, something went wrong.