This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 829
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds an option to set the `maxSelections` parameter in the `createPollDialog` and allows users to vote for more than one answer.
- Loading branch information
Showing
12 changed files
with
553 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
/** | ||
* This component expects the parent to specify a positive padding and | ||
* width. | ||
* It is used for multiple selection polls and mostly copied | ||
* from _StyledRadioButton.pcss to match it's style. | ||
*/ | ||
|
||
.mx_StyledPollCheckbox { | ||
$radio-circle-color: $quaternary-content; | ||
$active-radio-circle-color: $accent; | ||
position: relative; | ||
|
||
display: flex; | ||
align-items: baseline; | ||
flex-grow: 1; | ||
|
||
> .mx_StyledPollCheckbox_content { | ||
flex-grow: 1; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
|
||
margin-left: 8px; | ||
margin-right: 8px; | ||
} | ||
|
||
.mx_StyledPollCheckbox_spacer { | ||
flex-shrink: 0; | ||
flex-grow: 0; | ||
|
||
height: $font-16px; | ||
width: $font-16px; | ||
} | ||
|
||
input[type="checkbox"] { | ||
/* Remove the OS's representation */ | ||
margin: 0; | ||
padding: 0; | ||
appearance: none; | ||
|
||
+ div { | ||
flex-shrink: 0; | ||
flex-grow: 0; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
box-sizing: border-box; | ||
height: $font-16px; | ||
width: $font-16px; | ||
margin-left: 2px; /* For the highlight on focus */ | ||
|
||
border: $font-1-5px solid $radio-circle-color; | ||
border-radius: $font-16px; | ||
|
||
> div { | ||
box-sizing: border-box; | ||
|
||
height: $font-8px; | ||
width: $font-8px; | ||
|
||
border-radius: $font-8px; | ||
} | ||
} | ||
|
||
&.focus-visible { | ||
& + div { | ||
@mixin unreal-focus; | ||
} | ||
} | ||
|
||
&:checked { | ||
& + div { | ||
border-color: $active-radio-circle-color; | ||
|
||
& > div { | ||
background: $active-radio-circle-color; | ||
} | ||
} | ||
} | ||
|
||
&:disabled { | ||
& + div, | ||
& + div + span { | ||
opacity: 0.5; | ||
cursor: not-allowed; | ||
} | ||
|
||
& + div { | ||
border-color: $radio-circle-color; | ||
} | ||
} | ||
|
||
&:checked:disabled { | ||
& + div > div { | ||
background-color: $radio-circle-color; | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
.mx_StyledPollCheckbox_outlined { | ||
border: 1px solid $input-darker-bg-color; | ||
border-radius: 8px; | ||
} | ||
|
||
.mx_StyledPollCheckbox_checked { | ||
border-color: $accent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
/* This component is mostly copied from StyledRadioButton.tsx to match it's appearance in polls */ | ||
|
||
import React from "react"; | ||
import classnames from 'classnames'; | ||
|
||
interface IProps extends React.InputHTMLAttributes<HTMLInputElement> { | ||
inputRef?: React.RefObject<HTMLInputElement>; | ||
outlined?: boolean; | ||
} | ||
|
||
interface IState { | ||
} | ||
|
||
export default class StyledPollCheckbox extends React.PureComponent<IProps, IState> { | ||
public static readonly defaultProps = { | ||
className: '', | ||
}; | ||
|
||
public render() { | ||
const { children, className, disabled, outlined, inputRef, ...otherProps } = this.props; | ||
const _className = classnames( | ||
'mx_StyledPollCheckbox', | ||
className, | ||
{ | ||
"mx_StyledPollCheckbox_disabled": disabled, | ||
"mx_StyledPollCheckbox_enabled": !disabled, | ||
"mx_StyledPollCheckbox_checked": this.props.checked, | ||
"mx_StyledPollCheckbox_outlined": outlined, | ||
}); | ||
|
||
const checkbox = <React.Fragment> | ||
<input | ||
// Pass through the ref - used for keyboard shortcut access to some buttons | ||
ref={inputRef} | ||
type='checkbox' | ||
disabled={disabled} | ||
{...otherProps} | ||
/> | ||
{ /* Used to render the radio button circle */ } | ||
<div><div /></div> | ||
</React.Fragment>; | ||
|
||
return <label className={_className}> | ||
{ checkbox } | ||
<div className="mx_StyledPollCheckbox_content">{ children }</div> | ||
<div className="mx_StyledPollCheckbox_spacer" /> | ||
</label>; | ||
} | ||
} |
Oops, something went wrong.