mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-20 18:10:08 +02:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb440deed6 | ||
|
|
064c161b67 | ||
|
|
6abf0efc10 | ||
|
|
537b8301ec | ||
|
|
2ae87da37a | ||
|
|
0d248f3987 | ||
|
|
74aefc7b3c | ||
|
|
16ec1e3d2e | ||
|
|
db41e74cf9 |
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,3 +1,24 @@
|
||||
## [3.1.4](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.1.3...v3.1.4) (2022-09-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **License:** update license in package.json ([064c161](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/064c161b6736bb5574f28cb986c5899620fd69fe))
|
||||
|
||||
## [3.1.3](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.1.2...v3.1.3) (2022-09-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **DialogButton:** fix ref type ([74aefc7](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/74aefc7b3c19a98fb607e78c4063c098a2e12546))
|
||||
|
||||
## [3.1.2](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.1.1...v3.1.2) (2022-09-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **DialogButton:** fix types, add ref types ([db41e74](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/db41e74cf9f584301e59556e64a5c2371df18ed0))
|
||||
|
||||
## [3.1.1](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.1.0...v3.1.1) (2022-09-18)
|
||||
|
||||
|
||||
|
||||
20
LICENSE
20
LICENSE
@@ -1,4 +1,4 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
GNU LESSER GENERAL PUBLIC LICENSE (DECKY-FRONTEND-LIB v1)
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
@@ -457,6 +457,24 @@ DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
EXCEPTION NOTICE
|
||||
|
||||
1. The exception is that you may use, copy, link, modify and distribute
|
||||
under your own terms, binary object code versions of works based on the
|
||||
Library.
|
||||
|
||||
2. If you copy code from files distributed under the terms of the GNU
|
||||
General Public Licence or the GNU Library General Public Licence into a
|
||||
copy of this library, as this licence permits, the exception does not apply
|
||||
to the code that you add in this way. To avoid misleading anyone as to the
|
||||
status of such modified files, you must delete this exception notice from
|
||||
such code and/or adjust the licensing conditions notice accordingly.
|
||||
|
||||
3. If you write modifications of your own for this library, it is your
|
||||
choice whether to permit this exception to apply to your modifications. If
|
||||
you do not wish that, you must delete the exception notice from such code
|
||||
and/or adjust the licensing conditions notice accordingly.
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "decky-frontend-lib",
|
||||
"version": "3.1.1",
|
||||
"version": "3.1.4",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "decky-frontend-lib",
|
||||
"version": "3.1.1",
|
||||
"version": "3.1.4",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.6"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "decky-frontend-lib",
|
||||
"version": "3.1.1",
|
||||
"version": "3.1.4",
|
||||
"description": "A library for building decky plugins",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
@@ -30,7 +30,7 @@
|
||||
"components"
|
||||
],
|
||||
"author": "Jonas Dellinger <jonas@dellinger.dev>",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"license": "LGPL-2.1-with-decky-exceptions",
|
||||
"bugs": {
|
||||
"url": "https://github.com/SteamDeckHomebrew/decky-frontend-lib/issues"
|
||||
},
|
||||
|
||||
163
src/custom-components/ColorPickerModal.tsx
Normal file
163
src/custom-components/ColorPickerModal.tsx
Normal file
@@ -0,0 +1,163 @@
|
||||
import { gamepadSliderClasses, ConfirmModal, SliderField } from "../deck-components";
|
||||
import { useState, FC, CSSProperties } from "react";
|
||||
|
||||
interface ColorPickerModalProps {
|
||||
closeModal: () => void;
|
||||
onConfirm?(HSLString: string): any;
|
||||
title?: string;
|
||||
defaultH?: number;
|
||||
defaultS?: number;
|
||||
defaultL?: number;
|
||||
defaultA?: number;
|
||||
}
|
||||
|
||||
export const ColorPickerModal: FC<ColorPickerModalProps> = ({
|
||||
closeModal,
|
||||
onConfirm = () => {},
|
||||
title = "Color Picker",
|
||||
defaultH = 0,
|
||||
defaultS = 100,
|
||||
defaultL = 50,
|
||||
defaultA = 1,
|
||||
}) => {
|
||||
const [H, setH] = useState<number>(defaultH);
|
||||
const [S, setS] = useState<number>(defaultS);
|
||||
const [L, setL] = useState<number>(defaultL);
|
||||
const [A, setA] = useState<number>(defaultA);
|
||||
|
||||
const colorPickerCSSVars = {
|
||||
"--decky-color-picker-hvalue": `${H}`,
|
||||
"--decky-color-picker-svalue": `${S}%`,
|
||||
"--decky-color-picker-lvalue": `${L}%`,
|
||||
"--decky-color-picker-avalue": `${A}`,
|
||||
} as CSSProperties;
|
||||
|
||||
return (
|
||||
<ConfirmModal
|
||||
bAllowFullSize
|
||||
onCancel={closeModal}
|
||||
onOK={() => {
|
||||
onConfirm(`hsla(${H}, ${S}%, ${L}%, ${A})`);
|
||||
closeModal();
|
||||
}}
|
||||
>
|
||||
<style>
|
||||
{`
|
||||
/* This removes the cyan track color that is behind the slider head */
|
||||
.ColorPicker_Container .${gamepadSliderClasses.SliderTrack} {
|
||||
--left-track-color: #0000;
|
||||
/* This is for compatibility with the "Colored Toggles" CSSLoader Theme*/
|
||||
--colored-toggles-main-color: #0000;
|
||||
}
|
||||
|
||||
.ColorPicker_HSlider .${gamepadSliderClasses.SliderTrack} {
|
||||
background: linear-gradient(
|
||||
270deg,
|
||||
hsla(360, var(--decky-color-picker-svalue), var(--decky-color-picker-lvalue), var(--decky-color-picker-avalue)),
|
||||
hsla(270, var(--decky-color-picker-svalue), var(--decky-color-picker-lvalue), var(--decky-color-picker-avalue)),
|
||||
hsla(180, var(--decky-color-picker-svalue), var(--decky-color-picker-lvalue), var(--decky-color-picker-avalue)),
|
||||
hsla(90, var(--decky-color-picker-svalue), var(--decky-color-picker-lvalue), var(--decky-color-picker-avalue)),
|
||||
hsla(0, var(--decky-color-picker-svalue), var(--decky-color-picker-lvalue), var(--decky-color-picker-avalue))
|
||||
);
|
||||
}
|
||||
|
||||
.ColorPicker_SSlider .${gamepadSliderClasses.SliderTrack} {
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
hsla(var(--decky-color-picker-hvalue), 0%, var(--decky-color-picker-lvalue), var(--decky-color-picker-avalue)),
|
||||
hsla(var(--decky-color-picker-hvalue), 100%, var(--decky-color-picker-lvalue), var(--decky-color-picker-avalue))
|
||||
);
|
||||
}
|
||||
|
||||
.ColorPicker_LSlider .${gamepadSliderClasses.SliderTrack} {
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
hsla(var(--decky-color-picker-hvalue), var(--decky-color-picker-svalue), 0%, var(--decky-color-picker-avalue)),
|
||||
hsla(var(--decky-color-picker-hvalue), var(--decky-color-picker-svalue), 50%, var(--decky-color-picker-avalue)),
|
||||
hsla(var(--decky-color-picker-hvalue), var(--decky-color-picker-svalue), 100%, var(--decky-color-picker-avalue))
|
||||
);
|
||||
}
|
||||
|
||||
.ColorPicker_ASlider .${gamepadSliderClasses.SliderTrack} {
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
hsla(var(--decky-color-picker-hvalue), var(--decky-color-picker-svalue), var(--decky-color-picker-lvalue), 0),
|
||||
hsla(var(--decky-color-picker-hvalue), var(--decky-color-picker-svalue), var(--decky-color-picker-lvalue), 1)
|
||||
);
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
<div
|
||||
className="ColorPicker_ColorDisplayContainer"
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
marginBottom: "1em",
|
||||
// theres a large header by default on the modal, so this just pushes it up into that unused space
|
||||
marginTop: "-2.5em",
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<span style={{ fontSize: "1.5em" }}>
|
||||
<b>{title}</b>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: `hsla(${H}, ${S}%, ${L}%, ${A})`,
|
||||
width: "40px",
|
||||
height: "40px",
|
||||
}}
|
||||
></div>
|
||||
</div>
|
||||
<div className="ColorPicker_Container" style={colorPickerCSSVars}>
|
||||
<div className="ColorPicker_HSlider">
|
||||
<SliderField
|
||||
showValue
|
||||
editableValue
|
||||
label="Hue"
|
||||
value={H}
|
||||
min={0}
|
||||
max={360}
|
||||
onChange={setH}
|
||||
/>
|
||||
</div>
|
||||
<div className="ColorPicker_SSlider">
|
||||
<SliderField
|
||||
showValue
|
||||
editableValue
|
||||
label="Saturation"
|
||||
value={S}
|
||||
min={0}
|
||||
max={100}
|
||||
onChange={setS}
|
||||
/>
|
||||
</div>
|
||||
<div className="ColorPicker_LSlider">
|
||||
<SliderField
|
||||
showValue
|
||||
editableValue
|
||||
label="Lightness"
|
||||
value={L}
|
||||
min={0}
|
||||
max={100}
|
||||
onChange={setL}
|
||||
/>
|
||||
</div>
|
||||
<div className="ColorPicker_ASlider">
|
||||
<SliderField
|
||||
showValue
|
||||
editableValue
|
||||
label="Alpha"
|
||||
value={A}
|
||||
step={0.1}
|
||||
min={0}
|
||||
max={1}
|
||||
onChange={setA}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ConfirmModal>
|
||||
);
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
import { CSSProperties, FC } from 'react';
|
||||
import { CSSProperties, FC, RefAttributes } from 'react';
|
||||
|
||||
import { CommonUIModule } from '../webpack';
|
||||
|
||||
export interface DialogButtonProps {
|
||||
export interface DialogButtonProps extends RefAttributes<HTMLDivElement> {
|
||||
label?: string;
|
||||
style: CSSProperties;
|
||||
style?: CSSProperties;
|
||||
className?: string;
|
||||
noFocusRing?: boolean;
|
||||
description?: string;
|
||||
|
||||
@@ -307,9 +307,58 @@ type PlaySectionClasses = Record<
|
||||
string
|
||||
>;
|
||||
|
||||
type GamepadSliderClasses = Record<
|
||||
| "error-shake-duration"
|
||||
| "SliderControlPanelGroup"
|
||||
| "SliderControlAndNotches"
|
||||
| "WithDefaultValue"
|
||||
| "SliderControl"
|
||||
| "Disabled"
|
||||
| "SliderTrack"
|
||||
| "SliderHasNotches"
|
||||
| "SliderTrackDark"
|
||||
| "SliderHandleContainer"
|
||||
| "VerticalLineSliderHandleContainer"
|
||||
| "ParenSliderHandleContainer"
|
||||
| "SliderHandle"
|
||||
| "SliderHandleFocusPop"
|
||||
| "VerticalLineSliderHandle"
|
||||
| "ParenSliderHandle"
|
||||
| "Left"
|
||||
| "SliderControlWithIcon"
|
||||
| "Icon"
|
||||
| "SliderNotchContainer"
|
||||
| "SliderNotch"
|
||||
| "AlignToEnds"
|
||||
| "SliderNotchLabel"
|
||||
| "AlignToLeft"
|
||||
| "AlignToRight"
|
||||
| "SliderNotchTick"
|
||||
| "TickActive"
|
||||
| "LabelText"
|
||||
| "DescriptionValue"
|
||||
| "EditableValue"
|
||||
| "FakeEditableValue"
|
||||
| "RedBorder"
|
||||
| "EditableValueSuffix"
|
||||
| "ErrorShake"
|
||||
| "error-shake"
|
||||
| "CompoundSlider"
|
||||
| "CompoundSliderSubSlider"
|
||||
| "Right"
|
||||
| "CompoundSliderSubSliderLabelContainer"
|
||||
| "CompoundSliderSubSliderLabelPositioner"
|
||||
| "CompoundSliderSubSliderLabel"
|
||||
| "CompoundSliderSubSliderLabelInternal"
|
||||
| "DefaultValueTickContainer"
|
||||
| "DefaultValueTick",
|
||||
string
|
||||
>;
|
||||
|
||||
export const staticClasses: StaticClasses = findModule((mod) => typeof mod === 'object' && mod.TransitionMenuDelay);
|
||||
export const scrollClasses: ScrollClasses = findModule((mod) => typeof mod === 'object' && mod.ScrollPanel && mod.ScrollY);
|
||||
export const gamepadDialogClasses: GamepadDialogClasses = findModule((mod) => typeof mod === 'object' && mod.WithFirstRow);
|
||||
export const quickAccessControlsClasses: QuickAccessControlsClasses = findModule((mod) => typeof mod === 'object' && mod.PanelSectionRow);
|
||||
export const updaterFieldClasses: UpdaterFieldClasses = findModule((mod) => typeof mod === 'object' && mod.PatchNotes && mod.PostedTime);
|
||||
export const playSectionClasses: PlaySectionClasses = findModule((mod) => typeof mod === 'object' && mod.MenuButton && mod.MenuActive);
|
||||
export const gamepadSliderClasses: GamepadSliderClasses = findModule((mod) => typeof mod === 'object' && mod.SliderTrack && mod.SliderHasNotches);
|
||||
Reference in New Issue
Block a user