From d425ec5a9255c7e853edc57ee08d7f30c012484d Mon Sep 17 00:00:00 2001 From: Davide Iadeluca Date: Mon, 29 Jan 2024 08:45:39 +0100 Subject: [PATCH] refactor: further break code down into components --- js/src/forum/components/Poll.tsx | 64 +++++--------------- js/src/forum/components/Poll/PollImage.tsx | 8 +++ js/src/forum/components/Poll/PollOption.tsx | 4 +- js/src/forum/components/Poll/PollOptions.tsx | 59 ++++++++++++++++++ resources/less/forum.less | 12 ++++ 5 files changed, 97 insertions(+), 50 deletions(-) create mode 100644 js/src/forum/components/Poll/PollOptions.tsx diff --git a/js/src/forum/components/Poll.tsx b/js/src/forum/components/Poll.tsx index 7d0ff79c..356692cd 100644 --- a/js/src/forum/components/Poll.tsx +++ b/js/src/forum/components/Poll.tsx @@ -3,59 +3,27 @@ import Component from 'flarum/common/Component'; import PollTitle from './Poll/PollTitle'; import PollDescription from './Poll/PollDescription'; -import PollOption from './Poll/PollOption'; +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 (
- - -
-
- Privacy setting -
- - - -
- -
-
+
+ +
+
+ + +
+
+ Privacy setting + + +
+
+
); } diff --git a/js/src/forum/components/Poll/PollImage.tsx b/js/src/forum/components/Poll/PollImage.tsx index e69de29b..b33875a7 100644 --- a/js/src/forum/components/Poll/PollImage.tsx +++ b/js/src/forum/components/Poll/PollImage.tsx @@ -0,0 +1,8 @@ +import * as Mithril from 'mithril'; +import Component from 'flarum/common/Component'; + +export default class PollImage extends Component { + view(): Mithril.Children { + return; + } +} diff --git a/js/src/forum/components/Poll/PollOption.tsx b/js/src/forum/components/Poll/PollOption.tsx index 90c0e666..930cfe41 100644 --- a/js/src/forum/components/Poll/PollOption.tsx +++ b/js/src/forum/components/Poll/PollOption.tsx @@ -15,10 +15,10 @@ export default class PollOption extends Component { /> - Private to Project Members test + Private to Project Members test 23 - Only members of this project would be able to access + Only members of this project would be able to access 3 diff --git a/js/src/forum/components/Poll/PollOptions.tsx b/js/src/forum/components/Poll/PollOptions.tsx new file mode 100644 index 00000000..6823b2a2 --- /dev/null +++ b/js/src/forum/components/Poll/PollOptions.tsx @@ -0,0 +1,59 @@ +import * as Mithril from 'mithril'; +import Component from 'flarum/common/Component'; +import PollOption from './PollOption'; +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()} + +
+ ); + } + + pollOptions(): ItemList { + const items = new ItemList(); + + items.add('test', ); + + return items; + } +} diff --git a/resources/less/forum.less b/resources/less/forum.less index fc2ee822..21dd31a8 100755 --- a/resources/less/forum.less +++ b/resources/less/forum.less @@ -468,3 +468,15 @@ font-size: 0.875rem; line-height: 1.25rem; } + +.Index-poll { + display: flex; + gap: 15px; + + .PollImage { + } + + .Poll { + flex-grow: 1; + } +}