-
Notifications
You must be signed in to change notification settings - Fork 88
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: Allow to format text of button #4367
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compared to the normal buttons it seems like the text is a bit higher up here than there. Might be a non-issue since it’s only visible on hover / with background.
605976e
to
2b12340
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for trailing icons, unless we have other use cases I would wrap the button component into a tableHeaderButton
or something like that and make the style changes from there
Tested this with @szaimen on Window, it depends on your local font, we have a hack (1px margin) to center it with Segoe font which is aligned differently, but it breaks on other fonts (like I am using Roboto). See also #4200 |
2b12340
to
37ada1a
Compare
We have many buttons in Talk with custom text styles: LeftSidbar, Settings button, Conversation, TopBar, CallTime and etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this change to allow custom content of the button (otherwise it should be a prop, not a slot).
But I'm not sure if it is the best way to customize text styles.
With this change, the usage of custom styles requires creating a new element just to set class:
<template>
<NcButton class="my-button">
<!-- There is no meaning in this span, only for setting a text's color -->
<span class="my-button__text">Text</span>
<NcButton>
</template>
<styles scoped>
.my-button__text {
color: red;
}
</styles>
I'd prefer to have a prop
to set inside styles or classes:
<template>
<NcButton class="my-button" text-classes="my-button__text">
Text
<NcButton>
</template>
<styles scoped>
/* Also deep, but for my own classes, not NcButton's */
.my-button :deep(.my-button__text) {
color: red;
}
</styles>
Or
<template>
<NcButton class="my-button" text-styles="color: red">
Text
<NcButton>
</template>
I like the idea of having |
Once this is merged, one way or the other, we could then also adjust these lines nextcloud-vue/src/components/NcBreadcrumb/NcBreadcrumb.vue Lines 339 to 345 in 74a7e28
|
The more I think about this, the more I think we should went with this one. Why? Because we use the pattern of the default slot = content everywhere. Only moving the Button to |
I still don't get it. You can just set a class to the button and change the text styling? I think we should keep things simple :)
What does this do? |
Basically the problem is: Either we should allow to put any content inside the button, like the native html button allows, including styling. Or we should add a way to apply custom styles or classes to the text wrapper.
Yes but then you need to assume some internals of the button, and this is what you should not do.
No this is quite bad as you misuse it for stlying while you should use if for localization. So a overall problem is missing consistancy with the components architecture. Sometimes you use the default slot for content and allow child nodes, sometimes a property. But for the button we use the slot but only allow text. |
Signed-off-by: Ferdinand Thiessen <[email protected]>
37ada1a
to
7ed4f4b
Compare
To make sure I get it right, the use case (not talking about the wider discussion) is just about reveting text and the icon, right? |
No that is already implement in 8.x by using the It is about formatting the text, like color or weight. See the example added, it then can be used for the files list header (e.g. in files app or file picker) or for the log reader header. Simply speaking for every table header without to have using any hacks that depend on private internals of the component. |
After seeing all that validator issues @ShGKme fixes at the moment, maybe go with the alternative PR[1]. So that we do not allow arbitrary (and possibly wrong) content of the button but only text (and the icon). What do you think? [1] https://github.com/nextcloud-libraries/nextcloud-vue/pull/4393 |
With |
As this seems to get more positive feedback than the alternative #4393 Shall we go with this one? 👍 | 👎 ? |
@raimund-schluessler since you commented on the other one, what is your take here – approved or any feedback? :) |
Well then lets go with this one as it is less breaking? |
☑️ Resolves
Allow us to format the text of a button without dirty hacks like
:deep
selectors, I added the example why this is useful and where we should use this: Table headers.Places where we have this and can remove all custom hacks are: all file tables in the files app, the logreader app, the file picker.
🖼️ Screenshots
🏁 Checklist