From ee0bd9e8dc462a7faa62eef004b50f7636df7d43 Mon Sep 17 00:00:00 2001 From: Konrad Jamrozik Date: Thu, 27 Jun 2024 23:44:47 -0700 Subject: [PATCH] WIP: input slider component --- web/assets/spy_DodgerBlue_512px.svg | 1 + .../FactionsDataGrid/InputSlider.tsx | 82 +++++++++++++++++++ .../FactionsDataGrid/ManageFactionDialog.tsx | 4 + 3 files changed, 87 insertions(+) create mode 100644 web/assets/spy_DodgerBlue_512px.svg create mode 100644 web/src/components/FactionsDataGrid/InputSlider.tsx diff --git a/web/assets/spy_DodgerBlue_512px.svg b/web/assets/spy_DodgerBlue_512px.svg new file mode 100644 index 00000000..f6933fb2 --- /dev/null +++ b/web/assets/spy_DodgerBlue_512px.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/components/FactionsDataGrid/InputSlider.tsx b/web/src/components/FactionsDataGrid/InputSlider.tsx new file mode 100644 index 00000000..a00a348f --- /dev/null +++ b/web/src/components/FactionsDataGrid/InputSlider.tsx @@ -0,0 +1,82 @@ +/** This file was originally adapted from + * https://mui.com/material-ui/react-slider/#slider-with-input-field + */ +import { Button, Stack, SvgIcon, TextField } from '@mui/material' +import Box from '@mui/material/Box' +import Grid from '@mui/material/Grid' +import Slider from '@mui/material/Slider' +import _ from 'lodash' +import * as React from 'react' +import { assetNameColors } from '../../lib/rendering/renderAssets' + +export default function InputSlider(): React.JSX.Element { + const [value, setValue] = React.useState(30) + + function handleSliderChange(event: Event, newValue: number | number[]): void { + setValue(newValue as number) + } + + function handleInputChange(event: React.ChangeEvent): void { + setValue(event.target.value === '' ? 0 : Number(event.target.value)) + } + + function handleBlur(): void { + if (value < 0) { + setValue(0) + } else if (value > 100) { + setValue(100) + } + } + + return ( + + + + + + {/* https://game-icons.net/1x1/delapouite/spy.html */} + + + + + + + + + + + + + + + + + + ) +} diff --git a/web/src/components/FactionsDataGrid/ManageFactionDialog.tsx b/web/src/components/FactionsDataGrid/ManageFactionDialog.tsx index 5d453ef4..91300ec2 100644 --- a/web/src/components/FactionsDataGrid/ManageFactionDialog.tsx +++ b/web/src/components/FactionsDataGrid/ManageFactionDialog.tsx @@ -12,6 +12,7 @@ import { getNormalizedPower } from '../../lib/codesync/ruleset' import { factionNameRenderMap } from '../../lib/rendering/renderFactions' import { getSx } from '../../lib/rendering/renderUtils' import { Label } from '../Label' +import InputSlider from './InputSlider' const factionDetailsGridMaxWidthPx = 400 export type ManageFactionDialogProps = { @@ -82,6 +83,9 @@ export default function DeployMissionDialog( + + +