From adcd33ed911d544f75abfbdb9a5492e779fd1cf3 Mon Sep 17 00:00:00 2001 From: Sev Furneaux Date: Wed, 13 Nov 2024 12:32:43 +0000 Subject: [PATCH] react/livequestions: style filter sort and like card --- changelog/_8467.md | 8 + .../scss/components/_live_questions.scss | 81 ------- .../scss/components_user_facing/_card.scss | 4 + .../scss/components_user_facing/_rating.scss | 8 +- meinberlin/react/livequestions/Filters.jsx | 207 ++++++++++-------- meinberlin/react/livequestions/LikeCard.jsx | 52 +++++ .../react/livequestions/QuestionBox.jsx | 106 ++++----- .../react/livequestions/QuestionForm.jsx | 4 +- .../react/livequestions/QuestionList.jsx | 2 +- .../react/livequestions/QuestionModerator.jsx | 35 ++- .../react/livequestions/QuestionUser.jsx | 134 +++++------- 11 files changed, 287 insertions(+), 354 deletions(-) create mode 100644 changelog/_8467.md create mode 100644 meinberlin/react/livequestions/LikeCard.jsx diff --git a/changelog/_8467.md b/changelog/_8467.md new file mode 100644 index 0000000000..af5b431f50 --- /dev/null +++ b/changelog/_8467.md @@ -0,0 +1,8 @@ +### Changed + +- Restyled `Filters` component and added filter button + +### Added + +- Added new `LikeCard` component +– Added `LikeCard` component to `QuestionModerator` and `QuestionUser` components diff --git a/meinberlin/assets/scss/components/_live_questions.scss b/meinberlin/assets/scss/components/_live_questions.scss index 93907ea1f0..0b8ca57ac9 100644 --- a/meinberlin/assets/scss/components/_live_questions.scss +++ b/meinberlin/assets/scss/components/_live_questions.scss @@ -1,68 +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; } @@ -122,10 +57,6 @@ z-index: 1; } -.checkbox-btn { - display: inline-block; -} - .live_questions_infographic__footer { position: fixed; right: 0; @@ -177,10 +108,6 @@ } } -.live_questions__like { - padding-top: 0.5 * $spacer; -} - .live_question__presentation { margin-top: 5 * $spacer; } @@ -196,11 +123,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; - } -} diff --git a/meinberlin/assets/scss/components_user_facing/_card.scss b/meinberlin/assets/scss/components_user_facing/_card.scss index ae3c2cd5ea..2ea267005e 100644 --- a/meinberlin/assets/scss/components_user_facing/_card.scss +++ b/meinberlin/assets/scss/components_user_facing/_card.scss @@ -30,3 +30,7 @@ .card__link--hover { text-decoration: underline !important; // BO overide } + +.card__pill { + margin-bottom: 0.3em; +} \ No newline at end of file diff --git a/meinberlin/assets/scss/components_user_facing/_rating.scss b/meinberlin/assets/scss/components_user_facing/_rating.scss index cf9e4b9ba0..9a8d50bee5 100644 --- a/meinberlin/assets/scss/components_user_facing/_rating.scss +++ b/meinberlin/assets/scss/components_user_facing/_rating.scss @@ -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 { diff --git a/meinberlin/react/livequestions/Filters.jsx b/meinberlin/react/livequestions/Filters.jsx index db1316ad6f..483ad96dea 100644 --- a/meinberlin/react/livequestions/Filters.jsx +++ b/meinberlin/react/livequestions/Filters.jsx @@ -1,103 +1,124 @@ -import React from 'react' +import React, { useState } from 'react' import django from 'django' -export default class Filter extends React.Component { - selectCategory (e) { +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') + +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 ( -
- {this.props.categories.length > 0 - ?
-