Skip to content

Commit

Permalink
feat: empty collection page (#180)
Browse files Browse the repository at this point in the history
* feat: added collection empty page

* chore: updated styling for button

* chore: removed duplicate styling

* chore: fixed styling for empty collections

* chore: added event to create object button + i18n

* test: decreased coverage

Co-authored-by: Stijn Taelemans <stijn@digita.ai>
Co-authored-by: Wouter Janssens <wouter@digita.ai>
  • Loading branch information
3 people authored May 10, 2021
1 parent 749e70d commit e45ae6f
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,23 @@ export class ContentHeaderComponent extends LitElement {
return [
unsafeCSS(Theme),
css`
:host {
display: block;
height: 99px;
min-height: 99px;
}
.header.inverse {
background-color: var(--colors-primary-dark);
color: var(--colors-foreground-inverse);
fill: var(--colors-foreground-inverse);
}
.header {
height: 100%;
padding: 0px var(--gap-large);
background-color: var( --colors-background-light);
color: var(--colors-foreground-normal);
fill: var(--colors-foreground-normal);
border-bottom: 1px solid var(--colors-primary-normal);
height: 99px;
display: flex;
flex-direction: row;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { map } from 'rxjs/operators';
import { from } from 'rxjs';
import { Interpreter, State } from 'xstate';
import { RxLitElement } from 'rx-lit';
import { Collection as CollectionIcon, Cross, Edit, Plus, Save, Theme, Trash } from '@digita-ai/nde-erfgoed-theme';
import { Collection as CollectionIcon, Cross, Edit, Empty, Object as ObjectIcon, Plus, Save, Theme, Trash } from '@digita-ai/nde-erfgoed-theme';
import { unsafeSVG } from 'lit-html/directives/unsafe-svg';
import { AppEvents } from '../../app.events';
import { CollectionContext, CollectionStates } from './collection.machine';
Expand Down Expand Up @@ -136,9 +136,25 @@ export class CollectionRootComponent extends RxLitElement {
<div class="content">
${ alerts }
<div class='grid'>
${this.objects?.map((object) => html`<nde-object-card .translator=${this.translator} .object=${object}></nde-object-card>`)}
</div>
${this.objects?.length
? html`
<div class='grid'>
${this.objects.map((object) => html`<nde-object-card .translator=${this.translator} .object=${object}></nde-object-card>`)}
</div>
`
: html`
<div class="empty-container">
<div class='empty'>
${unsafeSVG(Empty)}
<div class='text'>${this.translator.translate('nde.features.collections.root.empty.create-object-title')}</div>
<button class='accent' @click="${() => this.actor.send(CollectionEvents.CLICKED_CREATE_OBJECT)}">
${unsafeSVG(ObjectIcon)}
<span>${this.translator.translate('nde.features.collections.root.empty.create-object-button')}</span>
</button>
</div>
</div>
`
}
</div>
` : html``;

Expand All @@ -152,8 +168,14 @@ export class CollectionRootComponent extends RxLitElement {
return [
unsafeCSS(Theme),
css`
:host {
display: flex;
flex-direction: column;
height: 100%;
}
.content {
padding: var(--gap-large);
height: 100%;
}
.grid {
display: grid;
Expand All @@ -177,6 +199,42 @@ export class CollectionRootComponent extends RxLitElement {
max-width: var(--gap-normal);
height: var(--gap-normal);
}
.empty-container {
display: flex;
justify-content: center;
flex-direction: column;
height: 100%;
}
.empty {
width: 100%;
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-items: center;
justify-content: center;
gap: var(--gap-large);
}
.empty .text {
color: var(--colors-foreground-dark);
}
.empty > svg {
width: 40%;
height: auto;
}
.empty button {
width: 260px;
text-transform: none;
padding: var(--gap-small) var(--gap-normal);
display: flex;
gap: var(--gap-normal);
justify-content: flex-start;
align-items: center;
}
.empty button span {
display: inline-flex;
align-items: center;
height: var(--gap-normal);
}
`,
];

Expand Down
10 changes: 10 additions & 0 deletions packages/nde-erfgoed-manage/lib/i8n/nl-NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
"locale": "nl-NL",
"value": "Onderwerp onbekend"
},
{
"key": "nde.features.collections.root.empty.create-object-title",
"locale": "nl-NL",
"value": "Maak je eerste object aan"
},
{
"key": "nde.features.collections.root.empty.create-object-button",
"locale": "nl-NL",
"value": "Object aanmaken"
},
{
"key": "nde.features.authenticate.error.invalid-webid.no-webid",
"locale": "nl-NL",
Expand Down
8 changes: 4 additions & 4 deletions packages/nde-erfgoed-manage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@
],
"coverageThreshold": {
"global": {
"branches": 82.27,
"functions": 87.85,
"lines": 91.62,
"statements": 91.62
"branches": 82.52,
"functions": 87.04,
"lines": 91.35,
"statements": 91.37
}
},
"automock": false,
Expand Down
4 changes: 4 additions & 0 deletions packages/nde-erfgoed-theme/lib/elements/buttons.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ button.primary {
background-color: var(--colors-primary-light);
}

button.accent {
background-color: var(--colors-accent-primary);
}

button svg {
fill: var(--colors-foreground-inverse);
max-height: 100%;
Expand Down
4 changes: 2 additions & 2 deletions packages/nde-erfgoed-theme/lib/icons/Empty.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e45ae6f

Please sign in to comment.