mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
✨ Added an app opacity slider
Added a slider to change individual app opacity on the AppShelf
This commit is contained in:
@@ -6,6 +6,7 @@ import { CSS } from '@dnd-kit/utilities';
|
|||||||
import { serviceItem } from '../../tools/types';
|
import { serviceItem } from '../../tools/types';
|
||||||
import PingComponent from '../modules/ping/PingModule';
|
import PingComponent from '../modules/ping/PingModule';
|
||||||
import AppShelfMenu from './AppShelfMenu';
|
import AppShelfMenu from './AppShelfMenu';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
item: {
|
item: {
|
||||||
@@ -25,8 +26,10 @@ export function SortableAppShelfItem(props: any) {
|
|||||||
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
|
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
|
||||||
id: props.id,
|
id: props.id,
|
||||||
});
|
});
|
||||||
|
const { config } = useConfig();
|
||||||
|
|
||||||
const style = {
|
const style = {
|
||||||
|
opacity: `${config.settings.appOpacity || 100}%`,
|
||||||
transform: CSS.Transform.toString(transform),
|
transform: CSS.Transform.toString(transform),
|
||||||
transition,
|
transition,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import SaveConfigComponent from '../Config/SaveConfig';
|
|||||||
import ModuleEnabler from './ModuleEnabler';
|
import ModuleEnabler from './ModuleEnabler';
|
||||||
import { ColorSelector } from './ColorSelector';
|
import { ColorSelector } from './ColorSelector';
|
||||||
import { ShadeSelector } from './ShadeSelector';
|
import { ShadeSelector } from './ShadeSelector';
|
||||||
|
import { OpacitySelector } from './OpacitySelector';
|
||||||
|
|
||||||
export default function CommonSettings(args: any) {
|
export default function CommonSettings(args: any) {
|
||||||
const { config, setConfig } = useConfig();
|
const { config, setConfig } = useConfig();
|
||||||
@@ -74,6 +75,7 @@ export default function CommonSettings(args: any) {
|
|||||||
<ColorSelector type="primary" />
|
<ColorSelector type="primary" />
|
||||||
<ColorSelector type="secondary" />
|
<ColorSelector type="secondary" />
|
||||||
<ShadeSelector />
|
<ShadeSelector />
|
||||||
|
<OpacitySelector />
|
||||||
<ConfigChanger />
|
<ConfigChanger />
|
||||||
<SaveConfigComponent />
|
<SaveConfigComponent />
|
||||||
<Text
|
<Text
|
||||||
|
|||||||
44
src/components/Settings/OpacitySelector.tsx
Normal file
44
src/components/Settings/OpacitySelector.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Group, Text, Slider } from '@mantine/core';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
|
export function OpacitySelector() {
|
||||||
|
const { config, setConfig } = useConfig();
|
||||||
|
|
||||||
|
const MARKS = [
|
||||||
|
{ value: 10, label: '10' },
|
||||||
|
{ value: 20, label: '20' },
|
||||||
|
{ value: 30, label: '30' },
|
||||||
|
{ value: 40, label: '40' },
|
||||||
|
{ value: 50, label: '50' },
|
||||||
|
{ value: 60, label: '60' },
|
||||||
|
{ value: 70, label: '70' },
|
||||||
|
{ value: 80, label: '80' },
|
||||||
|
{ value: 90, label: '90' },
|
||||||
|
{ value: 100, label: '100' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const setConfigOpacity = (opacity: number) => {
|
||||||
|
setConfig({
|
||||||
|
...config,
|
||||||
|
settings: {
|
||||||
|
...config.settings,
|
||||||
|
appOpacity: opacity,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group direction="column" spacing="xs" grow>
|
||||||
|
<Text>App Opacity</Text>
|
||||||
|
<Slider
|
||||||
|
defaultValue={config.settings.appOpacity || 100}
|
||||||
|
step={10}
|
||||||
|
min={10}
|
||||||
|
marks={MARKS}
|
||||||
|
styles={{ markLabel: { fontSize: 'xx-small' } }}
|
||||||
|
onChange={(value) => setConfigOpacity(value)}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { OptionValues } from '../components/modules/modules';
|
|
||||||
import { MantineTheme } from '@mantine/core';
|
import { MantineTheme } from '@mantine/core';
|
||||||
|
import { OptionValues } from '../components/modules/modules';
|
||||||
|
|
||||||
export interface Settings {
|
export interface Settings {
|
||||||
searchUrl: string;
|
searchUrl: string;
|
||||||
@@ -10,6 +10,7 @@ export interface Settings {
|
|||||||
secondaryColor?: MantineTheme['primaryColor'];
|
secondaryColor?: MantineTheme['primaryColor'];
|
||||||
primaryShade?: MantineTheme['primaryShade'];
|
primaryShade?: MantineTheme['primaryShade'];
|
||||||
background?: string;
|
background?: string;
|
||||||
|
appOpacity?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
|
|||||||
Reference in New Issue
Block a user