Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
  • Loading branch information
elzody committed Mar 13, 2024
1 parent 70ef9f3 commit ef67c61
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 149 deletions.
8 changes: 4 additions & 4 deletions src/modules/modals/CreateContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default {
NcIconSvgWrapper,
NcContextResource,
},
mixins: [svgHelper],
props: {
showModal: {
type: Boolean,
Expand All @@ -87,10 +88,6 @@ export default {
resources: [],
}
},
async mounted() {
await this.setIcon('equalizer')
},
mixins: [svgHelper],
watch: {
title() {
if (this.title.length >= 200) {
Expand All @@ -99,6 +96,9 @@ export default {
}
},
},
async mounted() {
await this.setIcon('equalizer')
},
methods: {
titleChangedManually() {
this.customTitleChosen = true
Expand Down
8 changes: 4 additions & 4 deletions src/modules/modals/EditContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default {
NcIconSvgWrapper,
NcContextResource,
},
mixins: [svgHelper],
props: {
showModal: {
type: Boolean,
Expand All @@ -91,10 +92,6 @@ export default {
resources: [],
}
},
async mounted() {
await this.setIcon('equalizer')
},
mixins: [svgHelper],
computed: {
...mapGetters(['getContext']),
...mapState(['tables', 'views']),
Expand All @@ -119,6 +116,9 @@ export default {
}
},
},
async mounted() {
await this.setIcon('equalizer')
},
methods: {
async setIcon(iconName) {
this.icon.name = iconName
Expand Down
6 changes: 3 additions & 3 deletions src/modules/navigation/partials/NavigationContextItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ export default {
icon: null,
}
},
computed: {
...mapGetters(['activeContext']),
},
async mounted() {
this.icon = await this.getContextIcon(this.context.iconName)
},
computed: {
...mapGetters(['activeContext']),
},
methods: {
emit,
async editContext() {
Expand Down
4 changes: 0 additions & 4 deletions src/modules/navigation/sections/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ import Magnify from 'vue-material-design-icons/Magnify.vue'
import Archive from 'vue-material-design-icons/Archive.vue'
import { getCurrentUser } from '@nextcloud/auth'
import NcIconPicker from '../../../shared/components/ncIconPicker/NcIconPicker.vue'
export default {
name: 'Navigation',
components: {
Expand All @@ -126,8 +124,6 @@ export default {
NcButton,
NcCounterBubble,
NcEmptyContent,
NcIconPicker,
},
data() {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Context.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="content first-row">
<div class="row">
<h1 style="display: flex; align-items: center;">
<NcIconSvgWrapper :svg="icon" :size="40" style="display: inline-block;"/>&nbsp; {{ activeContext.name }}
<NcIconSvgWrapper :svg="icon" :size="40" style="display: inline-block;" />&nbsp; {{ activeContext.name }}
</h1>
</div>
<div class="row">
Expand Down
79 changes: 39 additions & 40 deletions src/shared/components/ncIconPicker/NcIconPicker.vue
Original file line number Diff line number Diff line change
@@ -1,52 +1,51 @@
<template>
<NcPopover container="body" popup-role="dialog" :shown.sync="showIconPicker">
<template #trigger="slotProps">
<slot v-bind="slotProps" />
</template>
<NcPopover container="body" popup-role="dialog" :shown.sync="showIconPicker">
<template #trigger="slotProps">
<slot v-bind="slotProps" />
</template>

<IconPicker :icons="icons" @select="select"/>
</NcPopover>
<IconPicker :icons="icons" @select="select" />
</NcPopover>
</template>

<script>
import iconData from '../../../../img/material/meta.json'
import { NcPopover, NcButton } from '@nextcloud/vue'
import { NcPopover } from '@nextcloud/vue'
import IconPicker from './partials/IconPicker.vue'
export default {
name: 'NcIconPicker',
components: {
NcPopover,
NcButton,
IconPicker,
},
props: {
closeOnSelect: {
type: Boolean,
default: true,
},
},
data() {
return {
icons: iconData,
showIconPicker: false,
}
},
emits: ['select'],
methods: {
select(icon) {
this.$emit('select', icon)
if (this.closeOnSelect) {
this.showIconPicker = false
}
},
}
name: 'NcIconPicker',
components: {
NcPopover,
IconPicker,
},
props: {
closeOnSelect: {
type: Boolean,
default: true,
},
},
emits: ['select'],
data() {
return {
icons: iconData,
showIconPicker: false,
}
},
methods: {
select(icon) {
this.$emit('select', icon)
if (this.closeOnSelect) {
this.showIconPicker = false
}
},
},
}
</script>
22 changes: 11 additions & 11 deletions src/shared/components/ncIconPicker/mixins/svgHelper.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export default {
methods: {
uriToSvg(dataUri) {
const pattern = /data:image\/svg\+xml;base64,/
const strippedUri = dataUri.replace(pattern, '')
methods: {
uriToSvg(dataUri) {
const pattern = /data:image\/svg\+xml;base64,/
const strippedUri = dataUri.replace(pattern, '')

return atob(strippedUri)
},
async getContextIcon(iconName) {
const { default: icon } = await import(`@mdi/svg/svg/${iconName}.svg`)
return atob(strippedUri)
},
async getContextIcon(iconName) {
const { default: icon } = await import(`@mdi/svg/svg/${iconName}.svg`)

return this.uriToSvg(icon)
}
}
return this.uriToSvg(icon)
},
},
}
97 changes: 48 additions & 49 deletions src/shared/components/ncIconPicker/partials/Icon.vue
Original file line number Diff line number Diff line change
@@ -1,71 +1,70 @@
<template>
<NcButton
class="icon-picker__icon"
type="tertiary"
:aria-label="t('tables', 'Select icon for the application')"
@click.prevent="select">
<template #icon>
<NcIconSvgWrapper :svg="icon" :size="30" />
</template>
</NcButton>
<NcLoadingIcon v-if="loading"
:name="t('tables', 'Icon {iconName} loading', { iconName: name})"
:size="30" />
<NcButton v-else
class="icon-picker__icon"
type="tertiary"
:aria-label="t('tables', 'Select icon for the application')"
@click.prevent="select">
<template #icon>
<NcIconSvgWrapper :svg="icon" :size="30" />
</template>
</NcButton>
</template>

<script>
import { NcLoadingIcon, NcIconSvgWrapper, NcButton } from '@nextcloud/vue'
import svgHelper from '../mixins/svgHelper.js'
export default {
name: 'Icon',
name: 'Icon',
components: {
NcLoadingIcon,
NcIconSvgWrapper,
NcButton,
},
components: {
NcLoadingIcon,
NcIconSvgWrapper,
NcButton,
},
mixins: [svgHelper],
props: {
name: {
type: String,
default: null,
}
},
props: {
name: {
type: String,
default: null,
},
},
data() {
return {
loading: false,
icon: null,
}
},
emits: ['select'],
emits: ['select'],
mixins: [svgHelper],
data() {
return {
loading: true,
icon: null,
}
},
async mounted() {
this.icon = await this.getContextIcon(this.name)
},
async mounted() {
this.icon = await this.getContextIcon(this.name)
this.loading = false
},
methods: {
load() {
if (this.icon) {
this.loading = false
}
},
select() {
this.$emit('select', this.name)
}
}
methods: {
select() {
this.$emit('select', this.name)
},
},
}
</script>

<style>
.icon-picker__icon {
border-radius: 15px !important;
padding: 8px !important;
margin: 2px !important;
border: 2px solid transparent !important;
border-radius: 15px !important;
padding: 8px !important;
margin: 2px !important;
border: 2px solid transparent !important;
&:hover {
border: 2px solid var(--color-primary-element) !important;
}
&:hover {
border: 2px solid var(--color-primary-element) !important;
}
}
</style>
Loading

0 comments on commit ef67c61

Please sign in to comment.