-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor settings, make extensible
- Loading branch information
Showing
5 changed files
with
207 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import app from 'flarum/admin/app'; | ||
import ExtensionPage from 'flarum/admin/components/ExtensionPage'; | ||
import ItemList from 'flarum/common/utils/ItemList'; | ||
import Mithril from 'mithril'; | ||
|
||
export default class PollsSettingsPage extends ExtensionPage { | ||
content() { | ||
return ( | ||
<div className="PollsSettingsPage"> | ||
<div className="container"> | ||
<div className="PollsSettingsTabPage PollsSettingsPage--settings"> | ||
<div className="Form"> | ||
{this.settingsItems().toArray()} | ||
<div className="Form-group">{this.submitButton()}</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
settingsItems(): ItemList<Mithril.Children> { | ||
const items = new ItemList<Mithril.Children>(); | ||
|
||
items.add( | ||
'general', | ||
<div className="Section"> | ||
<h3>{app.translator.trans('fof-polls.admin.settings.general.heading')}</h3> | ||
<p className="helpText">{app.translator.trans('fof-polls.admin.settings.general.help')}</p> | ||
{this.generalItems().toArray()} | ||
</div> | ||
); | ||
|
||
items.add( | ||
'globalPolls', | ||
<div className="Section"> | ||
<h3>{app.translator.trans('fof-polls.admin.settings.global_polls.heading')}</h3> | ||
<p className="helpText">{app.translator.trans('fof-polls.admin.settings.global_polls.help')}</p> | ||
{this.globalPollsItems().toArray()} | ||
</div> | ||
); | ||
|
||
items.add( | ||
'image', | ||
<div className="Section"> | ||
<h3>{app.translator.trans('fof-polls.admin.settings.image.heading')}</h3> | ||
<p className="helpText">{app.translator.trans('fof-polls.admin.settings.image.help')}</p> | ||
{this.imageItems().toArray()} | ||
</div> | ||
); | ||
|
||
return items; | ||
} | ||
|
||
generalItems(): ItemList<Mithril.Children> { | ||
const items = new ItemList<Mithril.Children>(); | ||
|
||
items.add( | ||
'colorBlend', | ||
this.buildSettingComponent({ | ||
setting: 'fof-polls.optionsColorBlend', | ||
type: 'switch', | ||
label: app.translator.trans('fof-polls.admin.settings.options_color_blend'), | ||
help: app.translator.trans('fof-polls.admin.settings.options_color_blend_help'), | ||
}) | ||
); | ||
|
||
items.add( | ||
'maxOptions', | ||
this.buildSettingComponent({ | ||
setting: 'fof-polls.maxOptions', | ||
type: 'number', | ||
label: app.translator.trans('fof-polls.admin.settings.max_options'), | ||
min: 2, | ||
}) | ||
); | ||
|
||
return items; | ||
} | ||
|
||
globalPollsItems(): ItemList<Mithril.Children> { | ||
const items = new ItemList<Mithril.Children>(); | ||
|
||
items.add( | ||
'enableGlobalPolls', | ||
this.buildSettingComponent({ | ||
setting: 'fof-polls.enableGlobalPolls', | ||
type: 'boolean', | ||
label: app.translator.trans('fof-polls.admin.settings.enable_global_polls'), | ||
help: app.translator.trans('fof-polls.admin.settings.enable_global_polls_help'), | ||
}) | ||
); | ||
|
||
return items; | ||
} | ||
|
||
imageItems(): ItemList<Mithril.Children> { | ||
const items = new ItemList<Mithril.Children>(); | ||
|
||
items.add( | ||
'allowOptionImage', | ||
this.buildSettingComponent({ | ||
setting: 'fof-polls.allowOptionImage', | ||
type: 'switch', | ||
label: app.translator.trans('fof-polls.admin.settings.allow_option_image'), | ||
}) | ||
); | ||
|
||
items.add( | ||
'allowImageUploads', | ||
this.buildSettingComponent({ | ||
setting: 'fof-polls.allowImageUploads', | ||
type: 'switch', | ||
label: app.translator.trans('fof-polls.admin.settings.allow_image_uploads'), | ||
help: app.translator.trans('fof-polls.admin.settings.allow_image_uploads_help'), | ||
}) | ||
); | ||
|
||
items.add( | ||
'imageHeight', | ||
this.buildSettingComponent({ | ||
setting: 'fof-polls.image_height', | ||
type: 'number', | ||
label: app.translator.trans('fof-polls.admin.settings.image_height'), | ||
}) | ||
); | ||
|
||
items.add( | ||
'imageWidth', | ||
this.buildSettingComponent({ | ||
setting: 'fof-polls.image_width', | ||
type: 'number', | ||
label: app.translator.trans('fof-polls.admin.settings.image_width'), | ||
}) | ||
); | ||
|
||
return items; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import PollsSettingsPage from './PollsSettingsPage'; | ||
|
||
export const components = { | ||
PollsSettingsPage, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.PollsSettingsPage { | ||
padding-top: 20px; | ||
|
||
.Button { | ||
margin-right: 10px; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.PollsSettingsTabPage { | ||
background: @control-bg; // Use control background for coherence | ||
padding: 20px; | ||
border-radius: @border-radius; // Consistent border radius | ||
box-shadow: 0 2px 4px @shadow-color; // Subtle shadow for depth | ||
|
||
h3 { | ||
color: @primary-color; // Primary color for headings | ||
margin-bottom: 10px; | ||
} | ||
|
||
.Section { | ||
background: @body-bg; // Contrast with the section background | ||
border-radius: @border-radius; | ||
box-shadow: 0 1px 3px @shadow-color; | ||
padding: 15px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.Form { | ||
.control { | ||
background: @body-bg; | ||
border: 1px solid @muted-color; // Defines the input fields | ||
color: @text-color; | ||
padding: 6px 12px; | ||
border-radius: @border-radius; | ||
} | ||
input { | ||
max-width: 300px; | ||
} | ||
} | ||
} | ||
|
||
&--settings { | ||
//max-width: 720px; | ||
margin: 0 auto; // Center align for better presentation | ||
|
||
@media @desktop-up { | ||
margin: 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters