From bbc5d09a297d05dbe9a0e03f69ccc3167eb35034 Mon Sep 17 00:00:00 2001 From: Davide Iadeluca Date: Mon, 29 Jan 2024 15:07:53 +0100 Subject: [PATCH] feat: implement prototype of how results are shown --- js/src/forum/components/Poll.tsx | 7 ++- .../forum/components/Poll/PollDescription.tsx | 2 +- js/src/forum/components/Poll/PollOptions.tsx | 5 ++- js/src/forum/components/Poll/PollResult.tsx | 29 ++++++++++++ js/src/forum/components/Poll/PollTitle.tsx | 2 +- resources/less/forum.less | 45 +++++++++++++++++-- 6 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 js/src/forum/components/Poll/PollResult.tsx diff --git a/js/src/forum/components/Poll.tsx b/js/src/forum/components/Poll.tsx index 795f357a..e906c996 100644 --- a/js/src/forum/components/Poll.tsx +++ b/js/src/forum/components/Poll.tsx @@ -6,6 +6,7 @@ import PollDescription from './Poll/PollDescription'; import PollOptions from './Poll/PollOptions'; import PollSubmitButton from './Poll/PollSubmitButton'; import PollImage from './Poll/PollImage'; + export default class IndexPolls extends Component { view(): Mithril.Children { return ( @@ -14,11 +15,13 @@ export default class IndexPolls extends Component {
- - + + +
Privacy setting +
diff --git a/js/src/forum/components/Poll/PollDescription.tsx b/js/src/forum/components/Poll/PollDescription.tsx index 2c93efef..96fb4994 100644 --- a/js/src/forum/components/Poll/PollDescription.tsx +++ b/js/src/forum/components/Poll/PollDescription.tsx @@ -7,6 +7,6 @@ interface PollDescriptionAttrs extends ComponentAttrs { export default class PollDescription extends Component { view(): Mithril.Children { - return

{this.attrs.text}

; + return

{this.attrs.text}

; } } diff --git a/js/src/forum/components/Poll/PollOptions.tsx b/js/src/forum/components/Poll/PollOptions.tsx index 27c0ba7d..502ed4d5 100644 --- a/js/src/forum/components/Poll/PollOptions.tsx +++ b/js/src/forum/components/Poll/PollOptions.tsx @@ -1,22 +1,23 @@ import * as Mithril from 'mithril'; import Component from 'flarum/common/Component'; import PollOption from './PollOption'; +import PollResult from './PollResult'; import listItems from 'flarum/common/helpers/listItems'; import ItemList from 'flarum/common/utils/ItemList'; export default class PollOptions extends Component { view(): Mithril.Children { - return
{this.pollOptions().toArray()}
; + return
{this.pollOptions().toArray()}
; } pollOptions(): ItemList { const items = new ItemList(); items.add('test1', ); + items.add('test5', ); items.add('test2', ); items.add('test3', ); items.add('test4', ); - items.add('test5', ); return items; } diff --git a/js/src/forum/components/Poll/PollResult.tsx b/js/src/forum/components/Poll/PollResult.tsx new file mode 100644 index 00000000..02b2b882 --- /dev/null +++ b/js/src/forum/components/Poll/PollResult.tsx @@ -0,0 +1,29 @@ +import * as Mithril from 'mithril'; +import Component from 'flarum/common/Component'; +import PollOptionLabel from './PollOptionLabel'; + +export default class PollResults extends Component { + view(): Mithril.Children { + return ( + + ); + } +} diff --git a/js/src/forum/components/Poll/PollTitle.tsx b/js/src/forum/components/Poll/PollTitle.tsx index 690457e1..0ff3c7c0 100644 --- a/js/src/forum/components/Poll/PollTitle.tsx +++ b/js/src/forum/components/Poll/PollTitle.tsx @@ -7,6 +7,6 @@ interface PollTitleAttrs extends ComponentAttrs { export default class PollTitle extends Component { view(): Mithril.Children { - return

{this.attrs.text}

; + return

{this.attrs.text}

; } } diff --git a/resources/less/forum.less b/resources/less/forum.less index 374b5595..a4853e15 100755 --- a/resources/less/forum.less +++ b/resources/less/forum.less @@ -1,5 +1,6 @@ :root { --poll-option-color: var(--muted-color); + --poll-option-accent-color: var(--primary-color); --poll-option-active-color: var(--secondary-color); } @@ -406,7 +407,10 @@ .Poll-options { display: grid; gap: 10px; + padding: 10px; margin-bottom: 10px; + background: var(--control-bg); + border-radius: var(--border-radius); &.grid-layout { grid-template-columns: 1fr 1fr; @@ -421,9 +425,10 @@ display: flex; position: relative; padding: 10px; - border-color: var(--poll-option-color); - border-width: 1px; - border-style: solid; + // border-color: var(--poll-option-color); + // border-width: 1px; + // border-style: solid; + background: var(--body-bg); border-radius: 4px; cursor: pointer; @@ -432,12 +437,46 @@ } } +.PollResult { + display: flex; + flex-direction: row; + position: relative; + padding: 10px; + // border-color: var(--poll-option-color); + // border-width: 1px; + // border-style: solid; + border-radius: 4px; +} + +.PollResult-input, +.PollOption-input { + accent-color: var(--poll-option-accent-color); +} + .PollOption-information { display: flex; margin-left: 10px; flex-direction: column; } +.PollResults-row { + display: flex; + flex-grow: 1; + justify-content: space-between; +} +.PollResult-information { + display: flex; + margin-left: 10px; + justify-content: space-between; + flex-direction: column; + flex-grow: 1; +} + +.Poll-title, +.PollResult-number { + font-weight: 600; +} + .PollOption-label { display: block; font-weight: 600;