Skip to content

Commit

Permalink
Allow to show menu title for single Action
Browse files Browse the repository at this point in the history
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
  • Loading branch information
raimund-schluessler committed Jan 5, 2022
1 parent 48ef6b1 commit 9d2ceed
Showing 1 changed file with 40 additions and 22 deletions.
62 changes: 40 additions & 22 deletions src/components/Actions/Actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export default {
v-bind="firstActionBinding"
:class="{
[firstAction.icon]: firstAction.icon,
[firstActionClass]: firstActionClass }"
[firstActionClass]: firstActionClass,
'action-item--single--with-title': singleActionTitle }"
class="action-item action-item--single"
rel="nofollow noreferrer noopener"
:disabled="isDisabled"
Expand All @@ -148,6 +149,8 @@ export default {
<!-- Render the icon slot content of the first action -->
<VNodes :vnodes="firstActionIconSlot" />

{{ singleActionTitle }}

<!-- fake slot to gather main action -->
<span :aria-hidden="true" hidden>
<!-- @slot All action elements passed into the default slot will be used -->
Expand Down Expand Up @@ -273,6 +276,14 @@ export default {
default: false,
},
/**
* Force the title to show for single actions
*/
forceTitle: {
type: Boolean,
default: false,
},
/**
* Specify the menu title
*/
Expand Down Expand Up @@ -370,6 +381,13 @@ export default {
return this.actions.length === 1
&& this.firstActionElement !== null
},
/**
* Return the title of the single action if forced
* @returns {string}
*/
singleActionTitle() {
return this.forceTitle ? this.menuTitle : ''
},
isDisabled() {
return this.disabled
|| (this.actions.length === 1 && this.firstAction?.$props?.disabled)
Expand Down Expand Up @@ -683,27 +701,6 @@ export default {
border: none;
border-radius: $clickable-area / 2;
background-color: transparent;
}
&::v-deep .material-design-icon {
width: $clickable-area;
height: $clickable-area;
opacity: $opacity_full;
.material-design-icon__svg {
vertical-align: middle;
}
}
// icon-more
&__menutoggle {
// align menu icon in center
display: flex;
align-items: center;
justify-content: center;
opacity: $opacity_normal;
font-weight: bold;
line-height: $icon-size;
&--with-title {
position: relative;
Expand All @@ -728,6 +725,27 @@ export default {
left: ($clickable-area - 24px) / 2;
}
}
}
&::v-deep .material-design-icon {
width: $clickable-area;
height: $clickable-area;
opacity: $opacity_full;
.material-design-icon__svg {
vertical-align: middle;
}
}
// icon-more
&__menutoggle {
// align menu icon in center
display: flex;
align-items: center;
justify-content: center;
opacity: $opacity_normal;
font-weight: bold;
line-height: $icon-size;
&--primary {
opacity: $opacity_full;
Expand Down

0 comments on commit 9d2ceed

Please sign in to comment.