-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(plugin): settings-ui #3066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ArjixWasTaken
wants to merge
35
commits into
pear-devs:master
Choose a base branch
from
ArjixWasTaken:feat/settings-ui
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,235
−19
Draft
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
a95fbd5
init mdui
ArjixWasTaken 919f372
temp: do not tree-shake mdui
ArjixWasTaken b322c9c
Merge remote-tracking branch 'upstream/master' into mdui
ArjixWasTaken 64ba6f0
update pnpm-lock.yaml
ArjixWasTaken 808df2e
feat: allow ES5 and ES6 HTMLElements to co-exist
ArjixWasTaken b21db78
simplify code
ArjixWasTaken ddc8210
enable mdui CSS
ArjixWasTaken 396e0ff
small refactor
ArjixWasTaken 1074547
Merge branch 'master' into mdui
ArjixWasTaken e472ac4
fix CSS weirdness
ArjixWasTaken 47d8a17
fix theme
ArjixWasTaken d0c533f
make navigation buttons use m3 components
ArjixWasTaken bcd9c86
Merge branch 'th-ch:master' into mdui
ArjixWasTaken bc2bfeb
Merge branch 'master' into mdui
ArjixWasTaken 7f13640
Merge branch 'master' into mdui
ArjixWasTaken 9d3e57d
suppress Lit warnings
ArjixWasTaken 261a55b
remove polyfill
ArjixWasTaken edc82e7
Discard changes to src/plugins/navigation/components/back-button.tsx
ArjixWasTaken 21fb20d
Discard changes to src/plugins/navigation/components/forward-button.tsx
ArjixWasTaken b06cd2d
Discard changes to src/youtube-music.d.ts
ArjixWasTaken cd6a79f
Merge branch 'master' into mdui
ArjixWasTaken f06c383
Merge branch 'master' into mdui
ArjixWasTaken 07afd7e
Discard changes to .prettierrc
ArjixWasTaken 24107b9
Merge branch 'master' into mdui
ArjixWasTaken 3a86327
feat(plugin): settings-ui
ArjixWasTaken 252cab4
Merge branch 'master' into feat/settings-ui
ArjixWasTaken 4e97621
Merge branch 'master' into feat/settings-ui
ArjixWasTaken 8db9345
Merge branch 'pear-devs:master' into feat/settings-ui
ArjixWasTaken de9e8d2
apply eslint --fix
ArjixWasTaken 99cce0c
Merge branch 'pear-devs:master' into feat/settings-ui
ArjixWasTaken be7f39c
Merge branch 'pear-devs:master' into feat/settings-ui
ArjixWasTaken 86d5270
Merge branch 'master' into feat/settings-ui
ArjixWasTaken 4cd887c
start rewrite on settings ui
ArjixWasTaken e8cd5a6
Merge branch 'pear-devs:master' into feat/settings-ui
ArjixWasTaken 3a8cf53
Merge branch 'pear-devs:master' into feat/settings-ui
ArjixWasTaken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,40 @@ | ||
| diff --git a/jsx.en.d.ts b/jsx.en.d.ts | ||
| index 514d455dcdb436aaf7b2ee88deaefe01943c8b4b..48dff045dead4315936afd931336198996c88217 100644 | ||
| --- a/jsx.en.d.ts | ||
| +++ b/jsx.en.d.ts | ||
| @@ -1,12 +1,8 @@ | ||
| -import React from 'react'; | ||
| import { JQ } from '@mdui/jq'; | ||
|
|
||
| -type HTMLElementProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>; | ||
| +type HTMLElementProps = import("solid-js").JSX.HTMLAttributes<HTMLElement>; | ||
|
|
||
| -declare global { | ||
| - namespace React { | ||
| - namespace JSX { | ||
| - interface IntrinsicElements { | ||
| +export interface IntrinsicElements { | ||
| /** | ||
| * Avatar Component | ||
| * | ||
| @@ -3296,7 +3292,4 @@ declare global { | ||
| */ | ||
| 'order'?: number; | ||
| } & HTMLElementProps; | ||
| - } | ||
| - } | ||
| - } | ||
| } | ||
| diff --git a/package.json b/package.json | ||
| index 3fa3eeb471ce4c31d7ac1c9bcb2d6823947e91ca..c4b062020bf20b8db34ccfea500fa682a4af19a6 100644 | ||
| --- a/package.json | ||
| +++ b/package.json | ||
| @@ -60,5 +60,8 @@ | ||
| "tslib": "^2.8.1", | ||
| "@mdui/shared": "^1.0.8", | ||
| "@mdui/jq": "^3.0.3" | ||
| + }, | ||
| + "peerDependencies": { | ||
| + "solid-js": "^1.9.7" | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,73 @@ | ||
| import is from 'electron-is'; | ||
| import { app } from 'electron'; | ||
|
|
||
| import * as config from '@/config'; | ||
| import * as Plugins from '@/config/plugins'; | ||
|
|
||
| import { createBackend } from '@/utils'; | ||
|
|
||
| const getVersion = () => app.getVersion(); | ||
|
|
||
| const platform = () => { | ||
| const { arch } = process; | ||
|
|
||
| if (is.windows()) return `Windows (${arch})`; | ||
| if (is.macOS()) return `macOS (${arch})`; | ||
| if (is.linux()) { | ||
| const desktop = | ||
| process.env.XDG_CURRENT_DESKTOP || process.env.XDG_SESSION_DESKTOP; | ||
| const type = process.env.XDG_SESSION_TYPE; | ||
|
|
||
| return `Linux (desktop=${desktop}; type=${type}; arch=${arch})`; | ||
| } | ||
| return process.platform + ` (${arch})`; | ||
| }; | ||
|
|
||
| const versions = () => process.versions; | ||
|
|
||
| const plugins = { | ||
| enable: (id: string) => { | ||
| Plugins.enable(id); | ||
| }, | ||
| disable: (id: string) => { | ||
| Plugins.disable(id); | ||
| }, | ||
| }; | ||
|
|
||
| export type ConfigKey = Parameters<typeof config.get>[0]; | ||
|
|
||
| const configHandlers = { | ||
| get: <T extends ConfigKey>(key: T) => config.get(key), | ||
| set: (key: ConfigKey, value: unknown) => config.set(key, value), | ||
| }; | ||
|
|
||
| const loadSettings = () => config.getStore(); | ||
|
|
||
| export const backend = createBackend({ | ||
| start(ctx) { | ||
| ctx.ipc.handle('ytmd-sui:app-version', getVersion); | ||
| ctx.ipc.handle('ytmd-sui:platform', platform); | ||
| ctx.ipc.handle('ytmd-sui:versions', versions); | ||
| ctx.ipc.handle('ytmd-sui:load-settings', loadSettings); | ||
|
|
||
| ctx.ipc.handle('ytmd-sui:config-get', configHandlers.get); | ||
| ctx.ipc.handle('ytmd-sui:config-set', configHandlers.set); | ||
|
|
||
| ctx.ipc.handle('ytmd-sui:plugins-enable', plugins.enable); | ||
| ctx.ipc.handle('ytmd-sui:plugins-disable', plugins.disable); | ||
| }, | ||
|
|
||
| stop(ctx) { | ||
| ctx.ipc.removeHandler('ytmd-sui:app-version'); | ||
| ctx.ipc.removeHandler('ytmd-sui:platform'); | ||
| ctx.ipc.removeHandler('ytmd-sui:versions'); | ||
| ctx.ipc.removeHandler('ytmd-sui:load-settings'); | ||
|
|
||
| ctx.ipc.removeHandler('ytmd-sui:config-get'); | ||
| ctx.ipc.removeHandler('ytmd-sui:config-set'); | ||
|
|
||
| ctx.ipc.removeHandler('ytmd-sui:plugins-enable'); | ||
| ctx.ipc.removeHandler('ytmd-sui:plugins-disable'); | ||
| ctx.ipc.removeHandler('ytmd-sui:plugins-isEnabled'); | ||
| }, | ||
| }); |
This file contains hidden or 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,63 @@ | ||
| import { For } from 'solid-js'; | ||
|
|
||
| export interface SelectProps { | ||
| label: string; | ||
| description: string; | ||
|
|
||
| value: string; | ||
| options: { label: string; value: string }[]; | ||
| onSelect: (value: string) => void; | ||
| } | ||
|
|
||
| export const Select = (props: SelectProps) => { | ||
| return ( | ||
| <div | ||
| style={{ | ||
| 'display': 'flex', | ||
| 'align-items': 'flex-start', | ||
| 'justify-content': 'space-between', | ||
| 'gap': '24px', | ||
| 'margin-bottom': '20px', | ||
| }} | ||
| > | ||
| <label | ||
| style={{ | ||
| 'flex': '0 0 160px', | ||
| 'text-align': 'right', | ||
| 'color': 'var(--mdui-color-on-surface)', | ||
| 'font-size': '0.95rem', | ||
| 'font-weight': 500, | ||
| 'line-height': '1.4', | ||
| 'padding-top': '0.5rem', | ||
| }} | ||
| > | ||
| {props.label} | ||
| </label> | ||
| <div | ||
| style={{ | ||
| 'flex': 1, | ||
| 'display': 'flex', | ||
| 'flex-direction': 'column', | ||
| 'gap': '4px', | ||
| }} | ||
| > | ||
| <span | ||
| style={{ | ||
| 'color': 'var(--mdui-color-on-surface-variant)', | ||
| 'font-size': '0.8rem', | ||
| 'line-height': '1.3', | ||
| }} | ||
| > | ||
| {props.description} | ||
| </span> | ||
| <mdui-select style={{ width: '100%' }} value={props.value}> | ||
| <For each={props.options}> | ||
| {({ label, value }) => ( | ||
| <mdui-menu-item value={value}>{label}</mdui-menu-item> | ||
| )} | ||
| </For> | ||
| </mdui-select> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or 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,53 @@ | ||
| export interface ToggleProps { | ||
| label: string; | ||
| description: string; | ||
| value: boolean; | ||
| toggle: () => void; | ||
| } | ||
|
|
||
| export const Toggle = (props: ToggleProps) => { | ||
| return ( | ||
| <div | ||
| style={{ | ||
| 'display': 'flex', | ||
| 'align-items': 'flex-start', | ||
| 'justify-content': 'space-between', | ||
| 'gap': '24px', | ||
| 'margin-bottom': '20px', | ||
| }} | ||
| > | ||
| <label | ||
| style={{ | ||
| 'flex': '0 0 160px', | ||
| 'text-align': 'right', | ||
| 'color': 'var(--mdui-color-on-surface)', | ||
| 'font-size': '0.95rem', | ||
| 'font-weight': 500, | ||
| 'line-height': '1.4', | ||
| 'padding-top': '0.5rem', | ||
| }} | ||
| > | ||
| {props.label} | ||
| </label> | ||
| <div | ||
| style={{ | ||
| 'flex': 1, | ||
| 'display': 'flex', | ||
| 'flex-direction': 'column', | ||
| 'gap': '4px', | ||
| }} | ||
| > | ||
| <span | ||
| style={{ | ||
| 'color': 'var(--mdui-color-on-surface-variant)', | ||
| 'font-size': '0.8rem', | ||
| 'line-height': '1.3', | ||
| }} | ||
| > | ||
| {props.description} | ||
| </span> | ||
| <mdui-switch checked={props.value} /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or 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,81 @@ | ||
| import { t } from '@/i18n'; | ||
|
|
||
| import { Select } from '../Select'; | ||
| import { Toggle } from '../Toggle'; | ||
|
|
||
| export const General = () => { | ||
| const t$ = (key: string) => t(`main.menu.options.submenu.${key}`); | ||
|
|
||
| return ( | ||
| <> | ||
| {/* <Show | ||
| when={ | ||
| props.platform.startsWith('Windows') || | ||
| props.platform.startsWith('macOS') | ||
| } | ||
| > */} | ||
| <Toggle | ||
| description="Start Pear Music on login" | ||
| label={t$('start-at-login')} | ||
| toggle={() => {}} | ||
| value={true} | ||
| /> | ||
| {/* </Show> */} | ||
|
|
||
| <Select | ||
| description="Select the language for the application" | ||
| label={t$('language.label')} | ||
| onSelect={() => {}} | ||
| options={[ | ||
| // mock data | ||
| { value: 'en', label: 'English' }, | ||
| { value: 'gr', label: 'Ελληνικά' }, | ||
| ]} | ||
| value="en" | ||
| /> | ||
|
|
||
| <Select | ||
| description="Select which page to show when the application starts" | ||
| label={t$('starting-page.label')} | ||
| onSelect={() => {}} | ||
| options={[]} | ||
| value={''} | ||
| /> | ||
|
|
||
| <Toggle | ||
| description="Automatically get notified about new versions" | ||
| label={t$('auto-update')} | ||
| toggle={() => {}} | ||
| value={true} | ||
| /> | ||
|
|
||
| <Toggle | ||
| description="Resume last song when app starts" | ||
| label={t$('resume-on-start')} | ||
| toggle={() => {}} | ||
| value={true} | ||
| /> | ||
|
|
||
| <Toggle | ||
| description="Keep the application window on top of other windows" | ||
| label={t$('always-on-top')} | ||
| toggle={() => {}} | ||
| value={false} | ||
| /> | ||
|
|
||
| {/* <Show | ||
| when={ | ||
| props.platform.startsWith('Windows') || | ||
| props.platform.startsWith('Linux') | ||
| } | ||
| > */} | ||
| <Toggle | ||
| description="Hide the menu bar" | ||
| label={t$('hide-menu.label')} | ||
| toggle={() => {}} | ||
| value={false} | ||
| /> | ||
| {/* </Show> */} | ||
| </> | ||
| ); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'defaultConfig' is defined but never used.