Skip to content

Commit

Permalink
fix: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD committed Jun 14, 2024
1 parent 85efabb commit fc7c018
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 0 deletions.
60 changes: 60 additions & 0 deletions plugins/dorion-custom-keybinds/components/KeybindSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { css, classes } from './KeybindSection.tsx.scss'
import { Dropdown } from '../../../components/Dropdown'

const {
ui: {
Switch,

Check failure on line 6 in plugins/dorion-custom-keybinds/components/KeybindSection.tsx

View workflow job for this annotation

GitHub Actions / tsc-eslint-checks

'Switch' is assigned a value but never used
Text,

Check failure on line 7 in plugins/dorion-custom-keybinds/components/KeybindSection.tsx

View workflow job for this annotation

GitHub Actions / tsc-eslint-checks

'Text' is assigned a value but never used
HeaderTags,
Header,
injectCss
},
} = shelter

interface Props {

Check failure on line 14 in plugins/dorion-custom-keybinds/components/KeybindSection.tsx

View workflow job for this annotation

GitHub Actions / tsc-eslint-checks

'Props' is defined but never used
name: string
keybindActionTypes: Record<string, string>
internalName: string
description: string

keybinds: [number, number, number][]
enabled: boolean
}

let injectedCss = false

export function KeybindSection(props) {
if (!injectedCss) {
injectedCss = true
injectCss(css)
}

return (
<div class={classes.keybindSection}>
<div class={classes.actionSection}>
<Header size={HeaderTags.H5}>
Action
</Header>

<Dropdown
value={props.name}
options={Object.entries(props.keybindActionTypes).map(([key, value]) => {
return {
value: key,
label: value
}
})}
onChange={(e) => {
console.log(e)
}}
></Dropdown>
</div>

<div class={classes.keybindArea}>
<Header size={HeaderTags.H5}>
Keybind
</Header>
</div>
</div>
)
}
22 changes: 22 additions & 0 deletions plugins/dorion-custom-keybinds/components/KeybindSection.tsx.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.keybindSection {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}

.actionSection,
.keybindArea {
display: flex;
flex-direction: column;
align-items
}

.actionSection {
width: 50%;
}

.keybindArea {
width: 50%;
}
76 changes: 76 additions & 0 deletions plugins/dorion-custom-keybinds/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

import { KeybindSection } from "./components/KeybindSection"

Check failure on line 2 in plugins/dorion-custom-keybinds/index.tsx

View workflow job for this annotation

GitHub Actions / tsc-eslint-checks

Strings must use singlequote

const {
flux: {
intercept,

Check failure on line 6 in plugins/dorion-custom-keybinds/index.tsx

View workflow job for this annotation

GitHub Actions / tsc-eslint-checks

'intercept' is assigned a value but never used
dispatcher: FluxDispatcher,
},
observeDom,
ReactDOM,

Check failure on line 10 in plugins/dorion-custom-keybinds/index.tsx

View workflow job for this annotation

GitHub Actions / tsc-eslint-checks

'ReactDOM' is assigned a value but never used
ui: {
ReactiveRoot
}
} = shelter

const viewedKeybindsCallback = (e) => {
if (e.section !== 'Keybinds') return

const unsub = observeDom('#keybinds-tab', () => {
unsub()

const oldElm = document.querySelector('.browserNotice__7a436')
const owner = shelter.util.getFiberOwner(oldElm)
const proto = Object.getPrototypeOf(owner)

console.log(owner)
console.log(proto)

window.keybinds = {
owner,
proto,
}

const keybindsArea = document.querySelector('#keybinds-tab')
// const root = ReactDOM.createRoot(keybindsArea)
const keybindObjs = Object.entries(owner.keybindDescriptions).map(([key, value], i) => {

Check failure on line 36 in plugins/dorion-custom-keybinds/index.tsx

View workflow job for this annotation

GitHub Actions / tsc-eslint-checks

'value' is defined but never used
return {
id: i,
enabled: true,
action: key,
shortcut: [],
managed: false,
params: {}
}
})

// hide (don't remove) all children
for (const child of keybindsArea.children) {
child.style.display = 'none'
}

// root.render(
// owner.renderKeybinds(keybindObjs)
// )

keybindsArea.appendChild(
<ReactiveRoot>
<KeybindSection
name="test"
keybindActionTypes={owner.keybindActionTypes}
internalName="test"
description="test"
keybinds={keybindObjs.map(k => k.shortcut)}
enabled={true}
></KeybindSection>
</ReactiveRoot>
)
})
}

const subscriptions = [

Check failure on line 71 in plugins/dorion-custom-keybinds/index.tsx

View workflow job for this annotation

GitHub Actions / tsc-eslint-checks

'subscriptions' is assigned a value but never used
FluxDispatcher.subscribe('USER_SETTINGS_MODAL_SET_SECTION', viewedKeybindsCallback)
]



7 changes: 7 additions & 0 deletions plugins/dorion-custom-keybinds/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "dorion-custom-keybinds",
"dependencies": {
"@cumjar/websmack": "^1.2.0",
"spitroast": "^1.4.4"
}
}
5 changes: 5 additions & 0 deletions plugins/dorion-custom-keybinds/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Dorion Custom Keybinds",
"description": "Enable the use of global, customized keybinds",
"author": "SpikeHD"
}
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fc7c018

Please sign in to comment.