diff --git a/src/client/components/PageDocuments.js b/src/client/components/PageDocuments.js index 942ff932..8d269d4c 100644 --- a/src/client/components/PageDocuments.js +++ b/src/client/components/PageDocuments.js @@ -1,35 +1,25 @@ -import template from '../../templates/components/page-documents.html'; -import {unique} from '../../utils/common'; +import template from '../../templates/components/page-documents.html' +import {unique} from '../../utils/common' export default function (app) { - app.component('pageDocuments', { - bindings: { - documents: '<' - }, - template: template, - controllerAs: '$', - controller: function () { - let categories = unique(i => i.category); + app.component('pageDocuments', { + bindings: { + documents: '<' + }, + template: template, + controllerAs: '$', + controller: function () { + const documents = this.documents + const uniqueCategories = unique(i => i.category) + const documentsOf = category => documents.filter(i => i.category === category) - this.collections = []; - - let documents = this.documents; - let cats = categories(documents) - .map(cat => new Object({ - name: cat, - documents: [] - })); - - let docCollections = documents.reduce( - (cats, doc) => { - let c = cats.find(i => i.name === doc.category); - c.documents.push(doc); - return cats; - }, - cats - ); - - this.collections = this.collections.concat(docCollections); - } - }); -}; \ No newline at end of file + this.collections = uniqueCategories(documents) + .reduce((acc, category) => ( + [...acc, { + name: category, + documents: documentsOf(category) + }] + ), []) + } + }) +}; diff --git a/src/style/components/document.scss b/src/style/components/document.scss index 30d86a77..2397e76a 100644 --- a/src/style/components/document.scss +++ b/src/style/components/document.scss @@ -2,31 +2,47 @@ .document { display: flex; - flex-direction: column; - align-items: center; + flex-direction: row; padding: 0; - margin: 0 $single-margin $double-margin; - - p { - text-align: center; - } + margin-bottom: $single-margin; } .document__image{ + min-width: 4em; + width: 4em; + height: 4em; + + display: flex; + justify-content: center; + align-items: flex-start; + //align-items: center; + img { - width: 100%; + max-width: 100%; + max-height: 100%; box-shadow: $white-shadow; } } .document__image--medium{ - max-width: 7.5em; } .document__image--big{ max-width: 20em; } +.document__file { + margin-left: $single-margin; + flex-grow: 10; +} + +.document__file-info { + width: 25%; + flex-grow: 1; + font-size: $smaller-font-size; + text-align: right; +} + @media (max-width: $mobile-width) { .document { margin: 0 $single-margin/2 $single-margin; diff --git a/src/style/components/documents-container.scss b/src/style/components/documents-container.scss index 42d1ac73..a6004a12 100644 --- a/src/style/components/documents-container.scss +++ b/src/style/components/documents-container.scss @@ -1,10 +1,17 @@ @import "../variables"; .documents-container { - display: flex; - flex-wrap: wrap; - justify-content: center; - align-items: baseline; + margin-bottom: $post-margin; + + &__head { + margin-bottom: $double-margin; + } + + &__body { + display: flex; + flex-wrap: wrap; + flex-direction: column; + } } @media (max-width: $mobile-width) { diff --git a/src/templates/components/document.html b/src/templates/components/document.html index ddd3c544..fcadd510 100644 --- a/src/templates/components/document.html +++ b/src/templates/components/document.html @@ -1,12 +1,15 @@