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

NcButton: Add alignment property to change icon and text ordering #4366

Merged
merged 1 commit into from Aug 2, 2023

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Jul 26, 2023

☑️ Resolves

We sometimes need to change the alignment of icon and text of the button, currently this is dirty-hacked by using :deep selectors. Examples are the column headers on tables (file list, logreader, file picker).

🖼️ Screenshots

image

🏁 Checklist

  • 📘 Component documentation has been extended, updated or is not applicable

@susnux susnux added enhancement New feature or request 3. to review Waiting for reviews feature: button labels Jul 26, 2023
@susnux susnux requested a review from skjnldsv July 26, 2023 19:26
src/components/NcButton/NcButton.vue Outdated Show resolved Hide resolved
src/components/NcButton/NcButton.vue Outdated Show resolved Hide resolved
Comment on lines +205 to +220
<div>
<div style="display: flex; gap: 12px;">
<NcButton aria-label="Previous" type="tertiary">
<template #icon>
<IconLeft :size="20" />
</template>
Previous page
</NcButton>
<NcButton alignment="end-reverse" aria-label="Previous" type="primary">
<template #icon>
<IconRight :size="20" />
</template>
Next page
</NcButton>
</div>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(More examples)

Suggested change
<div>
<div style="display: flex; gap: 12px;">
<NcButton aria-label="Previous" type="tertiary">
<template #icon>
<IconLeft :size="20" />
</template>
Previous page
</NcButton>
<NcButton alignment="end-reverse" aria-label="Previous" type="primary">
<template #icon>
<IconRight :size="20" />
</template>
Next page
</NcButton>
</div>
</div>
<div style="display: flex; flex-direction: column; gap: 12px;">
<NcButton aria-label="central (default)" type="secondary" wide>
<template #icon>
<IconLeft :size="20" />
</template>
central (default)
</NcButton>
<div style="display: flex; gap: 12px;">
<div style="display: flex; flex-direction: column; gap: 12px; flex: 1">
<NcButton alignment="start" aria-label="start" type="secondary" wide>
<template #icon>
<IconLeft :size="20" />
</template>
start
</NcButton>
<NcButton alignment="start-reverse" aria-label="start-reverse" type="secondary" wide>
<template #icon>
<IconRight :size="20" />
</template>
start-reverse
</NcButton>
</div>
<div style="display: flex; flex-direction: column; gap: 12px; flex: 1">
<NcButton alignment="end" aria-label="end" type="secondary" wide>
<template #icon>
<IconLeft :size="20" />
</template>
end
</NcButton>
<NcButton alignment="end-reverse" aria-label="end-reverse" type="secondary" wide>
<template #icon>
<IconRight :size="20" />
</template>
end-reverse
</NcButton>
</div>
</div>
</div>

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "start-reverse" and "end" layouts should not exist though, they look off and should not be used or recommended.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jancborchardt start-reverse and end are the values for which this was feature is introduced (table headers sort icon should be on the opposite site of the alignment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But as discussed with Jan, we should not promote those stypes for anything but table headers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jancborchardt start-reverse and end are the values for which this was feature is introduced (table headers sort icon should be on the opposite site of the alignment)

Do you have end, not end-reversed button in file picker table?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, center-reversed also may make sense for aka pagination buttons or next-step buttons with right arrow.

image

We don't have such buttons right now. But it seems to me that the main reason for this is that developers do not use icons here because they are not supported and because it is not an option.

…lignment

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux requested a review from ShGKme July 27, 2023 09:05
Copy link
Contributor

@marcoambrosini marcoambrosini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there other applications for trailing icons in buttons? I'm not really sure we should implement this just for pagination. Those should be link anyway and we could have a very simple wrapper of the button that just does pagination for that.
What is the problem in tables?

@susnux
Copy link
Contributor Author

susnux commented Jul 27, 2023

@marcoambrosini the sorting icon should normally be on the opposite side of the text alignment, or at least on the end instead of the inline start.
So we discuessed different approaches like adding a "trailing-icon" slot (not good, as we never want a button with two icons). Or introducing a wrapper component which hacks the alignment using deep selectors (this is seems not to be a good solution as it depends on private classes of the button, instead we would have to introduce something like customClasses property to allow to inject our own classes which then can be safely be using with deep selectors).

But allowing to align the button content using a property seemed to be the best and cleanest solution, instead of introducing a wrapper component.

There are even more examples on where this could be used, as at least the "start" alignment is quite common (have left aligned content but full width of clickable area).

@skjnldsv skjnldsv added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Aug 2, 2023
@skjnldsv skjnldsv merged commit a756417 into master Aug 2, 2023
16 checks passed
@skjnldsv skjnldsv deleted the feat/ncbutton-alignment branch August 2, 2023 07:15
@skjnldsv skjnldsv mentioned this pull request Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish enhancement New feature or request feature: button
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants