-
Notifications
You must be signed in to change notification settings - Fork 91
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
Alternative style for CheckboxRadioSwitch (radio type) #2757
Conversation
…ype only Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
This comment was marked as outdated.
This comment was marked as outdated.
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
73b9690
to
adef64b
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
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.
Nice! :) Some design feedback:
- The last entry without icon should probably still be indented so the text is left-aligned with the others.
- Currently each individual item has a border-radius on all corners – but actually it is a group which should only have border-radius on the 4 outside corners. So only on the top left and top right of the first entry and the bottom left and bottom right of the last entry.
- Since we are increasing border-radius across the board, it’s probably best to go with
var(--border-radius-large)
for this
15e41b7
to
f3331d6
Compare
@jancborchardt Thanks for the feedback
The content is a slot. Its styling is done outside this component 😁.
Yep.
Completely agree... but: I did it like that initially and then I realized the radio elements are not necessarily next to each other so we need to handle both cases, IMO:
The main problem here is that it's impossible to select a predecessor in CSS (only a successor with An alternative is to add props to set border-radius manually. This might make more sense because it's weird to try to make a component aware of what's around it in order to define its own style. The video in the first comment has been updated. |
/** | ||
* Toggle the top left and right rounded corners for the alternative button style | ||
*/ | ||
buttonVariantFirst: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
|
||
/** | ||
* Toggle the bottom left and right rounded corners for the alternative button style | ||
*/ | ||
buttonVariantLast: { | ||
type: Boolean, | ||
default: false, | ||
}, |
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.
This should be automatically calculated.
Grouped-by-name radio can easily be targeted with first and last :)
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.
Alright, now using :first-of-type
and :last-of-type
.
We still need to get the information about whether they are direct successors or not (grouped or not). Still using a prop for that.
I also added the ability to group vertically (video is up-to-date in the first comment).
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.
We still need to get the information about whether they are direct successors or not (grouped or not). Still using a prop for that.
I don't think that's necessary (or even helpful). Grouped checkboxes need to be direct siblings with no checkboxes as siblings that are not grouped. So they need to be wrapped in a common container. Otherwise the markup will fail, without or with the grouped prop.
See this for example:
<template>
<div>
<div>
First toggle with three options
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="r" name="sharing_permission_radio" type="radio" :button-variant="true" :button-variant-v-grouped="true">Default permission read</CheckboxRadioSwitch>
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="rw" name="sharing_permission_radio" type="radio" :button-variant="true" :button-variant-v-grouped="true">Default permission read+write</CheckboxRadioSwitch>
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="rw" name="sharing_permission_radio" type="radio" :button-variant="true" :button-variant-v-grouped="true">Default permission read+write</CheckboxRadioSwitch>
</div>
<div>
Second toggle with two options
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="r" name="sharing_permission_radio" type="radio" :button-variant="true" :button-variant-v-grouped="true">Default permission read</CheckboxRadioSwitch>
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="rw" name="sharing_permission_radio" type="radio" :button-variant="true" :button-variant-v-grouped="true">Default permission read+write</CheckboxRadioSwitch>
Other toggle not grouped
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="rw" name="sharing_permission_radio" type="radio" :button-variant="true">Default permission read+write</CheckboxRadioSwitch>
<br>
sharingPermission: {{ sharingPermission }}
</div>
</div>
</template>
<script>
export default {
data() {
return {
sharingPermission: 'r',
}
}
}
</script>
Notice that the corners of the second last checkbox are missing, since there is another one not belonging to the group afterwards. For the three grouped checkboxes wrapped in a container, it works fine.
So imho we only need a prop to indicate horizontal/vertical grouping (would be nice to figure that out by CSS as well, but I don't know how) and leave the rest to the proper markup (give a common container to the grouped boxes).
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
f3331d6
to
16d87a8
Compare
/** | ||
* Toggle the top left and right rounded corners for the alternative button style | ||
*/ | ||
buttonVariantFirst: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
|
||
/** | ||
* Toggle the bottom left and right rounded corners for the alternative button style | ||
*/ | ||
buttonVariantLast: { | ||
type: Boolean, | ||
default: false, | ||
}, |
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.
We still need to get the information about whether they are direct successors or not (grouped or not). Still using a prop for that.
I don't think that's necessary (or even helpful). Grouped checkboxes need to be direct siblings with no checkboxes as siblings that are not grouped. So they need to be wrapped in a common container. Otherwise the markup will fail, without or with the grouped prop.
See this for example:
<template>
<div>
<div>
First toggle with three options
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="r" name="sharing_permission_radio" type="radio" :button-variant="true" :button-variant-v-grouped="true">Default permission read</CheckboxRadioSwitch>
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="rw" name="sharing_permission_radio" type="radio" :button-variant="true" :button-variant-v-grouped="true">Default permission read+write</CheckboxRadioSwitch>
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="rw" name="sharing_permission_radio" type="radio" :button-variant="true" :button-variant-v-grouped="true">Default permission read+write</CheckboxRadioSwitch>
</div>
<div>
Second toggle with two options
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="r" name="sharing_permission_radio" type="radio" :button-variant="true" :button-variant-v-grouped="true">Default permission read</CheckboxRadioSwitch>
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="rw" name="sharing_permission_radio" type="radio" :button-variant="true" :button-variant-v-grouped="true">Default permission read+write</CheckboxRadioSwitch>
Other toggle not grouped
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="rw" name="sharing_permission_radio" type="radio" :button-variant="true">Default permission read+write</CheckboxRadioSwitch>
<br>
sharingPermission: {{ sharingPermission }}
</div>
</div>
</template>
<script>
export default {
data() {
return {
sharingPermission: 'r',
}
}
}
</script>
Notice that the corners of the second last checkbox are missing, since there is another one not belonging to the group afterwards. For the three grouped checkboxes wrapped in a container, it works fine.
So imho we only need a prop to indicate horizontal/vertical grouping (would be nice to figure that out by CSS as well, but I don't know how) and leave the rest to the proper markup (give a common container to the grouped boxes).
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.
Looks great design-wise now! :)
@eneiluj regarding the border-radius, it could also be done by adding a parent/container and using first- and last-child on that.
dfb4afc
to
5b7f490
Compare
@raimund-schluessler What I meant is that from within the CheckboxRadioSwitch component, we can't know if all of the related CheckboxRadioSwitch are direct siblings (or if there are elements in between) so we need a prop for that. Of course they need to have a common direct parent but we need to know the intention of the developer as we can't guess it with CSS. @jancborchardt If you mean adding one container around all the CheckboxRadioSwitch of a group, this is not possible as this component is only one element. Thank you both for the feedback 💙 . So we can now choose if we display them grouped with the buttonVariantGrouped prop. This has an effect on the first/last (selected with |
Yes, that's true. I just wanted to point out, that, if Checkboxes are grouped, there must not be any other Checkboxes in the container that don't belong to this group. Otherwise the |
Why not adding a new component like https://github.com/nextcloud/polls/blob/master/src/js/components/Base/RadioGroupDiv.vue? |
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.
Hi, I think that the style of this component departs a bit from our design language, most notably due to the use of borders, which is something we've been trying to move away for some time. cc @jancborchardt
I know it might be too late for change but I'll leave an Idea of a similarly behaving component that we're using in our UI and whose style could probably fit here.
This also happens to be somewhat consistent with how they do radios in material design
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
5b7f490
to
114301e
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.
The code looks good and works as intended.
Regarding the design, I think @marcoambrosini proposal looks nice as well, but that's up to @nextcloud/designers to decide and can be improved later on.
Also, I would be in favor of the grouped checkboxes container component @dartcafe proposed, because
- grouped checkboxes obligatorily need a parent element containing only the checkboxes belonging to the group (otherwise the style fails) and a provided container component would make this more clear
- then the container would only need a single prop indicating whether the boxes are grouped vertically or horizontally
So something like this could be the result:
<CheckboxRadioSwitchGroup direction="vertical/horizontal">
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="r" name="sharing_permission_radio" type="radio" :button-variant="true">Default permission read</CheckboxRadioSwitch>
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="rw" name="sharing_permission_radio" type="radio" :button-variant="true">Default permission read+write</CheckboxRadioSwitch>
<CheckboxRadioSwitch :checked.sync="sharingPermission" value="rwx" name="sharing_permission_radio" type="radio" :button-variant="true">Default permission read+write+execute</CheckboxRadioSwitch>
</CheckboxRadioSwitchGroup>
@marcoambrosini I agree with @raimund-schluessler, in the end that's the decision of @nextcloud/designers. I completely understand if this is not merged because it does not go the same direction as most of the other components 😁 . @raimund-schluessler @dartcafe About the |
I can start a PR and move our implementation to this repository. I guess there is some more work to do - besides the documentaion - because it currently fits into our use cases. But I am also fine with it, if someone starts over. |
I'm totally onboard with creating a new component for this! |
@dartcafe I made a similar component like your RadioGroupDiv for the specific needs of a project: https://github.com/eneiluj/integration_visavid/blob/master/src/components/RadioElementSet.vue @marcoambrosini So we have multiple ways to go. Which one makes more sense?
|
Yeah, I'm not in favour. I would be ok creating a Let's keep it simple people! 🚀 |
This was inspired by nextcloud/server#26691
A new boolean prop
buttonVariant
toggles between the classic style and this one. It can be used with all types.If the CheckboxRadioSwitch elements are displayed next to each other vertically, their borders are "merged".
radio3.mp4