Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow customizing icon text when icon style is title #1110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
/addon/dist/
/addon/dist-zip/
/addon/package-lock.json

.DS_Store
10 changes: 8 additions & 2 deletions addon/src/components/edit-group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
computed: {
iconUrlToDisplay() {
return Groups.getIconUrl({
title: this.group.title,
title: this.group.iconText || this.group.title,
iconUrl: this.group.iconUrl,
iconColor: this.group.iconColor,
iconViewType: this.group.iconViewType,
Expand Down Expand Up @@ -225,7 +225,7 @@

getIconTypeUrl(iconType) {
return Groups.getIconUrl({
title: this.group.title,
title: this.group.iconText || this.group.title,
iconViewType: iconType,
iconColor: this.group.iconColor || 'rgb(66, 134, 244)',
});
Expand Down Expand Up @@ -375,6 +375,12 @@
</div>
</div>
</div>
<div class="field" v-if="group.iconViewType === 'title'">
<label class="label" v-text="'Icon Text'"></label>
<div class="control is-expanded">
<input v-model.trim="group.iconText" type="text" maxlength="16" class="input" placeholder="Customize icon text other than using title"/>
</div>
</div>

<div class="field">
<div class="control">
Expand Down
8 changes: 6 additions & 2 deletions addon/src/js/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export function create(id, title, defaultGroupProps = {}) {
const group = {
id,
title: null,
iconText: null,
iconColor: null,
iconUrl: null,
iconViewType: Constants.DEFAULT_GROUP_ICON_VIEW_TYPE,
Expand Down Expand Up @@ -343,6 +344,7 @@ export async function update(groupId, updateData) {

const KEYS_RESPONSIBLE_VIEW = Object.freeze([
'title',
'iconText',
'iconUrl',
'iconColor',
'iconViewType',
Expand Down Expand Up @@ -526,6 +528,7 @@ const ExternalExtensionGroupDependentKeys = new Set([
'title',
'isArchive',
'isSticky',
'iconText',
'iconColor',
'iconUrl',
'iconViewType',
Expand All @@ -538,6 +541,7 @@ export function mapForExternalExtension(group) {
title: getTitle(group),
isArchive: group.isArchive,
isSticky: group.isSticky,
iconText: group.iconText,
iconUrl: getIconUrl(group),
contextualIdentity: Containers.get(group.newTabContainer),
windowId: Cache.getWindowId(group.id) || null,
Expand Down Expand Up @@ -676,7 +680,7 @@ const emojiRegExp = /\p{RI}\p{RI}|\p{Emoji}(\p{EMod}+|\u{FE0F}\u{20E3}?|[\u{E002
const firstCharEmojiRegExp = new RegExp(`^(${emojiRegExp.source})`, emojiRegExp.flags);

export function getEmojiIcon(group) {
if (group.iconViewType === 'title') {
if (group.iconViewType === 'title' && !group.iconText) {
const [emoji] = firstCharEmojiRegExp.exec(group.title) || [];
return emoji;
}
Expand All @@ -702,7 +706,7 @@ export function getIconUrl(group, keyInObj = null) {

const stroke = 'transparent' === group.iconColor ? 'stroke="#606060" stroke-width="1"' : '',
emoji = getEmojiIcon(group),
title = emoji || group.title;
title = emoji || group.iconText || group.title;

const icons = {
'main-squares': `
Expand Down
2 changes: 1 addition & 1 deletion addon/src/popup/Popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@
computed: {
iconUrlToDisplay() {
return Groups.getIconUrl({
title: this.title,
title: this.iconText || this.title,
iconUrl: this.iconUrl,
iconColor: this.iconColor,
iconViewType: this.iconViewType,
Expand Down