Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions app/src/components/EspSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ declare module "react" {
import {
buildBudpyConfig,
defaultBackgroundColor,
maxScreenIdleHours,
maxScreenIdleMinutes,
normalizeBrightnessMode,
normalizeBrightnessValue,
normalizeColorValue,
normalizeScreenIdleMinutes,
normalizeScreenIdleUnit,
normalizeScreenSleepDimBrightness,
normalizeScreenSleepMode,
type Orientation,
} from "../lib/config";
import { saveStoredDeviceSetupInput } from "../lib/deviceSetupStorage";
Expand Down Expand Up @@ -98,6 +104,17 @@ export function EspSidebar({
const brightnessMode = normalizeBrightnessMode(input.brightnessMode);
const brightnessLabel =
brightnessMode === "auto" ? "Maximum brightness" : "Brightness";
const screenIdleMinutes = normalizeScreenIdleMinutes(input.screenIdleMinutes);
const screenIdleUnit = normalizeScreenIdleUnit(input.screenIdleUnit);
const screenSleepMode = normalizeScreenSleepMode(input.screenSleepMode);
const screenSleepDimBrightness = normalizeScreenSleepDimBrightness(
input.screenSleepDimBrightness,
);
const screenIdleValue =
screenIdleUnit === "hours" ? screenIdleMinutes / 60 : screenIdleMinutes;
const screenIdleMax =
screenIdleUnit === "hours" ? maxScreenIdleHours : maxScreenIdleMinutes;
const screenSleepEnabled = screenIdleMinutes > 0;

function updateInput(key: keyof DeviceSetupInput, value: string | number) {
onInputChange(key, value);
Expand Down Expand Up @@ -336,6 +353,81 @@ export function EspSidebar({
}
/>
</label>
<label className="form-field">
<span>Screen sleep after (0 = never)</span>
<input
name="screenIdleValue"
type="number"
min={0}
max={screenIdleMax}
step={1}
value={screenIdleValue}
onChange={(event) => {
const next = Number(event.target.value);
updateInput(
"screenIdleMinutes",
Math.round(
screenIdleUnit === "hours" ? next * 60 : next,
),
);
}}
/>
</label>
<label className="form-field">
<span>Sleep unit</span>
<select
name="screenIdleUnit"
value={screenIdleUnit}
onChange={(event) =>
updateInput(
"screenIdleUnit",
event.target.value === "hours" ? "hours" : "minutes",
)
}
>
<option value="minutes">Minutes</option>
<option value="hours">Hours</option>
</select>
</label>
<label className="form-field">
<span>Screen sleep mode</span>
<select
name="screenSleepMode"
value={screenSleepMode}
disabled={!screenSleepEnabled}
onChange={(event) =>
updateInput(
"screenSleepMode",
event.target.value === "dim" ? "dim" : "off",
)
}
>
<option value="off">Turn off</option>
<option value="dim">Dim</option>
</select>
</label>
{screenSleepMode === "dim" && (
<label className="form-field">
<span>
Dim brightness —{" "}
{Math.round((screenSleepDimBrightness / 255) * 100)}%
</span>
<input
name="screenSleepDimBrightness"
type="range"
min={0}
max={255}
step={1}
value={screenSleepDimBrightness}
onChange={(event) =>
updateInput(
"screenSleepDimBrightness",
Number(event.target.value),
)
}
/>
</label>
)}
</div>
<button
type="submit"
Expand Down
7 changes: 7 additions & 0 deletions app/src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
type Orientation,
orientations,
} from "../lib/config";
import { getTotalImageDataLength } from "../lib/imageField";
import type { LayoutCell } from "../models/LayoutCell";
import { GlobalVarsDialog } from "./GlobalVarsDialog";
import styles from "./Layout.module.css";
Expand Down Expand Up @@ -101,6 +102,10 @@ export function Layout({
() => fitCellsToOrientation(cells, orientation),
[cells, orientation],
);
const totalImageDataLength = useMemo(
() => getTotalImageDataLength(fittedCells),
[fittedCells],
);
const currentPage = normalizeLayoutPage(activePage);
const activePageCells = useMemo(
() => getCellsForPage(fittedCells, currentPage),
Expand Down Expand Up @@ -480,6 +485,8 @@ export function Layout({
manifest={selectedManifest}
isSettingsOpen={isSettingsOpen}
selectedArea={selectedArea}
orientation={orientation}
totalImageDataLength={totalImageDataLength}
plugins={plugins}
cellCount={fittedCells.length}
maxCells={maxLayoutCells}
Expand Down
15 changes: 15 additions & 0 deletions app/src/components/layout/LayoutCustomizationPanel.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,18 @@
padding-top: 0;
}
}

.image-field-preview {
display: block;
max-width: 100%;
max-height: 120px;
border-radius: 4px;
margin-bottom: 6px;
object-fit: contain;
}

.image-field-error {
color: var(--color-danger, #e5484d);
font-size: 12px;
margin: 4px 0 0;
}
Loading
Loading