-
-
Notifications
You must be signed in to change notification settings - Fork 22
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, general cleanup (#75)
* chore: refactor settings, general * Apply fixes from StyleCI * chore: drop support for php 7.3 --------- Co-authored-by: StyleCI Bot <[email protected]>
- Loading branch information
1 parent
8ef2f4f
commit f69a8be
Showing
24 changed files
with
2,340 additions
and
4,525 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
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
{ | ||
"private": true, | ||
"name": "@fof/nightmode", | ||
"version": "0.0.0", | ||
"private": true, | ||
"prettier": "@flarum/prettier-config", | ||
"dependencies": { | ||
"@flarum/prettier-config": "^1.0.0", | ||
"es-cookie": "^1.4.0", | ||
"flarum-tsconfig": "^1.0.2", | ||
"flarum-webpack-config": "^2.0.2", | ||
"webpack": "^5.88.2", | ||
"webpack-cli": "^5.1.4" | ||
}, | ||
"scripts": { | ||
"dev": "webpack --mode development --watch", | ||
"build": "webpack --mode production", | ||
"format": "prettier --write src", | ||
"format-check": "prettier --check src" | ||
"@flarum/prettier-config": "^1.0.0", | ||
"flarum-tsconfig": "^1.0.2", | ||
"flarum-webpack-config": "^2.0.2", | ||
"webpack": "^5.88.1", | ||
"webpack-cli": "^5.1.4", | ||
"es-cookie": "^1.5.0" | ||
}, | ||
"devDependencies": { | ||
"prettier": "^3.0.3" | ||
"prettier": "^3.0.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
} | ||
"scripts": { | ||
"dev": "webpack --mode development --watch", | ||
"build": "webpack --mode production", | ||
"format": "prettier --write src", | ||
"format-check": "prettier --check src" | ||
} | ||
} | ||
|
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,77 @@ | ||
import app from 'flarum/admin/app'; | ||
import ExtensionPage from 'flarum/admin/components/ExtensionPage'; | ||
import ItemList from 'flarum/common/utils/ItemList'; | ||
import Themes from '../../common/Themes'; | ||
import extractText from 'flarum/common/utils/extractText'; | ||
import type Mithril from 'mithril'; | ||
|
||
export default class NightmodeSettingsPage extends ExtensionPage { | ||
content() { | ||
return ( | ||
<div className="NightmodeSettingsPage"> | ||
<div className="container"> | ||
<div className="NightmodeSettingsTabPage NightmodeSettingsPage--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-nightmode.admin.settings.general.heading')}</h3> | ||
<p className="helpText">{app.translator.trans('fof-nightmode.admin.settings.general.help')}</p> | ||
{this.generalItems().toArray()} | ||
</div> | ||
); | ||
|
||
return items; | ||
} | ||
|
||
generalItems(): ItemList<Mithril.Children> { | ||
const items = new ItemList<Mithril.Children>(); | ||
|
||
items.add( | ||
'header-toggle', | ||
this.buildSettingComponent({ | ||
label: app.translator.trans('fof-nightmode.admin.settings.modal.always_show_theme_toggle_on_header'), | ||
setting: 'fofNightMode.show_theme_toggle_on_header_always', | ||
type: 'switch', | ||
}) | ||
); | ||
|
||
items.add( | ||
'default-theme', | ||
this.buildSettingComponent({ | ||
label: app.translator.trans('fof-nightmode.admin.settings.modal.default_theme'), | ||
help: app.translator.trans('fof-nightmode.admin.settings.modal.default_theme_helper'), | ||
setting: 'fof-nightmode.default_theme', | ||
type: 'select', | ||
options: this.populateThemes(), | ||
}) | ||
); | ||
|
||
return items; | ||
} | ||
|
||
populateThemes(): Record<number, string> { | ||
let options: Record<number, string> = {}; | ||
|
||
// add themes based on JS enum | ||
Object.keys(Themes).forEach((theme, i) => { | ||
if (theme === 'DEFAULT') return; | ||
|
||
options[i] = extractText(app.translator.trans(`fof-nightmode.admin.settings.modal.theme_${theme.toLowerCase()}`)); | ||
}); | ||
|
||
return options; | ||
} | ||
} |
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 NightmodeSettingsPage from './NightmodeSettingsPage'; | ||
|
||
export const components = { | ||
NightmodeSettingsPage, | ||
}; |
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
import app from 'flarum/admin/app'; | ||
import setSelectedTheme from '../common/setSelectedTheme'; | ||
import NightmodeSettingsPage from './components/NightmodeSettingsPage'; | ||
|
||
export * from './components'; | ||
|
||
app.initializers.add('fof-nightmode', () => { | ||
app.extensionData.for('fof-nightmode').registerPage(NightmodeSettingsPage); | ||
|
||
setSelectedTheme(); | ||
}); |
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
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
Oops, something went wrong.