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
28 changes: 1 addition & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"react-dom": "^18.3.1",
"react-resizable": "^3.0.4",
"react-sidebar": "^3.0.2",
"react-toastify": "11.0.3",
"react-toggle": "^4.1.3"
"react-toastify": "11.0.3"
},
"devDependencies": {
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.13",
Expand All @@ -34,7 +33,6 @@
"@types/react-dom": "^18.3.0",
"@types/react-resizable": "^3.0.3",
"@types/react-sidebar": "^3.0.2",
"@types/react-toggle": "^4.0.3",
"clean-webpack-plugin": "^4.0.0",
"css-loader": "7.1.2",
"eslint": "^9.20.1",
Expand Down
49 changes: 49 additions & 0 deletions src/css/Switch.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.switch {
position: relative;
width: 35px;
height: 20px;
display: inline-block;

span {
position: absolute;
background-color: #ffffff20;
border-radius: 20px;
top: 0;
left: 0;
right: 0;
bottom: 0;
transition: background-color .25s;
}

span::before {
background-color: white;
border-radius: 50%;
content: "";
position: absolute;
transition: all .25s;
left: 3px;
bottom: 3px;
height: 14px;
width: 14px;
}

&:hover input+span {
background-color: #ffffff40;
}

&:hover input:checked+span {
background-color: #ffffff80;
}

input:checked+span {
background-color: #ffffff60;
}

input:checked+span::before {
transform: translateX(15px);
}

input {
display: none;
}
}
49 changes: 0 additions & 49 deletions src/css/ToggleCheckbox.scss

This file was deleted.

32 changes: 16 additions & 16 deletions src/ui/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { Color, SettingsDescriptionValueJson } from "../livesplit-core";
import { assertNever, expect, Option } from "../util/OptionUtil";
import ColorPicker from "./ColorPicker";
import HotkeyButton from "./HotkeyButton";
import ToggleCheckbox from "./ToggleCheckbox";
import { UrlCache } from "../util/UrlCache";
import { FILE_EXT_IMAGES, openFileAsArrayBuffer } from "../util/FileUtil";
import * as FontList from "../util/FontList";
import { LiveSplitServer } from "../api/LiveSplitServer";
import { showDialog } from "./Dialog";
import { toast } from "react-toastify";
import Switch from "./Switch";

import "../css/Tooltip.scss";
import "../css/LiveSplitServerButton.scss";
Expand Down Expand Up @@ -202,9 +202,9 @@ export class SettingsComponent<T> extends React.Component<Props<T>> {
if ("Bool" in value) {
component = (
<div className="settings-value-box">
<ToggleCheckbox
value={value.Bool}
setValue={(value) => {
<Switch
checked={value.Bool}
setIsChecked={(value) => {
this.props.setValue(
valueIndex,
factory.fromBool(value)
Expand Down Expand Up @@ -323,9 +323,9 @@ export class SettingsComponent<T> extends React.Component<Props<T>> {
</div>;
} else {
const children = [
<ToggleCheckbox
value={value.OptionalString !== null}
setValue={(value) => {
<Switch
checked={value.OptionalString !== null}
setIsChecked={(value) => {
if (value) {
this.props.setValue(
valueIndex,
Expand Down Expand Up @@ -482,9 +482,9 @@ export class SettingsComponent<T> extends React.Component<Props<T>> {

component = (
<div className="settings-value-box optional-value">
<ToggleCheckbox
value={value.OptionalColor !== null}
setValue={(value) => {
<Switch
checked={value.OptionalColor !== null}
setIsChecked={(value) => {
if (value) {
this.props.setValue(
valueIndex,
Expand Down Expand Up @@ -743,9 +743,9 @@ export class SettingsComponent<T> extends React.Component<Props<T>> {
}
} else if ("OptionalTimingMethod" in value) {
const children = [
<ToggleCheckbox
value={value.OptionalTimingMethod !== null}
setValue={(value) => {
<Switch
checked={value.OptionalTimingMethod !== null}
setIsChecked={(value) => {
if (value) {
this.props.setValue(
valueIndex,
Expand Down Expand Up @@ -964,9 +964,9 @@ export class SettingsComponent<T> extends React.Component<Props<T>> {
);
} else if ("Font" in value) {
const children = [
<ToggleCheckbox
value={value.Font !== null}
setValue={(value) => {
<Switch
checked={value.Font !== null}
setIsChecked={(value) => {
if (value) {
this.props.setValue(
valueIndex,
Expand Down
17 changes: 17 additions & 0 deletions src/ui/Switch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";

import "../css/Switch.scss";

export default function Switch({ checked, setIsChecked }: {
checked: boolean,
setIsChecked: (checked: boolean) => void,
}) {
return (
<label style={{ cursor: "pointer", display: "flex", justifyContent: "center", alignItems: "center" }}>
<div className="switch">
<input type="checkbox" checked={checked} onChange={(e) => setIsChecked(e.target.checked)} />
<span />
</div>
</label>
);
}
28 changes: 0 additions & 28 deletions src/ui/ToggleCheckbox.tsx

This file was deleted.

Loading