-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Elizabeth Danzberger <[email protected]>
- Loading branch information
Showing
9 changed files
with
141 additions
and
149 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
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
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
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,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> |
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,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) | ||
}, | ||
}, | ||
} |
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,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> |
Oops, something went wrong.