Adds option for a section to have an icon

This commit is contained in:
Alicia Sykes 2021-06-02 19:06:28 +01:00
parent f08a4dfbad
commit fca9162f02
6 changed files with 102 additions and 91 deletions

View File

@ -105,6 +105,7 @@ All fields are optional, unless otherwise stated.
**`section`** **`section`**
- `name` - String: (required) The title of that section - `name` - String: (required) The title of that section
- `items` - Item[]: (required) An array of items - _See **`item`** below_ - `items` - Item[]: (required) An array of items - _See **`item`** below_
- `icon` - String: (optional) An single icon to be displayed next to the title _See **`icon`** below_
- `displayData`: An object with the following fields (all optional) - `displayData`: An object with the following fields (all optional)
- `collapsed` - Boolean: If true, the section will be collapsed initially (defaults to `false`) - `collapsed` - Boolean: If true, the section will be collapsed initially (defaults to `false`)
- `color` - String: A custom accent color for the section, as a hex code or HTML color (e.g. `#fff`) - `color` - String: A custom accent color for the section, as a hex code or HTML color (e.g. `#fff`)

View File

@ -13,6 +13,7 @@ appConfig:
fontAwesomeKey: 0821c65656 fontAwesomeKey: 0821c65656
sections: sections:
- name: Getting Started - name: Getting Started
icon: fab fa-github
items: items:
- title: Source - title: Source
description: Source code and documentation on GitHub description: Source code and documentation on GitHub

View File

@ -11,6 +11,7 @@
tabIndex="-1" tabIndex="-1"
> >
<label :for="`collapsible-${uniqueKey}`" class="lbl-toggle" tabindex="-1"> <label :for="`collapsible-${uniqueKey}`" class="lbl-toggle" tabindex="-1">
<Icon v-if="icon" :icon="icon" size="small" class="section-icon" />
<h3>{{ title }}</h3> <h3>{{ title }}</h3>
</label> </label>
<div class="collapsible-content"> <div class="collapsible-content">
@ -24,18 +25,23 @@
<script> <script>
import { localStorageKeys } from '@/utils/defaults'; import { localStorageKeys } from '@/utils/defaults';
import Icon from '@/components/LinkItems/ItemIcon.vue';
export default { export default {
name: 'CollapsableContainer', name: 'CollapsableContainer',
props: { props: {
uniqueKey: String, uniqueKey: String,
title: String, title: String,
icon: String,
collapsed: Boolean, collapsed: Boolean,
cols: Number, cols: Number,
rows: Number, rows: Number,
color: String, color: String,
customStyles: String, customStyles: String,
}, },
components: {
Icon,
},
data() { data() {
return { return {
isOpen: !this.collapsed, isOpen: !this.collapsed,
@ -135,11 +141,8 @@ export default {
display: none; display: none;
} }
label { label.lbl-toggle {
outline: none; outline: none;
}
.lbl-toggle {
display: block; display: block;
padding: 0.25rem; padding: 0.25rem;
cursor: pointer; cursor: pointer;
@ -147,12 +150,15 @@ export default {
transition: all 0.25s ease-out; transition: all 0.25s ease-out;
text-align: left; text-align: left;
color: var(--item-group-heading-text-color); //var(--item-group-background); color: var(--item-group-heading-text-color); //var(--item-group-background);
h3 { h3 {
margin: 0; margin: 0;
padding: 0; padding: 0;
display: inline; display: inline;
} }
.section-icon {
display: inline;
margin-right: 0.5rem;
}
} }
.lbl-toggle:hover { .lbl-toggle:hover {
@ -168,7 +174,6 @@ export default {
vertical-align: middle; vertical-align: middle;
margin-right: .7rem; margin-right: .7rem;
transform: translateY(-2px); transform: translateY(-2px);
transition: transform .2s ease-out; transition: transform .2s ease-out;
} }

View File

@ -1,6 +1,7 @@
<template> <template>
<Collapsable <Collapsable
:title="title" :title="title"
:icon="icon"
:uniqueKey="groupId" :uniqueKey="groupId"
:collapsed="displayData.collapsed" :collapsed="displayData.collapsed"
:cols="displayData.cols" :cols="displayData.cols"
@ -51,6 +52,7 @@ export default {
props: { props: {
groupId: String, groupId: String,
title: String, title: String,
icon: String,
displayData: Object, displayData: Object,
items: Array, items: Array,
itemSize: String, itemSize: String,

View File

@ -551,10 +551,11 @@ html[data-theme='minimal-dark'] {
--search-container-background: #14171e; --search-container-background: #14171e;
--curve-factor: 4px; --curve-factor: 4px;
--curve-factor-navbar: 8px; --curve-factor-navbar: 8px;
--item-group-heading-text-color: #fff;
--item-group-heading-text-color-hover: #ffffffbf;
label.lbl-toggle h3 { label.lbl-toggle h3 {
font-size: 1.8rem; font-size: 1.8rem;
color: #fff;
} }
section.filter-container { section.filter-container {

View File

@ -22,6 +22,7 @@
v-for="(section, index) in getSections(sections)" v-for="(section, index) in getSections(sections)"
:key="index" :key="index"
:title="section.name" :title="section.name"
:icon="section.icon || undefined"
:displayData="getDisplayData(section)" :displayData="getDisplayData(section)"
:groupId="`section-${index}`" :groupId="`section-${index}`"
:items="filterTiles(section.items)" :items="filterTiles(section.items)"