Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

[ENH] Implemented logic to allow expansion of long dataset names #282

Merged
merged 4 commits into from
Nov 17, 2023
Merged
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
26 changes: 0 additions & 26 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,6 @@
color: black;
}

.card-checkbox {
padding-right: 0;
}

.card-content {
padding-left: 0;
}

.card-modality {
font-size: 1em;
}

.card-text {
font-size: 1.25em;
}

.card-title {
font-size: 1.75em;

/* Ellipsis length truncation */
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

/* Card list */
#card-listbox {
border: 1em;
Expand Down
46 changes: 45 additions & 1 deletion components/ResultCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
class="card-title"
:data-cy="`card-${datasetUuid}-dataset`"
>
{{ datasetName }}
{{ titleExpanded ? datasetName : datasetName.slice(0, 60) }}
<span
v-if="datasetName.length > 60"
rmanaem marked this conversation as resolved.
Show resolved Hide resolved
class="expander"
:data-cy="`card-${datasetUuid}-expander`"
@click="expandText"
>{{ titleExpanded ? '...less' : "...more" }}</span>
</h5>
</b-row>
<b-row>
Expand Down Expand Up @@ -102,6 +108,7 @@ export default {
emits: ['update-downloads'],
data() {
return {
titleExpanded: false,
modalities: {
'http://purl.org/nidash/nidm#ArterialSpinLabeling': {
name: 'ASL',
Expand Down Expand Up @@ -143,6 +150,43 @@ export default {
updateDownloads(event) {
this.$emit('update-downloads', this.datasetUuid, event.target.checked);
},
expandText() {
this.titleExpanded = !this.titleExpanded;
},
},
};
</script>
<style>
.card-checkbox {
padding-right: 0;
}

.card-content {
padding-left: 0;
}

.card-modality {
font-size: 1em;
}

.card-text {
font-size: 1.25em;
}

.card-title {
font-size: 1.75em;
max-width: 100%;
white-space: normal;
}

.expanded {
white-space: normal;
}

.expander {
font-size: 15px !important;
font-style: italic;
color: #470A68;
cursor: pointer;
}
</style>
11 changes: 11 additions & 0 deletions cypress/component/ResultCard.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,15 @@ describe('Result card', () => {
cy.get('[data-cy="card-http://neurobagel.org/vocab/cool-dataset-checkbox"]').check();
cy.get('@spy').should('have.been.calledWith', 'http://neurobagel.org/vocab/cool-dataset', true);
});
it('Expands a long title and collapses it when clicked', () => {
props.datasetName = 'This is a veeeeeeeeeeeeeeeeeeeery long title that should be truncated';
rmanaem marked this conversation as resolved.
Show resolved Hide resolved
cy.mount(ResultCard, {
propsData: props,
});
cy.get('[data-cy="card-http://neurobagel.org/vocab/cool-dataset-dataset"]').should('not.contain', 'truncated');
cy.get('[data-cy="card-http://neurobagel.org/vocab/cool-dataset-expander"]').contains('...more').click();
cy.get('[data-cy="card-http://neurobagel.org/vocab/cool-dataset-dataset"]').should('be.visible').contains('This is a veeeeeeeeeeeeeeeeeeeery long title that should be truncated');
cy.get('[data-cy="card-http://neurobagel.org/vocab/cool-dataset-expander"]').contains('...less').click();
cy.get('[data-cy="card-http://neurobagel.org/vocab/cool-dataset-dataset"]').should('not.contain', 'truncated');
});
});