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

Show menu title for single Action #2436

Merged
merged 1 commit into from
Jan 5, 2022
Merged
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
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