Skip to content

Commit

Permalink
refactor: break code down into components
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Jan 29, 2024
1 parent ca72c92 commit 82e0d20
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 20 deletions.
28 changes: 8 additions & 20 deletions js/src/forum/components/Poll.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import * as Mithril from 'mithril';
import Component from 'flarum/common/Component';

import PollTitle from './Poll/PollTitle';
import PollDescription from './Poll/PollDescription';
import PollOption from './Poll/PollOption';
import PollSubmitButton from './Poll/PollSubmitButton';
export default class IndexPolls extends Component {
view(): Mithril.Children {
return (
<div className="Index-poll">
<b>Polls</b>
<p>Lorem Ipsum Dolor Sit amet Consectetur Adipiscing Elit </p>
<PollTitle />
<PollDescription />
<form>
<fieldset>
<legend className="sr-only">Privacy setting</legend>
Expand All @@ -29,24 +33,7 @@ export default class IndexPolls extends Component {
</span>
</span>
</label>
<label className="bbb">
<input
type="radio"
name="privacy-setting"
value="Private to Project Members"
className="ccc"
aria-labelledby="privacy-setting-1-label"
aria-describedby="privacy-setting-1-description"
/>
<span className="ddd">
<span id="privacy-setting-1-label" className="fff">
Private to Project Members
</span>
<span id="privacy-setting-1-description" className="ggg">
Only members of this project would be able to access
</span>
</span>
</label>
<PollOption />
<label className="bba bbb">
<input
type="radio"
Expand All @@ -66,6 +53,7 @@ export default class IndexPolls extends Component {
</span>
</label>
</div>
<PollSubmitButton />
</fieldset>
</form>
</div>
Expand Down
12 changes: 12 additions & 0 deletions js/src/forum/components/Poll/PollDescription.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as Mithril from 'mithril';
import Component from 'flarum/common/Component';

export default class PollDescription extends Component {
view(): Mithril.Children {
return (
<>
<p>Lorem Ipsum Dolor Sit amet Consectetur Adipiscing Elit Sit</p>
</>
);
}
}
Empty file.
27 changes: 27 additions & 0 deletions js/src/forum/components/Poll/PollOption.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as Mithril from 'mithril';
import Component from 'flarum/common/Component';

export default class PollOption extends Component {
view(): Mithril.Children {
return (
<label className="bbb">
<input
type="radio"
name="privacy-setting"
value="Private to Project Members"
className="ccc"
aria-labelledby="privacy-setting-1-label"
aria-describedby="privacy-setting-1-description"
/>
<span className="ddd">
<span id="privacy-setting-1-label" className="fff">
Private to Project Members test
</span>
<span id="privacy-setting-1-description" className="ggg">
Only members of this project would be able to access
</span>
</span>
</label>
);
}
}
13 changes: 13 additions & 0 deletions js/src/forum/components/Poll/PollSubmitButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as Mithril from 'mithril';
import Component from 'flarum/common/Component';
import Button from 'flarum/common/components/Button';

export default class PollSubmitButton extends Component {
view(): Mithril.Children {
return (
<Button className="Button" type="submit">
Submit
</Button>
);
}
}
12 changes: 12 additions & 0 deletions js/src/forum/components/Poll/PollTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as Mithril from 'mithril';
import Component from 'flarum/common/Component';

export default class PollTitle extends Component {
view(): Mithril.Children {
return (
<>
<p>Polls Title</p>
</>
);
}
}

0 comments on commit 82e0d20

Please sign in to comment.