···
-
Select as DiscordSelect
} from "@moonlight-mod/wp/discord/components/common/index";
import { useStateFromStores } from "@moonlight-mod/wp/discord/packages/flux";
import Flex from "@moonlight-mod/wp/discord/uikit/Flex";
···
const { value, displayName, description } = useConfigEntry<number>(ext.uniqueId, name);
const castedSetting = setting as NumberSettingType;
-
const min = castedSetting.min ?? 0;
-
const max = castedSetting.max ?? 100;
<FormItem className={Margins.marginTop20} title={displayName}>
-
{description && <FormText>{markdownify(description)}</FormText>}
-
initialValue={value ?? 0}
-
minValue={castedSetting.min ?? 0}
-
maxValue={castedSetting.max ?? 100}
-
onValueChange={(value: number) => {
-
const rounded = Math.max(min, Math.min(max, Math.round(value)));
-
MoonbaseSettingsStore.setExtensionConfig(ext.id, name, rounded);
···
+
Select as DiscordSelect,
} from "@moonlight-mod/wp/discord/components/common/index";
import { useStateFromStores } from "@moonlight-mod/wp/discord/packages/flux";
import Flex from "@moonlight-mod/wp/discord/uikit/Flex";
···
const { value, displayName, description } = useConfigEntry<number>(ext.uniqueId, name);
const castedSetting = setting as NumberSettingType;
+
const min = castedSetting.min;
+
const max = castedSetting.max;
+
const onChange = (value: number) => {
+
const rounded = min == null || max == null ? Math.round(value) : Math.max(min, Math.min(max, Math.round(value)));
+
MoonbaseSettingsStore.setExtensionConfig(ext.id, name, rounded);
<FormItem className={Margins.marginTop20} title={displayName}>
+
{min == null || max == null ? (
+
<Flex justify={Flex.Justify.BETWEEN} direction={Flex.Direction.HORIZONTAL}>
+
{description && <FormText>{markdownify(description)}</FormText>}
+
<NumberInputStepper value={value ?? 0} onChange={onChange} />
+
{description && <FormText>{markdownify(description)}</FormText>}
+
initialValue={value ?? 0}
+
onValueChange={onChange}
+
onValueRender={(value: number) => `${Math.round(value)}`}