Skip to content

Commit

Permalink
custom API icons
Browse files Browse the repository at this point in the history
Co-authored-by: Jennifer Kotler <jkotler@stsci.edu>
  • Loading branch information
kecnry and Jennifer Kotler committed Nov 25, 2024
1 parent 4e989b5 commit 2e9233d
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 22 deletions.
4 changes: 3 additions & 1 deletion jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ class ApplicationState(State):
'radialtocheck': read_icon(os.path.join(ICON_DIR, 'radialtocheck.svg'), 'svg+xml'),
'checktoradial': read_icon(os.path.join(ICON_DIR, 'checktoradial.svg'), 'svg+xml'),
'nuer': read_icon(os.path.join(ICON_DIR, 'right-east.svg'), 'svg+xml'),
'nuel': read_icon(os.path.join(ICON_DIR, 'left-east.svg'), 'svg+xml')
'nuel': read_icon(os.path.join(ICON_DIR, 'left-east.svg'), 'svg+xml'),
'api': read_icon(os.path.join(ICON_DIR, 'api.svg'), 'svg+xml'),
'api-lock': read_icon(os.path.join(ICON_DIR, 'api_lock.svg'), 'svg+xml'),
}, docstring="Custom application icons")

viewer_icons = DictCallbackProperty({}, docstring="Indexed icons (numbers) for viewers across the app") # noqa
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</j-tooltip>
<j-tooltip v-if="state.show_toolbar_buttons && checkNotebookContext()" tipid="app-api-hints">
<v-btn icon @click="state.show_api_hints = !state.show_api_hints" :class="{active : state.show_api_hints}">
<v-icon medium style="padding-top: 2px">mdi-code-tags</v-icon>
<img :src="state.icons['api']" width="24" class="invert-if-dark" style="opacity: 1.0"/>
</v-btn>
</j-tooltip>
<j-tooltip v-if="state.show_toolbar_buttons" tipid="app-snackbar-history">
Expand Down
3 changes: 2 additions & 1 deletion jdaviz/components/data_menu_add.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
v-if="api_hints_enabled"
:hover_api_hint.sync="hover_api_hint"
:lock_hover_api_hint.sync="lock_hover_api_hint"
:icons="icons"
/>
</v-list>
</v-menu>
Expand All @@ -80,6 +81,6 @@ module.exports = {
lock_hover_api_hint: false,
}
},
props: ['dataset_items', 'subset_tools', 'loaded_n_data', 'api_hints_enabled'],
props: ['dataset_items', 'subset_tools', 'loaded_n_data', 'api_hints_enabled', 'icons'],
};
</script>
32 changes: 13 additions & 19 deletions jdaviz/components/hover_api_hint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,29 @@
{{ hover_api_hint }}
</span>
</v-list-item-content>
<v-list-item-action>
<v-list-item-action style="margin-right: -8px">
<j-tooltip
tooltipcontent="toggle whether API hints persist after hovering to allow for copying text"
>
<v-badge
overlap
bottom
color="#007BA1"
:icon="lock_hover_api_hint ? 'mdi-lock-outline' : 'mdi-lock-open-outline'"
<v-btn
small
text
width="24"
:style="lock_hover_api_hint ? 'background-color: #c7510996 !important' : null"
@click="(e) => {e.stopPropagation(); $emit('update:lock_hover_api_hint', !lock_hover_api_hint); $emit('update:hover_api_hint', '')}"
>
<v-btn
icon
small
@click="(e) => {e.stopPropagation(); $emit('update:lock_hover_api_hint', !lock_hover_api_hint); $emit('update:hover_api_hint', '')}"
>
<v-icon
:color="lock_hover_api_hint ? '#007BA1' : null"
>
mdi-code-tags
</v-icon>
</v-btn>
</v-badge>
<img
:src="icons['api-lock']"
width="20"
class="invert-if-dark"/>
</v-btn>
</j-tooltip>
</v-list-item-action>
</v-list-item>
</template>

<script>
module.exports = {
props: ['hover_api_hint', 'lock_hover_api_hint'],
props: ['hover_api_hint', 'lock_hover_api_hint', 'icons'],
};
</script>
2 changes: 2 additions & 0 deletions jdaviz/configs/default/plugins/data_menu/data_menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
:subset_tools="subset_tools"
:loaded_n_data="loaded_n_data"
:api_hints_enabled="api_hints_enabled"
:icons="icons"
@add-data="(data_label) => {add_data_to_viewer({data_label: data_label})}"
@create-subset="(subset_type) => {create_subset({subset_type: subset_type}); data_menu_open = false}"
>
Expand Down Expand Up @@ -208,6 +209,7 @@
v-if="api_hints_enabled"
:hover_api_hint.sync="hover_api_hint"
:lock_hover_api_hint.sync="lock_hover_api_hint"
:icons="icons"
/>
<v-list-item class="dm-footer" v-if="loaded_n_data > 0">
<v-list-item-content style="display: inline-block">
Expand Down
105 changes: 105 additions & 0 deletions jdaviz/data/icons/api.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2e9233d

Please sign in to comment.