Skip to content

Commit

Permalink
react/livequestions: style filter sort and like card
Browse files Browse the repository at this point in the history
  • Loading branch information
sevfurneaux committed Nov 13, 2024
1 parent b352c8c commit dcfb26b
Show file tree
Hide file tree
Showing 12 changed files with 268 additions and 488 deletions.
12 changes: 12 additions & 0 deletions changelog/_8467.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### Removed

- Removed `Infobox` component

### Changed

- Restyled `Filters` component and added filter button

### Added

- Added new `LikeCard` component
– Added `LikeCard` component to `QuestionModerator` and `QuestionUser` components
122 changes: 0 additions & 122 deletions meinberlin/assets/scss/components/_live_questions.scss
Original file line number Diff line number Diff line change
@@ -1,109 +1,3 @@
.live_questions__filters {
@media screen and (min-width: $breakpoint-xs) {
display: inline-flex;
}
}

.live_questions__filters--parent {
width: 100%;
justify-content: space-between;
margin-bottom: $spacer;

@media screen and (min-width: $breakpoint-xs) {
display: inline-flex;
}
}

.live_questions__filters--dropdown {
@media screen and (min-width: $breakpoint-xs) {
margin-right: $spacer;
margin-bottom: 0;
}

button {
min-width: 100%;
}
}

.live_questions__filters--btns {
width: 100%;
display: inline-flex;
justify-content: flex-end;

.switch--btn {
border-radius: $border-radius;
}
}

.live_questions__filters--screen-btn {
width: 100%;
}

.live-question__action-bar {
width: 100%;
display: inline-flex;
justify-content: space-between;
}

.live_questions__question {
font-size: $font-size-lg;
margin-bottom: 0.25 * $spacer;
}

.infobox__box {
background-color: $bg-tertiary;
padding: 0.5 * $spacer $spacer;
font-size: $font-size-sm;
margin-bottom: $spacer;

i {
position: absolute;
color: $primary;
line-height: 1.2rem;
}
}

.infobox__text {
margin-left: 2 * $spacer;
}

.infobox__icon {
margin-left: -0.6 * $spacer;
position: absolute;
}

// infobox bigger
@media screen and (min-width: $breakpoint-xs) {
.infobox {
display: inline-flex;
}

.infobox__box {
text-align: center;
padding: $spacer;
margin-right: $spacer;
}

.infobox__box > i {
display: block;
position: relative;
}

.infobox__text {
margin-left: 0;
}

.infobox__icon {
display: block;
position: relative;
margin: auto;
}

.infobox__box--last {
margin-right: 0;
}
}

.progress {
margin-bottom: $spacer;
position: relative;
Expand All @@ -122,10 +16,6 @@
z-index: 1;
}

.checkbox-btn {
display: inline-block;
}

.live_questions_infographic__footer {
position: fixed;
right: 0;
Expand Down Expand Up @@ -177,10 +67,6 @@
}
}

.live_questions__like {
padding-top: 0.5 * $spacer;
}

.live_question__presentation {
margin-top: 5 * $spacer;
}
Expand All @@ -196,11 +82,3 @@
font-size: 0.6rem;
line-height: inherit;
}

.live_questions__select > .select2-container {
min-width: 100%;

@media screen and (min-width: $breakpoint-xs) {
min-width: 15rem;
}
}
4 changes: 4 additions & 0 deletions meinberlin/assets/scss/components_user_facing/_card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@
.card__link--hover {
text-decoration: underline !important; // BO overide
}

.card__pill {
margin-bottom: 0.3em;
}
8 changes: 4 additions & 4 deletions meinberlin/assets/scss/components_user_facing/_rating.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
i {
margin-right: 0.4em;
margin-bottom: 0.4em;
display: block;
display: inline;
}

@media screen and (min-width: $breakpoint-palm) {
display: inline;
}
&--active {
font-weight: bold;
}

.fa-chevron-up:before {
Expand Down
197 changes: 104 additions & 93 deletions meinberlin/react/livequestions/Filters.jsx
Original file line number Diff line number Diff line change
@@ -1,103 +1,114 @@
import React from 'react'
import React, { useState } from 'react'
import django from 'django'

export default class Filter extends React.Component {
selectCategory (e) {
const Filter = ({ categories, isModerator, displayOnShortlist, toggleDisplayOnShortlist, displayNotHiddenOnly, toggledisplayNotHiddenOnly, orderedByLikes, toggleOrdering, setCategories }) => {
const [category, setCategory] = useState(null)

const selectCategory = (e) => {
e.preventDefault()
const category = e.target.getAttribute('data-value')
this.props.setCategories(category)
setCategory(e.target.value)
}

getButtonClass () {
if (this.props.currentCategory === '-1') {
return 'btn btn--light btn--select live_questions__filters--dropdown dropdown-toggle'
} else {
return 'btn btn--light btn--select live_questions__filters--dropdown dropdown-toggle'
const handleSubmit = (e) => {
e.preventDefault()
if (category) {
setCategories(category)
}
}

render () {
const allTag = django.gettext('all')
const onlyShowMarkedText = django.gettext('only show marked questions')
const displayNotHiddenText = django.gettext('display only questions which are not hidden')
const orderLikesText = django.gettext('order by likes')
return (
<div className="live_questions__filters">
{this.props.categories.length > 0
? <div className="dropdown live_questions__filters--dropdown">
<button
className={this.getButtonClass()} type="button" id="dropdownMenuButton"
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
const allTag = django.gettext('all')
const onlyShowMarkedText = django.gettext('only show marked questions')
const displayNotHiddenText = django.gettext('display only questions which are not hidden')
const orderLikesText = django.gettext('order by likes')
const questionsText = django.gettext('Questions')
const filterText = django.gettext('Filter')
const affiliationText = django.gettext('Affiliation')

return (
<>
<h2 id="filter-form-heading">{questionsText}</h2>
<form className="form panel--heavy" onSubmit={handleSubmit} aria-labelledby="filter-form-heading">
{categories.length > 0 && (
<div className="form-group">
<label htmlFor="filterCategorySelect">{affiliationText}*</label>
<select
id="filterCategorySelect"
className="form-control"
onChange={selectCategory}
>
{this.props.currentCategoryName}
<i className="fa fa-caret-down" aria-label={onlyShowMarkedText} />
</button>
<div className="dropdown-menu" aria-labelledby="dropdownMenuButton">
<button className="dropdown-item" data-value={-1} onClick={this.selectCategory.bind(this)} href="#">{allTag}</button>
{this.props.categories.map((category, index) => {
return <button className="dropdown-item" key={index} data-value={category} onClick={this.selectCategory.bind(this)} href="#">{category}</button>
})}
</div>
</div> // eslint-disable-line react/jsx-closing-tag-location
: ''}
{this.props.isModerator &&
<div className="live_questions__filters--btns">
<div className="checkbox-btn u-spacer-right">
<label
htmlFor="markedCheck"
className={'btn switch--btn' + (this.props.displayOnShortlist ? ' active' : '')}
title={onlyShowMarkedText}
>
<input
className="radio__input"
type="checkbox"
id="markedCheck"
name="markedCheck"
checked={this.props.displayOnShortlist}
onChange={this.props.toggleDisplayOnShortlist} // eslint-disable-line react/jsx-handler-names
/>
<span className="visually-hidden">{onlyShowMarkedText}</span>
<i className="far fa-list-alt" aria-hidden="true" />
</label>
</div>
<div className="checkbox-btn u-spacer-right">
<label
htmlFor="displayNotHiddenOnly"
className={'btn switch--btn' + (this.props.displayNotHiddenOnly ? ' active' : '')}
title={displayNotHiddenText}
>
<input
className="radio__input"
type="checkbox"
id="displayNotHiddenOnly"
name="displayNotHiddenOnly"
checked={this.props.displayNotHiddenOnly}
onChange={this.props.toggledisplayNotHiddenOnly} // eslint-disable-line react/jsx-handler-names
/>
<span className="visually-hidden">{displayNotHiddenText}</span>
<i className="far fa-eye" aria-hidden="true" />
</label>
</div>
<div className="checkbox-btn">
<label
htmlFor="orderedByLikes"
className={'btn switch--btn' + (this.props.orderedByLikes ? ' active' : '')}
title={orderLikesText}
>
<input
className="radio__input"
type="checkbox"
id="orderedByLikes"
name="orderedByLikes"
checked={this.props.orderedByLikes}
onChange={this.props.toggleOrdering} // eslint-disable-line react/jsx-handler-names
/>
<span className="visually-hidden">{orderLikesText}</span>
<i className="far fa-thumbs-up" aria-hidden="true" />
</label>
</div>
</div>}
</div>
)
}
<option value={-1}>{allTag}</option>
{categories.map((cat) => (
<option key={cat} value={cat}>{cat}</option>
))}
</select>
</div>
)}
<div className="form-actions">
<div className="form-actions__right">
<button type="submit" className="button">{filterText}</button>
</div>
</div>
</form>
{isModerator && (
<div className="block">
<div className="checkbox-btn u-spacer-right">
<label
htmlFor="markedCheck"
className={'btn switch--btn' + (displayOnShortlist ? ' active' : '')}
title={onlyShowMarkedText}
>
<input
className="radio__input"
type="checkbox"
id="markedCheck"
name="markedCheck"
checked={displayOnShortlist}
onChange={toggleDisplayOnShortlist}
/>
<span className="visually-hidden">{onlyShowMarkedText}</span>
<i className="far fa-list-alt" aria-hidden="true" />
</label>
</div>
<div className="checkbox-btn u-spacer-right">
<label
htmlFor="displayNotHiddenOnly"
className={'btn switch--btn' + (displayNotHiddenOnly ? ' active' : '')}
title={displayNotHiddenText}
>
<input
className="radio__input"
type="checkbox"
id="displayNotHiddenOnly"
name="displayNotHiddenOnly"
checked={displayNotHiddenOnly}
onChange={toggledisplayNotHiddenOnly}
/>
<span className="visually-hidden">{displayNotHiddenText}</span>
<i className="far fa-eye" aria-hidden="true" />
</label>
</div>
<div className="checkbox-btn">
<label
htmlFor="orderedByLikes"
className={'btn switch--btn' + (orderedByLikes ? ' active' : '')}
title={orderLikesText}
>
<input
className="radio__input"
type="checkbox"
id="orderedByLikes"
name="orderedByLikes"
checked={orderedByLikes}
onChange={toggleOrdering}
/>
<span className="visually-hidden">{orderLikesText}</span>
<i className="far fa-thumbs-up" aria-hidden="true" />
</label>
</div>
</div>
)}
</>
)
}

export default Filter
Loading

0 comments on commit dcfb26b

Please sign in to comment.